From: <Conor.Dooley@microchip.com>
To: <christophe.jaillet@wanadoo.fr>, <Daire.McNamara@microchip.com>,
<a.zummo@towertech.it>, <alexandre.belloni@bootlin.com>
Cc: <linux-kernel@vger.kernel.org>, <kernel-janitors@vger.kernel.org>,
<linux-riscv@lists.infradead.org>, <linux-rtc@vger.kernel.org>
Subject: Re: [PATCH] rtc: mpfs: Use devm_clk_get_enabled() helper
Date: Wed, 24 Aug 2022 11:46:34 +0000 [thread overview]
Message-ID: <3513eb2e-5e18-152f-6111-f4606a73bc2f@microchip.com> (raw)
In-Reply-To: <c74a42f7-7d9a-6b52-85b2-d87dacd91be6@wanadoo.fr>
On 24/08/2022 12:27, Christophe JAILLET wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> Le 24/08/2022 à 11:58, Conor.Dooley@microchip.com a écrit :
>> Hey Christope,
>> Thanks for your patch.
>>
>> On 24/08/2022 09:18, Christophe JAILLET wrote:
>>> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>>>
>>> The devm_clk_get_enabled() helper:
>>> - calls devm_clk_get()
>>> - calls clk_prepare_enable() and registers what is needed in order to
>>> call clk_disable_unprepare() when needed, as a managed resource.
>>>
>>> This simplifies the code, the error handling paths and avoid the need of
>>> a dedicated function used with devm_add_action_or_reset().
>>>
>>> That said, mpfs_rtc_init_clk() is the same as devm_clk_get_enabled(), so
>>> use this function directly instead.
>>
>> Firstly, I think something is missing from the commit description here.
>> devm_clk_get_enabled() is not just a blanket "use this instead of get(),
>> prepare_enable()" & is only intended for cases where the clock would
>> be kept prepared or enabled for the whole lifetime of the driver. I think
>> it is worth pointing that out to help people who do not keep up with
>> every helper that is added.
>
> Ok, I'll update my commit log for other similar patches or should a v2
> be needed.
>
>>
>> I had a bit of a look through the documentation to see if the block would
>> keep track of time without the AHB clock enabled, but it does not seem to.
>> There is no reason to turn off the clock here (in fact it would seem
>> counter productive to disable it..) so it looks like the shoe fits in that
>> regard.
>>
>> However...
>>
>>> - devm_add_action_or_reset(dev, (void (*) (void *))clk_disable_unprepare, clk);
>>
>> ... this bit here concerns me a little. I don't think we should be
>> registering a callback here at all - if we power down Linux this is
>> going to end up stopping the RTC isn't it?
>>
>> I think this is left over from the v1 driver submission that reset
>> the block during probe & should be removed.
>
> My point is only that what is done must be undone at some point.
>
> What if an error occurs in the probe after the clk_get("rtc")?
> Is there any point keeping it prepared and enabled?
>
>
> There is a .remove function in this driver, so, it looks that it is
> expected that it can be unloaded.
>
> So undoing this clk operations via a managed resource looks the correct
> thing to do.
>
> Just my 2c, you must know this driver and the expected behavior better
> than me.
>
I am doing some more testing rn, before replying to Alexandre - I guess
I am just wondering if actually disabling the clock prior to to removing
the driver makes any sense. Maybe the lock just needs to be explicitly
marked as critical, in which case this patch makes complete sense to me.
Thanks,
Conor.
next prev parent reply other threads:[~2022-08-24 11:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-24 8:18 [PATCH] rtc: mpfs: Use devm_clk_get_enabled() helper Christophe JAILLET
2022-08-24 9:58 ` Conor.Dooley
2022-08-24 10:53 ` Alexandre Belloni
2022-08-24 12:27 ` Conor.Dooley
2022-08-24 11:27 ` Christophe JAILLET
2022-08-24 11:46 ` Conor.Dooley [this message]
2022-08-24 12:28 ` Alexandre Belloni
2022-08-24 13:25 ` Christophe JAILLET
2022-10-13 21:32 ` Alexandre Belloni
2022-10-13 21:34 ` Conor.Dooley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3513eb2e-5e18-152f-6111-f4606a73bc2f@microchip.com \
--to=conor.dooley@microchip.com \
--cc=Daire.McNamara@microchip.com \
--cc=a.zummo@towertech.it \
--cc=alexandre.belloni@bootlin.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-rtc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox