All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] mmc: tmio: Further fixup runtime PM management at remove
@ 2020-05-15 14:04 Ulf Hansson
  2020-05-15 15:02 ` Ulf Hansson
  2020-05-19 13:56 ` Wolfram Sang
  0 siblings, 2 replies; 12+ messages in thread
From: Ulf Hansson @ 2020-05-15 14:04 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson, Masahiro Yamada, Wolfram Sang
  Cc: Ulrich Hecht, Simon Horman, Niklas Soderlund, Geert Uytterhoeven

Before calling tmio_mmc_host_probe(), the caller is required to enable
clocks for its device, as to make it accessible when reading/writing
registers during probe.

Therefore, the responsibility to disable these clocks, in the error path of
->probe() and during ->remove(), is better managed outside
tmio_mmc_host_remove(). As a matter of fact, callers of
tmio_mmc_host_remove() already expects this to be the behaviour.

However, there's a problem with tmio_mmc_host_remove() when the Kconfig
option, CONFIG_PM, is set. More precisely, tmio_mmc_host_remove() may then
disable the clock via runtime PM, which leads to clock enable/disable
imbalance problems, when the caller of tmio_mmc_host_remove() also tries to
disable the same clocks.

Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/mmc/host/tmio_mmc_core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
index f31afd1c2671..ba301fb7656b 100644
--- a/drivers/mmc/host/tmio_mmc_core.c
+++ b/drivers/mmc/host/tmio_mmc_core.c
@@ -1231,12 +1231,14 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host)
 	cancel_work_sync(&host->done);
 	cancel_delayed_work_sync(&host->delayed_reset_work);
 	tmio_mmc_release_dma(host);
+	tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL);
 
-	pm_runtime_dont_use_autosuspend(&pdev->dev);
 	if (host->native_hotplug)
 		pm_runtime_put_noidle(&pdev->dev);
-	pm_runtime_put_sync(&pdev->dev);
+
 	pm_runtime_disable(&pdev->dev);
+	pm_runtime_dont_use_autosuspend(&pdev->dev);
+	pm_runtime_put_noidle(&pdev->dev);
 }
 EXPORT_SYMBOL_GPL(tmio_mmc_host_remove);
 
-- 
2.20.1


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

* Re: [PATCH 1/2] mmc: tmio: Further fixup runtime PM management at remove
  2020-05-15 14:04 [PATCH 1/2] mmc: tmio: Further fixup runtime PM management at remove Ulf Hansson
@ 2020-05-15 15:02 ` Ulf Hansson
  2020-05-18 20:02   ` Wolfram Sang
  2020-05-19 13:56 ` Wolfram Sang
  1 sibling, 1 reply; 12+ messages in thread
From: Ulf Hansson @ 2020-05-15 15:02 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson, Masahiro Yamada, Wolfram Sang
  Cc: Ulrich Hecht, Simon Horman, Niklas Soderlund, Geert Uytterhoeven

On Fri, 15 May 2020 at 16:04, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
> Before calling tmio_mmc_host_probe(), the caller is required to enable
> clocks for its device, as to make it accessible when reading/writing
> registers during probe.
>
> Therefore, the responsibility to disable these clocks, in the error path of
> ->probe() and during ->remove(), is better managed outside
> tmio_mmc_host_remove(). As a matter of fact, callers of
> tmio_mmc_host_remove() already expects this to be the behaviour.
>
> However, there's a problem with tmio_mmc_host_remove() when the Kconfig
> option, CONFIG_PM, is set. More precisely, tmio_mmc_host_remove() may then
> disable the clock via runtime PM, which leads to clock enable/disable
> imbalance problems, when the caller of tmio_mmc_host_remove() also tries to
> disable the same clocks.

Just realized that part of the commit message is missing, explaining
the change. I intend to add this:

To solve the problem, let's make sure tmio_mmc_host_remove() leaves
the device with clocks enabled, but also make sure to disable the
IRQs, as we normally do at ->runtime_suspend().

Also, this is untested, so relying on you guys with the HW at hand.

Kind regards
Uffe

>
> Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> ---
>  drivers/mmc/host/tmio_mmc_core.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
> index f31afd1c2671..ba301fb7656b 100644
> --- a/drivers/mmc/host/tmio_mmc_core.c
> +++ b/drivers/mmc/host/tmio_mmc_core.c
> @@ -1231,12 +1231,14 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host)
>         cancel_work_sync(&host->done);
>         cancel_delayed_work_sync(&host->delayed_reset_work);
>         tmio_mmc_release_dma(host);
> +       tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL);
>
> -       pm_runtime_dont_use_autosuspend(&pdev->dev);
>         if (host->native_hotplug)
>                 pm_runtime_put_noidle(&pdev->dev);
> -       pm_runtime_put_sync(&pdev->dev);
> +
>         pm_runtime_disable(&pdev->dev);
> +       pm_runtime_dont_use_autosuspend(&pdev->dev);
> +       pm_runtime_put_noidle(&pdev->dev);
>  }
>  EXPORT_SYMBOL_GPL(tmio_mmc_host_remove);
>
> --
> 2.20.1
>

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

* Re: [PATCH 1/2] mmc: tmio: Further fixup runtime PM management at remove
  2020-05-15 15:02 ` Ulf Hansson
@ 2020-05-18 20:02   ` Wolfram Sang
  0 siblings, 0 replies; 12+ messages in thread
From: Wolfram Sang @ 2020-05-18 20:02 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Masahiro Yamada, Ulrich Hecht, Simon Horman,
	Niklas Soderlund, Geert Uytterhoeven

[-- Attachment #1: Type: text/plain, Size: 1591 bytes --]

On Fri, May 15, 2020 at 05:02:08PM +0200, Ulf Hansson wrote:
> On Fri, 15 May 2020 at 16:04, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> >
> > Before calling tmio_mmc_host_probe(), the caller is required to enable
> > clocks for its device, as to make it accessible when reading/writing
> > registers during probe.
> >
> > Therefore, the responsibility to disable these clocks, in the error path of
> > ->probe() and during ->remove(), is better managed outside
> > tmio_mmc_host_remove(). As a matter of fact, callers of
> > tmio_mmc_host_remove() already expects this to be the behaviour.
> >
> > However, there's a problem with tmio_mmc_host_remove() when the Kconfig
> > option, CONFIG_PM, is set. More precisely, tmio_mmc_host_remove() may then
> > disable the clock via runtime PM, which leads to clock enable/disable
> > imbalance problems, when the caller of tmio_mmc_host_remove() also tries to
> > disable the same clocks.
> 
> Just realized that part of the commit message is missing, explaining
> the change. I intend to add this:
> 
> To solve the problem, let's make sure tmio_mmc_host_remove() leaves
> the device with clocks enabled, but also make sure to disable the
> IRQs, as we normally do at ->runtime_suspend().

Yeah, this paragraph is definately needed.

> Also, this is untested, so relying on you guys with the HW at hand.

I tested this on Gen3 M3-N (works fine!) and will next check your other
patch. If this is okay, too, I will check them on Gen2 tomorrow before I
give my Tested-by.

Ulf, thanks for working on this, too!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 1/2] mmc: tmio: Further fixup runtime PM management at remove
  2020-05-15 14:04 [PATCH 1/2] mmc: tmio: Further fixup runtime PM management at remove Ulf Hansson
  2020-05-15 15:02 ` Ulf Hansson
@ 2020-05-19 13:56 ` Wolfram Sang
  1 sibling, 0 replies; 12+ messages in thread
From: Wolfram Sang @ 2020-05-19 13:56 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Masahiro Yamada, Ulrich Hecht, Simon Horman,
	Niklas Soderlund, Geert Uytterhoeven

[-- Attachment #1: Type: text/plain, Size: 1208 bytes --]

On Fri, May 15, 2020 at 04:04:45PM +0200, Ulf Hansson wrote:
> Before calling tmio_mmc_host_probe(), the caller is required to enable
> clocks for its device, as to make it accessible when reading/writing
> registers during probe.
> 
> Therefore, the responsibility to disable these clocks, in the error path of
> ->probe() and during ->remove(), is better managed outside
> tmio_mmc_host_remove(). As a matter of fact, callers of
> tmio_mmc_host_remove() already expects this to be the behaviour.
> 
> However, there's a problem with tmio_mmc_host_remove() when the Kconfig
> option, CONFIG_PM, is set. More precisely, tmio_mmc_host_remove() may then
> disable the clock via runtime PM, which leads to clock enable/disable
> imbalance problems, when the caller of tmio_mmc_host_remove() also tries to
> disable the same clocks.
> 
> Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

Works fine on my Lager board, too. Imbalance is gone when rebinding, and
I can access large files on the SD card.

Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 1/2] mmc: tmio: Further fixup runtime PM management at remove
  2020-05-20 19:29       ` Geert Uytterhoeven
@ 2020-05-20 20:32         ` Wolfram Sang
  0 siblings, 0 replies; 12+ messages in thread
From: Wolfram Sang @ 2020-05-20 20:32 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Ulf Hansson, Linux MMC List, Masahiro Yamada, Ulrich Hecht,
	Simon Horman, Niklas Soderlund

[-- Attachment #1: Type: text/plain, Size: 540 bytes --]


> Commit 9b0d6855e756b60d ("mmc: renesas_sdhi: enforce manual correction
> for Gen3") fixed it.  However, there must be other later changes that
> have impact, as reverting 9b0d6855e756b60d and reapplying 7a7dab237027
> on both mmc/next~3 and mmc/next gives a working system.
> 
> Let's call it a day, no more bisecting today...

Thanks for the work, Geert!

This non-deterministic outcome already convinces me that we should
really first try to reproduce and fix the stalled SCC case before we
remove the workaround again.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 1/2] mmc: tmio: Further fixup runtime PM management at remove
  2020-05-20 18:19     ` Geert Uytterhoeven
@ 2020-05-20 19:29       ` Geert Uytterhoeven
  2020-05-20 20:32         ` Wolfram Sang
  0 siblings, 1 reply; 12+ messages in thread
From: Geert Uytterhoeven @ 2020-05-20 19:29 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Ulf Hansson, Linux MMC List, Masahiro Yamada, Ulrich Hecht,
	Simon Horman, Niklas Soderlund

Hi Wolfram,

On Wed, May 20, 2020 at 8:19 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> On Wed, May 20, 2020 at 5:49 PM Wolfram Sang
> <wsa+renesas@sang-engineering.com> wrote:
> > On Wed, May 20, 2020 at 04:30:33PM +0200, Geert Uytterhoeven wrote:
> > > On Tue, May 19, 2020 at 5:24 PM Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > > > Before calling tmio_mmc_host_probe(), the caller is required to enable
> > > > clocks for its device, as to make it accessible when reading/writing
> > > > registers during probe.
> > > >
> > > > Therefore, the responsibility to disable these clocks, in the error path of
> > > > ->probe() and during ->remove(), is better managed outside
> > > > tmio_mmc_host_remove(). As a matter of fact, callers of
> > > > tmio_mmc_host_remove() already expects this to be the behaviour.
> > > >
> > > > However, there's a problem with tmio_mmc_host_remove() when the Kconfig
> > > > option, CONFIG_PM, is set. More precisely, tmio_mmc_host_remove() may then
> > > > disable the clock via runtime PM, which leads to clock enable/disable
> > > > imbalance problems, when the caller of tmio_mmc_host_remove() also tries to
> > > > disable the same clocks.
> > > >
> > > > To solve the problem, let's make sure tmio_mmc_host_remove() leaves the
> > > > device with clocks enabled, but also make sure to disable the IRQs, as we
> > > > normally do at ->runtime_suspend().
> > > >
> > > > Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > > > Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> > > > Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> > > > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> > >
> > > Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > >
> > > (on R-Car Gen2, various Gen3, SH-Mobile AG5, R-Mobile A1, R-Mobile APE6,
> > >  RZ/A1, and RZ/A2)
> >
> > Thanks, Geert! If it is not too much to ask, could you try re-applying
> > commit 7a7dab237027 ("mmc: tmio: remove workaround for NON_REMOVABLE")
> > on top of all these patches and see if your NFS is still stalled?
> >
> > Sidenote: we still need to tackle the problem when SCC hangs because it
> > has no clock. However, I am still interested if all the PM updates have
> > an impact in the beaviour you observed here[1].
> >
> > [1] https://patchwork.kernel.org/patch/11149285/
>
> I reverted "[PATCH] WIP: clk: renesas: rcar-gen3: enable SDnH clk for HS
> modes" (which I still had applied in my local tree), and reapplied "mmc:
> tmio: remove workaround for NON_REMOVABLE", but I cannot reproduce the
> issue, with or without the top 3 commits on mmc/next:
> ff5a1a63febb0761 mmc: tmio: Further fixup runtime PM management at remove
> 774c44ceff3c5b3f mmc: tmio: Make sure the PM domain is 'started' while probing
> 4863bb62a87786ec mmc: renesas_sdhi: remove manual clk handling
>
> Let's see if I can bisect where it was fixed...

Commit 9b0d6855e756b60d ("mmc: renesas_sdhi: enforce manual correction
for Gen3") fixed it.  However, there must be other later changes that
have impact, as reverting 9b0d6855e756b60d and reapplying 7a7dab237027
on both mmc/next~3 and mmc/next gives a working system.

Let's call it a day, no more bisecting today...

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] 12+ messages in thread

* Re: [PATCH 1/2] mmc: tmio: Further fixup runtime PM management at remove
  2020-05-20 15:49   ` Wolfram Sang
@ 2020-05-20 18:19     ` Geert Uytterhoeven
  2020-05-20 19:29       ` Geert Uytterhoeven
  0 siblings, 1 reply; 12+ messages in thread
From: Geert Uytterhoeven @ 2020-05-20 18:19 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Ulf Hansson, Linux MMC List, Masahiro Yamada, Ulrich Hecht,
	Simon Horman, Niklas Soderlund

Hi Wolfram,

On Wed, May 20, 2020 at 5:49 PM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> On Wed, May 20, 2020 at 04:30:33PM +0200, Geert Uytterhoeven wrote:
> > On Tue, May 19, 2020 at 5:24 PM Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > > Before calling tmio_mmc_host_probe(), the caller is required to enable
> > > clocks for its device, as to make it accessible when reading/writing
> > > registers during probe.
> > >
> > > Therefore, the responsibility to disable these clocks, in the error path of
> > > ->probe() and during ->remove(), is better managed outside
> > > tmio_mmc_host_remove(). As a matter of fact, callers of
> > > tmio_mmc_host_remove() already expects this to be the behaviour.
> > >
> > > However, there's a problem with tmio_mmc_host_remove() when the Kconfig
> > > option, CONFIG_PM, is set. More precisely, tmio_mmc_host_remove() may then
> > > disable the clock via runtime PM, which leads to clock enable/disable
> > > imbalance problems, when the caller of tmio_mmc_host_remove() also tries to
> > > disable the same clocks.
> > >
> > > To solve the problem, let's make sure tmio_mmc_host_remove() leaves the
> > > device with clocks enabled, but also make sure to disable the IRQs, as we
> > > normally do at ->runtime_suspend().
> > >
> > > Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > > Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> > > Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> > > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> >
> > Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
> >
> > (on R-Car Gen2, various Gen3, SH-Mobile AG5, R-Mobile A1, R-Mobile APE6,
> >  RZ/A1, and RZ/A2)
>
> Thanks, Geert! If it is not too much to ask, could you try re-applying
> commit 7a7dab237027 ("mmc: tmio: remove workaround for NON_REMOVABLE")
> on top of all these patches and see if your NFS is still stalled?
>
> Sidenote: we still need to tackle the problem when SCC hangs because it
> has no clock. However, I am still interested if all the PM updates have
> an impact in the beaviour you observed here[1].
>
> [1] https://patchwork.kernel.org/patch/11149285/

I reverted "[PATCH] WIP: clk: renesas: rcar-gen3: enable SDnH clk for HS
modes" (which I still had applied in my local tree), and reapplied "mmc:
tmio: remove workaround for NON_REMOVABLE", but I cannot reproduce the
issue, with or without the top 3 commits on mmc/next:
ff5a1a63febb0761 mmc: tmio: Further fixup runtime PM management at remove
774c44ceff3c5b3f mmc: tmio: Make sure the PM domain is 'started' while probing
4863bb62a87786ec mmc: renesas_sdhi: remove manual clk handling

Let's see if I can bisect where it was fixed...

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] 12+ messages in thread

* Re: [PATCH 1/2] mmc: tmio: Further fixup runtime PM management at remove
  2020-05-20 14:30 ` Geert Uytterhoeven
  2020-05-20 15:18   ` Ulf Hansson
@ 2020-05-20 15:49   ` Wolfram Sang
  2020-05-20 18:19     ` Geert Uytterhoeven
  1 sibling, 1 reply; 12+ messages in thread
From: Wolfram Sang @ 2020-05-20 15:49 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Ulf Hansson, Linux MMC List, Masahiro Yamada, Ulrich Hecht,
	Simon Horman, Niklas Soderlund

[-- Attachment #1: Type: text/plain, Size: 2057 bytes --]

On Wed, May 20, 2020 at 04:30:33PM +0200, Geert Uytterhoeven wrote:
> Hi Ulf,
> 
> On Tue, May 19, 2020 at 5:24 PM Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > Before calling tmio_mmc_host_probe(), the caller is required to enable
> > clocks for its device, as to make it accessible when reading/writing
> > registers during probe.
> >
> > Therefore, the responsibility to disable these clocks, in the error path of
> > ->probe() and during ->remove(), is better managed outside
> > tmio_mmc_host_remove(). As a matter of fact, callers of
> > tmio_mmc_host_remove() already expects this to be the behaviour.
> >
> > However, there's a problem with tmio_mmc_host_remove() when the Kconfig
> > option, CONFIG_PM, is set. More precisely, tmio_mmc_host_remove() may then
> > disable the clock via runtime PM, which leads to clock enable/disable
> > imbalance problems, when the caller of tmio_mmc_host_remove() also tries to
> > disable the same clocks.
> >
> > To solve the problem, let's make sure tmio_mmc_host_remove() leaves the
> > device with clocks enabled, but also make sure to disable the IRQs, as we
> > normally do at ->runtime_suspend().
> >
> > Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> > Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> 
> Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
> 
> (on R-Car Gen2, various Gen3, SH-Mobile AG5, R-Mobile A1, R-Mobile APE6,
>  RZ/A1, and RZ/A2)

Thanks, Geert! If it is not too much to ask, could you try re-applying
commit 7a7dab237027 ("mmc: tmio: remove workaround for NON_REMOVABLE")
on top of all these patches and see if your NFS is still stalled?

Sidenote: we still need to tackle the problem when SCC hangs because it
has no clock. However, I am still interested if all the PM updates have
an impact in the beaviour you observed here[1].

[1] https://patchwork.kernel.org/patch/11149285/


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 1/2] mmc: tmio: Further fixup runtime PM management at remove
  2020-05-20 14:30 ` Geert Uytterhoeven
@ 2020-05-20 15:18   ` Ulf Hansson
  2020-05-20 15:49   ` Wolfram Sang
  1 sibling, 0 replies; 12+ messages in thread
From: Ulf Hansson @ 2020-05-20 15:18 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Linux MMC List, Masahiro Yamada, Wolfram Sang, Ulrich Hecht,
	Simon Horman, Niklas Soderlund

On Wed, 20 May 2020 at 16:30, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> Hi Ulf,
>
> On Tue, May 19, 2020 at 5:24 PM Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > Before calling tmio_mmc_host_probe(), the caller is required to enable
> > clocks for its device, as to make it accessible when reading/writing
> > registers during probe.
> >
> > Therefore, the responsibility to disable these clocks, in the error path of
> > ->probe() and during ->remove(), is better managed outside
> > tmio_mmc_host_remove(). As a matter of fact, callers of
> > tmio_mmc_host_remove() already expects this to be the behaviour.
> >
> > However, there's a problem with tmio_mmc_host_remove() when the Kconfig
> > option, CONFIG_PM, is set. More precisely, tmio_mmc_host_remove() may then
> > disable the clock via runtime PM, which leads to clock enable/disable
> > imbalance problems, when the caller of tmio_mmc_host_remove() also tries to
> > disable the same clocks.
> >
> > To solve the problem, let's make sure tmio_mmc_host_remove() leaves the
> > device with clocks enabled, but also make sure to disable the IRQs, as we
> > normally do at ->runtime_suspend().
> >
> > Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> > Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
>
> Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> (on R-Car Gen2, various Gen3, SH-Mobile AG5, R-Mobile A1, R-Mobile APE6,
>  RZ/A1, and RZ/A2)
>
> Gr{oetje,eeting}s,
>
>                         Geert

Thanks, patch amended!

Kind regards
Uffe

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

* Re: [PATCH 1/2] mmc: tmio: Further fixup runtime PM management at remove
  2020-05-19 15:24 Ulf Hansson
  2020-05-20 11:35 ` Ulf Hansson
@ 2020-05-20 14:30 ` Geert Uytterhoeven
  2020-05-20 15:18   ` Ulf Hansson
  2020-05-20 15:49   ` Wolfram Sang
  1 sibling, 2 replies; 12+ messages in thread
From: Geert Uytterhoeven @ 2020-05-20 14:30 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Linux MMC List, Masahiro Yamada, Wolfram Sang, Ulrich Hecht,
	Simon Horman, Niklas Soderlund

Hi Ulf,

On Tue, May 19, 2020 at 5:24 PM Ulf Hansson <ulf.hansson@linaro.org> wrote:
> Before calling tmio_mmc_host_probe(), the caller is required to enable
> clocks for its device, as to make it accessible when reading/writing
> registers during probe.
>
> Therefore, the responsibility to disable these clocks, in the error path of
> ->probe() and during ->remove(), is better managed outside
> tmio_mmc_host_remove(). As a matter of fact, callers of
> tmio_mmc_host_remove() already expects this to be the behaviour.
>
> However, there's a problem with tmio_mmc_host_remove() when the Kconfig
> option, CONFIG_PM, is set. More precisely, tmio_mmc_host_remove() may then
> disable the clock via runtime PM, which leads to clock enable/disable
> imbalance problems, when the caller of tmio_mmc_host_remove() also tries to
> disable the same clocks.
>
> To solve the problem, let's make sure tmio_mmc_host_remove() leaves the
> device with clocks enabled, but also make sure to disable the IRQs, as we
> normally do at ->runtime_suspend().
>
> Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>

(on R-Car Gen2, various Gen3, SH-Mobile AG5, R-Mobile A1, R-Mobile APE6,
 RZ/A1, and RZ/A2)

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] 12+ messages in thread

* Re: [PATCH 1/2] mmc: tmio: Further fixup runtime PM management at remove
  2020-05-19 15:24 Ulf Hansson
@ 2020-05-20 11:35 ` Ulf Hansson
  2020-05-20 14:30 ` Geert Uytterhoeven
  1 sibling, 0 replies; 12+ messages in thread
From: Ulf Hansson @ 2020-05-20 11:35 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson, Masahiro Yamada, Wolfram Sang,
	Geert Uytterhoeven
  Cc: Ulrich Hecht, Simon Horman, Niklas Soderlund, Geert Uytterhoeven

On Tue, 19 May 2020 at 17:24, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
> Before calling tmio_mmc_host_probe(), the caller is required to enable
> clocks for its device, as to make it accessible when reading/writing
> registers during probe.
>
> Therefore, the responsibility to disable these clocks, in the error path of
> ->probe() and during ->remove(), is better managed outside
> tmio_mmc_host_remove(). As a matter of fact, callers of
> tmio_mmc_host_remove() already expects this to be the behaviour.
>
> However, there's a problem with tmio_mmc_host_remove() when the Kconfig
> option, CONFIG_PM, is set. More precisely, tmio_mmc_host_remove() may then
> disable the clock via runtime PM, which leads to clock enable/disable
> imbalance problems, when the caller of tmio_mmc_host_remove() also tries to
> disable the same clocks.
>
> To solve the problem, let's make sure tmio_mmc_host_remove() leaves the
> device with clocks enabled, but also make sure to disable the IRQs, as we
> normally do at ->runtime_suspend().
>
> Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

Applied for next and by adding a stable tag.

Kind regards
Uffe


> ---
>  drivers/mmc/host/tmio_mmc_core.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
> index f31afd1c2671..ba301fb7656b 100644
> --- a/drivers/mmc/host/tmio_mmc_core.c
> +++ b/drivers/mmc/host/tmio_mmc_core.c
> @@ -1231,12 +1231,14 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host)
>         cancel_work_sync(&host->done);
>         cancel_delayed_work_sync(&host->delayed_reset_work);
>         tmio_mmc_release_dma(host);
> +       tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL);
>
> -       pm_runtime_dont_use_autosuspend(&pdev->dev);
>         if (host->native_hotplug)
>                 pm_runtime_put_noidle(&pdev->dev);
> -       pm_runtime_put_sync(&pdev->dev);
> +
>         pm_runtime_disable(&pdev->dev);
> +       pm_runtime_dont_use_autosuspend(&pdev->dev);
> +       pm_runtime_put_noidle(&pdev->dev);
>  }
>  EXPORT_SYMBOL_GPL(tmio_mmc_host_remove);
>
> --
> 2.20.1
>

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

* [PATCH 1/2] mmc: tmio: Further fixup runtime PM management at remove
@ 2020-05-19 15:24 Ulf Hansson
  2020-05-20 11:35 ` Ulf Hansson
  2020-05-20 14:30 ` Geert Uytterhoeven
  0 siblings, 2 replies; 12+ messages in thread
From: Ulf Hansson @ 2020-05-19 15:24 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson, Masahiro Yamada, Wolfram Sang,
	Geert Uytterhoeven
  Cc: Ulrich Hecht, Simon Horman, Niklas Soderlund, Geert Uytterhoeven

Before calling tmio_mmc_host_probe(), the caller is required to enable
clocks for its device, as to make it accessible when reading/writing
registers during probe.

Therefore, the responsibility to disable these clocks, in the error path of
->probe() and during ->remove(), is better managed outside
tmio_mmc_host_remove(). As a matter of fact, callers of
tmio_mmc_host_remove() already expects this to be the behaviour.

However, there's a problem with tmio_mmc_host_remove() when the Kconfig
option, CONFIG_PM, is set. More precisely, tmio_mmc_host_remove() may then
disable the clock via runtime PM, which leads to clock enable/disable
imbalance problems, when the caller of tmio_mmc_host_remove() also tries to
disable the same clocks.

To solve the problem, let's make sure tmio_mmc_host_remove() leaves the
device with clocks enabled, but also make sure to disable the IRQs, as we
normally do at ->runtime_suspend().

Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/mmc/host/tmio_mmc_core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
index f31afd1c2671..ba301fb7656b 100644
--- a/drivers/mmc/host/tmio_mmc_core.c
+++ b/drivers/mmc/host/tmio_mmc_core.c
@@ -1231,12 +1231,14 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host)
 	cancel_work_sync(&host->done);
 	cancel_delayed_work_sync(&host->delayed_reset_work);
 	tmio_mmc_release_dma(host);
+	tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL);
 
-	pm_runtime_dont_use_autosuspend(&pdev->dev);
 	if (host->native_hotplug)
 		pm_runtime_put_noidle(&pdev->dev);
-	pm_runtime_put_sync(&pdev->dev);
+
 	pm_runtime_disable(&pdev->dev);
+	pm_runtime_dont_use_autosuspend(&pdev->dev);
+	pm_runtime_put_noidle(&pdev->dev);
 }
 EXPORT_SYMBOL_GPL(tmio_mmc_host_remove);
 
-- 
2.20.1


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

end of thread, other threads:[~2020-05-20 20:32 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-15 14:04 [PATCH 1/2] mmc: tmio: Further fixup runtime PM management at remove Ulf Hansson
2020-05-15 15:02 ` Ulf Hansson
2020-05-18 20:02   ` Wolfram Sang
2020-05-19 13:56 ` Wolfram Sang
2020-05-19 15:24 Ulf Hansson
2020-05-20 11:35 ` Ulf Hansson
2020-05-20 14:30 ` Geert Uytterhoeven
2020-05-20 15:18   ` Ulf Hansson
2020-05-20 15:49   ` Wolfram Sang
2020-05-20 18:19     ` Geert Uytterhoeven
2020-05-20 19:29       ` Geert Uytterhoeven
2020-05-20 20:32         ` Wolfram Sang

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.