All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2 0/2] mmc: sdio: Keep card runtime resumed while adding function devices
@ 2017-06-09 12:27 Adrian Hunter
  2017-06-09 12:27 ` [PATCH V2 1/2] mmc: sdio: Tidy error path in mmc_attach_sdio() Adrian Hunter
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Adrian Hunter @ 2017-06-09 12:27 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: linux-mmc

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH V2 1/2] mmc: sdio: Tidy error path in mmc_attach_sdio()
  2017-06-09 12:27 [PATCH V2 0/2] mmc: sdio: Keep card runtime resumed while adding function devices Adrian Hunter
@ 2017-06-09 12:27 ` Adrian Hunter
  2017-06-09 12:27 ` [PATCH V2 2/2] mmc: sdio: Keep card runtime resumed while adding function devices Adrian Hunter
  2017-06-09 13:29 ` [PATCH V2 0/2] " Ulf Hansson
  2 siblings, 0 replies; 4+ messages in thread
From: Adrian Hunter @ 2017-06-09 12:27 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: linux-mmc

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.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/core/sdio.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
index fae732c870a9..f077fc8219d0 100644
--- a/drivers/mmc/core/sdio.c
+++ b/drivers/mmc/core/sdio.c
@@ -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);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH V2 2/2] mmc: sdio: Keep card runtime resumed while adding function devices
  2017-06-09 12:27 [PATCH V2 0/2] mmc: sdio: Keep card runtime resumed while adding function devices Adrian Hunter
  2017-06-09 12:27 ` [PATCH V2 1/2] mmc: sdio: Tidy error path in mmc_attach_sdio() Adrian Hunter
@ 2017-06-09 12:27 ` Adrian Hunter
  2017-06-09 13:29 ` [PATCH V2 0/2] " Ulf Hansson
  2 siblings, 0 replies; 4+ messages in thread
From: Adrian Hunter @ 2017-06-09 12:27 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: linux-mmc

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.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/core/sdio.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
index f077fc8219d0..cc43687ca241 100644
--- a/drivers/mmc/core/sdio.c
+++ b/drivers/mmc/core/sdio.c
@@ -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);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH V2 0/2] mmc: sdio: Keep card runtime resumed while adding function devices
  2017-06-09 12:27 [PATCH V2 0/2] mmc: sdio: Keep card runtime resumed while adding function devices Adrian Hunter
  2017-06-09 12:27 ` [PATCH V2 1/2] mmc: sdio: Tidy error path in mmc_attach_sdio() Adrian Hunter
  2017-06-09 12:27 ` [PATCH V2 2/2] mmc: sdio: Keep card runtime resumed while adding function devices Adrian Hunter
@ 2017-06-09 13:29 ` Ulf Hansson
  2 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2017-06-09 13:29 UTC (permalink / raw)
  To: Adrian Hunter; +Cc: linux-mmc

On 9 June 2017 at 14:27, Adrian Hunter <adrian.hunter@intel.com> wrote:
> 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

Thanks, applied for next!

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-06-09 13:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-09 12:27 [PATCH V2 0/2] mmc: sdio: Keep card runtime resumed while adding function devices Adrian Hunter
2017-06-09 12:27 ` [PATCH V2 1/2] mmc: sdio: Tidy error path in mmc_attach_sdio() Adrian Hunter
2017-06-09 12:27 ` [PATCH V2 2/2] mmc: sdio: Keep card runtime resumed while adding function devices Adrian Hunter
2017-06-09 13:29 ` [PATCH V2 0/2] " Ulf Hansson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.