Skip to contentSkip to conversation

mmc: core: Fix deadlock when the CONFIG_MMC_UNSAFE_RESUME is not defined

PATCH In review Sujit Reddy Thumma 4 participants 4 messages Nov 23, 2011 – Dec 1, 2011 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

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
index 271efea..950b97d 100644
@@ -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.
Acked-by on v2 1/1
#1 lore raw
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. 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.

Quoted 4 lines

Fix this deadlock by releasing host before ->remove() is called.

Looks good to me!

Acked-by on v2 1/1
#2 lore raw
In reply to Sujit Reddy Thumma
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. 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.

Looks correct!

Yours,
Linus Walleij

#3 lore raw
In reply to Sujit Reddy Thumma

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. 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 -0
index 271efea..950b97d 100644
@@ -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