mailbox: Fix TX completion init
authorLeyFoon Tan <lftan.linux@gmail.com>
Tue, 18 Mar 2014 18:46:16 +0000 (00:16 +0530)
committerSudeep Holla <sudeep.holla@arm.com>
Mon, 2 Jun 2014 09:44:05 +0000 (10:44 +0100)
For fast TX the complete could be called before being initialized as follows
 mbox_send_message --> poll_txdone --> tx_tick --> complete(&chan->tx_complete)

Init the completion early enough to fix the race.

Signed-off-by: LeyFoon Tan <lftan.linux@gmail.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
drivers/mailbox/mailbox.c

index 79d576e..cdf7d45 100644 (file)
@@ -278,6 +278,9 @@ int mbox_send_message(struct mbox_chan *chan, void *mssg)
        if (!chan || !chan->cl)
                return -EINVAL;
 
+       if (chan->cl->tx_block)
+               init_completion(&chan->tx_complete);
+
        t = _add_to_rbuf(chan, mssg);
        if (t < 0) {
                pr_err("Try increasing MBOX_TX_QUEUE_LEN\n");
@@ -291,7 +294,6 @@ int mbox_send_message(struct mbox_chan *chan, void *mssg)
 
        if (chan->cl->tx_block && chan->active_req) {
                int ret;
-               init_completion(&chan->tx_complete);
                ret = wait_for_completion_timeout(&chan->tx_complete,
                        chan->cl->tx_tout);
                if (ret == 0) {