From: Chuanxiao Dong <chuanxiao.dong@intel.com>
To: linux-mmc@vger.kernel.org
Cc: bo.he@intel.com
Subject: [RFC]mmc: fix dead lock issue when system entering S3
Date: Tue, 17 May 2011 15:53:52 +0800 [thread overview]
Message-ID: <20110517075352.GA3992@intel.com> (raw)
Hi all,
I encountered a dead lock issue. Two threads try to claim host, unfortunately
one thread needs to sync with the other. I encountered this issue with SD
card when testing system entering S3. Does anybody encounter the same issue?
Environment:
1. without CONFIG_MMC_UNSAFE_RESUME operation
2. the SD card mounted
During system tried to enter S3, mmc_pm_notifier will be called first to remove
SD card. So calling sequence in SD remove thread is like this:
mmc_claim_host
bus_ops->remove
....
....
mmc_cleanup_queue
kthread_stop(mq->thread)
...
...
Mean while, mmc_cleanup_queue wakes up mq->thread, the calling sequence in mq->thread is
like this:
mmc_queue_thread
mq->issue_fn (mmc_blk_issue_rq)
mmc_claim_host (dead lock)
....
....
Since mmc_claim_host is called in mq->thread (not SD remove thread) again,
unfortunately right now host is already claimed by SD remove thread which is
also waiting for mq->thread finished, so cause a dead lock here.
Move the mmc_claim_host(in mmc_pm_notifier) after bus_ops->remove can resolve
this dead lock. mmc_suspend_host() is using the same way to claim host.
Need to know your suggestions.
Signed-off-by: He Bo <bo.he@intel.com>
Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.com>
---
drivers/mmc/core/core.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 68091dd..1e27588 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1850,11 +1850,10 @@ int mmc_pm_notify(struct notifier_block *notify_block,
if (!host->bus_ops || host->bus_ops->suspend)
break;
- mmc_claim_host(host);
-
if (host->bus_ops->remove)
host->bus_ops->remove(host);
+ mmc_claim_host(host);
mmc_detach_bus(host);
mmc_release_host(host);
host->pm_flags = 0;
--
1.7.3.4
next reply other threads:[~2011-05-17 8:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-17 7:53 Chuanxiao Dong [this message]
2011-05-17 10:03 ` [RFC]mmc: fix dead lock issue when system entering S3 Dong, Chuanxiao
2011-05-18 7:58 ` Andrei Warkentin
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=20110517075352.GA3992@intel.com \
--to=chuanxiao.dong@intel.com \
--cc=bo.he@intel.com \
--cc=linux-mmc@vger.kernel.org \
/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).