diff mbox

mmc: dw_mmc: Don't send clock off command if power is off

Message ID 1426874420-25103-1-git-send-email-dianders@chromium.org
State New, archived
Headers show

Commit Message

Doug Anderson March 20, 2015, 6 p.m. UTC
We've already seen that it causes failures if we try to send the
"SDMMC_CMD_UPD_CLK" command when power is off to the system.  Here's
another case where we were doing it: we were sending an
SDMMC_CMD_UPD_CLK to set the clock to 0 when the card was already
powered off and the clock was already at 0.  Let's avoid that command
and avoid problems.

Signed-off-by: Doug Anderson <dianders@chromium.org>
---
 drivers/mmc/host/dw_mmc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Alim Akhtar March 22, 2015, 12:16 p.m. UTC | #1
Hi Doug,

On Fri, Mar 20, 2015 at 11:30 PM, Doug Anderson <dianders@chromium.org> wrote:
> We've already seen that it causes failures if we try to send the
> "SDMMC_CMD_UPD_CLK" command when power is off to the system.  Here's
> another case where we were doing it: we were sending an
> SDMMC_CMD_UPD_CLK to set the clock to 0 when the card was already
> powered off and the clock was already at 0.  Let's avoid that command
> and avoid problems.
>
> Signed-off-by: Doug Anderson <dianders@chromium.org>
> ---
>  drivers/mmc/host/dw_mmc.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
> index 47dfd0e..aeec698 100644
> --- a/drivers/mmc/host/dw_mmc.c
> +++ b/drivers/mmc/host/dw_mmc.c
> @@ -1172,8 +1172,9 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
>
>                 break;
>         case MMC_POWER_OFF:
> -               /* Turn clock off before power goes down */
> -               dw_mci_setup_bus(slot, false);
> +               /* Turn clock off before power goes down; only if powered */
> +               if (slot->host->vqmmc_enabled)
> +                       dw_mci_setup_bus(slot, false);
>
vqmmc_enabled is always _true_ when entering MMC_POWER_OFF case..right?
Is this done for extra protection? Or do you have a case where vqmmc
is OFF and driver still calls dw_mci_setup_bus from here?

>                 if (!IS_ERR(mmc->supply.vmmc))
>                         mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0);
> --
> 2.2.0.rc0.207.ga3a616c
>
> --
> 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
Doug Anderson March 22, 2015, 9:59 p.m. UTC | #2
Alim,

On Sun, Mar 22, 2015 at 5:16 AM, Alim Akhtar <alim.akhtar@gmail.com> wrote:
>>         case MMC_POWER_OFF:
>> -               /* Turn clock off before power goes down */
>> -               dw_mci_setup_bus(slot, false);
>> +               /* Turn clock off before power goes down; only if powered */
>> +               if (slot->host->vqmmc_enabled)
>> +                       dw_mci_setup_bus(slot, false);
>>
> vqmmc_enabled is always _true_ when entering MMC_POWER_OFF case..right?
> Is this done for extra protection? Or do you have a case where vqmmc
> is OFF and driver still calls dw_mci_setup_bus from here?

Hmm.  I know I got it into the debugger in at least one reboot case
where it was failing to turn the clock off.  I thought I confirmed it
was the core trying to call MMC_POWER_OFF when the power was already
off, but now I'm less certain.  I looked back at my debug session and
I don't see where I got that evidence.  :-/  Certainly if I put a
printout here right now I can't see my code making a difference.

Unfortunately the crash was a very rare one, so I may have to go back
to the drawing board here...

-Doug
--
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 March 27, 2015, 7:21 a.m. UTC | #3
Hi,

On 03/23/2015 06:59 AM, Doug Anderson wrote:
> Alim,
> 
> On Sun, Mar 22, 2015 at 5:16 AM, Alim Akhtar <alim.akhtar@gmail.com> wrote:
>>>         case MMC_POWER_OFF:
>>> -               /* Turn clock off before power goes down */
>>> -               dw_mci_setup_bus(slot, false);
>>> +               /* Turn clock off before power goes down; only if powered */
>>> +               if (slot->host->vqmmc_enabled)
>>> +                       dw_mci_setup_bus(slot, false);
>>>
>> vqmmc_enabled is always _true_ when entering MMC_POWER_OFF case..right?
>> Is this done for extra protection? Or do you have a case where vqmmc
>> is OFF and driver still calls dw_mci_setup_bus from here?
> 
> Hmm.  I know I got it into the debugger in at least one reboot case
> where it was failing to turn the clock off.  I thought I confirmed it
> was the core trying to call MMC_POWER_OFF when the power was already
> off, but now I'm less certain.  I looked back at my debug session and
> I don't see where I got that evidence.  :-/  Certainly if I put a
> printout here right now I can't see my code making a difference.

I'm not sure this is really needs...and i can't find any error case..

Best Regards,
Jaehoon Chung
> 
> Unfortunately the crash was a very rare one, so I may have to go back
> to the drawing board here...
> 
> -Doug
> 

--
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/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 47dfd0e..aeec698 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -1172,8 +1172,9 @@  static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 
 		break;
 	case MMC_POWER_OFF:
-		/* Turn clock off before power goes down */
-		dw_mci_setup_bus(slot, false);
+		/* Turn clock off before power goes down; only if powered */
+		if (slot->host->vqmmc_enabled)
+			dw_mci_setup_bus(slot, false);
 
 		if (!IS_ERR(mmc->supply.vmmc))
 			mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0);