mbox series

[0/9] mmc: convert to devm_clk_get_enabled() API

Message ID 20240827074857.2671808-1-xirui.zhang@vivo.com (mailing list archive)
Headers show
Series mmc: convert to devm_clk_get_enabled() API | expand

Message

zhangxirui Aug. 27, 2024, 7:48 a.m. UTC
This series use devm_clk_get_enabled() to simplify code 
and avoids the calls to clk_disable_unprepare() 

zhangxirui (9):
  mmc: cavium-thunderx: Use devm_clk_get_enabled() helpers
  mmc: davinci_mmc: Use devm_clk_get_enabled() helpers
  mmc: dw_mmc-hi3798cv200: Use devm_clk_get_enabled() helpers
  mmc: mvsdio: Use devm_clk_get_enabled() helpers
  mmc: mxcmmc: Use devm_clk_get_enabled() helpers
  mmc: mxs-mmc: Use devm_clk_get_enabled() helpers
  mmc: sdhci: milbeaut: Use devm_clk_get_enabled() helpers
  mmc: sdhci-of-arasan: Use devm_clk_get_enabled() helpers
  mmc: sdhci_f_sdh30: Use devm_clk_get_enabled() helpers

 drivers/mmc/host/cavium-thunderx.c    |  7 +-----
 drivers/mmc/host/davinci_mmc.c        |  8 +-----
 drivers/mmc/host/dw_mmc-hi3798cv200.c | 28 +++------------------
 drivers/mmc/host/mvsdio.c             | 13 +++-------
 drivers/mmc/host/mxcmmc.c             | 25 +++----------------
 drivers/mmc/host/mxs-mmc.c            | 13 +++-------
 drivers/mmc/host/sdhci-milbeaut.c     | 25 +++----------------
 drivers/mmc/host/sdhci-of-arasan.c    | 31 ++++-------------------
 drivers/mmc/host/sdhci_f_sdh30.c      | 36 ++++++++-------------------
 9 files changed, 35 insertions(+), 151 deletions(-)

Comments

Ulf Hansson Aug. 28, 2024, 3:11 p.m. UTC | #1
On Tue, 27 Aug 2024 at 09:34, zhangxirui <xirui.zhang@vivo.com> wrote:
>
> This series use devm_clk_get_enabled() to simplify code
> and avoids the calls to clk_disable_unprepare()

I agree that it simplifies code - but it also changes the behaviour,
in which order clocks are getting unprepared/disabled during the
->remove() phase. In other words, this needs to be thoroughly tested
and not just considered as a trivial cleanup series.

For example, if there is a PM domain attached to the mmc host device,
is it really okay to allow powering-off the PM domain before the
clocks are being gated? This could potentially happen if we apply the
$subject series.

Kind regards
Uffe

>
> zhangxirui (9):
>   mmc: cavium-thunderx: Use devm_clk_get_enabled() helpers
>   mmc: davinci_mmc: Use devm_clk_get_enabled() helpers
>   mmc: dw_mmc-hi3798cv200: Use devm_clk_get_enabled() helpers
>   mmc: mvsdio: Use devm_clk_get_enabled() helpers
>   mmc: mxcmmc: Use devm_clk_get_enabled() helpers
>   mmc: mxs-mmc: Use devm_clk_get_enabled() helpers
>   mmc: sdhci: milbeaut: Use devm_clk_get_enabled() helpers
>   mmc: sdhci-of-arasan: Use devm_clk_get_enabled() helpers
>   mmc: sdhci_f_sdh30: Use devm_clk_get_enabled() helpers
>
>  drivers/mmc/host/cavium-thunderx.c    |  7 +-----
>  drivers/mmc/host/davinci_mmc.c        |  8 +-----
>  drivers/mmc/host/dw_mmc-hi3798cv200.c | 28 +++------------------
>  drivers/mmc/host/mvsdio.c             | 13 +++-------
>  drivers/mmc/host/mxcmmc.c             | 25 +++----------------
>  drivers/mmc/host/mxs-mmc.c            | 13 +++-------
>  drivers/mmc/host/sdhci-milbeaut.c     | 25 +++----------------
>  drivers/mmc/host/sdhci-of-arasan.c    | 31 ++++-------------------
>  drivers/mmc/host/sdhci_f_sdh30.c      | 36 ++++++++-------------------
>  9 files changed, 35 insertions(+), 151 deletions(-)
>
> --
> 2.25.1
>
zhangxirui Aug. 30, 2024, 2:47 a.m. UTC | #2
On Wed, 28 Aug 2024 at 17:11, Ulf Hansson <ulf.hansson@linaro.org> wrote: 

> On Tue, 27 Aug 2024 at 09:34, zhangxirui <xirui.zhang@vivo.com> wrote:
> >
> > This series use devm_clk_get_enabled() to simplify code
> > and avoids the calls to clk_disable_unprepare()
> 
> I agree that it simplifies code - but it also changes the behaviour,
> in which order clocks are getting unprepared/disabled during the
> ->remove() phase. In other words, this needs to be thoroughly tested
> and not just considered as a trivial cleanup series.
> 
> For example, if there is a PM domain attached to the mmc host device,
> is it really okay to allow powering-off the PM domain before the
> clocks are being gated? This could potentially happen if we apply the
> $subject series.

