* [PATCH] mmc: tmio: Fix hang during suspend @ 2014-08-14 15:23 Geert Uytterhoeven 2014-08-15 12:49 ` Ian Molton 2014-08-15 14:42 ` Ulf Hansson 0 siblings, 2 replies; 7+ messages in thread From: Geert Uytterhoeven @ 2014-08-14 15:23 UTC (permalink / raw) To: Ian Molton, Chris Ball, Ulf Hansson Cc: linux-mmc, linux-sh, linux-kernel, Geert Uytterhoeven On R-Car Gen 2, the SDHI registers cannot be accessed while the SDHI module clock is disabled. Doing so will cause a lock-up. When suspending, enable the module clock before disabling the SDHI interrupts, and disable the clock again afterwards. This fixes suspend and resume on r8a7791/koelsch. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> --- drivers/mmc/host/tmio_mmc_pio.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c index faf0924e71cb..83192420a7e3 100644 --- a/drivers/mmc/host/tmio_mmc_pio.c +++ b/drivers/mmc/host/tmio_mmc_pio.c @@ -1147,8 +1147,18 @@ int tmio_mmc_host_suspend(struct device *dev) { struct mmc_host *mmc = dev_get_drvdata(dev); struct tmio_mmc_host *host = mmc_priv(mmc); + struct tmio_mmc_data *pdata = host->pdata; + + if (pdata->clk_enable) { + unsigned int f; + pdata->clk_enable(host->pdev, &f); + } tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL); + + if (pdata->clk_disable) + pdata->clk_disable(host->pdev); + return 0; } EXPORT_SYMBOL(tmio_mmc_host_suspend); -- 1.9.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] mmc: tmio: Fix hang during suspend 2014-08-14 15:23 [PATCH] mmc: tmio: Fix hang during suspend Geert Uytterhoeven @ 2014-08-15 12:49 ` Ian Molton 2014-08-18 12:36 ` Geert Uytterhoeven 2014-08-15 14:42 ` Ulf Hansson 1 sibling, 1 reply; 7+ messages in thread From: Ian Molton @ 2014-08-15 12:49 UTC (permalink / raw) To: Geert Uytterhoeven Cc: Chris Ball, Ulf Hansson, linux-mmc, linux-sh, linux-kernel On Thu, 14 Aug 2014 17:23:53 +0200 Geert Uytterhoeven <geert+renesas@glider.be> wrote: > On R-Car Gen 2, the SDHI registers cannot be accessed while the SDHI > module clock is disabled. Doing so will cause a lock-up. > > When suspending, enable the module clock before disabling the SDHI > interrupts, and disable the clock again afterwards. This feels wrong. Why can't interrupts be disabled prior to turning the clock off? -Ian > This fixes suspend and resume on r8a7791/koelsch. > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> > --- > drivers/mmc/host/tmio_mmc_pio.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c > index faf0924e71cb..83192420a7e3 100644 > --- a/drivers/mmc/host/tmio_mmc_pio.c > +++ b/drivers/mmc/host/tmio_mmc_pio.c > @@ -1147,8 +1147,18 @@ int tmio_mmc_host_suspend(struct device *dev) > { > struct mmc_host *mmc = dev_get_drvdata(dev); > struct tmio_mmc_host *host = mmc_priv(mmc); > + struct tmio_mmc_data *pdata = host->pdata; > + > + if (pdata->clk_enable) { > + unsigned int f; > + pdata->clk_enable(host->pdev, &f); > + } > > tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL); > + > + if (pdata->clk_disable) > + pdata->clk_disable(host->pdev); > + > return 0; > } > EXPORT_SYMBOL(tmio_mmc_host_suspend); > -- > 1.9.1 > -- Ian Molton <ian.molton@codethink.co.uk> ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mmc: tmio: Fix hang during suspend 2014-08-15 12:49 ` Ian Molton @ 2014-08-18 12:36 ` Geert Uytterhoeven 2014-08-18 13:10 ` Ulf Hansson 0 siblings, 1 reply; 7+ messages in thread From: Geert Uytterhoeven @ 2014-08-18 12:36 UTC (permalink / raw) To: Ian Molton Cc: Geert Uytterhoeven, Chris Ball, Ulf Hansson, Linux MMC List, Linux-sh list, linux-kernel@vger.kernel.org Hi Ian, On Fri, Aug 15, 2014 at 2:49 PM, Ian Molton <ian.molton@codethink.co.uk> wrote: > On Thu, 14 Aug 2014 17:23:53 +0200 > Geert Uytterhoeven <geert+renesas@glider.be> wrote: > >> On R-Car Gen 2, the SDHI registers cannot be accessed while the SDHI >> module clock is disabled. Doing so will cause a lock-up. >> >> When suspending, enable the module clock before disabling the SDHI >> interrupts, and disable the clock again afterwards. > > This feels wrong. Why can't interrupts be disabled prior to turning the clock off? The clock is handled by runtime PM. So if SDHI becomes idle, the clock is turned off. However, the card insertion interrupt is still enabled. If all interrupts would be disabled when the clock is turned off, I believe card insertion can no longer be detected. BTW, I'm still wondering why tmio_mmc_host_resume() works without enabling the clock, as it calls tmio_mmc_enable_dma(), which also writes to an SDHI register (CTL_DMA_ENABLE). >> This fixes suspend and resume on r8a7791/koelsch. >> >> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> >> --- >> drivers/mmc/host/tmio_mmc_pio.c | 10 ++++++++++ >> 1 file changed, 10 insertions(+) >> >> diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c >> index faf0924e71cb..83192420a7e3 100644 >> --- a/drivers/mmc/host/tmio_mmc_pio.c >> +++ b/drivers/mmc/host/tmio_mmc_pio.c >> @@ -1147,8 +1147,18 @@ int tmio_mmc_host_suspend(struct device *dev) >> { >> struct mmc_host *mmc = dev_get_drvdata(dev); >> struct tmio_mmc_host *host = mmc_priv(mmc); >> + struct tmio_mmc_data *pdata = host->pdata; >> + >> + if (pdata->clk_enable) { >> + unsigned int f; >> + pdata->clk_enable(host->pdev, &f); >> + } >> >> tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL); >> + >> + if (pdata->clk_disable) >> + pdata->clk_disable(host->pdev); >> + >> return 0; >> } >> EXPORT_SYMBOL(tmio_mmc_host_suspend); >> -- >> 1.9.1 Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mmc: tmio: Fix hang during suspend 2014-08-18 12:36 ` Geert Uytterhoeven @ 2014-08-18 13:10 ` Ulf Hansson 2014-08-19 9:18 ` Geert Uytterhoeven 0 siblings, 1 reply; 7+ messages in thread From: Ulf Hansson @ 2014-08-18 13:10 UTC (permalink / raw) To: Geert Uytterhoeven, Ian Molton Cc: Geert Uytterhoeven, Chris Ball, Linux MMC List, Linux-sh list, linux-kernel@vger.kernel.org On 18 August 2014 14:36, Geert Uytterhoeven <geert@linux-m68k.org> wrote: > Hi Ian, > > On Fri, Aug 15, 2014 at 2:49 PM, Ian Molton <ian.molton@codethink.co.uk> wrote: >> On Thu, 14 Aug 2014 17:23:53 +0200 >> Geert Uytterhoeven <geert+renesas@glider.be> wrote: >> >>> On R-Car Gen 2, the SDHI registers cannot be accessed while the SDHI >>> module clock is disabled. Doing so will cause a lock-up. >>> >>> When suspending, enable the module clock before disabling the SDHI >>> interrupts, and disable the clock again afterwards. >> >> This feels wrong. Why can't interrupts be disabled prior to turning the clock off? > > The clock is handled by runtime PM. So if SDHI becomes idle, the clock > is turned off. > However, the card insertion interrupt is still enabled. > If all interrupts would be disabled when the clock is turned off, I believe card > insertion can no longer be detected. > > BTW, I'm still wondering why tmio_mmc_host_resume() works without > enabling the clock, as it calls tmio_mmc_enable_dma(), which also writes to > an SDHI register (CTL_DMA_ENABLE). A while ago, I tried to rework the runtime PM handling of tmio. http://www.spinics.net/lists/linux-mmc/msg23177.html The hole set never got merged, due to that we couldn't get them tested on hardware and there were a lack in review. We might want to pick them up to see if those may solve our problem. :-) Kind regards Uffe > >>> This fixes suspend and resume on r8a7791/koelsch. >>> >>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> >>> --- >>> drivers/mmc/host/tmio_mmc_pio.c | 10 ++++++++++ >>> 1 file changed, 10 insertions(+) >>> >>> diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c >>> index faf0924e71cb..83192420a7e3 100644 >>> --- a/drivers/mmc/host/tmio_mmc_pio.c >>> +++ b/drivers/mmc/host/tmio_mmc_pio.c >>> @@ -1147,8 +1147,18 @@ int tmio_mmc_host_suspend(struct device *dev) >>> { >>> struct mmc_host *mmc = dev_get_drvdata(dev); >>> struct tmio_mmc_host *host = mmc_priv(mmc); >>> + struct tmio_mmc_data *pdata = host->pdata; >>> + >>> + if (pdata->clk_enable) { >>> + unsigned int f; >>> + pdata->clk_enable(host->pdev, &f); >>> + } >>> >>> tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL); >>> + >>> + if (pdata->clk_disable) >>> + pdata->clk_disable(host->pdev); >>> + >>> return 0; >>> } >>> EXPORT_SYMBOL(tmio_mmc_host_suspend); >>> -- >>> 1.9.1 > > Gr{oetje,eeting}s, > > Geert > > -- > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org > > In personal conversations with technical people, I call myself a hacker. But > when I'm talking to journalists I just say "programmer" or something like that. > -- Linus Torvalds ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mmc: tmio: Fix hang during suspend 2014-08-18 13:10 ` Ulf Hansson @ 2014-08-19 9:18 ` Geert Uytterhoeven 0 siblings, 0 replies; 7+ messages in thread From: Geert Uytterhoeven @ 2014-08-19 9:18 UTC (permalink / raw) To: Ulf Hansson Cc: Ian Molton, Geert Uytterhoeven, Chris Ball, Linux MMC List, Linux-sh list, linux-kernel@vger.kernel.org Hi Ulf, On Mon, Aug 18, 2014 at 3:10 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote: > On 18 August 2014 14:36, Geert Uytterhoeven <geert@linux-m68k.org> wrote: >> On Fri, Aug 15, 2014 at 2:49 PM, Ian Molton <ian.molton@codethink.co.uk> wrote: >>> On Thu, 14 Aug 2014 17:23:53 +0200 >>> Geert Uytterhoeven <geert+renesas@glider.be> wrote: >>>> On R-Car Gen 2, the SDHI registers cannot be accessed while the SDHI >>>> module clock is disabled. Doing so will cause a lock-up. >>>> >>>> When suspending, enable the module clock before disabling the SDHI >>>> interrupts, and disable the clock again afterwards. >>> >>> This feels wrong. Why can't interrupts be disabled prior to turning the clock off? >> >> The clock is handled by runtime PM. So if SDHI becomes idle, the clock >> is turned off. >> However, the card insertion interrupt is still enabled. >> If all interrupts would be disabled when the clock is turned off, I believe card >> insertion can no longer be detected. >> >> BTW, I'm still wondering why tmio_mmc_host_resume() works without >> enabling the clock, as it calls tmio_mmc_enable_dma(), which also writes to >> an SDHI register (CTL_DMA_ENABLE). > > A while ago, I tried to rework the runtime PM handling of tmio. > > http://www.spinics.net/lists/linux-mmc/msg23177.html > > The hole set never got merged, due to that we couldn't get them tested > on hardware and there were a lack in review. > > We might want to pick them up to see if those may solve our problem. :-) Thanks, I applied patches 4-8 (1-3 did get merged), and tried them on SDHI1 of r8a7791/koelsch. It still seems to work as before. However, I still need my patch to fix suspend. Your "[PATCH 8/8] mmc: tmio: Handle clock gating from runtime PM functions" manages the SDHI interface clock, while my patch manages the platform-specific SDHI module clock. >>>> This fixes suspend and resume on r8a7791/koelsch. >>>> >>>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> >>>> --- >>>> drivers/mmc/host/tmio_mmc_pio.c | 10 ++++++++++ >>>> 1 file changed, 10 insertions(+) >>>> >>>> diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c >>>> index faf0924e71cb..83192420a7e3 100644 >>>> --- a/drivers/mmc/host/tmio_mmc_pio.c >>>> +++ b/drivers/mmc/host/tmio_mmc_pio.c >>>> @@ -1147,8 +1147,18 @@ int tmio_mmc_host_suspend(struct device *dev) >>>> { >>>> struct mmc_host *mmc = dev_get_drvdata(dev); >>>> struct tmio_mmc_host *host = mmc_priv(mmc); >>>> + struct tmio_mmc_data *pdata = host->pdata; >>>> + >>>> + if (pdata->clk_enable) { >>>> + unsigned int f; >>>> + pdata->clk_enable(host->pdev, &f); >>>> + } >>>> >>>> tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL); >>>> + >>>> + if (pdata->clk_disable) >>>> + pdata->clk_disable(host->pdev); >>>> + >>>> return 0; >>>> } >>>> EXPORT_SYMBOL(tmio_mmc_host_suspend); Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mmc: tmio: Fix hang during suspend 2014-08-14 15:23 [PATCH] mmc: tmio: Fix hang during suspend Geert Uytterhoeven 2014-08-15 12:49 ` Ian Molton @ 2014-08-15 14:42 ` Ulf Hansson 2014-08-15 15:10 ` Geert Uytterhoeven 1 sibling, 1 reply; 7+ messages in thread From: Ulf Hansson @ 2014-08-15 14:42 UTC (permalink / raw) To: Geert Uytterhoeven Cc: Ian Molton, Chris Ball, linux-mmc, Linux-sh list, linux-kernel@vger.kernel.org On 14 August 2014 17:23, Geert Uytterhoeven <geert+renesas@glider.be> wrote: > On R-Car Gen 2, the SDHI registers cannot be accessed while the SDHI > module clock is disabled. Doing so will cause a lock-up. > > When suspending, enable the module clock before disabling the SDHI > interrupts, and disable the clock again afterwards. > > This fixes suspend and resume on r8a7791/koelsch. Out of curiosity, are you using CONFIG_PM_RUNTIME to trigger this bug? Kind regards Uffe > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> > --- > drivers/mmc/host/tmio_mmc_pio.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c > index faf0924e71cb..83192420a7e3 100644 > --- a/drivers/mmc/host/tmio_mmc_pio.c > +++ b/drivers/mmc/host/tmio_mmc_pio.c > @@ -1147,8 +1147,18 @@ int tmio_mmc_host_suspend(struct device *dev) > { > struct mmc_host *mmc = dev_get_drvdata(dev); > struct tmio_mmc_host *host = mmc_priv(mmc); > + struct tmio_mmc_data *pdata = host->pdata; > + > + if (pdata->clk_enable) { > + unsigned int f; > + pdata->clk_enable(host->pdev, &f); > + } > > tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL); > + > + if (pdata->clk_disable) > + pdata->clk_disable(host->pdev); > + > return 0; > } > EXPORT_SYMBOL(tmio_mmc_host_suspend); > -- > 1.9.1 > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mmc: tmio: Fix hang during suspend 2014-08-15 14:42 ` Ulf Hansson @ 2014-08-15 15:10 ` Geert Uytterhoeven 0 siblings, 0 replies; 7+ messages in thread From: Geert Uytterhoeven @ 2014-08-15 15:10 UTC (permalink / raw) To: Ulf Hansson Cc: Geert Uytterhoeven, Ian Molton, Chris Ball, linux-mmc, Linux-sh list, linux-kernel@vger.kernel.org Hi Ulf, On Fri, Aug 15, 2014 at 4:42 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote: > On 14 August 2014 17:23, Geert Uytterhoeven <geert+renesas@glider.be> wrote: >> On R-Car Gen 2, the SDHI registers cannot be accessed while the SDHI >> module clock is disabled. Doing so will cause a lock-up. >> >> When suspending, enable the module clock before disabling the SDHI >> interrupts, and disable the clock again afterwards. >> >> This fixes suspend and resume on r8a7791/koelsch. > > Out of curiosity, are you using CONFIG_PM_RUNTIME to trigger this bug? Yes I am: $ grep CONFIG_PM .config CONFIG_PM_SLEEP=y CONFIG_PM_SLEEP_SMP=y # CONFIG_PM_AUTOSLEEP is not set # CONFIG_PM_WAKELOCKS is not set CONFIG_PM_RUNTIME=y CONFIG_PM=y CONFIG_PM_DEBUG=y CONFIG_PM_ADVANCED_DEBUG=y # CONFIG_PM_TEST_SUSPEND is not set CONFIG_PM_SLEEP_DEBUG=y CONFIG_PM_OPP=y CONFIG_PM_CLK=y # CONFIG_PMIC_ADP5520 is not set # CONFIG_PMIC_DA903X is not set # CONFIG_PM_DEVFREQ is not set $ Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-08-19 9:18 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-08-14 15:23 [PATCH] mmc: tmio: Fix hang during suspend Geert Uytterhoeven 2014-08-15 12:49 ` Ian Molton 2014-08-18 12:36 ` Geert Uytterhoeven 2014-08-18 13:10 ` Ulf Hansson 2014-08-19 9:18 ` Geert Uytterhoeven 2014-08-15 14:42 ` Ulf Hansson 2014-08-15 15:10 ` Geert Uytterhoeven
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).