From: Peng Fan <peng.fan@oss.nxp.com>
To: Mike Tipton <quic_mdtipton@quicinc.com>
Cc: Sudeep Holla <sudeep.holla@arm.com>,
Cristian Marussi <cristian.marussi@arm.com>,
"Rafael J . Wysocki" <rafael@kernel.org>,
Viresh Kumar <viresh.kumar@linaro.org>,
arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cpufreq: scmi: Skip SCMI devices that aren't used by the CPUs
Date: Mon, 14 Apr 2025 16:38:32 +0800 [thread overview]
Message-ID: <20250414083832.GA19563@nxa18884-linux> (raw)
In-Reply-To: <20250411212941.1275572-1-quic_mdtipton@quicinc.com>
Hi Mike,
On Fri, Apr 11, 2025 at 02:29:41PM -0700, Mike Tipton wrote:
>Currently, all SCMI devices with performance domains attempt to register
>a cpufreq driver,
The scmi cpufreq device is created based on entry
{ SCMI_PROTOCOL_PERF, "cpufreq" },
So the scmi-cpufreq driver could only probe the upper single device.
How could the driver work with all SCMI devices with performance domains?
THanks,
Peng
even if their performance domains aren't used to
>control the CPUs. The cpufreq framework only supports registering a
>single driver, so only the first device will succeed. And if that device
>isn't used for the CPUs, then cpufreq will scale the wrong domains.
>
>To avoid this, return early from scmi_cpufreq_probe() if the probing
>SCMI device isn't referenced by the CPU device phandles.
>
>This keeps the existing assumption that all CPUs are controlled by a
>single SCMI device.
>
>Signed-off-by: Mike Tipton <quic_mdtipton@quicinc.com>
>---
> drivers/cpufreq/scmi-cpufreq.c | 29 +++++++++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
>
>diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c
>index 944e899eb1be..7981a879974b 100644
>--- a/drivers/cpufreq/scmi-cpufreq.c
>+++ b/drivers/cpufreq/scmi-cpufreq.c
>@@ -393,6 +393,32 @@ static struct cpufreq_driver scmi_cpufreq_driver = {
> .set_boost = cpufreq_boost_set_sw,
> };
>
>+static bool scmi_dev_used_by_cpus(struct device *scmi_dev)
>+{
>+ struct device_node *scmi_np = scmi_dev->of_node;
>+ struct device_node *np;
>+ struct device *cpu_dev;
>+ int cpu, idx;
>+
>+ for_each_possible_cpu(cpu) {
>+ cpu_dev = get_cpu_device(cpu);
>+ if (!cpu_dev)
>+ continue;
>+
>+ np = cpu_dev->of_node;
>+
>+ if (of_parse_phandle(np, "clocks", 0) == scmi_np)
>+ return true;
>+
>+ idx = of_property_match_string(np, "power-domain-names", "perf");
>+
>+ if (of_parse_phandle(np, "power-domains", idx) == scmi_np)
>+ return true;
>+ }
>+
>+ return false;
>+}
>+
> static int scmi_cpufreq_probe(struct scmi_device *sdev)
> {
> int ret;
>@@ -404,6 +430,9 @@ static int scmi_cpufreq_probe(struct scmi_device *sdev)
> if (!handle)
> return -ENODEV;
>
>+ if (!scmi_dev_used_by_cpus(dev))
>+ return 0;
>+
> scmi_cpufreq_driver.driver_data = sdev;
>
> perf_ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_PERF, &ph);
>--
>2.34.1
>
next prev parent reply other threads:[~2025-04-14 7:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-11 21:29 [PATCH] cpufreq: scmi: Skip SCMI devices that aren't used by the CPUs Mike Tipton
2025-04-14 8:38 ` Peng Fan [this message]
2025-04-14 8:23 ` Sudeep Holla
2025-04-14 10:28 ` Peng Fan
2025-04-14 15:34 ` Mike Tipton
2025-04-15 9:06 ` Peng Fan
2025-04-15 16:44 ` Mike Tipton
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=20250414083832.GA19563@nxa18884-linux \
--to=peng.fan@oss.nxp.com \
--cc=arm-scmi@vger.kernel.org \
--cc=cristian.marussi@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=quic_mdtipton@quicinc.com \
--cc=rafael@kernel.org \
--cc=sudeep.holla@arm.com \
--cc=viresh.kumar@linaro.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;
as well as URLs for NNTP newsgroup(s).