Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b45d92fd authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "drivers: mailbox: fix race resulting in multiple message submission"

parents 47869213 e5c2b83b
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ static int add_to_rbuf(struct mbox_chan *chan, void *mssg)
	return idx;
}

static void msg_submit(struct mbox_chan *chan)
static int __msg_submit(struct mbox_chan *chan)
{
	unsigned count, idx;
	unsigned long flags;
@@ -85,6 +85,24 @@ static void msg_submit(struct mbox_chan *chan)
exit:
	spin_unlock_irqrestore(&chan->lock, flags);

	return err;
}

static void msg_submit(struct mbox_chan *chan)
{
	int err = 0;

	/*
	 * If the controller returns -EAGAIN, then it means, our spinlock
	 * here is preventing the controller from receiving its interrupt,
	 * that would help clear the controller channels that are currently
	 * blocked waiting on the interrupt response.
	 * Retry again.
	 */
	do {
		err = __msg_submit(chan);
	} while (err == -EAGAIN);

	if (!err && (chan->txdone_method & TXDONE_BY_POLL))
		/* kick start the timer immediately to avoid delays */
		hrtimer_start(&chan->mbox->poll_hrt, 0, HRTIMER_MODE_REL);