public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/5] mmc: core: call pm_runtime_put_sync in pm_runtime_get_sync failed case
       [not found] <1362037031.6212.3.camel@fli24-HP-Compaq-8100-Elite-CMT-PC>
@ 2013-02-28  7:44 ` Li Fei
  2013-04-07 10:39   ` Ohad Ben-Cohen
  2013-04-08  1:36   ` [PATCH 2/5 V2] mmc: core: call pm_runtime_put_noidle " Li Fei
  0 siblings, 2 replies; 6+ messages in thread
From: Li Fei @ 2013-02-28  7:44 UTC (permalink / raw)
  To: cjb, ulf.hansson, johan.rudholm, subhashj, prakity,
	rafael.j.wysocki, thierry.reding, sachin.kamat
  Cc: linux-mmc, rjw, linux-kernel, chuansheng.liu, fei.li


Even in failed case of pm_runtime_get_sync, the usage_count
is incremented. In order to keep the usage_count with correct
value and runtime power management to behave correctly, call
pm_runtime_put(_sync) in such case.

Signed-off-by Liu Chuansheng <chuansheng.liu@intel.com>
Signed-off-by: Li Fei <fei.li@intel.com>
---
 drivers/mmc/core/sdio.c     |    3 +--
 drivers/mmc/core/sdio_bus.c |    4 +++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
index aa0719a..45ab6f32 100644
--- a/drivers/mmc/core/sdio.c
+++ b/drivers/mmc/core/sdio.c
@@ -874,6 +874,7 @@ static void mmc_sdio_detect(struct mmc_host *host)
 
 	mmc_release_host(host);
 
+out:
 	/*
 	 * Tell PM core it's OK to power off the card now.
 	 *
@@ -887,8 +888,6 @@ static void mmc_sdio_detect(struct mmc_host *host)
 	 */
 	if (host->caps & MMC_CAP_POWER_OFF_CARD)
 		pm_runtime_put_sync(&host->card->dev);
-
-out:
 	if (err) {
 		mmc_sdio_remove(host);
 
diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c
index 5e57048..d572b31 100644
--- a/drivers/mmc/core/sdio_bus.c
+++ b/drivers/mmc/core/sdio_bus.c
@@ -136,8 +136,10 @@ static int sdio_bus_probe(struct device *dev)
 	 */
 	if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD) {
 		ret = pm_runtime_get_sync(dev);
-		if (ret < 0)
+		if (ret < 0) {
+			pm_runtime_put_sync(dev);
 			goto out;
+		}
 	}
 
 	/* Set the default block size so the driver is sure it's something
-- 
1.7.4.1




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

* Re: [PATCH 2/5] mmc: core: call pm_runtime_put_sync in pm_runtime_get_sync failed case
  2013-02-28  7:44 ` [PATCH 2/5] mmc: core: call pm_runtime_put_sync in pm_runtime_get_sync failed case Li Fei
@ 2013-04-07 10:39   ` Ohad Ben-Cohen
  2013-04-08  1:36     ` Li, Fei
  2013-04-08  1:36   ` [PATCH 2/5 V2] mmc: core: call pm_runtime_put_noidle " Li Fei
  1 sibling, 1 reply; 6+ messages in thread
From: Ohad Ben-Cohen @ 2013-04-07 10:39 UTC (permalink / raw)
  To: Li Fei
  Cc: Chris Ball, ulf.hansson, johan.rudholm, subhashj, Philip Rakity,
	rafael.j.wysocki, thierry.reding, sachin.kamat,
	linux-mmc@vger.kernel.org, Rafael J. Wysocki,
	linux-kernel@vger.kernel.org, Chuansheng Liu

Hi Li,

On Thu, Feb 28, 2013 at 9:44 AM, Li Fei <fei.li@intel.com> wrote:
> Even in failed case of pm_runtime_get_sync, the usage_count
> is incremented. In order to keep the usage_count with correct
> value and runtime power management to behave correctly, call
> pm_runtime_put(_sync) in such case.

As with the remoteproc case, it is probably better to call the
put_noidle variant here. This way you are sure not to erroneously
invoke any underlying pm handler where your only intention is to fix
usage_count.

Thanks,
Ohad.

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

* RE: [PATCH 2/5] mmc: core: call pm_runtime_put_sync in pm_runtime_get_sync failed case
  2013-04-07 10:39   ` Ohad Ben-Cohen
