diff mbox

[3/3] mmc: sdhci-s3c: Add clk_(enable/disable) in runtime suspend/resume

Message ID 1347613731-29428-4-git-send-email-chander.kashyap@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Chander Kashyap Sept. 14, 2012, 9:08 a.m. UTC
Perform clock disable/enable in runtime suspend/resume.

Signed-off-by: Chander Kashyap <chander.kashyap@linaro.org>
---
 drivers/mmc/host/sdhci-s3c.c |   25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

Comments

Chris Ball Sept. 19, 2012, 6:14 a.m. UTC | #1
Hi Jaehoon, Girish,

On Fri, Sep 14 2012, Chander Kashyap wrote:
> Perform clock disable/enable in runtime suspend/resume.
>
> Signed-off-by: Chander Kashyap <chander.kashyap@linaro.org>
> ---
>  drivers/mmc/host/sdhci-s3c.c |   25 +++++++++++++++++++++++--
>  1 file changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
> index 3f4518d..ffffd51 100644
> --- a/drivers/mmc/host/sdhci-s3c.c
> +++ b/drivers/mmc/host/sdhci-s3c.c
> @@ -513,7 +513,9 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
>  		goto err_no_busclks;
>  	}
>  
> +#ifndef CONFIG_PM_RUNTIME
>  	clk_enable(sc->clk_bus[sc->cur_clk]);
> +#endif
>  
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	host->ioaddr = devm_request_and_ioremap(&pdev->dev, res);
> @@ -620,10 +622,13 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
>  	    gpio_is_valid(pdata->ext_cd_gpio))
>  		sdhci_s3c_setup_card_detect_gpio(sc);
>  
> +	clk_disable(sc->clk_io);
>  	return 0;
>  
>   err_req_regs:
> +#ifndef CONFIG_PM_RUNTIME
>  	clk_disable(sc->clk_bus[sc->cur_clk]);
> +#endif
>  	for (ptr = 0; ptr < MAX_BUS_CLK; ptr++) {
>  		if (sc->clk_bus[ptr]) {
>  			clk_put(sc->clk_bus[ptr]);
> @@ -656,12 +661,15 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
>  	if (gpio_is_valid(sc->ext_cd_gpio))
>  		gpio_free(sc->ext_cd_gpio);
>  
> +	clk_enable(sc->clk_io);
>  	sdhci_remove_host(host, 1);
>  
>  	pm_runtime_dont_use_autosuspend(&pdev->dev);
>  	pm_runtime_disable(&pdev->dev);
>  
> +#ifndef CONFIG_PM_RUNTIME
>  	clk_disable(sc->clk_bus[sc->cur_clk]);
> +#endif
>  	for (ptr = 0; ptr < 3; ptr++) {
>  		if (sc->clk_bus[ptr]) {
>  			clk_put(sc->clk_bus[ptr]);
> @@ -696,15 +704,28 @@ static int sdhci_s3c_resume(struct device *dev)
>  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;
> +
> +	ret = sdhci_runtime_suspend_host(host);
>  
> -	return sdhci_runtime_suspend_host(host);
> +	clk_disable(ourhost->clk_bus[ourhost->cur_clk]);
> +	clk_disable(busclk);
> +	return ret;
>  }
>  
>  static int sdhci_s3c_runtime_resume(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;
>  
> -	return sdhci_runtime_resume_host(host);
> +	clk_enable(busclk);
> +	clk_enable(ourhost->clk_bus[ourhost->cur_clk]);
> +	ret = sdhci_runtime_resume_host(host);
> +	return ret;
>  }
>  #endif

Could I get an ACK on this patch from one of you, please?

- Chris.
Jaehoon Chung Sept. 19, 2012, 7:43 a.m. UTC | #2
Looks good to me.

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

On 09/19/2012 03:14 PM, Chris Ball wrote:
> Hi Jaehoon, Girish,
> 
> On Fri, Sep 14 2012, Chander Kashyap wrote:
>> Perform clock disable/enable in runtime suspend/resume.
>>
>> Signed-off-by: Chander Kashyap <chander.kashyap@linaro.org>
>> ---
>>  drivers/mmc/host/sdhci-s3c.c |   25 +++++++++++++++++++++++--
>>  1 file changed, 23 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
>> index 3f4518d..ffffd51 100644
>> --- a/drivers/mmc/host/sdhci-s3c.c
>> +++ b/drivers/mmc/host/sdhci-s3c.c
>> @@ -513,7 +513,9 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
>>  		goto err_no_busclks;
>>  	}
>>  
>> +#ifndef CONFIG_PM_RUNTIME
>>  	clk_enable(sc->clk_bus[sc->cur_clk]);
>> +#endif
>>  
>>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>  	host->ioaddr = devm_request_and_ioremap(&pdev->dev, res);
>> @@ -620,10 +622,13 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
>>  	    gpio_is_valid(pdata->ext_cd_gpio))
>>  		sdhci_s3c_setup_card_detect_gpio(sc);
>>  
>> +	clk_disable(sc->clk_io);
>>  	return 0;
>>  
>>   err_req_regs:
>> +#ifndef CONFIG_PM_RUNTIME
>>  	clk_disable(sc->clk_bus[sc->cur_clk]);
>> +#endif
>>  	for (ptr = 0; ptr < MAX_BUS_CLK; ptr++) {
>>  		if (sc->clk_bus[ptr]) {
>>  			clk_put(sc->clk_bus[ptr]);
>> @@ -656,12 +661,15 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
>>  	if (gpio_is_valid(sc->ext_cd_gpio))
>>  		gpio_free(sc->ext_cd_gpio);
>>  
>> +	clk_enable(sc->clk_io);
>>  	sdhci_remove_host(host, 1);
>>  
>>  	pm_runtime_dont_use_autosuspend(&pdev->dev);
>>  	pm_runtime_disable(&pdev->dev);
>>  
>> +#ifndef CONFIG_PM_RUNTIME
>>  	clk_disable(sc->clk_bus[sc->cur_clk]);
>> +#endif
>>  	for (ptr = 0; ptr < 3; ptr++) {
>>  		if (sc->clk_bus[ptr]) {
>>  			clk_put(sc->clk_bus[ptr]);
>> @@ -696,15 +704,28 @@ static int sdhci_s3c_resume(struct device *dev)
>>  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;
>> +
>> +	ret = sdhci_runtime_suspend_host(host);
>>  
>> -	return sdhci_runtime_suspend_host(host);
>> +	clk_disable(ourhost->clk_bus[ourhost->cur_clk]);
>> +	clk_disable(busclk);
>> +	return ret;
>>  }
>>  
>>  static int sdhci_s3c_runtime_resume(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;
>>  
>> -	return sdhci_runtime_resume_host(host);
>> +	clk_enable(busclk);
>> +	clk_enable(ourhost->clk_bus[ourhost->cur_clk]);
>> +	ret = sdhci_runtime_resume_host(host);
>> +	return ret;
>>  }
>>  #endif
> 
> Could I get an ACK on this patch from one of you, please?
> 
> - Chris.
> 

--
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
Chris Ball Sept. 19, 2012, 8:05 a.m. UTC | #3
Hi,

On Wed, Sep 19 2012, Jaehoon Chung wrote:
> Looks good to me.
>
> Acked-by: Jaehoon Chung <jh80.chung@samsung.com>

Thanks, pushed to mmc-next for 3.7.  (The patch didn't merge cleanly
so I applied it by hand; let me know if anything looks wrong.)

- Chris.
Chander Kashyap Sept. 19, 2012, 2:12 p.m. UTC | #4
Hi Chris,

On 19 September 2012 13:13, Jaehoon Chung <jh80.chung@samsung.com> wrote:
> Looks good to me.
>
> Acked-by: Jaehoon Chung <jh80.chung@samsung.com>
>
> On 09/19/2012 03:14 PM, Chris Ball wrote:
>> Hi Jaehoon, Girish,
>>
>> On Fri, Sep 14 2012, Chander Kashyap wrote:
>>> Perform clock disable/enable in runtime suspend/resume.
>>>
>>> Signed-off-by: Chander Kashyap <chander.kashyap@linaro.org>
>>> ---
>>>  drivers/mmc/host/sdhci-s3c.c |   25 +++++++++++++++++++++++--
>>>  1 file changed, 23 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
>>> index 3f4518d..ffffd51 100644
>>> --- a/drivers/mmc/host/sdhci-s3c.c
>>> +++ b/drivers/mmc/host/sdhci-s3c.c
>>> @@ -513,7 +513,9 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
>>>              goto err_no_busclks;
>>>      }
>>>
>>> +#ifndef CONFIG_PM_RUNTIME
>>>      clk_enable(sc->clk_bus[sc->cur_clk]);
>>> +#endif
>>>
>>>      res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>>      host->ioaddr = devm_request_and_ioremap(&pdev->dev, res);
>>> @@ -620,10 +622,13 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
>>>          gpio_is_valid(pdata->ext_cd_gpio))
>>>              sdhci_s3c_setup_card_detect_gpio(sc);
>>>
>>> +    clk_disable(sc->clk_io);
This should be in #ifndef CONFIG_PM_RUNTIME check
>>>      return 0;
>>>
>>>   err_req_regs:
>>> +#ifndef CONFIG_PM_RUNTIME
>>>      clk_disable(sc->clk_bus[sc->cur_clk]);
>>> +#endif
>>>      for (ptr = 0; ptr < MAX_BUS_CLK; ptr++) {
>>>              if (sc->clk_bus[ptr]) {
>>>                      clk_put(sc->clk_bus[ptr]);
>>> @@ -656,12 +661,15 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
>>>      if (gpio_is_valid(sc->ext_cd_gpio))
>>>              gpio_free(sc->ext_cd_gpio);
>>>
>>> +    clk_enable(sc->clk_io);
This should be in #ifndef CONFIG_PM_RUNTIME check
>>>      sdhci_remove_host(host, 1);
>>>
>>>      pm_runtime_dont_use_autosuspend(&pdev->dev);
>>>      pm_runtime_disable(&pdev->dev);
>>>
>>> +#ifndef CONFIG_PM_RUNTIME
>>>      clk_disable(sc->clk_bus[sc->cur_clk]);
>>> +#endif
>>>      for (ptr = 0; ptr < 3; ptr++) {
>>>              if (sc->clk_bus[ptr]) {
>>>                      clk_put(sc->clk_bus[ptr]);
>>> @@ -696,15 +704,28 @@ static int sdhci_s3c_resume(struct device *dev)
>>>  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;
>>> +
>>> +    ret = sdhci_runtime_suspend_host(host);
>>>
>>> -    return sdhci_runtime_suspend_host(host);
>>> +    clk_disable(ourhost->clk_bus[ourhost->cur_clk]);
>>> +    clk_disable(busclk);
>>> +    return ret;
>>>  }
>>>
>>>  static int sdhci_s3c_runtime_resume(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;
>>>
>>> -    return sdhci_runtime_resume_host(host);
>>> +    clk_enable(busclk);
>>> +    clk_enable(ourhost->clk_bus[ourhost->cur_clk]);
>>> +    ret = sdhci_runtime_resume_host(host);
>>> +    return ret;
>>>  }
>>>  #endif
>>
>> Could I get an ACK on this patch from one of you, please?
>>
>> - Chris.
>>
>
I will resend this patch after fixing the issue.
Chris Ball Sept. 19, 2012, 2:21 p.m. UTC | #5
Hi,

On Wed, Sep 19 2012, Chander Kashyap wrote:
> I will resend this patch after fixing the issue.

Thanks; please base your new patch against current mmc-next.

- Chris.
Chander Kashyap Sept. 19, 2012, 2:22 p.m. UTC | #6
Thanks Chris ,
Sure i will do.

On 19 September 2012 19:51, Chris Ball <cjb@laptop.org> wrote:
> Hi,
>
> On Wed, Sep 19 2012, Chander Kashyap wrote:
>> I will resend this patch after fixing the issue.
>
> Thanks; please base your new patch against current mmc-next.
>
> - Chris.
> --
> Chris Ball   <cjb@laptop.org>   <http://printf.net/>
> One Laptop Per Child
> --
> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Heiko Stübner Oct. 17, 2012, 9:15 a.m. UTC | #7
Hi,

Am Freitag, 14. September 2012, 11:08:51 schrieb Chander Kashyap:
> Perform clock disable/enable in runtime suspend/resume.
> 
> Signed-off-by: Chander Kashyap <chander.kashyap@linaro.org>

It seems this patch breaks my S3C2416 based machine with 3.7-rc1. I'm not 
yet sure why, but the only response I get is loop of:

	mmc0: Timeout waiting for hardware interrupt.
	mmc0: Internal clock never stabilised.
	mmc0: Timeout waiting for hardware interrupt.
	mmc0: Internal clock never stabilised.


This only happens on the hsmmc channel using the gpio-based card detect and 
even prevents the card from beeing fully detected. The other hsmmc channel 
using a permanent emmc seems to be working fine.

And of course, when I revert this patch everything works fine again.

I'll investigate further, but it'd be also ok if someone has a fix for this 
before me :-) .


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
Jaehoon Chung Oct. 18, 2012, 2:04 a.m. UTC | #8
Hi Heiko,

Sorry, i didn't check this patch with s3c2416.
(i didn't have the s3c2416 board.)
If you have a problem, i think good that revert this patch for fixing your problem.
Also, i will check and share the result.

Best Regards,
Jaehoon Chung

On 10/17/2012 06:15 PM, Heiko Stübner wrote:
> Hi,
> 
> Am Freitag, 14. September 2012, 11:08:51 schrieb Chander Kashyap:
>> Perform clock disable/enable in runtime suspend/resume.
>>
>> Signed-off-by: Chander Kashyap <chander.kashyap@linaro.org>
> 
> It seems this patch breaks my S3C2416 based machine with 3.7-rc1. I'm not 
> yet sure why, but the only response I get is loop of:
> 
> 	mmc0: Timeout waiting for hardware interrupt.
> 	mmc0: Internal clock never stabilised.
> 	mmc0: Timeout waiting for hardware interrupt.
> 	mmc0: Internal clock never stabilised.
> 
> 
> This only happens on the hsmmc channel using the gpio-based card detect and 
> even prevents the card from beeing fully detected. The other hsmmc channel 
> using a permanent emmc seems to be working fine.
> 
> And of course, when I revert this patch everything works fine again.
> 
> I'll investigate further, but it'd be also ok if someone has a fix for this 
> before me :-) .
> 
> 
> 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
> 

--
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
Heiko Stübner Oct. 18, 2012, 7:41 a.m. UTC | #9
Hi,

Am Donnerstag, 18. Oktober 2012, 04:04:42 schrieb Jaehoon Chung:
> Sorry, i didn't check this patch with s3c2416.
> (i didn't have the s3c2416 board.)
> If you have a problem, i think good that revert this patch for fixing your
> problem. Also, i will check and share the result.


After looking a bit more through the code, I don't think the problem is 2416-
specific but seems to be caused by the gpio card-detect code.

sdhci_s3c_gpio_card_detect_thread calls sdhci_s3c_notify_change which in turn 
runs host->card_tasklet that seems to want to read stuff from the card. But 
this path seems to be missing a runtime-pm wakeup.

I'm not yet sure what to add, especially, as tasklet_finish (called on some 
occasions from tasklet_card) already has a runtime_pm_put call, which would be 
unpaired in this code path.

As there also could be other Samsung platforms affected that use the ext-gpio 
code, it's probably right to revert it for now. Or you see a easy fix :-) .


Heiko


> Best Regards,
> Jaehoon Chung
> 
> On 10/17/2012 06:15 PM, Heiko Stübner wrote:
> > Hi,
> > 
> > Am Freitag, 14. September 2012, 11:08:51 schrieb Chander Kashyap:
> >> Perform clock disable/enable in runtime suspend/resume.
> >> 
> >> Signed-off-by: Chander Kashyap <chander.kashyap@linaro.org>
> > 
> > It seems this patch breaks my S3C2416 based machine with 3.7-rc1. I'm not
> > 
> > yet sure why, but the only response I get is loop of:
> > 	mmc0: Timeout waiting for hardware interrupt.
> > 	mmc0: Internal clock never stabilised.
> > 	mmc0: Timeout waiting for hardware interrupt.
> > 	mmc0: Internal clock never stabilised.
> > 
> > This only happens on the hsmmc channel using the gpio-based card detect
> > and even prevents the card from beeing fully detected. The other hsmmc
> > channel using a permanent emmc seems to be working fine.
> > 
> > And of course, when I revert this patch everything works fine again.
> > 
> > I'll investigate further, but it'd be also ok if someone has a fix for
> > this before me :-) .
> > 
> > 
> > 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

--
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
Seungwon Jeon Oct. 18, 2012, 9:36 a.m. UTC | #10
On Thursday, October 18, 2012, Heiko Stübner <heiko@sntech.de> wrote:
> Hi,
> 
> Am Donnerstag, 18. Oktober 2012, 04:04:42 schrieb Jaehoon Chung:
> > Sorry, i didn't check this patch with s3c2416.
> > (i didn't have the s3c2416 board.)
> > If you have a problem, i think good that revert this patch for fixing your
> > problem. Also, i will check and share the result.
> 
> 
> After looking a bit more through the code, I don't think the problem is 2416-
> specific but seems to be caused by the gpio card-detect code.
> 
> sdhci_s3c_gpio_card_detect_thread calls sdhci_s3c_notify_change which in turn
> runs host->card_tasklet that seems to want to read stuff from the card. But
> this path seems to be missing a runtime-pm wakeup.
> 
> I'm not yet sure what to add, especially, as tasklet_finish (called on some
> occasions from tasklet_card) already has a runtime_pm_put call, which would be
> unpaired in this code path.
> 
> As there also could be other Samsung platforms affected that use the ext-gpio
> code, it's probably right to revert it for now. Or you see a easy fix :-) .
> 
Hi,

I think clock is disabled during bus transaction.
I'll send a patch. Could you test it?

Thanks.

Seungwon Jeon
> 
> Heiko
> 
> 
> > Best Regards,
> > Jaehoon Chung
> >
> > On 10/17/2012 06:15 PM, Heiko Stübner wrote:
> > > Hi,
> > >
> > > Am Freitag, 14. September 2012, 11:08:51 schrieb Chander Kashyap:
> > >> Perform clock disable/enable in runtime suspend/resume.
> > >>
> > >> Signed-off-by: Chander Kashyap <chander.kashyap@linaro.org>
> > >
> > > It seems this patch breaks my S3C2416 based machine with 3.7-rc1. I'm not
> > >
> > > yet sure why, but the only response I get is loop of:
> > > 	mmc0: Timeout waiting for hardware interrupt.
> > > 	mmc0: Internal clock never stabilised.
> > > 	mmc0: Timeout waiting for hardware interrupt.
> > > 	mmc0: Internal clock never stabilised.
> > >
> > > This only happens on the hsmmc channel using the gpio-based card detect
> > > and even prevents the card from beeing fully detected. The other hsmmc
> > > channel using a permanent emmc seems to be working fine.
> > >
> > > And of course, when I revert this patch everything works fine again.
> > >
> > > I'll investigate further, but it'd be also ok if someone has a fix for
> > > this before me :-) .
> > >
> > >
> > > 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
> 
> --
> 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

--
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
Heiko Stübner Oct. 18, 2012, 9:52 a.m. UTC | #11
Am Donnerstag, 18. Oktober 2012, 11:36:03 schrieb Seungwon Jeon:
> On Thursday, October 18, 2012, Heiko Stübner <heiko@sntech.de> wrote:
> > Hi,
> > 
> > Am Donnerstag, 18. Oktober 2012, 04:04:42 schrieb Jaehoon Chung:
> > > Sorry, i didn't check this patch with s3c2416.
> > > (i didn't have the s3c2416 board.)
> > > If you have a problem, i think good that revert this patch for fixing
> > > your problem. Also, i will check and share the result.
> > 
> > After looking a bit more through the code, I don't think the problem is
> > 2416- specific but seems to be caused by the gpio card-detect code.
> > 
> > sdhci_s3c_gpio_card_detect_thread calls sdhci_s3c_notify_change which in
> > turn runs host->card_tasklet that seems to want to read stuff from the
> > card. But this path seems to be missing a runtime-pm wakeup.
> > 
> > I'm not yet sure what to add, especially, as tasklet_finish (called on
> > some occasions from tasklet_card) already has a runtime_pm_put call,
> > which would be unpaired in this code path.
> > 
> > As there also could be other Samsung platforms affected that use the
> > ext-gpio code, it's probably right to revert it for now. Or you see a
> > easy fix :-) .
> 
> Hi,
> 
> I think clock is disabled during bus transaction.
> I'll send a patch. Could you test it?

Sure, I'll test it.

Heiko


> > > On 10/17/2012 06:15 PM, Heiko Stübner wrote:
> > > > Hi,
> > > > 
> > > > Am Freitag, 14. September 2012, 11:08:51 schrieb Chander Kashyap:
> > > >> Perform clock disable/enable in runtime suspend/resume.
> > > >> 
> > > >> Signed-off-by: Chander Kashyap <chander.kashyap@linaro.org>
> > > > 
> > > > It seems this patch breaks my S3C2416 based machine with 3.7-rc1. I'm
> > > > not
> > > > 
> > > > yet sure why, but the only response I get is loop of:
> > > > 	mmc0: Timeout waiting for hardware interrupt.
> > > > 	mmc0: Internal clock never stabilised.
> > > > 	mmc0: Timeout waiting for hardware interrupt.
> > > > 	mmc0: Internal clock never stabilised.
> > > > 
> > > > This only happens on the hsmmc channel using the gpio-based card
> > > > detect and even prevents the card from beeing fully detected. The
> > > > other hsmmc channel using a permanent emmc seems to be working fine.
> > > > 
> > > > And of course, when I revert this patch everything works fine again.
> > > > 
> > > > I'll investigate further, but it'd be also ok if someone has a fix
> > > > for this before me :-) .
> > > > 
> > > > 
> > > > 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
> > 
> > --
> > 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

--
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
diff mbox

Patch

diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index 3f4518d..ffffd51 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -513,7 +513,9 @@  static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
 		goto err_no_busclks;
 	}
 
+#ifndef CONFIG_PM_RUNTIME
 	clk_enable(sc->clk_bus[sc->cur_clk]);
+#endif
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	host->ioaddr = devm_request_and_ioremap(&pdev->dev, res);
@@ -620,10 +622,13 @@  static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
 	    gpio_is_valid(pdata->ext_cd_gpio))
 		sdhci_s3c_setup_card_detect_gpio(sc);
 
+	clk_disable(sc->clk_io);
 	return 0;
 
  err_req_regs:
+#ifndef CONFIG_PM_RUNTIME
 	clk_disable(sc->clk_bus[sc->cur_clk]);
+#endif
 	for (ptr = 0; ptr < MAX_BUS_CLK; ptr++) {
 		if (sc->clk_bus[ptr]) {
 			clk_put(sc->clk_bus[ptr]);
@@ -656,12 +661,15 @@  static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
 	if (gpio_is_valid(sc->ext_cd_gpio))
 		gpio_free(sc->ext_cd_gpio);
 
+	clk_enable(sc->clk_io);
 	sdhci_remove_host(host, 1);
 
 	pm_runtime_dont_use_autosuspend(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
+#ifndef CONFIG_PM_RUNTIME
 	clk_disable(sc->clk_bus[sc->cur_clk]);
+#endif
 	for (ptr = 0; ptr < 3; ptr++) {
 		if (sc->clk_bus[ptr]) {
 			clk_put(sc->clk_bus[ptr]);
@@ -696,15 +704,28 @@  static int sdhci_s3c_resume(struct device *dev)
 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;
+
+	ret = sdhci_runtime_suspend_host(host);
 
-	return sdhci_runtime_suspend_host(host);
+	clk_disable(ourhost->clk_bus[ourhost->cur_clk]);
+	clk_disable(busclk);
+	return ret;
 }
 
 static int sdhci_s3c_runtime_resume(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;
 
-	return sdhci_runtime_resume_host(host);
+	clk_enable(busclk);
+	clk_enable(ourhost->clk_bus[ourhost->cur_clk]);
+	ret = sdhci_runtime_resume_host(host);
+	return ret;
 }
 #endif