Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758284AbaLLInL (ORCPT ); Fri, 12 Dec 2014 03:43:11 -0500 Received: from service87.mimecast.com ([91.220.42.44]:37119 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751428AbaLLInJ convert rfc822-to-8bit (ORCPT ); Fri, 12 Dec 2014 03:43:09 -0500 Message-ID: <548AAA95.6020001@arm.com> Date: Fri, 12 Dec 2014 14:13:01 +0530 From: Sudeep Holla User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Ashwin Chaugule , "jaswinder.singh@linaro.org" CC: Sudeep Holla , "arnd@arndb.de" , "patches@linaro.org" , "linaro-acpi@lists.linaro.org" , "linux-kernel@vger.kernel.org" , "broonie@kernel.org" , "linux-arm-kernel@lists.infradead.org" Subject: Re: [Linaro-acpi] [PATCH] Mailbox: Complete wait event only if Tx was successful References: <1418242572-20998-1-git-send-email-ashwin.chaugule@linaro.org> In-Reply-To: <1418242572-20998-1-git-send-email-ashwin.chaugule@linaro.org> X-OriginalArrivalTime: 12 Dec 2014 08:43:04.0775 (UTC) FILETIME=[A53F1D70:01D015E7] X-MC-Unique: 114121208430600201 Content-Type: text/plain; charset=WINDOWS-1252; format=flowed Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Ashwin, On Thursday 11 December 2014 01:46 AM, Ashwin Chaugule wrote: > If a wait_for_completion_timeout() call returns due to a timeout, > the mbox code can still call complete() after returning from the wait. > This can cause subsequent transmissions on a channel to fail, since > the wait_for_completion_timeout() sees the completion variable > is !=0, caused by the erroneous complete() call, and immediately > returns without waiting for the time as expected by the client. > > Fix this by calling complete() only if the TX was successful. > > Signed-off-by: Ashwin Chaugule > --- > drivers/mailbox/mailbox.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c > index 17e9e4a..4acaddb 100644 > --- a/drivers/mailbox/mailbox.c > +++ b/drivers/mailbox/mailbox.c > @@ -101,7 +101,7 @@ static void tx_tick(struct mbox_chan *chan, int r) > if (mssg && chan->cl->tx_done) > chan->cl->tx_done(chan->cl, mssg, r); > > - if (chan->cl->tx_block) > + if ((!r) && chan->cl->tx_block) > complete(&chan->tx_complete); Just curious to check if there's another possible race which is a different issue. Suppose the timer fired and indicated that the Tx is complete, then it tries to execute complete while the wait_for_completion_timeout timed out. Does that make sense ? So if yes, how about adding !completion_done(..) to the check while you are at this ? Regards, Sudeep -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/