linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: don't lock the bus in __spi_pump_messages if it is already locked
@ 2016-03-17 23:18 Heiko Stübner
  2016-03-18  5:23 ` Vignesh R
  0 siblings, 1 reply; 2+ messages in thread
From: Heiko Stübner @ 2016-03-17 23:18 UTC (permalink / raw)
  To: Mark Brown
  Cc: Kevin Hilman, Vignesh R, Jon Hunter,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-spi-u79uwXL29TY76Z2rM5mHXA

External users may use spi_bus_lock to get exclusive access. This will
also grab the bus_lock_mutex and may therefore result in a deadlock if
__spi_pump_messages also tries to get the mutex.

Fixes: 49023d2e4ead ("spi: core: Fix deadlock when sending messages")
Signed-off-by: Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
---
 drivers/spi/spi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index de2f2f9..62f962b 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1160,7 +1160,7 @@ static void __spi_pump_messages(struct spi_master *master, bool in_kthread,
 		}
 	}
 
-	if (!bus_locked)
+	if (!bus_locked && !master->bus_lock_flag)
 		mutex_lock(&master->bus_lock_mutex);
 
 	trace_spi_message_start(master->cur_msg);
@@ -1192,7 +1192,7 @@ static void __spi_pump_messages(struct spi_master *master, bool in_kthread,
 	}
 
 out:
-	if (!bus_locked)
+	if (!bus_locked && !master->bus_lock_flag)
 		mutex_unlock(&master->bus_lock_mutex);
 
 	/* Prod the scheduler in case transfer_one() was busy waiting */
-- 
2.6.4


--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2016-03-18  5:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-17 23:18 [PATCH] spi: don't lock the bus in __spi_pump_messages if it is already locked Heiko Stübner
2016-03-18  5:23 ` Vignesh R

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