* [PATCH] mmc: sdhci-esdhc-imx: Enable/Disable mmc clock during runtime suspend @ 2017-12-21 13:22 Michael Trimarchi 2017-12-21 14:43 ` Michael Nazzareno Trimarchi 2018-01-03 16:26 ` Ulf Hansson 0 siblings, 2 replies; 7+ messages in thread From: Michael Trimarchi @ 2017-12-21 13:22 UTC (permalink / raw) To: Adrian Hunter; +Cc: Ulf Hansson, linux-mmc mmc clock can be stopped during runtime suspend and restart during runtime resume. This let us know to not have any clock running and this reduce the EMI of the device when the bus is not in use Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com> --- drivers/mmc/host/sdhci-esdhc-imx.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index 7123ef9..9a5e96f 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -196,6 +196,7 @@ struct pltfm_imx_data { struct clk *clk_ipg; struct clk *clk_ahb; struct clk *clk_per; + unsigned int actual_clock; enum { NO_CMD_PENDING, /* no multiblock command pending*/ MULTIBLK_IN_PROCESS, /* exact multiblock cmd in process */ @@ -1346,6 +1347,9 @@ static int sdhci_esdhc_runtime_suspend(struct device *dev) ret = sdhci_runtime_suspend_host(host); + imx_data->actual_clock = host->mmc->actual_clock; + esdhc_pltfm_set_clock(host, 0); + if (!sdhci_sdio_irq_enabled(host)) { clk_disable_unprepare(imx_data->clk_per); clk_disable_unprepare(imx_data->clk_ipg); @@ -1366,6 +1370,7 @@ static int sdhci_esdhc_runtime_resume(struct device *dev) clk_prepare_enable(imx_data->clk_ipg); } clk_prepare_enable(imx_data->clk_ahb); + esdhc_pltfm_set_clock(host, imx_data->actual_clock); return sdhci_runtime_resume_host(host); } -- 2.7.4 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] mmc: sdhci-esdhc-imx: Enable/Disable mmc clock during runtime suspend 2017-12-21 13:22 [PATCH] mmc: sdhci-esdhc-imx: Enable/Disable mmc clock during runtime suspend Michael Trimarchi @ 2017-12-21 14:43 ` Michael Nazzareno Trimarchi 2018-01-03 16:26 ` Ulf Hansson 1 sibling, 0 replies; 7+ messages in thread From: Michael Nazzareno Trimarchi @ 2017-12-21 14:43 UTC (permalink / raw) To: Adrian Hunter; +Cc: Ulf Hansson, linux-mmc Hi I have some questions: On Thu, Dec 21, 2017 at 2:22 PM, Michael Trimarchi <michael@amarulasolutions.com> wrote: > mmc clock can be stopped during runtime suspend and restart during runtime > resume. This let us know to not have any clock running and this reduce > the EMI of the device when the bus is not in use > > Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com> > --- > drivers/mmc/host/sdhci-esdhc-imx.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c > index 7123ef9..9a5e96f 100644 > --- a/drivers/mmc/host/sdhci-esdhc-imx.c > +++ b/drivers/mmc/host/sdhci-esdhc-imx.c > @@ -196,6 +196,7 @@ struct pltfm_imx_data { > struct clk *clk_ipg; > struct clk *clk_ahb; > struct clk *clk_per; > + unsigned int actual_clock; > enum { > NO_CMD_PENDING, /* no multiblock command pending*/ > MULTIBLK_IN_PROCESS, /* exact multiblock cmd in process */ > @@ -1346,6 +1347,9 @@ static int sdhci_esdhc_runtime_suspend(struct device *dev) > > ret = sdhci_runtime_suspend_host(host); > > + imx_data->actual_clock = host->mmc->actual_clock; > + esdhc_pltfm_set_clock(host, 0); > + > if (!sdhci_sdio_irq_enabled(host)) { > clk_disable_unprepare(imx_data->clk_per); > clk_disable_unprepare(imx_data->clk_ipg); What if the runtime suspend fail in the sdhci_runtime_suspend_host? Is the runtime resume called? Because in the old code the ret is not taken in account to unprepare and disable the clock so I did not take in account too. Is this correct? Michael > @@ -1366,6 +1370,7 @@ static int sdhci_esdhc_runtime_resume(struct device *dev) > clk_prepare_enable(imx_data->clk_ipg); > } > clk_prepare_enable(imx_data->clk_ahb); > + esdhc_pltfm_set_clock(host, imx_data->actual_clock); > > return sdhci_runtime_resume_host(host); > } > -- > 2.7.4 > -- | Michael Nazzareno Trimarchi Amarula Solutions BV | | COO - Founder Cruquiuskade 47 | | +31(0)851119172 Amsterdam 1018 AM NL | | [`as] http://www.amarulasolutions.com | ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mmc: sdhci-esdhc-imx: Enable/Disable mmc clock during runtime suspend 2017-12-21 13:22 [PATCH] mmc: sdhci-esdhc-imx: Enable/Disable mmc clock during runtime suspend Michael Trimarchi 2017-12-21 14:43 ` Michael Nazzareno Trimarchi @ 2018-01-03 16:26 ` Ulf Hansson 2018-01-03 16:38 ` Michael Nazzareno Trimarchi 1 sibling, 1 reply; 7+ messages in thread From: Ulf Hansson @ 2018-01-03 16:26 UTC (permalink / raw) To: Michael Trimarchi; +Cc: Adrian Hunter, linux-mmc@vger.kernel.org On 21 December 2017 at 14:22, Michael Trimarchi <michael@amarulasolutions.com> wrote: > mmc clock can be stopped during runtime suspend and restart during runtime > resume. This let us know to not have any clock running and this reduce > the EMI of the device when the bus is not in use > > Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com> > --- > drivers/mmc/host/sdhci-esdhc-imx.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c > index 7123ef9..9a5e96f 100644 > --- a/drivers/mmc/host/sdhci-esdhc-imx.c > +++ b/drivers/mmc/host/sdhci-esdhc-imx.c > @@ -196,6 +196,7 @@ struct pltfm_imx_data { > struct clk *clk_ipg; > struct clk *clk_ahb; > struct clk *clk_per; > + unsigned int actual_clock; > enum { > NO_CMD_PENDING, /* no multiblock command pending*/ > MULTIBLK_IN_PROCESS, /* exact multiblock cmd in process */ > @@ -1346,6 +1347,9 @@ static int sdhci_esdhc_runtime_suspend(struct device *dev) > > ret = sdhci_runtime_suspend_host(host); > > + imx_data->actual_clock = host->mmc->actual_clock; > + esdhc_pltfm_set_clock(host, 0); I guess want the clock to stay on "if sdhci_sdio_irq_enabled(host)". So you should probably move the above inside the below if statement. > + > if (!sdhci_sdio_irq_enabled(host)) { > clk_disable_unprepare(imx_data->clk_per); > clk_disable_unprepare(imx_data->clk_ipg); > @@ -1366,6 +1370,7 @@ static int sdhci_esdhc_runtime_resume(struct device *dev) > clk_prepare_enable(imx_data->clk_ipg); > } > clk_prepare_enable(imx_data->clk_ahb); > + esdhc_pltfm_set_clock(host, imx_data->actual_clock); > > return sdhci_runtime_resume_host(host); > } > -- > 2.7.4 > Kind regards Uffe ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mmc: sdhci-esdhc-imx: Enable/Disable mmc clock during runtime suspend 2018-01-03 16:26 ` Ulf Hansson @ 2018-01-03 16:38 ` Michael Nazzareno Trimarchi 2018-01-03 16:56 ` Ulf Hansson 0 siblings, 1 reply; 7+ messages in thread From: Michael Nazzareno Trimarchi @ 2018-01-03 16:38 UTC (permalink / raw) To: Ulf Hansson; +Cc: Adrian Hunter, linux-mmc@vger.kernel.org Hi On Wed, Jan 3, 2018 at 5:26 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote: > On 21 December 2017 at 14:22, Michael Trimarchi > <michael@amarulasolutions.com> wrote: >> mmc clock can be stopped during runtime suspend and restart during runtime >> resume. This let us know to not have any clock running and this reduce >> the EMI of the device when the bus is not in use >> >> Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com> >> --- >> drivers/mmc/host/sdhci-esdhc-imx.c | 5 +++++ >> 1 file changed, 5 insertions(+) >> >> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c >> index 7123ef9..9a5e96f 100644 >> --- a/drivers/mmc/host/sdhci-esdhc-imx.c >> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c >> @@ -196,6 +196,7 @@ struct pltfm_imx_data { >> struct clk *clk_ipg; >> struct clk *clk_ahb; >> struct clk *clk_per; >> + unsigned int actual_clock; >> enum { >> NO_CMD_PENDING, /* no multiblock command pending*/ >> MULTIBLK_IN_PROCESS, /* exact multiblock cmd in process */ >> @@ -1346,6 +1347,9 @@ static int sdhci_esdhc_runtime_suspend(struct device *dev) >> >> ret = sdhci_runtime_suspend_host(host); >> >> + imx_data->actual_clock = host->mmc->actual_clock; >> + esdhc_pltfm_set_clock(host, 0); > > I guess want the clock to stay on "if sdhci_sdio_irq_enabled(host)". > So you should probably move the above inside the below if statement. > Well I'm not quite sure about it. Some wifi chipset has the wakeup interrupt on external gpio and someone wakeup from DAT1. Why clock should be required? Anyway I should even rebalance resume. Michael >> + >> if (!sdhci_sdio_irq_enabled(host)) { >> clk_disable_unprepare(imx_data->clk_per); >> clk_disable_unprepare(imx_data->clk_ipg); >> @@ -1366,6 +1370,7 @@ static int sdhci_esdhc_runtime_resume(struct device *dev) >> clk_prepare_enable(imx_data->clk_ipg); >> } >> clk_prepare_enable(imx_data->clk_ahb); >> + esdhc_pltfm_set_clock(host, imx_data->actual_clock); >> >> return sdhci_runtime_resume_host(host); >> } >> -- >> 2.7.4 >> > > Kind regards > Uffe ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mmc: sdhci-esdhc-imx: Enable/Disable mmc clock during runtime suspend 2018-01-03 16:38 ` Michael Nazzareno Trimarchi @ 2018-01-03 16:56 ` Ulf Hansson 2018-01-03 16:58 ` Michael Nazzareno Trimarchi 0 siblings, 1 reply; 7+ messages in thread From: Ulf Hansson @ 2018-01-03 16:56 UTC (permalink / raw) To: Michael Nazzareno Trimarchi; +Cc: Adrian Hunter, linux-mmc@vger.kernel.org On 3 January 2018 at 17:38, Michael Nazzareno Trimarchi <michael@amarulasolutions.com> wrote: > Hi > > On Wed, Jan 3, 2018 at 5:26 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote: >> On 21 December 2017 at 14:22, Michael Trimarchi >> <michael@amarulasolutions.com> wrote: >>> mmc clock can be stopped during runtime suspend and restart during runtime >>> resume. This let us know to not have any clock running and this reduce >>> the EMI of the device when the bus is not in use >>> >>> Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com> >>> --- >>> drivers/mmc/host/sdhci-esdhc-imx.c | 5 +++++ >>> 1 file changed, 5 insertions(+) >>> >>> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c >>> index 7123ef9..9a5e96f 100644 >>> --- a/drivers/mmc/host/sdhci-esdhc-imx.c >>> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c >>> @@ -196,6 +196,7 @@ struct pltfm_imx_data { >>> struct clk *clk_ipg; >>> struct clk *clk_ahb; >>> struct clk *clk_per; >>> + unsigned int actual_clock; >>> enum { >>> NO_CMD_PENDING, /* no multiblock command pending*/ >>> MULTIBLK_IN_PROCESS, /* exact multiblock cmd in process */ >>> @@ -1346,6 +1347,9 @@ static int sdhci_esdhc_runtime_suspend(struct device *dev) >>> >>> ret = sdhci_runtime_suspend_host(host); >>> >>> + imx_data->actual_clock = host->mmc->actual_clock; >>> + esdhc_pltfm_set_clock(host, 0); >> >> I guess want the clock to stay on "if sdhci_sdio_irq_enabled(host)". >> So you should probably move the above inside the below if statement. >> > > Well I'm not quite sure about it. Some wifi chipset has the wakeup > interrupt on external gpio > and someone wakeup from DAT1. Why clock should be required? The clock should not be needed when using external GPIO (also described as an out-band IRQ/wakeup), but from DAT1. When sdhci_sdio_irq_enabled() returns true, that *should* indicate that DAT1 is used. Although, there may be reasons to re-visit this later, because the hole SDIO irq thing around wakeups for sdhci, is being reworked by Adrian [1]. > > Anyway I should even rebalance resume. Yes. [...] Kind regards Uffe [1] https://www.spinics.net/lists/linux-mmc/msg47512.html ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mmc: sdhci-esdhc-imx: Enable/Disable mmc clock during runtime suspend 2018-01-03 16:56 ` Ulf Hansson @ 2018-01-03 16:58 ` Michael Nazzareno Trimarchi 2018-01-03 17:26 ` Michael Nazzareno Trimarchi 0 siblings, 1 reply; 7+ messages in thread From: Michael Nazzareno Trimarchi @ 2018-01-03 16:58 UTC (permalink / raw) To: Ulf Hansson; +Cc: Adrian Hunter, linux-mmc@vger.kernel.org Hi On Wed, Jan 3, 2018 at 5:56 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote: > On 3 January 2018 at 17:38, Michael Nazzareno Trimarchi > <michael@amarulasolutions.com> wrote: >> Hi >> >> On Wed, Jan 3, 2018 at 5:26 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote: >>> On 21 December 2017 at 14:22, Michael Trimarchi >>> <michael@amarulasolutions.com> wrote: >>>> mmc clock can be stopped during runtime suspend and restart during runtime >>>> resume. This let us know to not have any clock running and this reduce >>>> the EMI of the device when the bus is not in use >>>> >>>> Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com> >>>> --- >>>> drivers/mmc/host/sdhci-esdhc-imx.c | 5 +++++ >>>> 1 file changed, 5 insertions(+) >>>> >>>> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c >>>> index 7123ef9..9a5e96f 100644 >>>> --- a/drivers/mmc/host/sdhci-esdhc-imx.c >>>> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c >>>> @@ -196,6 +196,7 @@ struct pltfm_imx_data { >>>> struct clk *clk_ipg; >>>> struct clk *clk_ahb; >>>> struct clk *clk_per; >>>> + unsigned int actual_clock; >>>> enum { >>>> NO_CMD_PENDING, /* no multiblock command pending*/ >>>> MULTIBLK_IN_PROCESS, /* exact multiblock cmd in process */ >>>> @@ -1346,6 +1347,9 @@ static int sdhci_esdhc_runtime_suspend(struct device *dev) >>>> >>>> ret = sdhci_runtime_suspend_host(host); >>>> >>>> + imx_data->actual_clock = host->mmc->actual_clock; >>>> + esdhc_pltfm_set_clock(host, 0); >>> >>> I guess want the clock to stay on "if sdhci_sdio_irq_enabled(host)". >>> So you should probably move the above inside the below if statement. >>> >> >> Well I'm not quite sure about it. Some wifi chipset has the wakeup >> interrupt on external gpio >> and someone wakeup from DAT1. Why clock should be required? > > The clock should not be needed when using external GPIO (also > described as an out-band IRQ/wakeup), but from DAT1. > Ok, I will re-post new patches > When sdhci_sdio_irq_enabled() returns true, that *should* indicate > that DAT1 is used. Although, there may be reasons to re-visit this > later, because the hole SDIO irq thing around wakeups for sdhci, is > being reworked by Adrian [1]. I will take a look on this post Regards Michael > >> >> Anyway I should even rebalance resume. > > Yes. > > [...] > > Kind regards > Uffe > > [1] > https://www.spinics.net/lists/linux-mmc/msg47512.html ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mmc: sdhci-esdhc-imx: Enable/Disable mmc clock during runtime suspend 2018-01-03 16:58 ` Michael Nazzareno Trimarchi @ 2018-01-03 17:26 ` Michael Nazzareno Trimarchi 0 siblings, 0 replies; 7+ messages in thread From: Michael Nazzareno Trimarchi @ 2018-01-03 17:26 UTC (permalink / raw) To: Ulf Hansson; +Cc: Adrian Hunter, linux-mmc@vger.kernel.org Hi Ulf I have still a small question because I'm changing this driver: We have in sdhci_pxav3_runtime_suspend ret = sdhci_runtime_suspend_host(host); if (ret) return ret; clk_disable_unprepare(pxa->clk_io); if (!IS_ERR(pxa->clk_core)) clk_disable_unprepare(pxa->clk_core); and in the other driver like this one ret = sdhci_runtime_suspend_host(host); if (!sdhci_sdio_irq_enabled(host)) { imx_data->actual_clock = host->mmc->actual_clock; esdhc_pltfm_set_clock(host, 0); clk_disable_unprepare(imx_data->clk_per); clk_disable_unprepare(imx_data->clk_ipg); } clk_disable_unprepare(imx_data->clk_ahb); Now to be more funny we have int sdhci_runtime_suspend_host(struct sdhci_host *host) { unsigned long flags; mmc_retune_timer_stop(host->mmc); if (host->tuning_mode != SDHCI_TUNING_MODE_3) mmc_retune_needed(host->mmc); spin_lock_irqsave(&host->lock, flags); host->ier &= SDHCI_INT_CARD_INT; sdhci_writel(host, host->ier, SDHCI_INT_ENABLE); sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE); spin_unlock_irqrestore(&host->lock, flags); synchronize_hardirq(host->irq); spin_lock_irqsave(&host->lock, flags); host->runtime_suspended = true; spin_unlock_irqrestore(&host->lock, flags); return 0; } Anyway. What we need to do with the clock in general if we have a fail before? Michael On Wed, Jan 3, 2018 at 5:58 PM, Michael Nazzareno Trimarchi <michael@amarulasolutions.com> wrote: > Hi > > On Wed, Jan 3, 2018 at 5:56 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote: >> On 3 January 2018 at 17:38, Michael Nazzareno Trimarchi >> <michael@amarulasolutions.com> wrote: >>> Hi >>> >>> On Wed, Jan 3, 2018 at 5:26 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote: >>>> On 21 December 2017 at 14:22, Michael Trimarchi >>>> <michael@amarulasolutions.com> wrote: >>>>> mmc clock can be stopped during runtime suspend and restart during runtime >>>>> resume. This let us know to not have any clock running and this reduce >>>>> the EMI of the device when the bus is not in use >>>>> >>>>> Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com> >>>>> --- >>>>> drivers/mmc/host/sdhci-esdhc-imx.c | 5 +++++ >>>>> 1 file changed, 5 insertions(+) >>>>> >>>>> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c >>>>> index 7123ef9..9a5e96f 100644 >>>>> --- a/drivers/mmc/host/sdhci-esdhc-imx.c >>>>> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c >>>>> @@ -196,6 +196,7 @@ struct pltfm_imx_data { >>>>> struct clk *clk_ipg; >>>>> struct clk *clk_ahb; >>>>> struct clk *clk_per; >>>>> + unsigned int actual_clock; >>>>> enum { >>>>> NO_CMD_PENDING, /* no multiblock command pending*/ >>>>> MULTIBLK_IN_PROCESS, /* exact multiblock cmd in process */ >>>>> @@ -1346,6 +1347,9 @@ static int sdhci_esdhc_runtime_suspend(struct device *dev) >>>>> >>>>> ret = sdhci_runtime_suspend_host(host); >>>>> >>>>> + imx_data->actual_clock = host->mmc->actual_clock; >>>>> + esdhc_pltfm_set_clock(host, 0); >>>> >>>> I guess want the clock to stay on "if sdhci_sdio_irq_enabled(host)". >>>> So you should probably move the above inside the below if statement. >>>> >>> >>> Well I'm not quite sure about it. Some wifi chipset has the wakeup >>> interrupt on external gpio >>> and someone wakeup from DAT1. Why clock should be required? >> >> The clock should not be needed when using external GPIO (also >> described as an out-band IRQ/wakeup), but from DAT1. >> > > Ok, I will re-post new patches > >> When sdhci_sdio_irq_enabled() returns true, that *should* indicate >> that DAT1 is used. Although, there may be reasons to re-visit this >> later, because the hole SDIO irq thing around wakeups for sdhci, is >> being reworked by Adrian [1]. > > I will take a look on this post > > Regards > > Michael > >> >>> >>> Anyway I should even rebalance resume. >> >> Yes. >> >> [...] >> >> Kind regards >> Uffe >> >> [1] >> https://www.spinics.net/lists/linux-mmc/msg47512.html -- | Michael Nazzareno Trimarchi Amarula Solutions BV | | COO - Founder Cruquiuskade 47 | | +31(0)851119172 Amsterdam 1018 AM NL | | [`as] http://www.amarulasolutions.com | ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-01-03 17:26 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-12-21 13:22 [PATCH] mmc: sdhci-esdhc-imx: Enable/Disable mmc clock during runtime suspend Michael Trimarchi 2017-12-21 14:43 ` Michael Nazzareno Trimarchi 2018-01-03 16:26 ` Ulf Hansson 2018-01-03 16:38 ` Michael Nazzareno Trimarchi 2018-01-03 16:56 ` Ulf Hansson 2018-01-03 16:58 ` Michael Nazzareno Trimarchi 2018-01-03 17:26 ` Michael Nazzareno Trimarchi
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox