RE: [RFC]mmc: fix dead lock issue when system entering S3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Just found Andrei Warkentin also submitted a RFC patch, which included more fix for mounted root file system media. Please ignore this thread.

> -----Original Message-----
> From: linux-mmc-owner@xxxxxxxxxxxxxxx
> [mailto:linux-mmc-owner@xxxxxxxxxxxxxxx] On Behalf Of Chuanxiao Dong
> Sent: Tuesday, May 17, 2011 3:54 PM
> To: linux-mmc@xxxxxxxxxxxxxxx
> Cc: He, Bo
> Subject: [RFC]mmc: fix dead lock issue when system entering S3
> 
> 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@xxxxxxxxx>
> Signed-off-by: Chuanxiao Dong <chuanxiao.dong@xxxxxxxxx>
> ---
>  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
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux