mmc: tmio: remove Gen2+ workaround and fix up
Subsystems (2)
cover mmc: tmio: remove Gen2+ workaround and fix up
Hi!
The second patch in this series removes a workaround that forced eMMC devices always on and that is no longer required.
Removing it does expose a bug, however, that leads to a clock imbalance due to the clock being enabled by both PM and the hardware driver. (See
https://www.spinics.net/lists/linux-mmc/msg54009.html for discussion.) This bug is taken care of by the first patch.
Tested on r8a7790 (Lager), r8a7795 and r8a7796 (Salvator-X) with SD and eMMC, before and after suspend.
CU
Uli
Ulrich Hecht (2):
mmc: tmio: leave clock handling to PM if enabled
mmc: tmio: remove obsolete PM workaround
drivers/mmc/host/tmio_mmc_core.c | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/2 mmc: tmio: leave clock handling to PM if enabled
This fixes a clock imbalance that occurs because the SD clock is handled by both PM and the hardware driver.
See https://www.spinics.net/lists/linux-mmc/msg44431.html for details.
This patch removes the clock handling from the driver's PM callbacks and turns the clock off after probing.
--- drivers/mmc/host/tmio_mmc_core.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)
drivers/mmc/host/tmio_mmc_core.c +6 -18
@@ -1260,9 +1260,14 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host)/* See if we also get DMA */ tmio_mmc_request_dma (_host, pdata); -pm_runtime_set_active (&pdev->dev); +#ifdef CONFIG_PM +/* PM handles the clock; disable it so it won't be enabled twice. */ +if (_host->clk_disable) + _host->clk_disable (_host); +pm_runtime_get_sync (&pdev->dev);pm_runtime_set_autosuspend_delay (&pdev->dev,50 );pm_runtime_use_autosuspend (&pdev->dev); +#endif ret =mmc_add_host (mmc);if (ret)
@@ -1302,20 +1307,6 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host)EXPORT_SYMBOL_GPL (tmio_mmc_host_remove);#ifdef CONFIG_PM -static int tmio_mmc_clk_enable (struct tmio_mmc_host *host) -{ -if (!host->clk_enable) -return -ENOTSUPP ; - -return host->clk_enable (host); -} - -static void tmio_mmc_clk_disable (struct tmio_mmc_host *host) -{ -if (host->clk_disable) - host->clk_disable (host); -} -int tmio_mmc_host_runtime_suspend (struct device *dev) {struct tmio_mmc_host *host =dev_get_drvdata (dev);
@@ -1325,8 +1316,6 @@ int tmio_mmc_host_runtime_suspend(struct device *dev)if (host->clk_cache) host->set_clock (host,0 ); -tmio_mmc_clk_disable (host); -return 0 ; }EXPORT_SYMBOL_GPL (tmio_mmc_host_runtime_suspend);
@@ -1340,7 +1329,6 @@ int tmio_mmc_host_runtime_resume(struct device *dev) {struct tmio_mmc_host *host =dev_get_drvdata (dev); -tmio_mmc_clk_enable (host);tmio_mmc_hw_reset (host->mmc);if (host->clk_cache)
Signature · 1 line
2.7.4
Re: [PATCH 1/2] mmc: tmio: leave clock handling to PM if enabled
Quoted 9 lines · Ulrich Hecht
This fixes a clock imbalance that occurs because the SD clock is handled by both PM and the hardware driver.
See https://www.spinics.net/lists/linux-mmc/msg44431.html for details.This patch removes the clock handling from the driver's PM callbacks and turns the clock off after probing.
Reported-by Geert Uytterhoeven <[email protected]>Signed-off-by Ulrich Hecht <[email protected]>
Thanks, Uli!
Niklas, I'd really like your feedback on this one because you did the PM refactorization lately.
I will have a look later, too.
Re: [PATCH 1/2] mmc: tmio: leave clock handling to PM if enabled
Quoted 8 lines · Wolfram Sang
Quoted 7 lines · Ulrich Hecht
This fixes a clock imbalance that occurs because the SD clock is handled by both PM and the hardware driver.
See https://www.spinics.net/lists/linux-mmc/msg44431.html for details.This patch removes the clock handling from the driver's PM callbacks and turns the clock off after probing.
Quoted 7 lines
Quoted 2 lines
Reported-by Geert Uytterhoeven <[email protected]>Signed-off-by Ulrich Hecht <[email protected]>Thanks, Uli!
Niklas, I'd really like your feedback on this one because you did the PM refactorization lately.
I would like to test this too. Unfortunately I'm on the road and will be back in the office the 23rd so I will have to postpone doing so until then. My initial comment is that this looks good, thanks Ulrich.
Quoted 3 lines
I will have a look later, too.
Signature · 2 lines
Regards, Niklas Söderlund
Re: [PATCH 1/2] mmc: tmio: leave clock handling to PM if enabled
In reply to Ulrich HechtQuoted 4 lines · Ulrich Hecht
This fixes a clock imbalance that occurs because the SD clock is handled by both PM and the hardware driver.
See https://www.spinics.net/lists/linux-mmc/msg44431.html for details.
This is a generic problem, when a device are being attached to a genpd and when the genpd has got the ->stop|start() callbacks assigned, as to manage device clocks.
Can you try to describe this problem a little bit more in detail, as I think that's important to carry in the change log.
Quoted 2 lines
This patch removes the clock handling from the driver's PM callbacks and
runtime PM callbacks and/or system PM callbacks?
Quoted 13 lines
turns the clock off after probing.
Reported-by Geert Uytterhoeven <[email protected]>Signed-off-by Ulrich Hecht <[email protected]>--- drivers/mmc/host/tmio_mmc_core.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)drivers/mmc/host/tmio_mmc_core.c +0
-0
drivers/mmc/host/tmio_mmc_core.c int tmio_mmc_host_probe(struct tmio_mmc_host *_host) · line 1266
Quoted 8 lines
drivers/mmc/host/tmio_mmc_core.c +4
-1@@ -1260,9 +1260,14 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host)/* See if we also get DMA */ tmio_mmc_request_dma (_host, pdata); -pm_runtime_set_active (&pdev->dev); +#ifdef CONFIG_PM +/* PM handles the clock; disable it so it won't be enabled twice. */ +if (_host->clk_disable) + _host->clk_disable (_host);
The clock managed here, is that the same clock as being managed by genpd's ->stop|start() callbacks?
drivers/mmc/host/tmio_mmc_core.c int tmio_mmc_host_probe(struct tmio_mmc_host *_host) · line 1270
Quoted 4 lines
drivers/mmc/host/tmio_mmc_core.c +2
-0+pm_runtime_get_sync (&pdev->dev);pm_runtime_set_autosuspend_delay (&pdev->dev,50 );pm_runtime_use_autosuspend (&pdev->dev); +#endif
So what happens if you have CONFIG_PM set, but the device doesn't have a genpd attached?
I am guessing the driver should handle the clock in such scenario, right?
Quoted 42 lines
drivers/mmc/host/tmio_mmc_core.c +0
-18ret =mmc_add_host (mmc);if (ret)@@ -1302,20 +1307,6 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host)EXPORT_SYMBOL_GPL (tmio_mmc_host_remove);#ifdef CONFIG_PM -static int tmio_mmc_clk_enable (struct tmio_mmc_host *host) -{ -if (!host->clk_enable) -return -ENOTSUPP ; - -return host->clk_enable (host); -} - -static void tmio_mmc_clk_disable (struct tmio_mmc_host *host) -{ -if (host->clk_disable) - host->clk_disable (host); -} -int tmio_mmc_host_runtime_suspend (struct device *dev) {struct tmio_mmc_host *host =dev_get_drvdata (dev);@@ -1325,8 +1316,6 @@ int tmio_mmc_host_runtime_suspend(struct device *dev)if (host->clk_cache) host->set_clock (host,0 ); -tmio_mmc_clk_disable (host); -return 0 ; }EXPORT_SYMBOL_GPL (tmio_mmc_host_runtime_suspend);@@ -1340,7 +1329,6 @@ int tmio_mmc_host_runtime_resume(struct device *dev) {struct tmio_mmc_host *host =dev_get_drvdata (dev); -tmio_mmc_clk_enable (host);tmio_mmc_hw_reset (host->mmc);if (host->clk_cache) --
Quoted 2 lines
2.7.4
Kind regards
Uffe
Re: [PATCH 1/2] mmc: tmio: leave clock handling to PM if enabled
Hi Ulf,
Quoted 42 lines · Ulf Hansson
Quoted 3 lines · Ulrich Hecht
This fixes a clock imbalance that occurs because the SD clock is handled by both PM and the hardware driver.
See https://www.spinics.net/lists/linux-mmc/msg44431.html for details.This is a generic problem, when a device are being attached to a genpd and when the genpd has got the ->stop|start() callbacks assigned, as to manage device clocks.
Can you try to describe this problem a little bit more in detail, as I think that's important to carry in the change log.
Quoted 2 lines
This patch removes the clock handling from the driver's PM callbacks and
runtime PM callbacks and/or system PM callbacks?
Quoted 13 lines
turns the clock off after probing.
Reported-by Geert Uytterhoeven <[email protected]>Signed-off-by Ulrich Hecht <[email protected]>--- drivers/mmc/host/tmio_mmc_core.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)drivers/mmc/host/tmio_mmc_core.c +0
-0drivers/mmc/host/tmio_mmc_core.c int tmio_mmc_host_probe(struct tmio_mmc_host *_host) · line 1266
Quoted 8 lines
drivers/mmc/host/tmio_mmc_core.c +4
-1@@ -1260,9 +1260,14 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host)/* See if we also get DMA */ tmio_mmc_request_dma (_host, pdata); -pm_runtime_set_active (&pdev->dev); +#ifdef CONFIG_PM +/* PM handles the clock; disable it so it won't be enabled twice. */ +if (_host->clk_disable) + _host->clk_disable (_host);The clock managed here, is that the same clock as being managed by genpd's ->stop|start() callbacks?
Quoted 7 lines
drivers/mmc/host/tmio_mmc_core.c int tmio_mmc_host_probe(struct tmio_mmc_host *_host) · line 1270
Quoted 4 lines
drivers/mmc/host/tmio_mmc_core.c +2
-0+pm_runtime_get_sync (&pdev->dev);pm_runtime_set_autosuspend_delay (&pdev->dev,50 );pm_runtime_use_autosuspend (&pdev->dev); +#endif So what happens if you have
CONFIG_PMset, but the device doesn't have a genpd attached?
That's OK for all SoCs served by renesas_sdhi_internal_dmac.c and renesas_sdhi_sys_dmac.c, as they all have their clock domain described in DT...
Quoted 1 line
I am guessing the driver should handle the clock in such scenario, right?
... but it's not for (non-Renesas) systems served by tmio_mmc.c.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] 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
PATCH 2/2 mmc: tmio: remove obsolete PM workaround
In reply to Ulrich HechtObsoleted by
"mmc: tmio: move runtime PM enablement to the driver implementations".
--- drivers/mmc/host/tmio_mmc_core.c | 9 --------- 1 file changed, 9 deletions(-)
drivers/mmc/host/tmio_mmc_core.c +0 -9
@@ -1221,15 +1221,6 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host) _host->reset = tmio_mmc_reset;/* -* On Gen2+, eMMC with NONREMOVABLE currently fails because native -* hotplug gets disabled. It seems RuntimePM related yet we need further -* research. Since we are planning a PM overhaul anyway, let's enforce -* for now the device being active by enabling native hotplug always. -*/ -if (pdata->flags &TMIO_MMC_MIN_RCAR2 ) - _host->native_hotplug = true; - -/* * While using internal tmio hardware logic for card detection, we need * to ensure it stays powered for it to work. */
Signature · 1 line
2.7.4
Re: [PATCH 2/2] mmc: tmio: remove obsolete PM workaround
Quoted 2 lines · Ulrich Hecht
Obsoleted by
"mmc: tmio: move runtime PM enablement to the driver implementations".
commit 7ff213193310ef8d ("mmc: tmio: move runtime PM enablement to the driver implementations")
Quoted 16 lines
Signed-off-by Ulrich Hecht <[email protected]>--- drivers/mmc/host/tmio_mmc_core.c | 9 --------- 1 file changed, 9 deletions(-)drivers/mmc/host/tmio_mmc_core.c +0
-2@@ -1221,15 +1221,6 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host) _host->reset = tmio_mmc_reset;/* -* On Gen2+, eMMC with NONREMOVABLE currently fails because native -* hotplug gets disabled. It seems RuntimePM related yet we need further
drivers/mmc/host/tmio_mmc_core.c int tmio_mmc_host_probe(struct tmio_mmc_host *_host) · line 1226
Quoted 10 lines
drivers/mmc/host/tmio_mmc_core.c +0
-7-* research. Since we are planning a PM overhaul anyway, let's enforce -* for now the device being active by enabling native hotplug always. -*/ -if (pdata->flags &TMIO_MMC_MIN_RCAR2 ) - _host->native_hotplug = true; - -/* * While using internal tmio hardware logic for card detection, we need * to ensure it stays powered for it to work. */
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] 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
Hi Ulrich,
Thanks for your work.
Quoted 13 lines · Ulrich Hecht
Hi!
The second patch in this series removes a workaround that forced eMMC devices always on and that is no longer required.
Removing it does expose a bug, however, that leads to a clock imbalance due to the clock being enabled by both PM and the hardware driver. (See
https://www.spinics.net/lists/linux-mmc/msg54009.html for discussion.) This bug is taken care of by the first patch.Tested on r8a7790 (Lager), r8a7795 and r8a7796 (Salvator-X) with SD and eMMC, before and after suspend.
Quoted 7 lines
CU
UliUlrich Hecht (2):
mmc: tmio: leave clock handling to PM if enabled
mmc: tmio: remove obsolete PM workaround
Quoted 7 lines
drivers/mmc/host/tmio_mmc_core.c | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-)Signature · 1 line
2.7.4
Signature · 2 lines
Regards, Niklas Söderlund