@ 2013-04-08  1:36     ` Li, Fei
  0 siblings, 0 replies; 6+ messages in thread
From: Li, Fei @ 2013-04-08  1:36 UTC (permalink / raw)
  To: Ohad Ben-Cohen
  Cc: Chris Ball, ulf.hansson@linaro.org, johan.rudholm@stericsson.com,
	subhashj@codeaurora.org, Philip Rakity, Wysocki, Rafael J,
	thierry.reding@avionic-design.de, sachin.kamat@linaro.org,
	linux-mmc@vger.kernel.org, Rafael J. Wysocki,
	linux-kernel@vger.kernel.org, Liu, Chuansheng

> 
> Hi Li,
> 
> On Thu, Feb 28, 2013 at 9:44 AM, Li Fei <fei.li@intel.com> wrote:
> > Even in failed case of pm_runtime_get_sync, the usage_count
> > is incremented. In order to keep the usage_count with correct
> > value and runtime power management to behave correctly, call
> > pm_runtime_put(_sync) in such case.
> 
> As with the remoteproc case, it is probably better to call the
> put_noidle variant here. This way you are sure not to erroneously
> invoke any underlying pm handler where your only intention is to fix
> usage_count.

Thanks for your check and feedback, and will update it in V2 soon.

Regards,
Fei
> 
> Thanks,
> Ohad.

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

* [PATCH 2/5 V2] mmc: core: call pm_runtime_put_noidle in pm_runtime_get_sync failed case
  2013-02-28  7:44 ` [PATCH 2/5] mmc: core: call pm_runtime_put_sync in pm_runtime_get_sync failed case Li Fei
  2013-04-07 10:39   ` Ohad Ben-Cohen
@ 2013-04-08  1:36   ` Li Fei
  2013-04-08 12:48     ` Ohad Ben-Cohen
  1 sibling, 1 reply; 6+ messages in thread
From: Li Fei @ 2013-04-08  1:36 UTC (permalink / raw)
  To: cjb, ohad
  Cc: ulf.hansson, johan.rudholm, subhashj, rafael.j.wysocki,
	thierry.reding, sachin.kamat, linux-mmc, rjw, linux-kernel,
	chuansheng.liu, fei.li


Even in failed case of pm_runtime_get_sync, the usage_count
is incremented. In order to keep the usage_count with correct
value and runtime power management to behave correctly, call
pm_runtime_put_noidle in such case.

Signed-off-by Liu Chuansheng <chuansheng.liu@intel.com>
Signed-off-by: Li Fei <fei.li@intel.com>
---
 drivers/mmc/core/sdio.c     |    4 +++-
 drivers/mmc/core/sdio_bus.c |    3 +--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
index aa0719a..6889a82 100644
--- a/drivers/mmc/core/sdio.c
+++ b/drivers/mmc/core/sdio.c
@@ -861,8 +861,10 @@ static void mmc_sdio_detect(struct mmc_host *host)
 	/* Make sure card is powered before detecting it */
 	if (host->caps & MMC_CAP_POWER_OFF_CARD) {
 		err = pm_runtime_get_sync(&host->card->dev);
-		if (err < 0)
+		if (err < 0) {
+			pm_runtime_put_noidle(&host->card->dev);
 			goto out;
+		}
 	}
 
 	mmc_claim_host(host);
diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c
index 5e57048..7bfefb5 100644
--- a/drivers/mmc/core/sdio_bus.c
+++ b/drivers/mmc/core/sdio_bus.c
@@ -137,7 +137,7 @@ static int sdio_bus_probe(struct device *dev)
 	if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD) {
 		ret = pm_runtime_get_sync(dev);
 		if (ret < 0)
-			goto out;
+			goto disable_runtimepm;
 	}
 
 	/* Set the default block size so the driver is sure it's something
@@ -157,7 +157,6 @@ static int sdio_bus_probe(struct device *dev)
 disable_runtimepm:
 	if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD)
 		pm_runtime_put_noidle(dev);
-out:
 	return ret;
 }
 
-- 
1.7.4.1

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

* Re: [PATCH 2/5 V2] mmc: core: call pm_runtime_put_noidle in pm_runtime_get_sync failed case
  2013-04-08  1:36   ` [PATCH 2/5 V2] mmc: core: call pm_runtime_put_noidle " Li Fei
