[PATCH 0/2] clk: renesas: rzg2l: Disable unused clocks after resume

Claudiu posted 2 patches 1 month, 1 week ago
drivers/clk/clk.c               |  9 +++++----
drivers/clk/renesas/rzg2l-cpg.c | 24 ++++++++++++++++++++++++
include/linux/clk.h             | 12 ++++++++++++
3 files changed, 41 insertions(+), 4 deletions(-)
[PATCH 0/2] clk: renesas: rzg2l: Disable unused clocks after resume
Posted by Claudiu 1 month, 1 week ago
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

Hi,

This series disables clocks that remain unused after resume.
This is necessary when the resume process is done with the help of the
bootloader, as the bootloader enables various clocks when returning from
resume.

On the RZ/G3S SoC (where this series was tested), the bootloader enables
the SDHI clocks (for all SDHI modules, of which 2 are used by Linux and
1 is unused) and the clocks for a serial IP (unused by Linux).

Testing was done on the RZ/G3S SMARC Carrier II board.

Thank you,
Claudiu Benea

Claudiu Beznea (2):
  clk: Export clk_disable_unused()
  clk: renesas: rzg2l: Register PM notifier to disable unused clocks

 drivers/clk/clk.c               |  9 +++++----
 drivers/clk/renesas/rzg2l-cpg.c | 24 ++++++++++++++++++++++++
 include/linux/clk.h             | 12 ++++++++++++
 3 files changed, 41 insertions(+), 4 deletions(-)

-- 
2.43.0
Re: [PATCH 0/2] clk: renesas: rzg2l: Disable unused clocks after resume
Posted by Brian Masney 1 month, 1 week ago
Hi Claudiu,

On Thu, Aug 21, 2025 at 11:03:30AM +0300, Claudiu wrote:
> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> 
> Hi,
> 
> This series disables clocks that remain unused after resume.
> This is necessary when the resume process is done with the help of the
> bootloader, as the bootloader enables various clocks when returning from
> resume.
> 
> On the RZ/G3S SoC (where this series was tested), the bootloader enables
> the SDHI clocks (for all SDHI modules, of which 2 are used by Linux and
> 1 is unused) and the clocks for a serial IP (unused by Linux).
> 
> Testing was done on the RZ/G3S SMARC Carrier II board.

Do you think that other boards would also benefit from this change? If
so, what do you think about putting the call to register_pm_notifier()
inside an __init block in clk.c so that this same change doesn't have to
be implemented across various clk drivers?

Alternatively, if this is board specific, could this be fixed in the
boot loader so that the clock that's not used by Linus is properly shut
down on resume?

I'm not the subsystem maintainer, so I'm not asking you to make any of
these changes.

Brian
Re: [PATCH 0/2] clk: renesas: rzg2l: Disable unused clocks after resume
Posted by claudiu beznea 1 month, 1 week ago
Hi, Brian,

On 8/25/25 20:05, Brian Masney wrote:
> Hi Claudiu,
> 
> On Thu, Aug 21, 2025 at 11:03:30AM +0300, Claudiu wrote:
>> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>
>> Hi,
>>
>> This series disables clocks that remain unused after resume.
>> This is necessary when the resume process is done with the help of the
>> bootloader, as the bootloader enables various clocks when returning from
>> resume.
>>
>> On the RZ/G3S SoC (where this series was tested), the bootloader enables
>> the SDHI clocks (for all SDHI modules, of which 2 are used by Linux and
>> 1 is unused) and the clocks for a serial IP (unused by Linux).
>>
>> Testing was done on the RZ/G3S SMARC Carrier II board.
> 
> Do you think that other boards would also benefit from this change? If
> so, what do you think about putting the call to register_pm_notifier()
> inside an __init block in clk.c so that this same change doesn't have to
> be implemented across various clk drivers?

Yes, that was my other approach I was thinking about. I wanted to see how other 
people consider this version.

> 
> Alternatively, if this is board specific, could this be fixed in the
> boot loader so that the clock that's not used by Linus is properly shut
> down on resume?

As a result of your request I did some more investigations on my side, I can say 
that, yes, in theory that could be also handled by bootloader.

I can drop this and try to do it in bootloader, if any. Please let me know if 
you still consider this (or the variant that implements it in a generic way) 
necessary.

Thank you for your review,
Claudiu

> 
> I'm not the subsystem maintainer, so I'm not asking you to make any of
> these changes.
> 
> Brian
>
Re: [PATCH 0/2] clk: renesas: rzg2l: Disable unused clocks after resume
Posted by Brian Masney 1 month, 1 week ago
Hi Claudiu,

On Tue, Aug 26, 2025 at 02:01:56PM +0300, claudiu beznea wrote:
> On 8/25/25 20:05, Brian Masney wrote:
> > On Thu, Aug 21, 2025 at 11:03:30AM +0300, Claudiu wrote:
> > > From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> > > This series disables clocks that remain unused after resume.
> > > This is necessary when the resume process is done with the help of the
> > > bootloader, as the bootloader enables various clocks when returning from
> > > resume.
> > > 
> > > On the RZ/G3S SoC (where this series was tested), the bootloader enables
> > > the SDHI clocks (for all SDHI modules, of which 2 are used by Linux and
> > > 1 is unused) and the clocks for a serial IP (unused by Linux).
> > > 
> > > Testing was done on the RZ/G3S SMARC Carrier II board.
> > 
> > Do you think that other boards would also benefit from this change? If
> > so, what do you think about putting the call to register_pm_notifier()
> > inside an __init block in clk.c so that this same change doesn't have to
> > be implemented across various clk drivers?
> 
> Yes, that was my other approach I was thinking about. I wanted to see how
> other people consider this version.
> 
> > 
> > Alternatively, if this is board specific, could this be fixed in the
> > boot loader so that the clock that's not used by Linus is properly shut
> > down on resume?
> 
> As a result of your request I did some more investigations on my side, I can
> say that, yes, in theory that could be also handled by bootloader.
> 
> I can drop this and try to do it in bootloader, if any. Please let me know
> if you still consider this (or the variant that implements it in a generic
> way) necessary.

Personally I would go the route of fixing this in the bootloader for
this particular platform.

If this issue affects other platforms, particularly across multiple
SoC vendors, then I think it would be worthwhile to have a discussion
about adding this functionality to the clk core.

Brian
Re: [PATCH 0/2] clk: renesas: rzg2l: Disable unused clocks after resume
Posted by Geert Uytterhoeven 1 month ago
Hi Brian,

On Tue, 26 Aug 2025 at 13:52, Brian Masney <bmasney@redhat.com> wrote:
> On Tue, Aug 26, 2025 at 02:01:56PM +0300, claudiu beznea wrote:
> > On 8/25/25 20:05, Brian Masney wrote:
> > > On Thu, Aug 21, 2025 at 11:03:30AM +0300, Claudiu wrote:
> > > > From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> > > > This series disables clocks that remain unused after resume.
> > > > This is necessary when the resume process is done with the help of the
> > > > bootloader, as the bootloader enables various clocks when returning from
> > > > resume.
> > > >
> > > > On the RZ/G3S SoC (where this series was tested), the bootloader enables
> > > > the SDHI clocks (for all SDHI modules, of which 2 are used by Linux and
> > > > 1 is unused) and the clocks for a serial IP (unused by Linux).
> > > >
> > > > Testing was done on the RZ/G3S SMARC Carrier II board.
> > >
> > > Do you think that other boards would also benefit from this change? If
> > > so, what do you think about putting the call to register_pm_notifier()
> > > inside an __init block in clk.c so that this same change doesn't have to
> > > be implemented across various clk drivers?
> >
> > Yes, that was my other approach I was thinking about. I wanted to see how
> > other people consider this version.
> >
> > > Alternatively, if this is board specific, could this be fixed in the
> > > boot loader so that the clock that's not used by Linus is properly shut
> > > down on resume?
> >
> > As a result of your request I did some more investigations on my side, I can
> > say that, yes, in theory that could be also handled by bootloader.
> >
> > I can drop this and try to do it in bootloader, if any. Please let me know
> > if you still consider this (or the variant that implements it in a generic
> > way) necessary.
>
> Personally I would go the route of fixing this in the bootloader for
> this particular platform.
>
> If this issue affects other platforms, particularly across multiple
> SoC vendors, then I think it would be worthwhile to have a discussion
> about adding this functionality to the clk core.

How would the bootloader know which clocks are not used by Linux?
And why to offload this to the bootloader for resume, but not for boot?

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
Re: [PATCH 0/2] clk: renesas: rzg2l: Disable unused clocks after resume
Posted by Brian Masney 1 month ago
Hi Geert,

