From: Doug Anderson <dianders@chromium.org>
To: Grant Likely <grant.likely@secretlab.ca>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Mark Brown <broonie@opensource.wolfsonmicro.com>,
Olof Johansson <olof@lixom.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Bryan Freed <bfreed@chromium.org>,
Doug Anderson <dianders@chromium.org>,
spi-devel-general@lists.sourceforge.net,
linux-kernel@vger.kernel.org
Subject: [REPOST PATCH] spi: Unlock a spinlock before calling into the controller driver.
Date: Wed, 13 Mar 2013 11:17:40 -0700 [thread overview]
Message-ID: <1363198660-21656-1-git-send-email-dianders@chromium.org> (raw)
In-Reply-To: <1340409205-23606-1-git-send-email-bfreed@chromium.org>
From: Bryan Freed <bfreed@chromium.org>
spi_pump_messages() calls into a controller driver with
unprepare_transfer_hardware() which is documented as "This may sleep".
As in the prepare_transfer_hardware() call below, we should release the
queue_lock spinlock before making the call.
Rework the logic a bit to hold queue_lock to protect the 'busy' flag,
then release it to call unprepare_transfer_hardware().
Signed-off-by: Bryan Freed <bfreed@chromium.org>
Reviewed-by: Doug Anderson <dianders@chromium.org>
Signed-off-by: Doug Anderson <dianders@chromium.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
---
During a rebase we noticed that this old patch never actually landed
anywhere. I haven't gone through an reproduced the original bug on
ToT but I believe that this patch is still required. Perhaps it could
land somewhere? ;) Thanks!
drivers/spi/spi.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index f996c60..5b96250 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -543,17 +543,16 @@ static void spi_pump_messages(struct kthread_work *work)
/* Lock queue and check for queue work */
spin_lock_irqsave(&master->queue_lock, flags);
if (list_empty(&master->queue) || !master->running) {
- if (master->busy && master->unprepare_transfer_hardware) {
- ret = master->unprepare_transfer_hardware(master);
- if (ret) {
- spin_unlock_irqrestore(&master->queue_lock, flags);
- dev_err(&master->dev,
- "failed to unprepare transfer hardware\n");
- return;
- }
+ if (!master->busy) {
+ spin_unlock_irqrestore(&master->queue_lock, flags);
+ return;
}
master->busy = false;
spin_unlock_irqrestore(&master->queue_lock, flags);
+ if (master->unprepare_transfer_hardware &&
+ master->unprepare_transfer_hardware(master))
+ dev_err(&master->dev,
+ "failed to unprepare transfer hardware\n");
return;
}
--
1.8.1.3
next prev parent reply other threads:[~2013-03-13 18:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-22 23:53 [PATCH] spi: Unlock a spinlock before calling into the controller driver Bryan Freed
2012-06-24 23:54 ` Olof Johansson
[not found] ` <CAOesGMgq5HRz+pDFQtED5GPN0RUrON=_k_y4YHHzKrMkHnVk4A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-06-25 17:07 ` Doug Anderson
[not found] ` <CAD=FV=UpBG8gmPjWDF0M9EMSvs4pg7icocMXJ1r3Lmi8frZsrg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-06-25 18:56 ` Linus Walleij
[not found] ` <1340409205-23606-1-git-send-email-bfreed-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2012-06-25 19:01 ` Linus Walleij
2013-03-13 18:17 ` Doug Anderson [this message]
2013-04-01 13:24 ` [REPOST PATCH] " Mark Brown
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=1363198660-21656-1-git-send-email-dianders@chromium.org \
--to=dianders@chromium.org \
--cc=bfreed@chromium.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=grant.likely@secretlab.ca \
--cc=gregkh@linuxfoundation.org \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=olof@lixom.net \
--cc=spi-devel-general@lists.sourceforge.net \
/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).