From: Adrian Hunter <adrian.hunter@intel.com>
To: Aaron Lu <aaron.lu@amd.com>
Cc: Chris Ball <cjb@laptop.org>,
linux-mmc@vger.kernel.org, Philip Rakity <prakity@marvell.com>
Subject: Re: [PATCH 2/2] mmc: sdhci: Deal with failure case in sdhci_suspend_host
Date: Wed, 28 Dec 2011 14:23:32 +0200 [thread overview]
Message-ID: <4EFB0A44.5070006@intel.com> (raw)
In-Reply-To: <1325041873-1320-3-git-send-email-aaron.lu@amd.com>
On 28/12/11 05:11, Aaron Lu wrote:
> If there are errors happened in sdhci_suspend_host, handle it so that
> when the function returns with error, the host's behaviour is the same
> before this function call, e.g. card detection is enabled and tuning
> timer is active, etc.
>
> Previously, sdhci_suspend_host will return the error code and rely on
> the calling function to handle it. sdhci-pci will handle it in
> sdhci_pci_suspend while sdhci-platform code will not.
>
> Signed-off-by: Philip Rakity <prakity@marvell.com>
> Signed-off-by: Aaron Lu <aaron.lu@amd.com>
> ---
> drivers/mmc/host/sdhci-pci.c | 9 ++-------
> drivers/mmc/host/sdhci.c | 27 +++++++++++++++++++++------
> 2 files changed, 23 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
> index d2e77fb..494d14b 100644
> --- a/drivers/mmc/host/sdhci-pci.c
> +++ b/drivers/mmc/host/sdhci-pci.c
> @@ -1013,7 +1013,7 @@ static int sdhci_pci_suspend(struct device *dev)
> ret = sdhci_suspend_host(slot->host);
>
> if (ret)
> - goto err_pci_suspend;
> + return ret;
>
> slot_pm_flags = slot->host->mmc->pm_flags;
> if (slot_pm_flags & MMC_PM_WAKE_SDIO_IRQ)
> @@ -1025,7 +1025,7 @@ static int sdhci_pci_suspend(struct device *dev)
> if (chip->fixes && chip->fixes->suspend) {
> ret = chip->fixes->suspend(chip);
> if (ret)
> - goto err_pci_suspend;
> + return ret;
> }
>
> pci_save_state(pdev);
> @@ -1042,11 +1042,6 @@ static int sdhci_pci_suspend(struct device *dev)
> }
>
> return 0;
> -
> -err_pci_suspend:
> - while (--i >= 0)
> - sdhci_resume_host(chip->slots[i]->host);
> - return ret;
This doesn't look right. This is about having multiple
host controllers on the same PCI device. If those
hosts have been successfully suspended, then they must
be resumed on error.
> }
>
> static int sdhci_pci_resume(struct device *dev)
> 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;
> }
next prev parent reply other threads:[~2011-12-28 12:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-28 3:11 [PATCH 0/2] mmc: sdhci: Fix for sdhci suspend function Aaron Lu
2011-12-28 3:11 ` [PATCH 1/2] mmc: sdhci: Fix tuning timer incorrect setting when suspending host Aaron Lu
2011-12-28 12:24 ` Adrian Hunter
2011-12-28 3:11 ` [PATCH 2/2] mmc: sdhci: Deal with failure case in sdhci_suspend_host Aaron Lu
2011-12-28 12:23 ` Adrian Hunter [this message]
2011-12-29 2:32 ` Aaron Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4EFB0A44.5070006@intel.com \
--to=adrian.hunter@intel.com \
--cc=aaron.lu@amd.com \
--cc=cjb@laptop.org \
--cc=linux-mmc@vger.kernel.org \
--cc=prakity@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.