linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: Unlock a spinlock before calling into the controller driver.
@ 2012-06-22 23:53 Bryan Freed
  2012-06-24 23:54 ` Olof Johansson
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Bryan Freed @ 2012-06-22 23:53 UTC (permalink / raw)
  To: spi-devel-general; +Cc: grant.likely, linux-kernel, Bryan Freed

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>

---
 drivers/spi/spi.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index fc0da39..f7f9df9 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -532,17 +532,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.7.7.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-04-01 13:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [REPOST PATCH] " Doug Anderson
2013-04-01 13:24   ` Mark Brown

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).