From: Jonathan Cameron <jic23@kernel.org>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: "Andy Shevchenko" <andy.shevchenko@gmail.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Heiko Stuebner" <heiko@sntech.de>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
linux-iio <linux-iio@vger.kernel.org>,
"David Wu" <david.wu@rock-chips.com>,
"Anand Ashok Dumbre" <anand.ashok.dumbre@xilinx.com>,
"Vladimir Zapolskiy" <vz@mleia.com>,
"Paul Cercueil" <paul@crapouillou.net>,
"Antoniu Miclaus" <antoniu.miclaus@analog.com>,
"Sascha Hauer" <kernel@pengutronix.de>,
"Jonathan Cameron" <Jonathan.Cameron@huawei.com>,
"Nuno Sa" <nuno.sa@analog.com>,
"Michal Simek" <michal.simek@xilinx.com>,
"Simon Xue" <xxm@rock-chips.com>
Subject: Re: [PATCH 06/13] iio: adc: rockchip_saradc: Benefit from devm_clk_get_enabled() to simplify
Date: Sat, 20 Aug 2022 12:42:35 +0100 [thread overview]
Message-ID: <20220820124235.223d4a7e@jic23-huawei> (raw)
In-Reply-To: <bd8472f2-e4d0-2a63-98a5-5e1fe8ad6255@metafoo.de>
On Tue, 16 Aug 2022 10:38:41 +0200
Lars-Peter Clausen <lars@metafoo.de> wrote:
> On 8/16/22 10:27, Lars-Peter Clausen wrote:
> > On 8/16/22 10:20, Andy Shevchenko wrote:
> >> On Mon, Aug 15, 2022 at 10:42 AM Uwe Kleine-König
> >> <u.kleine-koenig@pengutronix.de> wrote:
> >>> On Mon, Aug 15, 2022 at 10:30:45AM +0300, Andy Shevchenko wrote:
> >>>> On Mon, Aug 15, 2022 at 12:31 AM Uwe Kleine-König
> >>>> <u.kleine-koenig@pengutronix.de> wrote:
> >>>>> On Sun, Aug 14, 2022 at 10:01:08PM +0300, Andy Shevchenko wrote:
> >>>>>> On Sat, Aug 13, 2022 at 7:21 PM Jonathan Cameron
> >>>>>> <jic23@kernel.org> wrote:
> >>>>>>> On Mon, 8 Aug 2022 22:47:33 +0200
> >>>>>>> Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:
> >>>>>>>
> >>>>>>>> Make use of devm_clk_get_enabled() to replace some code that
> >>>>>>>> effectively
> >>>>>>>> open codes this new function.
> >>>>>>>>
> >>>>>>>> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> >>>>>>>> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> >>>>>>> This might have side effects as it now enables the clock before
> >>>>>>> calling
> >>>>>>> the clk_set_rate(). Also changes the clock start up ordering.
> >>>>>>> Neither is that
> >>>>>>> scary a change, but on really fussy hardware they might cause
> >>>>>>> problems.
> >>>>>>>
> >>>>>>> Add a few rock-chips people who have sent patches in last few years
> >>>>>>> to hopefully take a look or even better run a test.
> >>>>>> I believe you found a bug in the patch. The possible solutions are:
> >>>>>> - not take the patch
> >>>>>> - disable and re-enable clock around clk_set_rate()
> >>>>>>
> >>>>>> IIRC clk_set_rate() will spit a WARN if clock is enabled.
> >>>>> You mean in general? I think that's wrong. There might be some
> >>>>> clks that
> >>>>> do that, but I'd consider them strange. If you ask me, calling
> >>>>> clk_set_rate() for a *disabled* clk is the strange concept ...
> >>>> I think it's correct from the logic and electrical perspective. That's
> >>>> why the preparation and enablement are separated in CCF. But please
> >>>> double check, because I can't remember everything by heart.
> >>> In my book the separation is done because "enabling" has to sleep for
> >>> some clks (e.g. PLLs) while a sleeping clk_enable() is bad for various
> >>> use cases and most clks don't sleep for enabling.
> >> Yeah, but the idea of changing clock rate on the fly may produce
> >> interesting side-effects on hardware level (with PLL latencies to lock
> >> the phase and possible glitches). So, changing clock against enabled
> >> hardware (not in reset / power off state) seems not a good idea.
> >
> > The clk_set_rate() API will internally disable the clock, if the clock
> > chip requires it. See `CLK_SET_RATE_GATE` flag.
> Sorry, I misremembered. If `CLK_SET_RATE_GATE` is set `set_rate` will
> return an error if the clock is enabled when `set_rate` is called.
Thanks for chasing that down.
In that case I definitely don't want to take this without input from those
who can test it!
Jonathan
> >
> > But I tend to agree, the better idiom is to `set_rate` we should do
> > that before `enable`. This will avoid any unintentional glitches on
> > the clock signal
> >
>
next prev parent reply other threads:[~2022-08-20 11:32 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-08 20:47 [PATCH 01/13] iio: adc: ad7124: Benefit from devm_clk_get_enabled() to simplify Uwe Kleine-König
2022-08-08 20:47 ` [PATCH 02/13] iio: adc: ad7768-1: " Uwe Kleine-König
2022-08-08 20:47 ` [PATCH 03/13] iio: adc: ad9467: " Uwe Kleine-König
2022-08-08 20:47 ` [PATCH 04/13] iio: adc: ad9467: Benefit from devm_clk_get_prepared() " Uwe Kleine-König
2022-08-08 21:01 ` Andy Shevchenko
2022-08-09 5:37 ` [PATCH 04/13] iio: adc: ingenic-adc: " Uwe Kleine-König
2022-08-13 16:19 ` Jonathan Cameron
2022-08-08 20:47 ` [PATCH 05/13] iio: adc: lpc18xx: Benefit from devm_clk_get_enabled() " Uwe Kleine-König
2022-08-13 16:25 ` Jonathan Cameron
2022-08-08 20:47 ` [PATCH 06/13] iio: adc: rockchip_saradc: " Uwe Kleine-König
2022-08-13 16:31 ` Jonathan Cameron
2022-08-14 19:01 ` Andy Shevchenko
2022-08-14 21:30 ` Uwe Kleine-König
2022-08-15 7:30 ` Andy Shevchenko
2022-08-15 7:41 ` Uwe Kleine-König
2022-08-16 8:20 ` Andy Shevchenko
2022-08-16 8:27 ` Lars-Peter Clausen
2022-08-16 8:38 ` Lars-Peter Clausen
2022-08-20 11:42 ` Jonathan Cameron [this message]
2022-08-08 20:47 ` [PATCH 07/13] iio: adc: ti-ads131e08: " Uwe Kleine-König
2022-08-08 20:47 ` [PATCH 08/13] iio: adc: xilinx-ams: " Uwe Kleine-König
2022-08-08 20:47 ` [PATCH 09/13] iio: adc: xilinx-xadc: " Uwe Kleine-König
2022-08-08 20:47 ` [PATCH 10/13] iio: frequency: adf4371: " Uwe Kleine-König
2022-08-08 20:47 ` [PATCH 11/13] iio: frequency: admv1013: " Uwe Kleine-König
2022-08-13 16:37 ` Jonathan Cameron
2022-08-14 19:04 ` Andy Shevchenko
2022-08-20 11:45 ` Jonathan Cameron
2022-08-08 20:47 ` [PATCH 12/13] iio: frequency: adrf6780: " Uwe Kleine-König
2022-08-08 20:47 ` [PATCH 13/13] iio: imu: adis16475: " Uwe Kleine-König
2022-08-13 16:39 ` [PATCH 01/13] iio: adc: ad7124: " Jonathan Cameron
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=20220820124235.223d4a7e@jic23-huawei \
--to=jic23@kernel.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=Michael.Hennerich@analog.com \
--cc=anand.ashok.dumbre@xilinx.com \
--cc=andy.shevchenko@gmail.com \
--cc=antoniu.miclaus@analog.com \
--cc=david.wu@rock-chips.com \
--cc=heiko@sntech.de \
--cc=kernel@pengutronix.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=michal.simek@xilinx.com \
--cc=nuno.sa@analog.com \
--cc=paul@crapouillou.net \
--cc=u.kleine-koenig@pengutronix.de \
--cc=vz@mleia.com \
--cc=xxm@rock-chips.com \
/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