From: Chuan Liu <chuan.liu@amlogic.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Viresh Kumar <vireshk@kernel.org>, Nishanth Menon <nm@ti.com>,
Stephen Boyd <sboyd@kernel.org>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
kelvin.zhang@amlogic.com, Xianwei Zhao <xianwei.zhao@amlogic.com>
Subject: Re: [PATCH] opp: Allow multiple clocks for primary clock operations
Date: Fri, 4 Dec 2026 15:14:06 +0800 [thread overview]
Message-ID: <d162aba9-9f42-43c5-9eef-72cdde5732b8@amlogic.com> (raw)
In-Reply-To: <axFFEsXCqN0JyPPF@vireshk-B250M-D3H>
Hi Viresh,
Thanks for the clarification.
On 12/3/2026 6:31 PM, Viresh Kumar wrote:
> [ EXTERNAL EMAIL ]
>
> On 01-12-26, 21:01, Chuan Liu wrote:
>> OPP core uses opp_table->clk as the primary clock in several paths, e.g.:
>>
>> dev_pm_opp_set_rate()
>
> Right and using the simple set-rate routine for a multi-clock device is
> incorrect.
I fully understand that this is not a good approach and this
modification breaks the previous boundary between single-clk and multi-clk.
> We need a different routine for that. Keeping clk as Error in that
> case is the right thing to do.. We only agreed to change the assert, as
> single-clk assert == clk[0] assert (as index sent is 0 in those cases)..
I think we should keep the existing single-clock OPP APIs unchanged and
introduce indexed variants, this will also keep the assert_single_clk()
in the function that supports single-clk, for example:
- dev_pm_opp_init_cpufreq_table_indexed()
- dev_pm_opp_set_rate_indexed()
The idea is to let cpufreq-dt specify a primary clock index for OPP
lookup and frequency selection, while the OPP core's config_clks()
callback continues to configure all clocks associated with the selected OPP.
One detail is that the OPP core has different clock initialization
paths. In the default single-clock path, opp_table->clk is populated
without necessarily having opp_table->clks[] available. Therefore,
simply making the existing APIs wrappers around the indexed variants
(using index 0) may not preserve the existing behavior.
To handle this, cpufreq_dt_platform_data could provide a
*primary_clk_index* and a *have_multi_clk* flag. cpufreq-dt would use
the existing APIs for single-clock platforms and the indexed variants
only when multi-clock support is enabled. This would avoid changing the
existing single-clock API semantics, for example:
@@ -53,7 +53,10 @@ static int set_target(struct cpufreq_policy *policy,
unsigned int index)
struct private_data *priv = policy->driver_data;
unsigned long freq = policy->freq_table[index].frequency;
- return dev_pm_opp_set_rate(priv->cpu_dev, freq * 1000);
+ if (!data->have_multi_clk)
+ return dev_pm_opp_set_rate(priv->cpu_dev, freq * 1000);
+ else
+ return dev_pm_opp_set_rate_indexed(priv->cpu_dev, freq *
1000, data->primary_clk_index);
Would you consider this approach acceptable? If not, I'd appreciate your
suggestion on how best to support this use case without weakening the
existing single-clock restrictions.
>
> I thought your code worked fine with just that change.
Sorry, I didn't bring this up for your opinion in the previous thread.
>
> --
> viresh
More generally, I think supporting multiple clocks in cpufreq-dt is
becoming increasingly important. It already supports multiple
regulators, and as SoCs adopt finer-grained clock and voltage control to
optimize CPU dynamic power, coordinated scaling of multiple clocks will
become more common. Supporting multiple clocks would therefore be a
natural extension of cpufreq-dt.
--
Best regards,
Chuan
prev parent reply other threads:[~2026-12-04 7:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 9:34 Chuan Liu via B4 Relay
2026-12-01 10:12 ` Viresh Kumar
2026-12-01 13:01 ` Chuan Liu
2026-12-01 13:50 ` Zhongqiu Han
2026-12-04 7:17 ` Chuan Liu
2026-12-03 10:31 ` Viresh Kumar
2026-12-04 7:14 ` Chuan Liu [this message]
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=d162aba9-9f42-43c5-9eef-72cdde5732b8@amlogic.com \
--to=chuan.liu@amlogic.com \
--cc=kelvin.zhang@amlogic.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=nm@ti.com \
--cc=sboyd@kernel.org \
--cc=viresh.kumar@linaro.org \
--cc=vireshk@kernel.org \
--cc=xianwei.zhao@amlogic.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
all inboxes | Powered by JetHome®