@ 2013-04-08 12:48     ` Ohad Ben-Cohen
  2013-04-12 18:15       ` Chris Ball
  0 siblings, 1 reply; 6+ messages in thread
From: Ohad Ben-Cohen @ 2013-04-08 12:48 UTC (permalink / raw)
  To: Li Fei
  Cc: Chris Ball, ulf.hansson, johan.rudholm, subhashj,
	rafael.j.wysocki, thierry.reding, sachin.kamat,
	linux-mmc@vger.kernel.org, Rafael J. Wysocki,
	linux-kernel@vger.kernel.org, Chuansheng Liu, Coelho, Luciano

On Mon, Apr 8, 2013 at 4:36 AM, Li Fei <fei.li@intel.com> wrote:
> Even in failed case of pm_runtime_get_sync, the usage_count
> is incremented. In order to keep the usage_count with correct
> value and runtime power management to behave correctly, call
> pm_runtime_put_noidle in such case.
>
> Signed-off-by Liu Chuansheng <chuansheng.liu@intel.com>
> Signed-off-by: Li Fei <fei.li@intel.com>

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

BTW, Li, could you please move to _noidle in those other places where
your previous patch was already applied? I think we have at least the
12xx driver (cc'ing Luca).

Thanks!
Ohad.

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

* Re: [PATCH 2/5 V2] mmc: core: call pm_runtime_put_noidle in pm_runtime_get_sync failed case
  2013-04-08 12:48     ` Ohad Ben-Cohen
@ 2013-04-12 18:15       ` Chris Ball
  0 siblings, 0 replies; 6+ messages in thread
From: Chris Ball @ 2013-04-12 18:15 UTC (permalink / raw)
  To: Ohad Ben-Cohen
  Cc: Li Fei, ulf.hansson, johan.rudholm, subhashj, rafael.j.wysocki,
	thierry.reding, sachin.kamat, linux-mmc@vger.kernel.org,
	Rafael J. Wysocki, linux-kernel@vger.kernel.org, Chuansheng Liu,
	Coelho, Luciano

Hi,

On Mon, Apr 08 2013, Ohad Ben-Cohen wrote:
> On Mon, Apr 8, 2013 at 4:36 AM, Li Fei <fei.li@intel.com> wrote:
>> Even in failed case of pm_runtime_get_sync, the usage_count
>> is incremented. In order to keep the usage_count with correct
>> value and runtime power management to behave correctly, call
>> pm_runtime_put_noidle in such case.
>>
>> Signed-off-by Liu Chuansheng <chuansheng.liu@intel.com>
>> Signed-off-by: Li Fei <fei.li@intel.com>
>
> Acked-by: Ohad Ben-Cohen <ohad@wizery.com>

Thanks, pushed this patch to mmc-next for 3.10.

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

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

end of thread, other threads:[~2013-04-12 18:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1362037031.6212.3.camel@fli24-HP-Compaq-8100-Elite-CMT-PC>
2013-02-28  7:44 ` [PATCH 2/5] mmc: core: call pm_runtime_put_sync in pm_runtime_get_sync failed case Li Fei
2013-04-07 10:39   ` Ohad Ben-Cohen
2013-04-08  1:36     ` Li, Fei
2013-04-08  1:36   ` [PATCH 2/5 V2] mmc: core: call pm_runtime_put_noidle " Li Fei
2013-04-08 12:48     ` Ohad Ben-Cohen
2013-04-12 18:15       ` Chris Ball

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