mmc: avoid removing non-removable hosts during suspend
PATCH 1/1 mmc: avoid removing non-removable hosts during suspend
The Weibu F3C MiniPC has an onboard AP6255 module, presenting two SDIO functions on a single MMC host (Bluetooth/btsdio and WiFi/brcmfmac), and the mmc layer correctly detects this as non-removable.
After suspend/resume, the wifi and bluetooth interfaces disappear and do not get probed again.
The conditions here are:
1. During suspend, we reach mmc_pm_notify()
2. mmc_pm_notify() calls mmc_sdio_pre_suspend() to see if we can suspend the SDIO host. However, mmc_sdio_pre_suspend() returns -ENOSYS because btsdio_driver does not have a suspend method.
3. mmc_pm_notify() proceeds to remove the card
4. Upon resume, mmc_rescan() does nothing with this host, because of the rescan_entered check which aims to only scan a non-removable device a single time (i.e. during boot).
Fix the loss of functionality by detecting that we are unable to suspend a non-removable host, so avoid the forced removal in that case. The comment above this function already indicates that this code was only intended for removable devices.
--- drivers/mmc/core/core.c | 8 ++++++++ 1 file changed, 8 insertions(+)
Replaces previous approach:
[PATCH] mmc: allow rescan of non-removable hosts on resume
drivers/mmc/core/core.c +8 -0
@@ -2763,6 +2763,14 @@ static int mmc_pm_notify(struct notifier_block *notify_block,if (!err)break ; +if (!mmc_card_is_removable (host)) { +dev_warn (mmc_dev (host), +"pre_suspend failed for non-removable host: " +"%d\n" , err); +/* Avoid removing non-removable hosts */ +break ; + } +/* Calling bus_ops->remove() with a claimed host can deadlock */ host->bus_ops->remove (host);mmc_claim_host (host);
Signature · 1 line
2.14.1
Ulf Hansson
AppliedQuoted 22 lines · Daniel Drake
The Weibu F3C MiniPC has an onboard AP6255 module, presenting two SDIO functions on a single MMC host (Bluetooth/btsdio and WiFi/brcmfmac), and the mmc layer correctly detects this as non-removable.
After suspend/resume, the wifi and bluetooth interfaces disappear and do not get probed again.
The conditions here are:
1. During suspend, we reach
mmc_pm_notify()2.
mmc_pm_notify()callsmmc_sdio_pre_suspend()to see if we can suspend the SDIO host. However,mmc_sdio_pre_suspend()returns-ENOSYSbecausebtsdio_driverdoes not have a suspend method.3.
mmc_pm_notify()proceeds to remove the card4. Upon resume,
mmc_rescan()does nothing with this host, because of therescan_enteredcheck which aims to only scan a non-removable device a single time (i.e. during boot).
Quoted 6 lines
Fix the loss of functionality by detecting that we are unable to suspend a non-removable host, so avoid the forced removal in that case. The comment above this function already indicates that this code was only intended for removable devices.
Signed-off-by Daniel Drake <[email protected]>
Thanks, applied for next!
Kind regards
Uffe
Quoted 29 lines
--- drivers/mmc/core/core.c | 8 ++++++++ 1 file changed, 8 insertions(+)Replaces previous approach:
[PATCH] mmc: allow rescan of non-removable hosts on resumedrivers/mmc/core/core.c +8
-1@@ -2763,6 +2763,14 @@ static int mmc_pm_notify(struct notifier_block *notify_block,if (!err)break ; +if (!mmc_card_is_removable (host)) { +dev_warn (mmc_dev (host), +"pre_suspend failed for non-removable host: " +"%d\n" , err); +/* Avoid removing non-removable hosts */ +break ; + } +/* Calling bus_ops->remove() with a claimed host can deadlock */ host->bus_ops->remove (host);mmc_claim_host (host); --2.14.1