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

Commit 52a49306 authored by Andrew Bresticker's avatar Andrew Bresticker Committed by Jassi Brar
Browse files

mailbox: Don't unnecessarily re-arm the polling timer



poll_txdone() will unconditionally re-arm the polling timer if there was
an active request, even if the active request completed and no other
requests were submitted.  This is fixed by:
 - only re-arming the timer if the controller reported that the current
   transmission has not completed, and,
 - moving the call to poll_txdone() into msg_submit() so that the
   controller gets polled (and the timer re-armed, if necessary) whenever
   a new message is submitted.

Signed-off-by: default avatarAndrew Bresticker <abrestic@chromium.org>
Reviewed-by: default avatarThierry Reding <treding@nvidia.com>
Signed-off-by: default avatarJassi Brar <jaswinder.singh@linaro.org>
parent 0df1f248
Loading
Loading
Loading
Loading
+8 −5
Original line number Original line Diff line number Diff line
@@ -28,6 +28,8 @@
static LIST_HEAD(mbox_cons);
static LIST_HEAD(mbox_cons);
static DEFINE_MUTEX(con_mutex);
static DEFINE_MUTEX(con_mutex);


static void poll_txdone(unsigned long data);

static int add_to_rbuf(struct mbox_chan *chan, void *mssg)
static int add_to_rbuf(struct mbox_chan *chan, void *mssg)
{
{
	int idx;
	int idx;
@@ -60,7 +62,7 @@ static void msg_submit(struct mbox_chan *chan)
	unsigned count, idx;
	unsigned count, idx;
	unsigned long flags;
	unsigned long flags;
	void *data;
	void *data;
	int err;
	int err = -EBUSY;


	spin_lock_irqsave(&chan->lock, flags);
	spin_lock_irqsave(&chan->lock, flags);


@@ -84,6 +86,9 @@ static void msg_submit(struct mbox_chan *chan)
	}
	}
exit:
exit:
	spin_unlock_irqrestore(&chan->lock, flags);
	spin_unlock_irqrestore(&chan->lock, flags);

	if (!err && chan->txdone_method == TXDONE_BY_POLL)
		poll_txdone((unsigned long)chan->mbox);
}
}


static void tx_tick(struct mbox_chan *chan, int r)
static void tx_tick(struct mbox_chan *chan, int r)
@@ -117,10 +122,11 @@ static void poll_txdone(unsigned long data)
		struct mbox_chan *chan = &mbox->chans[i];
		struct mbox_chan *chan = &mbox->chans[i];


		if (chan->active_req && chan->cl) {
		if (chan->active_req && chan->cl) {
			resched = true;
			txdone = chan->mbox->ops->last_tx_done(chan);
			txdone = chan->mbox->ops->last_tx_done(chan);
			if (txdone)
			if (txdone)
				tx_tick(chan, 0);
				tx_tick(chan, 0);
			else
				resched = true;
		}
		}
	}
	}


@@ -252,9 +258,6 @@ int mbox_send_message(struct mbox_chan *chan, void *mssg)


	msg_submit(chan);
	msg_submit(chan);


	if (chan->txdone_method	== TXDONE_BY_POLL)
		poll_txdone((unsigned long)chan->mbox);

	if (chan->cl->tx_block && chan->active_req) {
	if (chan->cl->tx_block && chan->active_req) {
		unsigned long wait;
		unsigned long wait;
		int ret;
		int ret;