* [PATCH v2 2/2] mmc: sdhci: Deal with failure case in sdhci_suspend_host
@ 2011-12-29 2:50 Aaron Lu
2011-12-30 7:23 ` Adrian Hunter
0 siblings, 1 reply; 3+ messages in thread
From: Aaron Lu @ 2011-12-29 2:50 UTC (permalink / raw)
To: Chris Ball; +Cc: linux-mmc, Aaron Lu, Philip Rakity, Adrian Hunter
V2: Error processing code in sdhci_pci_suspend should not be deleted,
it is used to resume hosts which are already successfully suspended for
a multi slot pci device as suggested by Adrian.
If there are errors happened in sdhci_suspend_host, handle it so that
when the function returns with an error, the host's behaviour is the
same before this function call, e.g. card detection is enabled and
tuning timer is active, etc.
Signed-off-by: Philip Rakity <prakity@marvell.com>
Signed-off-by: Aaron Lu <aaron.lu@amd.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
---
drivers/mmc/host/sdhci.c | 27 +++++++++++++++++++++------
1 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 2007d37..37aeb81 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2339,25 +2339,40 @@ out:
int sdhci_suspend_host(struct sdhci_host *host)
{
- int ret;
+ int ret, has_tuning_timer;
sdhci_disable_card_detection(host);
/* Disable tuning since we are suspending */
- if (host->version >= SDHCI_SPEC_300 && host->tuning_count &&
- host->tuning_mode == SDHCI_TUNING_MODE_1) {
+ has_tuning_timer = host->version >= SDHCI_SPEC_300 &&
+ host->tuning_count && host->tuning_mode == SDHCI_TUNING_MODE_1;
+ if (has_tuning_timer) {
del_timer_sync(&host->tuning_timer);
host->flags &= ~SDHCI_NEEDS_RETUNING;
}
ret = mmc_suspend_host(host->mmc);
if (ret)
- return ret;
+ goto err_suspend;
+
+ if (host->vmmc) {
+ ret = regulator_disable(host->vmmc);
+ if (ret)
+ goto err_suspend;
+ }
free_irq(host->irq, host);
- if (host->vmmc)
- ret = regulator_disable(host->vmmc);
+ return 0;
+
+err_suspend:
+ if (has_tuning_timer) {
+ host->flags |= SDHCI_NEEDS_RETUNING;
+ mod_timer(&host->tuning_timer, jiffies +
+ host->tuning_count * HZ);
+ }
+
+ sdhci_enable_card_detection(host);
return ret;
}
--
1.7.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 2/2] mmc: sdhci: Deal with failure case in sdhci_suspend_host
2011-12-29 2:50 [PATCH v2 2/2] mmc: sdhci: Deal with failure case in sdhci_suspend_host Aaron Lu
@ 2011-12-30 7:23 ` Adrian Hunter
2012-01-03 0:11 ` Chris Ball
0 siblings, 1 reply; 3+ messages in thread
From: Adrian Hunter @ 2011-12-30 7:23 UTC (permalink / raw)
To: Aaron Lu; +Cc: Chris Ball, linux-mmc, Philip Rakity
On 29/12/2011 4:50 a.m., Aaron Lu wrote:
> V2: Error processing code in sdhci_pci_suspend should not be deleted,
> it is used to resume hosts which are already successfully suspended for
> a multi slot pci device as suggested by Adrian.
>
> If there are errors happened in sdhci_suspend_host, handle it so that
> when the function returns with an error, the host's behaviour is the
> same before this function call, e.g. card detection is enabled and
> tuning timer is active, etc.
>
> Signed-off-by: Philip Rakity<prakity@marvell.com>
> Signed-off-by: Aaron Lu<aaron.lu@amd.com>
> Cc: Adrian Hunter<adrian.hunter@intel.com>
> ---
> drivers/mmc/host/sdhci.c | 27 +++++++++++++++++++++------
> 1 files changed, 21 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 2007d37..37aeb81 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -2339,25 +2339,40 @@ out:
>
> int sdhci_suspend_host(struct sdhci_host *host)
> {
> - int ret;
> + int ret, has_tuning_timer;
>
> sdhci_disable_card_detection(host);
>
> /* Disable tuning since we are suspending */
> - if (host->version>= SDHCI_SPEC_300&& host->tuning_count&&
> - host->tuning_mode == SDHCI_TUNING_MODE_1) {
> + has_tuning_timer = host->version>= SDHCI_SPEC_300&&
> + host->tuning_count&& host->tuning_mode == SDHCI_TUNING_MODE_1;
> + if (has_tuning_timer) {
> del_timer_sync(&host->tuning_timer);
> host->flags&= ~SDHCI_NEEDS_RETUNING;
> }
>
> ret = mmc_suspend_host(host->mmc);
> if (ret)
> - return ret;
> + goto err_suspend;
> +
> + if (host->vmmc) {
> + ret = regulator_disable(host->vmmc);
> + if (ret)
> + goto err_suspend;
> + }
This is slightly in conflict with my patch
"mmc: sdhci: fix vmmc handling"
Maybe you guys could ack/nack that
and adjust this accordingly.
>
> free_irq(host->irq, host);
>
> - if (host->vmmc)
> - ret = regulator_disable(host->vmmc);
> + return 0;
> +
> +err_suspend:
> + if (has_tuning_timer) {
> + host->flags |= SDHCI_NEEDS_RETUNING;
> + mod_timer(&host->tuning_timer, jiffies +
> + host->tuning_count * HZ);
> + }
> +
> + sdhci_enable_card_detection(host);
>
> return ret;
> }
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2 2/2] mmc: sdhci: Deal with failure case in sdhci_suspend_host
2011-12-30 7:23 ` Adrian Hunter
@ 2012-01-03 0:11 ` Chris Ball
0 siblings, 0 replies; 3+ messages in thread
From: Chris Ball @ 2012-01-03 0:11 UTC (permalink / raw)
To: Adrian Hunter; +Cc: Aaron Lu, linux-mmc, Philip Rakity
Hi Aaron,
On Fri, Dec 30 2011, Adrian Hunter wrote:
> On 29/12/2011 4:50 a.m., Aaron Lu wrote:
>> V2: Error processing code in sdhci_pci_suspend should not be deleted,
>> it is used to resume hosts which are already successfully suspended for
>> a multi slot pci device as suggested by Adrian.
>>
>> If there are errors happened in sdhci_suspend_host, handle it so that
>> when the function returns with an error, the host's behaviour is the
>> same before this function call, e.g. card detection is enabled and
>> tuning timer is active, etc.
>>
>> Signed-off-by: Philip Rakity<prakity@marvell.com>
>> Signed-off-by: Aaron Lu<aaron.lu@amd.com>
>> Cc: Adrian Hunter<adrian.hunter@intel.com>
>> ---
>> drivers/mmc/host/sdhci.c | 27 +++++++++++++++++++++------
>> 1 files changed, 21 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
>> index 2007d37..37aeb81 100644
>> --- a/drivers/mmc/host/sdhci.c
>> +++ b/drivers/mmc/host/sdhci.c
>> @@ -2339,25 +2339,40 @@ out:
>>
>> int sdhci_suspend_host(struct sdhci_host *host)
>> {
>> - int ret;
>> + int ret, has_tuning_timer;
>>
>> sdhci_disable_card_detection(host);
>>
>> /* Disable tuning since we are suspending */
>> - if (host->version>= SDHCI_SPEC_300&& host->tuning_count&&
>> - host->tuning_mode == SDHCI_TUNING_MODE_1) {
>> + has_tuning_timer = host->version>= SDHCI_SPEC_300&&
>> + host->tuning_count&& host->tuning_mode == SDHCI_TUNING_MODE_1;
>> + if (has_tuning_timer) {
>> del_timer_sync(&host->tuning_timer);
>> host->flags&= ~SDHCI_NEEDS_RETUNING;
>> }
>>
>> ret = mmc_suspend_host(host->mmc);
>> if (ret)
>> - return ret;
>> + goto err_suspend;
>> +
>> + if (host->vmmc) {
>> + ret = regulator_disable(host->vmmc);
>> + if (ret)
>> + goto err_suspend;
>> + }
>
> This is slightly in conflict with my patch
> "mmc: sdhci: fix vmmc handling"
>
> Maybe you guys could ack/nack that
> and adjust this accordingly.
I've pushed Adrian's vmmc patch to mmc-next now, so this can be reworked.
Thanks,
- Chris.
--
Chris Ball <cjb@laptop.org> <http://printf.net/>
One Laptop Per Child
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-01-03 0:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-29 2:50 [PATCH v2 2/2] mmc: sdhci: Deal with failure case in sdhci_suspend_host Aaron Lu
2011-12-30 7:23 ` Adrian Hunter
2012-01-03 0:11 ` Chris Ball
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox