All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: fix a deadlock between system suspend and MMC block IO
@ 2012-01-04 14:28 Guennadi Liakhovetski
  2012-01-04 14:37 ` Chris Ball
  0 siblings, 1 reply; 7+ messages in thread
From: Guennadi Liakhovetski @ 2012-01-04 14:28 UTC (permalink / raw)
  To: linux-mmc; +Cc: Chris Ball

Performing MMC block IO with simultaneous STR can lead to a deadlock: the
mmc_pm_notify() function claims the host and then calls bus .remove()
method, which lands in mmc_blk_remove(), which calls mmc_blk_remove_req()
then it goes to -> mmc_cleanup_queue() -> kthread_stop(), which waits for
the mmc-block thread to stop. If the mmc-block thread at that time is
processing block requests, it will also try to claim the host in
mmc_blk_issue_rq() and block there. This patch fixes the problem by
calling .remove() before claiming the host.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
 drivers/mmc/core/core.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index a2aa860..a68f085 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2476,11 +2476,11 @@ int mmc_pm_notify(struct notifier_block *notify_block,
 		if (!host->bus_ops || host->bus_ops->suspend)
 			break;
 
-		mmc_claim_host(host);
-
+		/* On 2 occasions above bus_ops->remove() is called unlocked */
 		if (host->bus_ops->remove)
 			host->bus_ops->remove(host);
 
+		mmc_claim_host(host);
 		mmc_detach_bus(host);
 		mmc_power_off(host);
 		mmc_release_host(host);
-- 
1.7.2.5


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

end of thread, other threads:[~2012-01-11 19:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-04 14:28 [PATCH] mmc: fix a deadlock between system suspend and MMC block IO Guennadi Liakhovetski
2012-01-04 14:37 ` Chris Ball
2012-01-04 14:40   ` Nath, Arindam
2012-01-04 15:03     ` Chris Ball
2012-01-11  8:56       ` Nath, Arindam
2012-01-11 19:30         ` Chris Ball
2012-01-04 14:45   ` Guennadi Liakhovetski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.