mmc: core: Fix deadlock when the CONFIG_MMC_UNSAFE_RESUME is not defined
PATCH v2 1/1 mmc: core: Fix deadlock when the CONFIG_MMC_UNSAFE_RESUME is not defined
mmc_suspend_host() tries to claim host during suspend and release it only when the bus suspend operation is compeleted. If CONFIG_MMC_UNSAFE_RESUME is defined and the host is flagged as removable, mmc_suspend_host() tries to remove the card. In this process, the file system sync can get blocked trying to acquire host which is already claimed by mmc_suspend_host() causing deadlock.
Fix this deadlock by releasing host before ->remove() is called.
---
Changes in v2:
- Addressed review comment from Ulf Hansson.
--- drivers/mmc/core/core.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/mmc/core/core.c +2 -1
@@ -2333,6 +2333,8 @@ int mmc_suspend_host(struct mmc_host *host)mmc_poweroff_notify (host); err = host->bus_ops->suspend (host); } +mmc_do_release_host (host); +if (err == -ENOSYS || !host->bus_ops->resume) {/* * We simply "remove" the card in this case.
@@ -2347,7 +2349,6 @@ int mmc_suspend_host(struct mmc_host *host) host->pm_flags =0 ; err =0 ; } -mmc_do_release_host (host); }else { err = -EBUSY ; }
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Quoted 8 lines · Sujit Reddy Thumma
mmc_suspend_host()tries to claim host during suspend and release it only when the bus suspend operation is compeleted. IfCONFIG_MMC_UNSAFE_RESUMEis defined and the host is flagged as removable,mmc_suspend_host()tries to remove the card. In this process, the file system sync can get blocked trying to acquire host which is already claimed bymmc_suspend_host()causing deadlock.
Quoted 4 lines
Fix this deadlock by releasing host before ->remove() is called.
Signed-off-by Sujit Reddy Thumma <[email protected]>
Looks good to me!
Quoted 11 lines · Sujit Reddy Thumma
mmc_suspend_host()tries to claim host during suspend and release it only when the bus suspend operation is compeleted. IfCONFIG_MMC_UNSAFE_RESUMEis defined and the host is flagged as removable,mmc_suspend_host()tries to remove the card. In this process, the file system sync can get blocked trying to acquire host which is already claimed bymmc_suspend_host()causing deadlock.Fix this deadlock by releasing host before ->remove() is called.
Signed-off-by Sujit Reddy Thumma <[email protected]>
Looks correct!
Yours,
Linus Walleij
Hi,
Quoted 33 lines · Sujit Reddy Thumma
mmc_suspend_host()tries to claim host during suspend and release it only when the bus suspend operation is compeleted. IfCONFIG_MMC_UNSAFE_RESUMEis defined and the host is flagged as removable,mmc_suspend_host()tries to remove the card. In this process, the file system sync can get blocked trying to acquire host which is already claimed bymmc_suspend_host()causing deadlock.Fix this deadlock by releasing host before ->remove() is called.
Signed-off-by Sujit Reddy Thumma <[email protected]>---
Changes in v2:
- Addressed review comment from Ulf Hansson.--- drivers/mmc/core/core.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)drivers/mmc/core/core.c +2
-0@@ -2333,6 +2333,8 @@ int mmc_suspend_host(struct mmc_host *host)mmc_poweroff_notify (host); err = host->bus_ops->suspend (host); } +mmc_do_release_host (host); +if (err == -ENOSYS || !host->bus_ops->resume) {/* * We simply "remove" the card in this case.
drivers/mmc/core/core.c int mmc_suspend_host(struct mmc_host *host) · line 2354
Quoted 7 lines
drivers/mmc/core/core.c +0
-1@@ -2347,7 +2349,6 @@ int mmc_suspend_host(struct mmc_host *host) host->pm_flags =0 ; err =0 ; } -mmc_do_release_host (host); }else { err = -EBUSY ; }
Thanks very much, pushed to mmc-next for 3.2 with ACKs from Ulf and Linus.
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child