public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: fix runtime PM with -ENOSYS suspend case
@ 2011-07-17 15:38 Daniel Drake
  2011-07-19  2:00 ` Chris Ball
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Drake @ 2011-07-17 15:38 UTC (permalink / raw)
  To: cjb; +Cc: linux-mmc, ohad

From: Ohad Ben-Cohen <ohad@wizery.com>

In the case where a driver returns -ENOSYS from its suspend handler
to indicate that the device should be powered down over suspend, the
remove routine of the driver was not being called, leading to lots of
confusion during resume.

The problem is that runtime PM is disabled during this process,
and when we reach mmc_sdio_remove, calling the runtime PM functions here
(validly) return errors, and this was causing us to skip the remove
function.

Fix this by ignoring the error value of pm_runtime_get_sync(), which
can return valid errors. This also matches the behaviour of
pci_device_remove().

Signed-off-by: Daniel Drake <dsd@laptop.org>
---
 drivers/mmc/core/sdio_bus.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

For linux-3.1.

diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c
index d2565df..e4e6822 100644
--- a/drivers/mmc/core/sdio_bus.c
+++ b/drivers/mmc/core/sdio_bus.c
@@ -167,11 +167,8 @@ static int sdio_bus_remove(struct device *dev)
 	int ret = 0;
 
 	/* Make sure card is powered before invoking ->remove() */
-	if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD) {
-		ret = pm_runtime_get_sync(dev);
-		if (ret < 0)
-			goto out;
-	}
+	if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD)
+		pm_runtime_get_sync(dev);
 
 	drv->remove(func);
 
@@ -191,7 +188,6 @@ static int sdio_bus_remove(struct device *dev)
 	if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD)
 		pm_runtime_put_sync(dev);
 
-out:
 	return ret;
 }
 
-- 
1.7.6


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

* Re: [PATCH] mmc: fix runtime PM with -ENOSYS suspend case
  2011-07-17 15:38 [PATCH] mmc: fix runtime PM with -ENOSYS suspend case Daniel Drake
@ 2011-07-19  2:00 ` Chris Ball
  0 siblings, 0 replies; 2+ messages in thread
From: Chris Ball @ 2011-07-19  2:00 UTC (permalink / raw)
  To: Daniel Drake; +Cc: linux-mmc

Hi Dan,

On Sun, Jul 17 2011, Daniel Drake wrote:
> From: Ohad Ben-Cohen <ohad@wizery.com>
>
> In the case where a driver returns -ENOSYS from its suspend handler
> to indicate that the device should be powered down over suspend, the
> remove routine of the driver was not being called, leading to lots of
> confusion during resume.
>
> The problem is that runtime PM is disabled during this process,
> and when we reach mmc_sdio_remove, calling the runtime PM functions here
> (validly) return errors, and this was causing us to skip the remove
> function.
>
> Fix this by ignoring the error value of pm_runtime_get_sync(), which
> can return valid errors. This also matches the behaviour of
> pci_device_remove().
>
> Signed-off-by: Daniel Drake <dsd@laptop.org>
> ---
>  drivers/mmc/core/sdio_bus.c |    8 ++------
>  1 files changed, 2 insertions(+), 6 deletions(-)
>
> For linux-3.1.
>
> diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c
> index d2565df..e4e6822 100644
> --- a/drivers/mmc/core/sdio_bus.c
> +++ b/drivers/mmc/core/sdio_bus.c
> @@ -167,11 +167,8 @@ static int sdio_bus_remove(struct device *dev)
>  	int ret = 0;
>  
>  	/* Make sure card is powered before invoking ->remove() */
> -	if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD) {
> -		ret = pm_runtime_get_sync(dev);
> -		if (ret < 0)
> -			goto out;
> -	}
> +	if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD)
> +		pm_runtime_get_sync(dev);
>  
>  	drv->remove(func);
>  
> @@ -191,7 +188,6 @@ static int sdio_bus_remove(struct device *dev)
>  	if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD)
>  		pm_runtime_put_sync(dev);
>  
> -out:
>  	return ret;
>  }

Thanks very much, pushed to mmc-next for 3.1.

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

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

end of thread, other threads:[~2011-07-19  2:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-17 15:38 [PATCH] mmc: fix runtime PM with -ENOSYS suspend case Daniel Drake
2011-07-19  2:00 ` Chris Ball

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox