All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: sdhci-s3c: fix the card detection in runtime-pm
@ 2012-10-18  9:59 Seungwon Jeon
  2012-10-18 11:02 ` [PATCH v2] " Heiko Stübner
  0 siblings, 1 reply; 16+ messages in thread
From: Seungwon Jeon @ 2012-10-18  9:59 UTC (permalink / raw)
  To: linux-mmc
  Cc: 'Heiko Stübner', 'Chander Kashyap',
	'Chris Ball'

If host clock is disabled, host cannot detect a card
in case of using CD internal for detection.

Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com>
---
 drivers/mmc/host/sdhci-s3c.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index 2903949..e57f200 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -747,7 +747,8 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
 		sdhci_s3c_setup_card_detect_gpio(sc);
 
 #ifdef CONFIG_PM_RUNTIME
-	clk_disable(sc->clk_io);
+	if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL)
+		clk_disable(sc->clk_io);
 #endif
 	return 0;
 
@@ -794,7 +795,8 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
 		gpio_free(sc->ext_cd_gpio);
 
 #ifdef CONFIG_PM_RUNTIME
-	clk_enable(sc->clk_io);
+	if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL)
+		clk_enable(sc->clk_io);
 #endif
 	sdhci_remove_host(host, 1);
 
-- 
1.7.0.4



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

* [PATCH v2] mmc: sdhci-s3c: fix the card detection in runtime-pm
  2012-10-18  9:59 [PATCH] mmc: sdhci-s3c: fix the card detection in runtime-pm Seungwon Jeon
@ 2012-10-18 11:02 ` Heiko Stübner
  2012-10-19  8:04   ` Seungwon Jeon
  0 siblings, 1 reply; 16+ messages in thread
From: Heiko Stübner @ 2012-10-18 11:02 UTC (permalink / raw)
  To: Seungwon Jeon; +Cc: linux-mmc, 'Chander Kashyap', 'Chris Ball'

If host clock is disabled, host cannot detect a card
in case of using the internal or gpio card-detect for detection.

Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com>
Tested-by: Heiko Stuebner <heiko@sntech.de>
---
I've added the SDHCI_CD_GPIO to the conditional. With this change it works
on my machine. But I'm not sure if this would also be necessary for the 
external card detect.

 drivers/mmc/host/sdhci-s3c.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index 0cabf18..649dc32 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -750,7 +750,9 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
 		sdhci_s3c_setup_card_detect_gpio(sc);
 
 #ifdef CONFIG_PM_RUNTIME
-	clk_disable(sc->clk_io);
+	if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL &&
+	    pdata->cd_type != S3C_SDHCI_CD_GPIO)
+		clk_disable(sc->clk_io);
 #endif
 	return 0;
 
@@ -797,7 +799,9 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
 		gpio_free(sc->ext_cd_gpio);
 
 #ifdef CONFIG_PM_RUNTIME
-	clk_enable(sc->clk_io);
+	if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL &&
+	    pdata->cd_type != S3C_SDHCI_CD_GPIO)
+		clk_enable(sc->clk_io);
 #endif
 	sdhci_remove_host(host, 1);
 
-- 
1.7.2.3


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

* RE: [PATCH v2] mmc: sdhci-s3c: fix the card detection in runtime-pm
  2012-10-18 11:02 ` [PATCH v2] " Heiko Stübner
@ 2012-10-19  8:04   ` Seungwon Jeon
  2012-10-19  8:10     ` Heiko Stübner
  0 siblings, 1 reply; 16+ messages in thread
From: Seungwon Jeon @ 2012-10-19  8:04 UTC (permalink / raw)
  To: 'Heiko Stübner'
  Cc: linux-mmc, 'Chander Kashyap', 'Chris Ball'

On Thursday, October 18, 2012, Heiko Stuebner <heiko@sntech.de>
> If host clock is disabled, host cannot detect a card
> in case of using the internal or gpio card-detect for detection.
> 
> Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com>
> Tested-by: Heiko Stuebner <heiko@sntech.de>
> ---
> I've added the SDHCI_CD_GPIO to the conditional. With this change it works
> on my machine. But I'm not sure if this would also be necessary for the
> external card detect.

Card detection will be asserted out of host in case of using SDHCI_CD_GPIO.
Adding SDHCI_CD_GPIO to the conditional seems unnecessary.

Thanks.
Seungwon Jeon

> 
>  drivers/mmc/host/sdhci-s3c.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
> index 0cabf18..649dc32 100644
> --- a/drivers/mmc/host/sdhci-s3c.c
> +++ b/drivers/mmc/host/sdhci-s3c.c
> @@ -750,7 +750,9 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
>  		sdhci_s3c_setup_card_detect_gpio(sc);
> 
>  #ifdef CONFIG_PM_RUNTIME
> -	clk_disable(sc->clk_io);
> +	if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL &&
> +	    pdata->cd_type != S3C_SDHCI_CD_GPIO)
> +		clk_disable(sc->clk_io);
>  #endif
>  	return 0;
> 
> @@ -797,7 +799,9 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
>  		gpio_free(sc->ext_cd_gpio);
> 
>  #ifdef CONFIG_PM_RUNTIME
> -	clk_enable(sc->clk_io);
> +	if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL &&
> +	    pdata->cd_type != S3C_SDHCI_CD_GPIO)
> +		clk_enable(sc->clk_io);
>  #endif
>  	sdhci_remove_host(host, 1);
> 
> --
> 1.7.2.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

* Re: [PATCH v2] mmc: sdhci-s3c: fix the card detection in runtime-pm
  2012-10-19  8:04   ` Seungwon Jeon
@ 2012-10-19  8:10     ` Heiko Stübner
  2012-10-29 21:16       ` Chris Ball
  0 siblings, 1 reply; 16+ messages in thread
From: Heiko Stübner @ 2012-10-19  8:10 UTC (permalink / raw)
  To: Seungwon Jeon; +Cc: linux-mmc, 'Chander Kashyap', 'Chris Ball'

Am Freitag, 19. Oktober 2012, 10:04:14 schrieb Seungwon Jeon:
> On Thursday, October 18, 2012, Heiko Stuebner <heiko@sntech.de>
> 
> > If host clock is disabled, host cannot detect a card
> > in case of using the internal or gpio card-detect for detection.
> > 
> > Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com>
> > Tested-by: Heiko Stuebner <heiko@sntech.de>
> > ---
> > I've added the SDHCI_CD_GPIO to the conditional. With this change it
> > works on my machine. But I'm not sure if this would also be necessary
> > for the external card detect.
> 
> Card detection will be asserted out of host in case of using SDHCI_CD_GPIO.
> Adding SDHCI_CD_GPIO to the conditional seems unnecessary.

But it _was_ necessary :-) . Because only then did the problem go away. You 
might be right, that there exists a better solution for this, but something in 
the original patch is at least still missing to fix the problem.

Heiko


> >  drivers/mmc/host/sdhci-s3c.c |    8 ++++++--
> >  1 files changed, 6 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
> > index 0cabf18..649dc32 100644
> > --- a/drivers/mmc/host/sdhci-s3c.c
> > +++ b/drivers/mmc/host/sdhci-s3c.c
> > @@ -750,7 +750,9 @@ static int __devinit sdhci_s3c_probe(struct
> > platform_device *pdev)
> > 
> >  		sdhci_s3c_setup_card_detect_gpio(sc);
> >  
> >  #ifdef CONFIG_PM_RUNTIME
> > 
> > -	clk_disable(sc->clk_io);
> > +	if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL &&
> > +	    pdata->cd_type != S3C_SDHCI_CD_GPIO)
> > +		clk_disable(sc->clk_io);
> > 
> >  #endif
> >  
> >  	return 0;
> > 
> > @@ -797,7 +799,9 @@ static int __devexit sdhci_s3c_remove(struct
> > platform_device *pdev)
> > 
> >  		gpio_free(sc->ext_cd_gpio);
> >  
> >  #ifdef CONFIG_PM_RUNTIME
> > 
> > -	clk_enable(sc->clk_io);
> > +	if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL &&
> > +	    pdata->cd_type != S3C_SDHCI_CD_GPIO)
> > +		clk_enable(sc->clk_io);
> > 
> >  #endif
> >  
> >  	sdhci_remove_host(host, 1);
> > 
> > --
> > 1.7.2.3
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

* Re: [PATCH v2] mmc: sdhci-s3c: fix the card detection in runtime-pm
  2012-10-19  8:10     ` Heiko Stübner
@ 2012-10-29 21:16       ` Chris Ball
  2012-10-29 22:37         ` Heiko Stübner
                           ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Chris Ball @ 2012-10-29 21:16 UTC (permalink / raw)
  To: Heiko Stübner; +Cc: Seungwon Jeon, linux-mmc, 'Chander Kashyap'

Hi,

On Fri, Oct 19 2012, Heiko Stübner wrote:
> Am Freitag, 19. Oktober 2012, 10:04:14 schrieb Seungwon Jeon:
>> On Thursday, October 18, 2012, Heiko Stuebner <heiko@sntech.de>
>> 
>> > If host clock is disabled, host cannot detect a card
>> > in case of using the internal or gpio card-detect for detection.
>> > 
>> > Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com>
>> > Tested-by: Heiko Stuebner <heiko@sntech.de>
>> > ---
>> > I've added the SDHCI_CD_GPIO to the conditional. With this change it
>> > works on my machine. But I'm not sure if this would also be necessary
>> > for the external card detect.
>> 
>> Card detection will be asserted out of host in case of using SDHCI_CD_GPIO.
>> Adding SDHCI_CD_GPIO to the conditional seems unnecessary.
>
> But it _was_ necessary :-) . Because only then did the problem go away. You 
> might be right, that there exists a better solution for this, but something in 
> the original patch is at least still missing to fix the problem.

Seungwon, what would you like to do here?  (I'm unhappy taking a patch
with your name on it that's been modified in a way you disagree with.)

Thanks,

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

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

* Re: [PATCH v2] mmc: sdhci-s3c: fix the card detection in runtime-pm
  2012-10-29 21:16       ` Chris Ball
@ 2012-10-29 22:37         ` Heiko Stübner
  2012-10-30  3:54           ` Seungwon Jeon
                             ` (2 more replies)
  2012-10-30  5:28         ` [PATCH v2 2/2] mmc: sdhci-s3c: fix the card detection in runtime-pm Seungwon Jeon
  2012-11-09 10:41         ` [PATCH v3] mmc: sdhci-s3c: ensure non-transaction of bus before clk_disable Seungwon Jeon
  2 siblings, 3 replies; 16+ messages in thread
From: Heiko Stübner @ 2012-10-29 22:37 UTC (permalink / raw)
  To: Chris Ball; +Cc: Seungwon Jeon, linux-mmc, 'Chander Kashyap'

Hi Chris,

Am Montag, 29. Oktober 2012, 22:16:47 schrieb Chris Ball:
> Hi,
> 
> On Fri, Oct 19 2012, Heiko Stübner wrote:
> > Am Freitag, 19. Oktober 2012, 10:04:14 schrieb Seungwon Jeon:
> >> On Thursday, October 18, 2012, Heiko Stuebner <heiko@sntech.de>
> >> 
> >> > If host clock is disabled, host cannot detect a card
> >> > in case of using the internal or gpio card-detect for detection.
> >> > 
> >> > Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com>
> >> > Tested-by: Heiko Stuebner <heiko@sntech.de>
> >> > ---
> >> > I've added the SDHCI_CD_GPIO to the conditional. With this change it
> >> > works on my machine. But I'm not sure if this would also be necessary
> >> > for the external card detect.
> >> 
> >> Card detection will be asserted out of host in case of using
> >> SDHCI_CD_GPIO. Adding SDHCI_CD_GPIO to the conditional seems
> >> unnecessary.
> > 
> > But it _was_ necessary :-) . Because only then did the problem go away.
> > You might be right, that there exists a better solution for this, but
> > something in the original patch is at least still missing to fix the
> > problem.
> 
> Seungwon, what would you like to do here?  (I'm unhappy taking a patch
> with your name on it that's been modified in a way you disagree with.)

I agree with Seungwon, that the solution in my v2 is not the correct one :-) - 
should've called it RFC or so. The gpio-card-detect code _should_ be able to 
handle the resume of the host itself in the card detect case, but it seems 
it's not able to.

The patch in its v1 form does not fix the problem commit 2abeb5c5ded2 (mmc: 
sdhci-s3c: Add clk_(enable/disable) in runtime suspend/resume) has caused for 
Samsung devices using the gpio card-detect - it's broken in 3.7 currently.


So for 3.7 the easiest way would of course be to revert the commit above and 
find a correct solution for 3.8.


Heiko

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

* RE: [PATCH v2] mmc: sdhci-s3c: fix the card detection in runtime-pm
  2012-10-29 22:37         ` Heiko Stübner
@ 2012-10-30  3:54           ` Seungwon Jeon
  2012-10-30  5:28           ` [PATCH v2 1/2] mmc: sdhci-s3c: ensure non-transaction of bus before clk_disable Seungwon Jeon
  2013-01-22 10:48           ` [PATCH 2/2] mmc: block: don't start new request when the card is removed Seungwon Jeon
  2 siblings, 0 replies; 16+ messages in thread
From: Seungwon Jeon @ 2012-10-30  3:54 UTC (permalink / raw)
  To: 'Heiko Stübner', 'Chris Ball'
  Cc: linux-mmc, 'Chander Kashyap'

Tuesday, October 30, 2012, Heiko Stuebner <heiko@sntech.de> wrote:
> Hi Chris,
> 
> Am Montag, 29. Oktober 2012, 22:16:47 schrieb Chris Ball:
> > Hi,
> >
> > On Fri, Oct 19 2012, Heiko Stübner wrote:
> > > Am Freitag, 19. Oktober 2012, 10:04:14 schrieb Seungwon Jeon:
> > >> On Thursday, October 18, 2012, Heiko Stuebner <heiko@sntech.de>
> > >>
> > >> > If host clock is disabled, host cannot detect a card
> > >> > in case of using the internal or gpio card-detect for detection.
> > >> >
> > >> > Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com>
> > >> > Tested-by: Heiko Stuebner <heiko@sntech.de>
> > >> > ---
> > >> > I've added the SDHCI_CD_GPIO to the conditional. With this change it
> > >> > works on my machine. But I'm not sure if this would also be necessary
> > >> > for the external card detect.
> > >>
> > >> Card detection will be asserted out of host in case of using
> > >> SDHCI_CD_GPIO. Adding SDHCI_CD_GPIO to the conditional seems
> > >> unnecessary.
> > >
> > > But it _was_ necessary :-) . Because only then did the problem go away.
> > > You might be right, that there exists a better solution for this, but
> > > something in the original patch is at least still missing to fix the
> > > problem.
> >
> > Seungwon, what would you like to do here?  (I'm unhappy taking a patch
> > with your name on it that's been modified in a way you disagree with.)
> 
> I agree with Seungwon, that the solution in my v2 is not the correct one :-) -
> should've called it RFC or so. The gpio-card-detect code _should_ be able to
> handle the resume of the host itself in the card detect case, but it seems
> it's not able to.
> 
> The patch in its v1 form does not fix the problem commit 2abeb5c5ded2 (mmc:
> sdhci-s3c: Add clk_(enable/disable) in runtime suspend/resume) has caused for
> Samsung devices using the gpio card-detect - it's broken in 3.7 currently.
> 
> 
> So for 3.7 the easiest way would of course be to revert the commit above and
> find a correct solution for 3.8.

Hi Chris,

This patch doesn't aim Heiko's problem but guarantee card detection for using internal CD.
Clock should be enabled for internal card detection of host.

Thanks,
Seungwon Jeon
> 
> 
> Heiko
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

* [PATCH v2 1/2] mmc: sdhci-s3c: ensure non-transaction of bus before clk_disable
  2012-10-29 22:37         ` Heiko Stübner
  2012-10-30  3:54           ` Seungwon Jeon
@ 2012-10-30  5:28           ` Seungwon Jeon
  2012-11-07 19:34             ` Chris Ball
  2013-01-22 10:48           ` [PATCH 2/2] mmc: block: don't start new request when the card is removed Seungwon Jeon
  2 siblings, 1 reply; 16+ messages in thread
From: Seungwon Jeon @ 2012-10-30  5:28 UTC (permalink / raw)
  To: linux-mmc
  Cc: 'Chris Ball', 'Heiko Stübner',
	'Chander Kashyap'

clock shoud be supplied during bus transaction. This patch defers
clk_disabe in runtime_suspend if cmd/data line is used.

Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com>
Acked-by: Heiko Stuebner <heiko@sntech.de>
---
Rebased with mmc-next.

 drivers/mmc/host/sdhci-s3c.c |   13 +++++++++----
 drivers/mmc/host/sdhci.c     |   20 ++++----------------
 drivers/mmc/host/sdhci.h     |   11 +++++++++++
 3 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index a093e2e..a79b153 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -845,12 +845,17 @@ static int sdhci_s3c_runtime_suspend(struct device *dev)
 	struct sdhci_host *host = dev_get_drvdata(dev);
 	struct sdhci_s3c *ourhost = to_s3c(host);
 	struct clk *busclk = ourhost->clk_io;
-	int ret;
+	int ret = 0;
 
-	ret = sdhci_runtime_suspend_host(host);
+	if (!(readl(host->ioaddr + SDHCI_PRESENT_STATE) &
+			(SDHCI_CMD_INHIBIT | SDHCI_DATA_INHIBIT))) {
+		ret = sdhci_runtime_suspend_host(host);
+		clk_disable_unprepare(ourhost->clk_bus[ourhost->cur_clk]);
+		clk_disable_unprepare(busclk);
+	} else {
+		sdhci_runtime_pm_put(host);
+	}
 
-	clk_disable_unprepare(ourhost->clk_bus[ourhost->cur_clk]);
-	clk_disable_unprepare(busclk);
 	return ret;
 }
 
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index f05a377..d62646d 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -54,20 +54,6 @@ static void sdhci_finish_command(struct sdhci_host *);
 static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode);
 static void sdhci_tuning_timer(unsigned long data);
 
-#ifdef CONFIG_PM_RUNTIME
-static int sdhci_runtime_pm_get(struct sdhci_host *host);
-static int sdhci_runtime_pm_put(struct sdhci_host *host);
-#else
-static inline int sdhci_runtime_pm_get(struct sdhci_host *host)
-{
-	return 0;
-}
-static inline int sdhci_runtime_pm_put(struct sdhci_host *host)
-{
-	return 0;
-}
-#endif
-
 static void sdhci_dumpregs(struct sdhci_host *host)
 {
 	pr_debug(DRIVER_NAME ": =========== REGISTER DUMP (%s)===========\n",
@@ -2535,16 +2521,18 @@ EXPORT_SYMBOL_GPL(sdhci_enable_irq_wakeups);
 
 #ifdef CONFIG_PM_RUNTIME
 
-static int sdhci_runtime_pm_get(struct sdhci_host *host)
+int sdhci_runtime_pm_get(struct sdhci_host *host)
 {
 	return pm_runtime_get_sync(host->mmc->parent);
 }
+EXPORT_SYMBOL_GPL(sdhci_runtime_pm_get);
 
-static int sdhci_runtime_pm_put(struct sdhci_host *host)
+int sdhci_runtime_pm_put(struct sdhci_host *host)
 {
 	pm_runtime_mark_last_busy(host->mmc->parent);
 	return pm_runtime_put_autosuspend(host->mmc->parent);
 }
+EXPORT_SYMBOL_GPL(sdhci_runtime_pm_put);
 
 int sdhci_runtime_suspend_host(struct sdhci_host *host)
 {
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 71a4a7e..a42a192 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -385,8 +385,19 @@ extern void sdhci_enable_irq_wakeups(struct sdhci_host *host);
 #endif
 
 #ifdef CONFIG_PM_RUNTIME
+extern int sdhci_runtime_pm_get(struct sdhci_host *host);
+extern int sdhci_runtime_pm_put(struct sdhci_host *host);
 extern int sdhci_runtime_suspend_host(struct sdhci_host *host);
 extern int sdhci_runtime_resume_host(struct sdhci_host *host);
+#else
+inline int sdhci_runtime_pm_get(struct sdhci_host *host)
+{
+	return 0;
+}
+inline int sdhci_runtime_pm_put(struct sdhci_host *host)
+{
+	return 0;
+}
 #endif
 
 #endif /* __SDHCI_HW_H */
-- 
1.7.0.4



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

* [PATCH v2 2/2] mmc: sdhci-s3c: fix the card detection in runtime-pm
  2012-10-29 21:16       ` Chris Ball
  2012-10-29 22:37         ` Heiko Stübner
@ 2012-10-30  5:28         ` Seungwon Jeon
  2012-11-07 19:36           ` Chris Ball
  2012-11-09 10:41         ` [PATCH v3] mmc: sdhci-s3c: ensure non-transaction of bus before clk_disable Seungwon Jeon
  2 siblings, 1 reply; 16+ messages in thread
From: Seungwon Jeon @ 2012-10-30  5:28 UTC (permalink / raw)
  Cc: linux-mmc, 'Chris Ball', 'Heiko Stübner',
	'Chander Kashyap'

If host clock is disabled, host cannot detect a card
in case of using CD internal for detection.

Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com>
---
Rebased with mmc-next.

 drivers/mmc/host/sdhci-s3c.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index a79b153..d680c0b 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -747,7 +747,8 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
 		sdhci_s3c_setup_card_detect_gpio(sc);
 
 #ifdef CONFIG_PM_RUNTIME
-	clk_disable_unprepare(sc->clk_io);
+	if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL)
+		clk_disable_unprepare(sc->clk_io);
 #endif
 	return 0;
 
@@ -794,7 +795,8 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
 		gpio_free(sc->ext_cd_gpio);
 
 #ifdef CONFIG_PM_RUNTIME
-	clk_prepare_enable(sc->clk_io);
+	if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL)
+		clk_prepare_enable(sc->clk_io);
 #endif
 	sdhci_remove_host(host, 1);
 
-- 
1.7.0.4



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

* Re: [PATCH v2 1/2] mmc: sdhci-s3c: ensure non-transaction of bus before clk_disable
  2012-10-30  5:28           ` [PATCH v2 1/2] mmc: sdhci-s3c: ensure non-transaction of bus before clk_disable Seungwon Jeon
@ 2012-11-07 19:34             ` Chris Ball
  0 siblings, 0 replies; 16+ messages in thread
From: Chris Ball @ 2012-11-07 19:34 UTC (permalink / raw)
  To: Seungwon Jeon
  Cc: linux-mmc, 'Heiko Stübner', 'Chander Kashyap'

Hi,

On Tue, Oct 30 2012, Seungwon Jeon wrote:
> clock shoud be supplied during bus transaction. This patch defers
> clk_disabe in runtime_suspend if cmd/data line is used.
>
> Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com>
> Acked-by: Heiko Stuebner <heiko@sntech.de>

Thanks, pushed to mmc-next for 3.7.

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

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

* Re: [PATCH v2 2/2] mmc: sdhci-s3c: fix the card detection in runtime-pm
  2012-10-30  5:28         ` [PATCH v2 2/2] mmc: sdhci-s3c: fix the card detection in runtime-pm Seungwon Jeon
@ 2012-11-07 19:36           ` Chris Ball
  0 siblings, 0 replies; 16+ messages in thread
From: Chris Ball @ 2012-11-07 19:36 UTC (permalink / raw)
  To: Seungwon Jeon
  Cc: linux-mmc, 'Heiko Stübner', 'Chander Kashyap'

Hi,

On Tue, Oct 30 2012, Seungwon Jeon wrote:
> If host clock is disabled, host cannot detect a card
> in case of using CD internal for detection.
>
> Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com>

Thanks, pushed to mmc-next for 3.7.

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

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

* [PATCH v3] mmc: sdhci-s3c: ensure non-transaction of bus before clk_disable
  2012-10-29 21:16       ` Chris Ball
  2012-10-29 22:37         ` Heiko Stübner
  2012-10-30  5:28         ` [PATCH v2 2/2] mmc: sdhci-s3c: fix the card detection in runtime-pm Seungwon Jeon
@ 2012-11-09 10:41         ` Seungwon Jeon
  2 siblings, 0 replies; 16+ messages in thread
From: Seungwon Jeon @ 2012-11-09 10:41 UTC (permalink / raw)
  To: linux-mmc
  Cc: 'Chris Ball', 'Heiko Stübner',
	'Chander Kashyap', 'Fengguang Wu'

clock shoud be supplied during bus transaction. This patch defers
clk_disabe in runtime_suspend if cmd/data line is used.

Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com>
Acked-by: Heiko Stuebner <heiko@sntech.de>
---
V3: Removed the error message. (reported by Fengguang Wu)

 drivers/mmc/host/sdhci-s3c.c |   13 +++++++++----
 drivers/mmc/host/sdhci.c     |   20 ++++----------------
 drivers/mmc/host/sdhci.h     |   12 ++++++++++++
 3 files changed, 25 insertions(+), 20 deletions(-)

diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index a54dd5d..d680c0b 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -847,12 +847,17 @@ static int sdhci_s3c_runtime_suspend(struct device *dev)
 	struct sdhci_host *host = dev_get_drvdata(dev);
 	struct sdhci_s3c *ourhost = to_s3c(host);
 	struct clk *busclk = ourhost->clk_io;
-	int ret;
+	int ret = 0;
 
-	ret = sdhci_runtime_suspend_host(host);
+	if (!(readl(host->ioaddr + SDHCI_PRESENT_STATE) &
+			(SDHCI_CMD_INHIBIT | SDHCI_DATA_INHIBIT))) {
+		ret = sdhci_runtime_suspend_host(host);
+		clk_disable_unprepare(ourhost->clk_bus[ourhost->cur_clk]);
+		clk_disable_unprepare(busclk);
+	} else {
+		sdhci_runtime_pm_put(host);
+	}
 
-	clk_disable_unprepare(ourhost->clk_bus[ourhost->cur_clk]);
-	clk_disable_unprepare(busclk);
 	return ret;
 }
 
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index c7851c0..59b60e1 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -54,20 +54,6 @@ static void sdhci_finish_command(struct sdhci_host *);
 static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode);
 static void sdhci_tuning_timer(unsigned long data);
 
