Skip to contentSkip to conversation

mmc: sdio: Keep card runtime resumed while adding function devices

PATCH Applied Adrian Hunter 2 participants 4 messages Jun 9, 2017 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

v2 cover mmc: sdio: Keep card runtime resumed while adding function devices

Hi

Here is V2 of the patch to keep an SDIO card runtime resumed while adding function devices.

Changes in V2:

mmc: sdio: Tidy error path in mmc_attach_sdio()
New patch

mmc: sdio: Keep card runtime resumed while adding function devices
Move call to pm_runtime_get_noresume() before pm_runtime_set_active().
Do not use pm_runtime_put() incorrectly (or at all) in the error path.

Adrian Hunter (2):
mmc: sdio: Tidy error path in mmc_attach_sdio()
mmc: sdio: Keep card runtime resumed while adding function devices

 drivers/mmc/core/sdio.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

Regards
Adrian

#1 lore raw

PATCH v2 1/2 mmc: sdio: Tidy error path in mmc_attach_sdio()

The error path deletes the device by calling mmc_sdio_remove() which must be called without the host claimed. Simplify the error path so it does just that and add a comment about why we don't disable runtime PM.

---
 drivers/mmc/core/sdio.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/mmc/core/sdio.c +6 -7
index fae732c870a9..f077fc8219d0 100644
@@ -1159,15 +1159,14 @@ int mmc_attach_sdio(struct mmc_host *host)
 	return 0;
 
 
-remove_added:
-	/* Remove without lock if the device has been added. */
-	mmc_sdio_remove(host);
-	mmc_claim_host(host);
 remove:
-	/* And with lock if it hasn't been added. */
 	mmc_release_host(host);
-	if (host->card)
-		mmc_sdio_remove(host);
+remove_added:
+	/*
+	 * The devices are being deleted so it is not necessary to disable
+	 * runtime PM.
+	 */
+	mmc_sdio_remove(host);
 	mmc_claim_host(host);
 err:
 	mmc_detach_bus(host);
Signature · 1 line
1.9.1
#2 lore raw

PATCH v2 2/2 mmc: sdio: Keep card runtime resumed while adding function devices

In reply to Adrian Hunter

Drivers core will runtime suspend a device with no driver. That means the SDIO card will be runtime suspended as soon as it is added. It is then runtime resumed to add each function. That is entirely pointless, so add pm runtime get/put to keep the SDIO card runtime resumed until the function devices have been added.

---
 drivers/mmc/core/sdio.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/mmc/core/sdio.c +12 -1
index f077fc8219d0..cc43687ca241 100644
@@ -1104,6 +1104,12 @@ int mmc_attach_sdio(struct mmc_host *host)
 	 */
 	if (host->caps & MMC_CAP_POWER_OFF_CARD) {
 		/*
+		 * Do not allow runtime suspend until after SDIO function
+		 * devices are added.
+		 */
+		pm_runtime_get_noresume(&card->dev);
+
+		/*
 		 * Let runtime PM core know our card is active
 		 */
 		err = pm_runtime_set_active(&card->dev);
@@ -1155,6 +1161,9 @@ int mmc_attach_sdio(struct mmc_host *host)
 			goto remove_added;
 	}
 
+	if (host->caps & MMC_CAP_POWER_OFF_CARD)
+		pm_runtime_put(&card->dev);
+
 	mmc_claim_host(host);
 	return 0;
 
@@ -1164,7 +1173,9 @@ int mmc_attach_sdio(struct mmc_host *host)
 remove_added:
 	/*
 	 * The devices are being deleted so it is not necessary to disable
-	 * runtime PM.
+	 * runtime PM. Similarly we also don't pm_runtime_put() the SDIO card
+	 * because it needs to be active to remove any function devices that
+	 * were probed, and after that it gets deleted.
 	 */
 	mmc_sdio_remove(host);
 	mmc_claim_host(host);
Signature · 1 line
1.9.1
Applied
#3 lore raw
In reply to Adrian Hunter
Quoted 22 lines · Adrian Hunter

Hi

Here is V2 of the patch to keep an SDIO card runtime resumed while adding function devices.

Changes in V2:

mmc: sdio: Tidy error path in mmc_attach_sdio()
New patch

mmc: sdio: Keep card runtime resumed while adding function devices
Move call to pm_runtime_get_noresume() before pm_runtime_set_active().
Do not use pm_runtime_put() incorrectly (or at all) in the error path.

Adrian Hunter (2):
mmc: sdio: Tidy error path in mmc_attach_sdio()
mmc: sdio: Keep card runtime resumed while adding function devices

Quoted 6 lines
 drivers/mmc/core/sdio.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

Regards
Adrian

Thanks, applied for next!

Kind regards
Uffe