From: Chris Ball <cjb@laptop.org>
To: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: linux-mmc@vger.kernel.org
Subject: Re: [PATCH] mmc: fix a deadlock between system suspend and MMC block IO
Date: Wed, 04 Jan 2012 09:37:14 -0500 [thread overview]
Message-ID: <m2lipnfs9x.fsf@bob.laptop.org> (raw)
In-Reply-To: <Pine.LNX.4.64.1201041527480.30506@axis700.grange> (Guennadi Liakhovetski's message of "Wed, 4 Jan 2012 15:28:45 +0100 (CET)")
Hi,
On Wed, Jan 04 2012, Guennadi Liakhovetski wrote:
> 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);
Thanks. The commit message explanation is very good, but the comment is
a bit cryptic. Shall we make it longer? I think even just:
/* Calling bus_ops->remove() with a claimed host can deadlock */
would be better.
- Chris.
--
Chris Ball <cjb@laptop.org> <http://printf.net/>
One Laptop Per Child
next prev parent reply other threads:[~2012-01-04 14:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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=m2lipnfs9x.fsf@bob.laptop.org \
--to=cjb@laptop.org \
--cc=g.liakhovetski@gmx.de \
--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 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.