-#ifdef CONFIG_PM_RUNTIME
-static int sdhci_runtime_pm_get(struct sdhci_host *host);
-static int sdhci_runtime_pm_put(struct sdhci_host *host);
-#else
-static inline int sdhci_runtime_pm_get(struct sdhci_host *host)
-{
-	return 0;
-}
-static inline int sdhci_runtime_pm_put(struct sdhci_host *host)
-{
-	return 0;
-}
-#endif
-
 static void sdhci_dumpregs(struct sdhci_host *host)
 {
 	pr_debug(DRIVER_NAME ": =========== REGISTER DUMP (%s)===========\n",
@@ -2538,16 +2524,18 @@ EXPORT_SYMBOL_GPL(sdhci_enable_irq_wakeups);
 
 #ifdef CONFIG_PM_RUNTIME
 
-static int sdhci_runtime_pm_get(struct sdhci_host *host)
+int sdhci_runtime_pm_get(struct sdhci_host *host)
 {
 	return pm_runtime_get_sync(host->mmc->parent);
 }
+EXPORT_SYMBOL_GPL(sdhci_runtime_pm_get);
 
-static int sdhci_runtime_pm_put(struct sdhci_host *host)
+int sdhci_runtime_pm_put(struct sdhci_host *host)
 {
 	pm_runtime_mark_last_busy(host->mmc->parent);
 	return pm_runtime_put_autosuspend(host->mmc->parent);
 }
+EXPORT_SYMBOL_GPL(sdhci_runtime_pm_put);
 
 int sdhci_runtime_suspend_host(struct sdhci_host *host)
 {
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 71a4a7e..02edce1 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -385,8 +385,20 @@ extern void sdhci_enable_irq_wakeups(struct sdhci_host *host);
 #endif
 
 #ifdef CONFIG_PM_RUNTIME
+extern int sdhci_runtime_pm_get(struct sdhci_host *host);
+extern int sdhci_runtime_pm_put(struct sdhci_host *host);
 extern int sdhci_runtime_suspend_host(struct sdhci_host *host);
 extern int sdhci_runtime_resume_host(struct sdhci_host *host);
+#else
+static inline int sdhci_runtime_pm_get(struct sdhci_host *host)
+{
+	return 0;
+}
+
+static inline int sdhci_runtime_pm_put(struct sdhci_host *host)
+{
+	return 0;
+}
 #endif
 
 #endif /* __SDHCI_HW_H */
-- 
1.7.0.4



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

* [PATCH 2/2] mmc: block: don't start new request when the card is removed
  2012-10-29 22:37         ` Heiko Stübner
  2012-10-30  3:54           ` Seungwon Jeon
  2012-10-30  5:28           ` [PATCH v2 1/2] mmc: sdhci-s3c: ensure non-transaction of bus before clk_disable Seungwon Jeon
@ 2013-01-22 10:48           ` Seungwon Jeon
  2013-02-01  5:25             ` Jaehoon Chung
                               ` (2 more replies)
  2 siblings, 3 replies; 16+ messages in thread
From: Seungwon Jeon @ 2013-01-22 10:48 UTC (permalink / raw)
  To: linux-mmc
  Cc: 'Chris Ball', 'Sujit Reddy Thumma',
	'Adrian Hunter'

Current request can be started newly while handling the error.
But if the card is removed, it's unnecessary to restart a request.
This makes the extra error handling.

Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com>
---
 drivers/mmc/card/block.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index f79b468..1170afe 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -1456,8 +1456,14 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc)
 
  start_new_req:
 	if (rqc) {
-		mmc_blk_rw_rq_prep(mq->mqrq_cur, card, 0, mq);
-		mmc_start_req(card->host, &mq->mqrq_cur->mmc_active, NULL);
+		if (mmc_card_removed(card)) {
+			rqc->cmd_flags |= REQ_QUIET;
+			blk_end_request_all(rqc, -EIO);
+		} else {
+			mmc_blk_rw_rq_prep(mq->mqrq_cur, card, 0, mq);
+			mmc_start_req(card->host,
+				      &mq->mqrq_cur->mmc_active, NULL);
+		}
 	}
 
 	return 0;
-- 
1.7.0.4



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

* Re: [PATCH 2/2] mmc: block: don't start new request when the card is removed
  2013-01-22 10:48           ` [PATCH 2/2] mmc: block: don't start new request when the card is removed Seungwon Jeon
@ 2013-02-01  5:25             ` Jaehoon Chung
  2013-02-08 12:08             ` Konstantin Dorfman
  2013-02-11 17:03             ` Chris Ball
  2 siblings, 0 replies; 16+ messages in thread
From: Jaehoon Chung @ 2013-02-01  5:25 UTC (permalink / raw)
  To: Seungwon Jeon
  Cc: linux-mmc, 'Chris Ball', 'Sujit Reddy Thumma',
	'Adrian Hunter'

Hi Seungwon,

It looks good to me..

Acked-by: Jaehoon Chung <jh80.chung@samsung.com>

On 01/22/2013 07:48 PM, Seungwon Jeon wrote:
> Current request can be started newly while handling the error.
> But if the card is removed, it's unnecessary to restart a request.
> This makes the extra error handling.
> 
> Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com>
> ---
>  drivers/mmc/card/block.c |   10 ++++++++--
>  1 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> index f79b468..1170afe 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -1456,8 +1456,14 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc)
>  
>   start_new_req:
>  	if (rqc) {
> -		mmc_blk_rw_rq_prep(mq->mqrq_cur, card, 0, mq);
> -		mmc_start_req(card->host, &mq->mqrq_cur->mmc_active, NULL);
> +		if (mmc_card_removed(card)) {
> +			rqc->cmd_flags |= REQ_QUIET;
> +			blk_end_request_all(rqc, -EIO);
> +		} else {
> +			mmc_blk_rw_rq_prep(mq->mqrq_cur, card, 0, mq);
> +			mmc_start_req(card->host,
> +				      &mq->mqrq_cur->mmc_active, NULL);
> +		}
>  	}
>  
>  	return 0;
> 


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

* Re: [PATCH 2/2] mmc: block: don't start new request when the card is removed
  2013-01-22 10:48           ` [PATCH 2/2] mmc: block: don't start new request when the card is removed Seungwon Jeon
  2013-02-01  5:25             ` Jaehoon Chung
@ 2013-02-08 12:08             ` Konstantin Dorfman
  2013-02-11 17:03             ` Chris Ball
  2 siblings, 0 replies; 16+ messages in thread
From: Konstantin Dorfman @ 2013-02-08 12:08 UTC (permalink / raw)
  To: Seungwon Jeon
  Cc: linux-mmc, 'Chris Ball', 'Sujit Reddy Thumma',
	'Adrian Hunter'


Tested-by: Konstantin Dorfman <kdorfman@codeaurora.org>

On 01/22/2013 12:48 PM, Seungwon Jeon wrote:
> Current request can be started newly while handling the error.
> But if the card is removed, it's unnecessary to restart a request.
> This makes the extra error handling.
>
> Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com>
> ---
>   drivers/mmc/card/block.c |   10 ++++++++--
>   1 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> index f79b468..1170afe 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -1456,8 +1456,14 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc)
>
>    start_new_req:
>   	if (rqc) {
> -		mmc_blk_rw_rq_prep(mq->mqrq_cur, card, 0, mq);
> -		mmc_start_req(card->host, &mq->mqrq_cur->mmc_active, NULL);
> +		if (mmc_card_removed(card)) {
> +			rqc->cmd_flags |= REQ_QUIET;
> +			blk_end_request_all(rqc, -EIO);
> +		} else {
> +			mmc_blk_rw_rq_prep(mq->mqrq_cur, card, 0, mq);
> +			mmc_start_req(card->host,
> +				      &mq->mqrq_cur->mmc_active, NULL);
> +		}
>   	}
>
>   	return 0;
>


