Message ID | 1375825071-20922-4-git-send-email-dianders@chromium.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Tuesday 06 of August 2013 14:37:50 Doug Anderson wrote: > After suspend/resume all of the dw_mmc registers are reset to > defaults. We restore most of them, but specifically don't setup the > clock registers after resume unless we've got a powered card. Things > still work because the core will eventually call set_ios() and we'll > set things up. > > There doesn't seem to be any reason that I can see _not_ to set things > up after resume. Restoring this state makes the code easier to reason > about and should help prevent bugs. It also allows us to do a > register dump before and after suspend/resume to confirm that we've > set things up OK. > > I examined the state of the dw_mmc instance before and after suspend > after this patch. I had no card inserted in an SD card slot. > > Before this patch, differences were: > * CLKDIV (0x08) > * CLKENA (0x10) > * TMOUT (0x14) > * CMD (0x2C) - difference is not important > * CLKSEL (0x9C - exynos specific) > > After this patch, only TMOUT was different. I have a separate patch > for that. > > Signed-off-by: Doug Anderson <dianders@chromium.org> > --- > Changes in v4: None > Changes in v3: None > Changes in v2: None > > drivers/mmc/host/dw_mmc.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c > index 13a363c..0fa3135 100644 > --- a/drivers/mmc/host/dw_mmc.c > +++ b/drivers/mmc/host/dw_mmc.c > @@ -2522,9 +2522,7 @@ int dw_mci_resume(struct dw_mci *host) > struct dw_mci_slot *slot = host->slot[i]; > if (!slot) > continue; > - if (slot->mmc->pm_flags & MMC_PM_KEEP_POWER) { > - dw_mci_set_ios(slot->mmc, &slot->mmc->ios); > - } > + dw_mci_set_ios(slot->mmc, &slot->mmc->ios); > > ret = mmc_resume_host(host->slot[i]->mmc); > if (ret < 0) Reviewed-by: Tomasz Figa <t.figa@samsung.com> Best regards, Tomasz -- 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
On Wed, August 07, 2013, Doug Anderson wrote: > After suspend/resume all of the dw_mmc registers are reset to > defaults. We restore most of them, but specifically don't setup the > clock registers after resume unless we've got a powered card. Things > still work because the core will eventually call set_ios() and we'll > set things up. Hmm, I didn't get the need of this call during resume. I think set_ios is only valid where core layer calls. Besides, important things is ios's parameters. If suspend has finished successfully, last call of set_ios() is from mmc_power_off(). On seeing fields of 'mmc->ios' stored last, these values aren't proper in resume phase. Please check mmc_power_off() function. In case MMC_PM_KEEP_POWER it could be kept. Thanks, Seungwon Jeon > > There doesn't seem to be any reason that I can see _not_ to set things > up after resume. Restoring this state makes the code easier to reason > about and should help prevent bugs. It also allows us to do a > register dump before and after suspend/resume to confirm that we've > set things up OK. > > I examined the state of the dw_mmc instance before and after suspend > after this patch. I had no card inserted in an SD card slot. > > Before this patch, differences were: > * CLKDIV (0x08) > * CLKENA (0x10) > * TMOUT (0x14) > * CMD (0x2C) - difference is not important > * CLKSEL (0x9C - exynos specific) > > After this patch, only TMOUT was different. I have a separate patch > for that. > > Signed-off-by: Doug Anderson <dianders@chromium.org> > --- > Changes in v4: None > Changes in v3: None > Changes in v2: None > > drivers/mmc/host/dw_mmc.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c > index 13a363c..0fa3135 100644 > --- a/drivers/mmc/host/dw_mmc.c > +++ b/drivers/mmc/host/dw_mmc.c > @@ -2522,9 +2522,7 @@ int dw_mci_resume(struct dw_mci *host) > struct dw_mci_slot *slot = host->slot[i]; > if (!slot) > continue; > - if (slot->mmc->pm_flags & MMC_PM_KEEP_POWER) { > - dw_mci_set_ios(slot->mmc, &slot->mmc->ios); > - } > + dw_mci_set_ios(slot->mmc, &slot->mmc->ios); > > ret = mmc_resume_host(host->slot[i]->mmc); > if (ret < 0) > -- > 1.8.3 > > -- > 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, On Fri, Aug 9, 2013 at 6:35 AM, Seungwon Jeon <tgih.jun@samsung.com> wrote: > On Wed, August 07, 2013, Doug Anderson wrote: >> After suspend/resume all of the dw_mmc registers are reset to >> defaults. We restore most of them, but specifically don't setup the >> clock registers after resume unless we've got a powered card. Things >> still work because the core will eventually call set_ios() and we'll >> set things up. > > Hmm, I didn't get the need of this call during resume. > I think set_ios is only valid where core layer calls. > Besides, important things is ios's parameters. > If suspend has finished successfully, last call of set_ios() is from mmc_power_off(). > On seeing fields of 'mmc->ios' stored last, these values aren't proper in resume phase. > Please check mmc_power_off() function. > In case MMC_PM_KEEP_POWER it could be kept. Most of my reasoning has to do with the fact that the state of the system after suspend/resume should not be significantly different than the state of the system before suspend/resume. If the state of the system is different in the two cases it points out potential problems or inefficiencies. To make this more concrete: 1. Boot up a system with no card in the SD Card slot. 2. Note down the value of registers like CLKDIV, CLKENA, etc. 3. Suspend / resume (S2R) 4. Check the values of CLKDIV, CLKENA, etc. You will notice that they are different. This is a bad sign and can be a source of bugs (though I don't know of any). ...or it could mean that power draw is different (could be better, could be worse) after a suspend/resume cycle. Said another way, if the value of CLKDIV, CLKENA, etc is not important when a card is not inserted, why do they get initialized at boot time? In general, I think that the mmc core code makes the assumption that it's up to the driver to make sure that its state is preserved across S2R. For dw_mmc the driver doesn't do the "brute force" that some drivers do of just saving and restoring all registers using a copy loop. Instead, the dw_mmc driver runs code that tries to set the state back to something reasonable. Without my patch the dw_mmc driver doesn't run any code that restores these registers. dw_mci_set_ios() will do so. Another option would be to forcibly save/restore registers in suspend/resume. -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
On Sat, August 10, 2013,Doug Anderson wrote: > Seungwon, > > On Fri, Aug 9, 2013 at 6:35 AM, Seungwon Jeon <tgih.jun@samsung.com> wrote: > > On Wed, August 07, 2013, Doug Anderson wrote: > >> After suspend/resume all of the dw_mmc registers are reset to > >> defaults. We restore most of them, but specifically don't setup the > >> clock registers after resume unless we've got a powered card. Things > >> still work because the core will eventually call set_ios() and we'll > >> set things up. > > > > Hmm, I didn't get the need of this call during resume. > > I think set_ios is only valid where core layer calls. > > Besides, important things is ios's parameters. > > If suspend has finished successfully, last call of set_ios() is from mmc_power_off(). > > On seeing fields of 'mmc->ios' stored last, these values aren't proper in resume phase. > > Please check mmc_power_off() function. > > In case MMC_PM_KEEP_POWER it could be kept. > > Most of my reasoning has to do with the fact that the state of the > system after suspend/resume should not be significantly different than > the state of the system before suspend/resume. If the state of the > system is different in the two cases it points out potential problems > or inefficiencies. > > To make this more concrete: > > 1. Boot up a system with no card in the SD Card slot. > 2. Note down the value of registers like CLKDIV, CLKENA, etc. > 3. Suspend / resume (S2R) > 4. Check the values of CLKDIV, CLKENA, etc. > > You will notice that they are different. This is a bad sign and can > be a source of bugs (though I don't know of any). ...or it could mean > that power draw is different (could be better, could be worse) after a > suspend/resume cycle. > > > Said another way, if the value of CLKDIV, CLKENA, etc is not important > when a card is not inserted, why do they get initialized at boot time? > > > In general, I think that the mmc core code makes the assumption that > it's up to the driver to make sure that its state is preserved across > S2R. For dw_mmc the driver doesn't do the "brute force" that some > drivers do of just saving and restoring all registers using a copy > loop. Instead, the dw_mmc driver runs code that tries to set the > state back to something reasonable. Without my patch the dw_mmc > driver doesn't run any code that restores these registers. > dw_mci_set_ios() will do so. This seems pretty associated with [1/4 patch]. (Anyway continued, ...) Basically, both CLKDIV and CLKENA will be set with the reset value of zero. This means clock is disabled. While resume of dw_mmc is completed, initial configuration registers will be set except for runtime registers. I think registers related to clock are close to runtime. Core layer knows the correct clock rate for current device mode and will actually request it by set_ios. If core layer requests set_ios no more after dw_mmc resume is completed, dw_mmc will keep the clock to be disabled. Then, dw_mmc doesn't need self call of dw_mci_set_ios. Thanks, Seungwon Jeon > > Another option would be to forcibly save/restore registers in suspend/resume. > > -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 --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 13a363c..0fa3135 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -2522,9 +2522,7 @@ int dw_mci_resume(struct dw_mci *host) struct dw_mci_slot *slot = host->slot[i]; if (!slot) continue; - if (slot->mmc->pm_flags & MMC_PM_KEEP_POWER) { - dw_mci_set_ios(slot->mmc, &slot->mmc->ios); - } + dw_mci_set_ios(slot->mmc, &slot->mmc->ios); ret = mmc_resume_host(host->slot[i]->mmc); if (ret < 0)
After suspend/resume all of the dw_mmc registers are reset to defaults. We restore most of them, but specifically don't setup the clock registers after resume unless we've got a powered card. Things still work because the core will eventually call set_ios() and we'll set things up. There doesn't seem to be any reason that I can see _not_ to set things up after resume. Restoring this state makes the code easier to reason about and should help prevent bugs. It also allows us to do a register dump before and after suspend/resume to confirm that we've set things up OK. I examined the state of the dw_mmc instance before and after suspend after this patch. I had no card inserted in an SD card slot. Before this patch, differences were: * CLKDIV (0x08) * CLKENA (0x10) * TMOUT (0x14) * CMD (0x2C) - difference is not important * CLKSEL (0x9C - exynos specific) After this patch, only TMOUT was different. I have a separate patch for that. Signed-off-by: Doug Anderson <dianders@chromium.org> --- Changes in v4: None Changes in v3: None Changes in v2: None drivers/mmc/host/dw_mmc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)