* [PATCH v2] clk: scmi: migrate round_rate() to determine_rate()
@ 2025-08-27 17:12 Brian Masney
2025-08-29 10:00 ` Sudeep Holla
2025-08-29 10:09 ` Peng Fan
0 siblings, 2 replies; 5+ messages in thread
From: Brian Masney @ 2025-08-27 17:12 UTC (permalink / raw)
To: Sudeep Holla, Cristian Marussi, Michael Turquette, Stephen Boyd
Cc: arm-scmi, linux-arm-kernel, linux-clk, linux-kernel, Brian Masney
This driver implements both the determine_rate() and round_rate() clk
ops, and the round_rate() clk ops is deprecated. When both are defined,
clk_core_determine_round_nolock() from the clk core will only use the
determine_rate() clk ops.
The existing scmi_clk_determine_rate() is a noop implementation that
lets the firmware round the rate as appropriate. Drop the existing
determine_rate implementation and convert the existing round_rate()
implementation over to determine_rate().
scmi_clk_determine_rate() was added recently when the clock parent
support was added, so it's not expected that this change will regress
anything.
Signed-off-by: Brian Masney <bmasney@redhat.com>
---
Changes since v1:
- Split out individual patch from larger v1 114 patch series
- Drop noop determine_rate implementation; convert round_rate
---
drivers/clk/clk-scmi.c | 35 ++++++++++++++++-------------------
1 file changed, 16 insertions(+), 19 deletions(-)
diff --git a/drivers/clk/clk-scmi.c b/drivers/clk/clk-scmi.c
index d2408403283fc72f0cf902e65f4c08bcbc7b4b0b..78dd2d9c7cabd18f2a05cffd0408cfefaf34fce0 100644
--- a/drivers/clk/clk-scmi.c
+++ b/drivers/clk/clk-scmi.c
@@ -54,8 +54,8 @@ static unsigned long scmi_clk_recalc_rate(struct clk_hw *hw,
return rate;
}
-static long scmi_clk_round_rate(struct clk_hw *hw, unsigned long rate,
- unsigned long *parent_rate)
+static int scmi_clk_determine_rate(struct clk_hw *hw,
+ struct clk_rate_request *req)
{
u64 fmin, fmax, ftmp;
struct scmi_clk *clk = to_scmi_clk(hw);
@@ -67,20 +67,27 @@ static long scmi_clk_round_rate(struct clk_hw *hw, unsigned long rate,
* running at then.
*/
if (clk->info->rate_discrete)
- return rate;
+ return 0;
fmin = clk->info->range.min_rate;
fmax = clk->info->range.max_rate;
- if (rate <= fmin)
- return fmin;
- else if (rate >= fmax)
- return fmax;
+ if (req->rate <= fmin) {
+ req->rate = fmin;
+
+ return 0;
+ } else if (req->rate >= fmax) {
+ req->rate = fmax;
- ftmp = rate - fmin;
+ return 0;
+ }
+
+ ftmp = req->rate - fmin;
ftmp += clk->info->range.step_size - 1; /* to round up */
do_div(ftmp, clk->info->range.step_size);
- return ftmp * clk->info->range.step_size + fmin;
+ req->rate = ftmp * clk->info->range.step_size + fmin;
+
+ return 0;
}
static int scmi_clk_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -119,15 +126,6 @@ static u8 scmi_clk_get_parent(struct clk_hw *hw)
return p_idx;
}
-static int scmi_clk_determine_rate(struct clk_hw *hw, struct clk_rate_request *req)
-{
- /*
- * Suppose all the requested rates are supported, and let firmware
- * to handle the left work.
- */
- return 0;
-}
-
static int scmi_clk_enable(struct clk_hw *hw)
{
struct scmi_clk *clk = to_scmi_clk(hw);
@@ -300,7 +298,6 @@ scmi_clk_ops_alloc(struct device *dev, unsigned long feats_key)
/* Rate ops */
ops->recalc_rate = scmi_clk_recalc_rate;
- ops->round_rate = scmi_clk_round_rate;
ops->determine_rate = scmi_clk_determine_rate;
if (feats_key & BIT(SCMI_CLK_RATE_CTRL_SUPPORTED))
ops->set_rate = scmi_clk_set_rate;
---
base-commit: 3c642997252eef4449cb6b6e02af3dc22515d817
change-id: 20250827-clk-scmi-round-rate-7e3d4099134a
Best regards,
--
Brian Masney <bmasney@redhat.com>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] clk: scmi: migrate round_rate() to determine_rate()
2025-08-29 10:09 ` Peng Fan
@ 2025-08-29 9:59 ` Sudeep Holla
2025-08-29 13:33 ` Peng Fan
0 siblings, 1 reply; 5+ messages in thread
From: Sudeep Holla @ 2025-08-29 9:59 UTC (permalink / raw)
To: Peng Fan
Cc: Brian Masney, Cristian Marussi, Sudeep Holla, Michael Turquette,
Stephen Boyd, arm-scmi, linux-arm-kernel, linux-clk, linux-kernel
On Fri, Aug 29, 2025 at 06:09:03PM +0800, Peng Fan wrote:
> On Wed, Aug 27, 2025 at 01:12:07PM -0400, Brian Masney wrote:
> >This driver implements both the determine_rate() and round_rate() clk
> >ops, and the round_rate() clk ops is deprecated. When both are defined,
> >clk_core_determine_round_nolock() from the clk core will only use the
> >determine_rate() clk ops.
> >
> >The existing scmi_clk_determine_rate() is a noop implementation that
> >lets the firmware round the rate as appropriate. Drop the existing
> >determine_rate implementation and convert the existing round_rate()
> >implementation over to determine_rate().
> >
> >scmi_clk_determine_rate() was added recently when the clock parent
> >support was added, so it's not expected that this change will regress
> >anything.
> >
> >Signed-off-by: Brian Masney <bmasney@redhat.com>
>
> Reviewed-by: Peng Fan <peng.fan@nxp.com>
Peng,
It would be great if you can test it with parent clock support on i.MX
platforms just to be sure this doesn't regress anything.
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] clk: scmi: migrate round_rate() to determine_rate()
2025-08-27 17:12 [PATCH v2] clk: scmi: migrate round_rate() to determine_rate() Brian Masney
@ 2025-08-29 10:00 ` Sudeep Holla
2025-08-29 10:09 ` Peng Fan
1 sibling, 0 replies; 5+ messages in thread
From: Sudeep Holla @ 2025-08-29 10:00 UTC (permalink / raw)
To: Brian Masney
Cc: Cristian Marussi, Sudeep Holla, Michael Turquette, Stephen Boyd,
arm-scmi, linux-arm-kernel, linux-clk, linux-kernel
On Wed, Aug 27, 2025 at 01:12:07PM -0400, Brian Masney wrote:
> This driver implements both the determine_rate() and round_rate() clk
> ops, and the round_rate() clk ops is deprecated. When both are defined,
> clk_core_determine_round_nolock() from the clk core will only use the
> determine_rate() clk ops.
>
> The existing scmi_clk_determine_rate() is a noop implementation that
> lets the firmware round the rate as appropriate. Drop the existing
> determine_rate implementation and convert the existing round_rate()
> implementation over to determine_rate().
>
> scmi_clk_determine_rate() was added recently when the clock parent
> support was added, so it's not expected that this change will regress
> anything.
>
Changes LGTM,
Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
I assume it can go via clk tree.
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] clk: scmi: migrate round_rate() to determine_rate()
2025-08-27 17:12 [PATCH v2] clk: scmi: migrate round_rate() to determine_rate() Brian Masney
2025-08-29 10:00 ` Sudeep Holla
@ 2025-08-29 10:09 ` Peng Fan
2025-08-29 9:59 ` Sudeep Holla
1 sibling, 1 reply; 5+ messages in thread
From: Peng Fan @ 2025-08-29 10:09 UTC (permalink / raw)
To: Brian Masney
Cc: Sudeep Holla, Cristian Marussi, Michael Turquette, Stephen Boyd,
arm-scmi, linux-arm-kernel, linux-clk, linux-kernel
On Wed, Aug 27, 2025 at 01:12:07PM -0400, Brian Masney wrote:
>This driver implements both the determine_rate() and round_rate() clk
>ops, and the round_rate() clk ops is deprecated. When both are defined,
>clk_core_determine_round_nolock() from the clk core will only use the
>determine_rate() clk ops.
>
>The existing scmi_clk_determine_rate() is a noop implementation that
>lets the firmware round the rate as appropriate. Drop the existing
>determine_rate implementation and convert the existing round_rate()
>implementation over to determine_rate().
>
>scmi_clk_determine_rate() was added recently when the clock parent
>support was added, so it's not expected that this change will regress
>anything.
>
>Signed-off-by: Brian Masney <bmasney@redhat.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] clk: scmi: migrate round_rate() to determine_rate()
2025-08-29 9:59 ` Sudeep Holla
@ 2025-08-29 13:33 ` Peng Fan
0 siblings, 0 replies; 5+ messages in thread
From: Peng Fan @ 2025-08-29 13:33 UTC (permalink / raw)
To: Sudeep Holla
Cc: Brian Masney, Cristian Marussi, Michael Turquette, Stephen Boyd,
arm-scmi, linux-arm-kernel, linux-clk, linux-kernel
On Fri, Aug 29, 2025 at 10:59:15AM +0100, Sudeep Holla wrote:
>On Fri, Aug 29, 2025 at 06:09:03PM +0800, Peng Fan wrote:
>> On Wed, Aug 27, 2025 at 01:12:07PM -0400, Brian Masney wrote:
>> >This driver implements both the determine_rate() and round_rate() clk
>> >ops, and the round_rate() clk ops is deprecated. When both are defined,
>> >clk_core_determine_round_nolock() from the clk core will only use the
>> >determine_rate() clk ops.
>> >
>> >The existing scmi_clk_determine_rate() is a noop implementation that
>> >lets the firmware round the rate as appropriate. Drop the existing
>> >determine_rate implementation and convert the existing round_rate()
>> >implementation over to determine_rate().
>> >
>> >scmi_clk_determine_rate() was added recently when the clock parent
>> >support was added, so it's not expected that this change will regress
>> >anything.
>> >
>> >Signed-off-by: Brian Masney <bmasney@redhat.com>
>>
>> Reviewed-by: Peng Fan <peng.fan@nxp.com>
>
>Peng,
>
>It would be great if you can test it with parent clock support on i.MX
>platforms just to be sure this doesn't regress anything.
Just gave a test on i.MX95-EVK, it boots well and eth0 works,
the results in /sys/kernel/debug/clk/clk_summary also looks correct.
Tested-by: Peng Fan <peng.fan@nxp.com> #i.MX95-19x19-EVK
Regards
Peng
>
>--
>Regards,
>Sudeep
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-08-29 12:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-27 17:12 [PATCH v2] clk: scmi: migrate round_rate() to determine_rate() Brian Masney
2025-08-29 10:00 ` Sudeep Holla
2025-08-29 10:09 ` Peng Fan
2025-08-29 9:59 ` Sudeep Holla
2025-08-29 13:33 ` Peng Fan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).