-- 
Konstantin Dorfman,
QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center,
Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation

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

* Re: [PATCH 2/2] mmc: block: don't start new request when the card is removed
  2013-01-22 10:48           ` [PATCH 2/2] mmc: block: don't start new request when the card is removed Seungwon Jeon
  2013-02-01  5:25             ` Jaehoon Chung
  2013-02-08 12:08             ` Konstantin Dorfman
@ 2013-02-11 17:03             ` Chris Ball
  2 siblings, 0 replies; 16+ messages in thread
From: Chris Ball @ 2013-02-11 17:03 UTC (permalink / raw)
  To: Seungwon Jeon
  Cc: linux-mmc, 'Sujit Reddy Thumma', 'Adrian Hunter'

Hi,

On Tue, Jan 22 2013, Seungwon Jeon wrote:
> Current request can be started newly while handling the error.
> But if the card is removed, it's unnecessary to restart a request.
> This makes the extra error handling.
>
> Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com>
> ---
>  drivers/mmc/card/block.c |   10 ++++++++--
>  1 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> index f79b468..1170afe 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -1456,8 +1456,14 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc)
>  
>   start_new_req:
>  	if (rqc) {
> -		mmc_blk_rw_rq_prep(mq->mqrq_cur, card, 0, mq);
> -		mmc_start_req(card->host, &mq->mqrq_cur->mmc_active, NULL);
> +		if (mmc_card_removed(card)) {
> +			rqc->cmd_flags |= REQ_QUIET;
> +			blk_end_request_all(rqc, -EIO);
> +		} else {
> +			mmc_blk_rw_rq_prep(mq->mqrq_cur, card, 0, mq);
> +			mmc_start_req(card->host,
> +				      &mq->mqrq_cur->mmc_active, NULL);
> +		}
>  	}
>  
>  	return 0;

Thanks, pushed to mmc-next for 3.9.

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

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

end of thread, other threads:[~2013-02-11 17:03 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-18  9:59 [PATCH] mmc: sdhci-s3c: fix the card detection in runtime-pm Seungwon Jeon
2012-10-18 11:02 ` [PATCH v2] " Heiko Stübner
2012-10-19  8:04   ` Seungwon Jeon
2012-10-19  8:10     ` Heiko Stübner
2012-10-29 21:16       ` Chris Ball
2012-10-29 22:37         ` Heiko Stübner
2012-10-30  3:54           ` Seungwon Jeon
2012-10-30  5:28           ` [PATCH v2 1/2] mmc: sdhci-s3c: ensure non-transaction of bus before clk_disable Seungwon Jeon
2012-11-07 19:34             ` Chris Ball
2013-01-22 10:48           ` [PATCH 2/2] mmc: block: don't start new request when the card is removed Seungwon Jeon
2013-02-01  5:25             ` Jaehoon Chung
2013-02-08 12:08             ` Konstantin Dorfman
2013-02-11 17:03             ` Chris Ball
2012-10-30  5:28         ` [PATCH v2 2/2] mmc: sdhci-s3c: fix the card detection in runtime-pm Seungwon Jeon
2012-11-07 19:36           ` Chris Ball
2012-11-09 10:41         ` [PATCH v3] mmc: sdhci-s3c: ensure non-transaction of bus before clk_disable Seungwon Jeon

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.