On Sat, 23 Feb 2008, Alan Stern wrote:In fact this turns out to be exactly the problem with the MMC subsystem. It uses a dedicated workqueue (kmmcd) to handle state changes, and mmc_suspend_host() does a flush_workqueue(). If the workqueue contains an entry to register or unregister a device, this is guaranteed to deadlock -- and that's exactly what happens when Zdenek inserts or removes a card during the disk-drive spindown time of a system sleep. It looks like the best solution is for mmc_suspend_host() not to flush the workqueue; instead the workqueue should prevent itself from running during a suspend. Right now the easiest way to accomplish this is for the workqueue routines (mmc_detect() and siblings) to acquire the mmc_host's device semaphore. If in the future the MMC subsystem adds dynamic PM support then a more complicated arrangement will be needed. So the patch below, in combination with the previous patch, might just fix the whole problem. Alan Stern Index: usb-2.6/drivers/mmc/core/core.c =================================================================== --- usb-2.6.orig/drivers/mmc/core/core.c +++ usb-2.6/drivers/mmc/core/core.c @@ -731,8 +731,6 @@ void mmc_stop_host(struct mmc_host *host */ int mmc_suspend_host(struct mmc_host *host, pm_message_t state) { - mmc_flush_scheduled_work(); - mmc_bus_get(host); if (host->bus_ops && !host->bus_dead) { if (host->bus_ops->suspend) Index: usb-2.6/drivers/mmc/core/mmc.c =================================================================== --- usb-2.6.orig/drivers/mmc/core/mmc.c +++ usb-2.6/drivers/mmc/core/mmc.c @@ -441,6 +441,7 @@ static void mmc_detect(struct mmc_host * BUG_ON(!host); BUG_ON(!host->card); + down(&mmc_classdev(host)->sem); mmc_claim_host(host); /* @@ -449,6 +450,7 @@ static void mmc_detect(struct mmc_host * err = mmc_send_status(host->card, NULL); mmc_release_host(host); + up(&mmc_classdev(host)->sem); if (err) { mmc_remove(host); Index: usb-2.6/drivers/mmc/core/sd.c =================================================================== --- usb-2.6.orig/drivers/mmc/core/sd.c +++ usb-2.6/drivers/mmc/core/sd.c @@ -500,6 +500,7 @@ static void mmc_sd_detect(struct mmc_hos BUG_ON(!host); BUG_ON(!host->card); + down(&mmc_classdev(host)->sem); mmc_claim_host(host); /* @@ -508,6 +509,7 @@ static void mmc_sd_detect(struct mmc_hos err = mmc_send_status(host->card, NULL); mmc_release_host(host); + up(&mmc_classdev(host)->sem); if (err) { mmc_sd_remove(host); Index: usb-2.6/drivers/mmc/core/sdio.c =================================================================== --- usb-2.6.orig/drivers/mmc/core/sdio.c +++ usb-2.6/drivers/mmc/core/sdio.c @@ -195,6 +195,7 @@ static void mmc_sdio_detect(struct mmc_h BUG_ON(!host); BUG_ON(!host->card); + down(&mmc_classdev(host)->sem); mmc_claim_host(host); /* @@ -203,6 +204,7 @@ static void mmc_sdio_detect(struct mmc_h err = mmc_select_card(host->card); mmc_release_host(host); + up(&mmc_classdev(host)->sem); if (err) { mmc_sdio_remove(host); --
| debian developer | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
| Greg Kroah-Hartman | [PATCH 014/196] kobject: remove incorrect comment in kobject_rename |
| Vladislav Bolkhovitin | Re: Integration of SCST in the mainstream Linux kernel |
| Stephen Rothwell | Re: Announce: Linux-next (Or Andrew's dream :-)) |
git: | |
| Gerrit Renker | [PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side) |
| David Miller | [GIT]: Networking |
| Radu Rendec | htb parallelism on multi-core platforms |
| David Miller | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