Thanks for the reply, are you saying that merging the above patch will 
lead to the following issue?

before:
bus_remove -> driver_remove -> clk unprepare 
           -> dev_pm_domain_detach
           -> device_unbind_cleanup
after:
bus_remove -> driver_remove (delete clk unprepare) 
           -> dev_pm_domain_detach 
           -> device_unbind_cleanup (devm_clk_get_enbaled ->relase(clk unprepare))

But I think this issue is not only specific to the MMC host, it will also 
occur with other devices, if there is a PM domain attachded an use devm_clk_get_enbaled API. 

So, can we solve this problem by swap device_ubind_cleanup and dev_pm_domain_detach ? 
clk unprepare -> power off not power off -> clk unprepare

bus_remove -> driver_remove 
           -> device_unbind_cleanup
           -> dev_pm_domain_detach 

Thanks.

> >
> > zhangxirui (9):
> >   mmc: cavium-thunderx: Use devm_clk_get_enabled() helpers
> >   mmc: davinci_mmc: Use devm_clk_get_enabled() helpers
> >   mmc: dw_mmc-hi3798cv200: Use devm_clk_get_enabled() helpers
> >   mmc: mvsdio: Use devm_clk_get_enabled() helpers
> >   mmc: mxcmmc: Use devm_clk_get_enabled() helpers
> >   mmc: mxs-mmc: Use devm_clk_get_enabled() helpers
> >   mmc: sdhci: milbeaut: Use devm_clk_get_enabled() helpers
> >   mmc: sdhci-of-arasan: Use devm_clk_get_enabled() helpers
> >   mmc: sdhci_f_sdh30: Use devm_clk_get_enabled() helpers
Ulf Hansson Aug. 30, 2024, 10:27 a.m. UTC | #3
+ Stephen

On Fri, 30 Aug 2024 at 04:32, zhangxirui <xirui.zhang@vivo.com> wrote:
>
> On Wed, 28 Aug 2024 at 17:11, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
> > On Tue, 27 Aug 2024 at 09:34, zhangxirui <xirui.zhang@vivo.com> wrote:
> > >
> > > This series use devm_clk_get_enabled() to simplify code
> > > and avoids the calls to clk_disable_unprepare()
> >
> > I agree that it simplifies code - but it also changes the behaviour,
> > in which order clocks are getting unprepared/disabled during the
> > ->remove() phase. In other words, this needs to be thoroughly tested
> > and not just considered as a trivial cleanup series.
> >
> > For example, if there is a PM domain attached to the mmc host device,
> > is it really okay to allow powering-off the PM domain before the
> > clocks are being gated? This could potentially happen if we apply the
> > $subject series.
>
> Thanks for the reply, are you saying that merging the above patch will
> lead to the following issue?
>
> before:
> bus_remove -> driver_remove -> clk unprepare
>            -> dev_pm_domain_detach
>            -> device_unbind_cleanup
> after:
> bus_remove -> driver_remove (delete clk unprepare)
>            -> dev_pm_domain_detach
>            -> device_unbind_cleanup (devm_clk_get_enbaled ->relase(clk unprepare))

Correct!

>
> But I think this issue is not only specific to the MMC host, it will also
> occur with other devices, if there is a PM domain attachded an use devm_clk_get_enbaled API.

Right. Which kind of questions whether the API is really that useful,
from a cleanup point of view.

>
> So, can we solve this problem by swap device_ubind_cleanup and dev_pm_domain_detach ?
> clk unprepare -> power off not power off -> clk unprepare

That may work, I don't know.

Another option is simply to avoid using devm_clk_get_enabled(), unless
you know that the HW can cope with the potentially changed behaviour.

I have looped in Stephen to allow him to provide us his thoughts
around this too.

>
> bus_remove -> driver_remove
>            -> device_unbind_cleanup
>            -> dev_pm_domain_detach
>
> Thanks.
>
> > >
> > > zhangxirui (9):
> > >   mmc: cavium-thunderx: Use devm_clk_get_enabled() helpers
> > >   mmc: davinci_mmc: Use devm_clk_get_enabled() helpers
> > >   mmc: dw_mmc-hi3798cv200: Use devm_clk_get_enabled() helpers
> > >   mmc: mvsdio: Use devm_clk_get_enabled() helpers
> > >   mmc: mxcmmc: Use devm_clk_get_enabled() helpers
> > >   mmc: mxs-mmc: Use devm_clk_get_enabled() helpers
> > >   mmc: sdhci: milbeaut: Use devm_clk_get_enabled() helpers
> > >   mmc: sdhci-of-arasan: Use devm_clk_get_enabled() helpers
> > >   mmc: sdhci_f_sdh30: Use devm_clk_get_enabled() helpers

Kind regards
Uffe