Revert "Revert "mailbox: avoid timer start from callback""
authorDom Cobley <popcornmix@gmail.com>
Wed, 15 Jun 2022 13:59:03 +0000 (14:59 +0100)
committerDom Cobley <popcornmix@gmail.com>
Wed, 15 Jun 2022 13:59:03 +0000 (14:59 +0100)
This reverts commit 9f465c869042d8e42de1a19add8cbdd6399dbeaf.

drivers/mailbox/mailbox.c

index 0b821a5..3e7d4b2 100644 (file)
@@ -82,9 +82,12 @@ static void msg_submit(struct mbox_chan *chan)
 exit:
        spin_unlock_irqrestore(&chan->lock, flags);
 
-       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);
+       /* kick start the timer immediately to avoid delays */
+       if (!err && (chan->txdone_method & TXDONE_BY_POLL)) {
+               /* but only if not already active */
+               if (!hrtimer_active(&chan->mbox->poll_hrt))
+                       hrtimer_start(&chan->mbox->poll_hrt, 0, HRTIMER_MODE_REL);
+       }
 }
 
 static void tx_tick(struct mbox_chan *chan, int r)
@@ -122,11 +125,10 @@ static enum hrtimer_restart txdone_hrtimer(struct hrtimer *hrtimer)
                struct mbox_chan *chan = &mbox->chans[i];
 
                if (chan->active_req && chan->cl) {
+                       resched = true;
                        txdone = chan->mbox->ops->last_tx_done(chan);
                        if (txdone)
                                tx_tick(chan, 0);
-                       else
-                               resched = true;
                }
        }