All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: sdhci: Fix to handle MMC_POWER_UNDEFINED
@ 2016-12-19 13:33 Adrian Hunter
  2016-12-20 10:49 ` Ulf Hansson
  0 siblings, 1 reply; 2+ messages in thread
From: Adrian Hunter @ 2016-12-19 13:33 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: linux-mmc

Since commit c2c24819b280 ("mmc: core: Don't power off the card when
starting the host"), the power state can still be MMC_POWER_UNDEFINED after
mmc_start_host() is called. That can trigger a warning in SDHCI during
runtime resume as it tries to restore the I/O state. Handle
MMC_POWER_UNDEFINED simply by not updating the I/O state in that case.

Fixes: c2c24819b280 ("mmc: core: Don't power off the card when starting the host")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci.c | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 111991e5b9a0..23909804ffb8 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1576,6 +1576,9 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 	unsigned long flags;
 	u8 ctrl;
 
+	if (ios->power_mode == MMC_POWER_UNDEFINED)
+		return;
+
 	spin_lock_irqsave(&host->lock, flags);
 
 	if (host->flags & SDHCI_DEVICE_DEAD) {
@@ -2938,22 +2941,24 @@ int sdhci_runtime_resume_host(struct sdhci_host *host)
 
 	sdhci_init(host, 0);
 
-	/* Force clock and power re-program */
-	host->pwr = 0;
-	host->clock = 0;
-	mmc->ops->start_signal_voltage_switch(mmc, &mmc->ios);
-	mmc->ops->set_ios(mmc, &mmc->ios);
+	if (mmc->ios.power_mode != MMC_POWER_UNDEFINED) {
+		/* Force clock and power re-program */
+		host->pwr = 0;
+		host->clock = 0;
+		mmc->ops->start_signal_voltage_switch(mmc, &mmc->ios);
+		mmc->ops->set_ios(mmc, &mmc->ios);
 
-	if ((host_flags & SDHCI_PV_ENABLED) &&
-		!(host->quirks2 & SDHCI_QUIRK2_PRESET_VALUE_BROKEN)) {
-		spin_lock_irqsave(&host->lock, flags);
-		sdhci_enable_preset_value(host, true);
-		spin_unlock_irqrestore(&host->lock, flags);
-	}
+		if ((host_flags & SDHCI_PV_ENABLED) &&
+		    !(host->quirks2 & SDHCI_QUIRK2_PRESET_VALUE_BROKEN)) {
+			spin_lock_irqsave(&host->lock, flags);
+			sdhci_enable_preset_value(host, true);
+			spin_unlock_irqrestore(&host->lock, flags);
+		}
 
-	if ((mmc->caps2 & MMC_CAP2_HS400_ES) &&
-	    mmc->ops->hs400_enhanced_strobe)
-		mmc->ops->hs400_enhanced_strobe(mmc, &mmc->ios);
+		if ((mmc->caps2 & MMC_CAP2_HS400_ES) &&
+		    mmc->ops->hs400_enhanced_strobe)
+			mmc->ops->hs400_enhanced_strobe(mmc, &mmc->ios);
+	}
 
 	spin_lock_irqsave(&host->lock, flags);
 
-- 
1.9.1


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

* Re: [PATCH] mmc: sdhci: Fix to handle MMC_POWER_UNDEFINED
  2016-12-19 13:33 [PATCH] mmc: sdhci: Fix to handle MMC_POWER_UNDEFINED Adrian Hunter
@ 2016-12-20 10:49 ` Ulf Hansson
  0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2016-12-20 10:49 UTC (permalink / raw)
  To: Adrian Hunter; +Cc: linux-mmc

On 19 December 2016 at 14:33, Adrian Hunter <adrian.hunter@intel.com> wrote:
> Since commit c2c24819b280 ("mmc: core: Don't power off the card when
> starting the host"), the power state can still be MMC_POWER_UNDEFINED after
> mmc_start_host() is called. That can trigger a warning in SDHCI during
> runtime resume as it tries to restore the I/O state. Handle
> MMC_POWER_UNDEFINED simply by not updating the I/O state in that case.
>
> Fixes: c2c24819b280 ("mmc: core: Don't power off the card when starting the host")
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>

Adrian, thanks for fixing this - my bad! Applied for fixes!

Kind regards
Uffe

> ---
>  drivers/mmc/host/sdhci.c | 33 +++++++++++++++++++--------------
>  1 file changed, 19 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 111991e5b9a0..23909804ffb8 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -1576,6 +1576,9 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
>         unsigned long flags;
>         u8 ctrl;
>
> +       if (ios->power_mode == MMC_POWER_UNDEFINED)
> +               return;
> +
>         spin_lock_irqsave(&host->lock, flags);
>
>         if (host->flags & SDHCI_DEVICE_DEAD) {
> @@ -2938,22 +2941,24 @@ int sdhci_runtime_resume_host(struct sdhci_host *host)
>
>         sdhci_init(host, 0);
>
> -       /* Force clock and power re-program */
> -       host->pwr = 0;
> -       host->clock = 0;
> -       mmc->ops->start_signal_voltage_switch(mmc, &mmc->ios);
> -       mmc->ops->set_ios(mmc, &mmc->ios);
> +       if (mmc->ios.power_mode != MMC_POWER_UNDEFINED) {
> +               /* Force clock and power re-program */
> +               host->pwr = 0;
> +               host->clock = 0;
> +               mmc->ops->start_signal_voltage_switch(mmc, &mmc->ios);
> +               mmc->ops->set_ios(mmc, &mmc->ios);
>
> -       if ((host_flags & SDHCI_PV_ENABLED) &&
> -               !(host->quirks2 & SDHCI_QUIRK2_PRESET_VALUE_BROKEN)) {
> -               spin_lock_irqsave(&host->lock, flags);
> -               sdhci_enable_preset_value(host, true);
> -               spin_unlock_irqrestore(&host->lock, flags);
> -       }
> +               if ((host_flags & SDHCI_PV_ENABLED) &&
> +                   !(host->quirks2 & SDHCI_QUIRK2_PRESET_VALUE_BROKEN)) {
> +                       spin_lock_irqsave(&host->lock, flags);
> +                       sdhci_enable_preset_value(host, true);
> +                       spin_unlock_irqrestore(&host->lock, flags);
> +               }
>
> -       if ((mmc->caps2 & MMC_CAP2_HS400_ES) &&
> -           mmc->ops->hs400_enhanced_strobe)
> -               mmc->ops->hs400_enhanced_strobe(mmc, &mmc->ios);
> +               if ((mmc->caps2 & MMC_CAP2_HS400_ES) &&
> +                   mmc->ops->hs400_enhanced_strobe)
> +                       mmc->ops->hs400_enhanced_strobe(mmc, &mmc->ios);
> +       }
>
>         spin_lock_irqsave(&host->lock, flags);
>
> --
> 1.9.1
>
> --
> 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] 2+ messages in thread

end of thread, other threads:[~2016-12-20 10:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-19 13:33 [PATCH] mmc: sdhci: Fix to handle MMC_POWER_UNDEFINED Adrian Hunter
2016-12-20 10:49 ` Ulf Hansson

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.