linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jassi Brar <jassisinghbrar@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: gregkh@linuxfoundation.org, s-anna@ti.com, tony@atomide.com,
	omar.ramirez@copitl.com, loic.pallardy@st.com,
	lftan.linux@gmail.com, slapdau@yahoo.com.au,
	courtney.cavin@sonymobile.com, rafael.j.wysocki@intel.com,
	robherring2@gmail.com, arnd@arndb.de, joshc@codeaurora.org,
	linus.walleij@linaro.org, galak@codeaurora.org,
	ks.giri@samsung.com, Jassi Brar <jaswinder.singh@linaro.org>
Subject: [PATCHv4 4/5] mailbox: Fix TX completion init
Date: Wed, 19 Mar 2014 00:16:16 +0530	[thread overview]
Message-ID: <1395168376-29200-1-git-send-email-jaswinder.singh@linaro.org> (raw)
In-Reply-To: <1395168169-28978-1-git-send-email-jaswinder.singh@linaro.org>

From: LeyFoon Tan <lftan.linux@gmail.com>

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 | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index 79d576e..cdf7d45 100644
--- a/drivers/mailbox/mailbox.c
+++ b/drivers/mailbox/mailbox.c
@@ -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) {
-- 
1.8.1.2


  parent reply	other threads:[~2014-03-18 18:46 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-18 18:42 [PATCHv4 0/5] Common Mailbox Framework Jassi Brar
2014-03-18 18:44 ` [PATCHv4 1/5] mailbox: rename pl320-ipc specific mailbox.h Jassi Brar
2014-03-18 18:45 ` [PATCHv4 2/5] mailbox: Introduce framework for mailbox Jassi Brar
2014-03-19  4:00   ` Girish KS
2014-03-19  5:20     ` Jassi Brar
2014-03-19  6:02       ` Girish KS
2014-03-28 22:08   ` [PATCHv4,2/5] " Markus Mayer
2014-03-29  3:54     ` Jassi Brar
2014-03-31 22:05       ` Markus Mayer
2014-03-18 18:45 ` [PATCHv4 3/5] mailbox: pl320: Introduce common API driver Jassi Brar
2014-03-18 19:10   ` Rob Herring
2014-03-19  5:40     ` Jassi Brar
2014-03-18 18:46 ` Jassi Brar [this message]
2014-03-18 18:46 ` [PATCHv4 5/5] mailbox: Fix deleteing poll timer Jassi Brar
2014-03-27 22:51 ` [PATCHv4 1/5] mailbox: rename pl320-ipc specific mailbox.h Markus Mayer
2014-03-29  3:55   ` Jassi Brar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1395168376-29200-1-git-send-email-jaswinder.singh@linaro.org \
    --to=jassisinghbrar@gmail.com \
    --cc=arnd@arndb.de \
    --cc=courtney.cavin@sonymobile.com \
    --cc=galak@codeaurora.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jaswinder.singh@linaro.org \
    --cc=joshc@codeaurora.org \
    --cc=ks.giri@samsung.com \
    --cc=lftan.linux@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loic.pallardy@st.com \
    --cc=omar.ramirez@copitl.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=robherring2@gmail.com \
    --cc=s-anna@ti.com \
    --cc=slapdau@yahoo.com.au \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).