On Mon, Sep 01, 2025 at 11:46:34AM +0200, Geert Uytterhoeven wrote:
> On Tue, 26 Aug 2025 at 13:52, Brian Masney <bmasney@redhat.com> wrote:
> > On Tue, Aug 26, 2025 at 02:01:56PM +0300, claudiu beznea wrote:
> > > On 8/25/25 20:05, Brian Masney wrote:
> > > > On Thu, Aug 21, 2025 at 11:03:30AM +0300, Claudiu wrote:
> > > > > From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> > > > > This series disables clocks that remain unused after resume.
> > > > > This is necessary when the resume process is done with the help of the
> > > > > bootloader, as the bootloader enables various clocks when returning from
> > > > > resume.
> > > > >
> > > > > On the RZ/G3S SoC (where this series was tested), the bootloader enables
> > > > > the SDHI clocks (for all SDHI modules, of which 2 are used by Linux and
> > > > > 1 is unused) and the clocks for a serial IP (unused by Linux).
> > > > >
> > > > > Testing was done on the RZ/G3S SMARC Carrier II board.
> > > >
> > > > Do you think that other boards would also benefit from this change? If
> > > > so, what do you think about putting the call to register_pm_notifier()
> > > > inside an __init block in clk.c so that this same change doesn't have to
> > > > be implemented across various clk drivers?
> > >
> > > Yes, that was my other approach I was thinking about. I wanted to see how
> > > other people consider this version.
> > >
> > > > Alternatively, if this is board specific, could this be fixed in the
> > > > boot loader so that the clock that's not used by Linus is properly shut
> > > > down on resume?
> > >
> > > As a result of your request I did some more investigations on my side, I can
> > > say that, yes, in theory that could be also handled by bootloader.
> > >
> > > I can drop this and try to do it in bootloader, if any. Please let me know
> > > if you still consider this (or the variant that implements it in a generic
> > > way) necessary.
> >
> > Personally I would go the route of fixing this in the bootloader for
> > this particular platform.
> >
> > If this issue affects other platforms, particularly across multiple
> > SoC vendors, then I think it would be worthwhile to have a discussion
> > about adding this functionality to the clk core.
> 
> How would the bootloader know which clocks are not used by Linux?
> And why to offload this to the bootloader for resume, but not for boot?

If the bootloader is involved with resume, then I assume that it's also
involved with suspend as well? If so, could the boot loader save the
state of the 3 clocks on suspend, and set them back to that same state
on resume?

How widespread is this issue? Does it just affect this board, or is it
common across other boards?

There are some longstanding issues with clk_disable_unused that Stephen
talked about at Linux Plumbers almost two years ago [1]. We'll have to
wait to hear back from him, however I suspect he may be reluctant to
expand the scope of clk_disable_unused even further given the existing
issues.

[1] https://www.youtube.com/watch?v=tXYzM8yLIQA

Brian
Re: [PATCH 0/2] clk: renesas: rzg2l: Disable unused clocks after resume
Posted by Claudiu Beznea 1 month ago
Hi, Stephen,

On 26.08.2025 14:52, Brian Masney wrote:
> Hi Claudiu,
> 
> On Tue, Aug 26, 2025 at 02:01:56PM +0300, claudiu beznea wrote:
>> On 8/25/25 20:05, Brian Masney wrote:
>>> On Thu, Aug 21, 2025 at 11:03:30AM +0300, Claudiu wrote:
>>>> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>>> This series disables clocks that remain unused after resume.
>>>> This is necessary when the resume process is done with the help of the
>>>> bootloader, as the bootloader enables various clocks when returning from
>>>> resume.
>>>>
>>>> On the RZ/G3S SoC (where this series was tested), the bootloader enables
>>>> the SDHI clocks (for all SDHI modules, of which 2 are used by Linux and
>>>> 1 is unused) and the clocks for a serial IP (unused by Linux).
>>>>
>>>> Testing was done on the RZ/G3S SMARC Carrier II board.
>>>
>>> Do you think that other boards would also benefit from this change? If
>>> so, what do you think about putting the call to register_pm_notifier()
>>> inside an __init block in clk.c so that this same change doesn't have to
>>> be implemented across various clk drivers?
>>
>> Yes, that was my other approach I was thinking about. I wanted to see how
>> other people consider this version.
>>
>>>
>>> Alternatively, if this is board specific, could this be fixed in the
>>> boot loader so that the clock that's not used by Linus is properly shut
>>> down on resume?
>>
>> As a result of your request I did some more investigations on my side, I can
>> say that, yes, in theory that could be also handled by bootloader.
>>
>> I can drop this and try to do it in bootloader, if any. Please let me know
>> if you still consider this (or the variant that implements it in a generic
>> way) necessary.
> 
> Personally I would go the route of fixing this in the bootloader for
> this particular platform.
> 
> If this issue affects other platforms, particularly across multiple
> SoC vendors, then I think it would be worthwhile to have a discussion
> about adding this functionality to the clk core.
> 

Could you please let us know if you prefer a mechanism like
clk_disable_unused() in Linux for resume path?

Thank you,
Claudiu