* [PATCH] cpufreq: scmi: Skip SCMI devices that aren't used by the CPUs
@ 2025-04-11 21:29 Mike Tipton
2025-04-14 8:38 ` Peng Fan
2025-04-15 9:06 ` Peng Fan
0 siblings, 2 replies; 7+ messages in thread
From: Mike Tipton @ 2025-04-11 21:29 UTC (permalink / raw)
To: Sudeep Holla, Cristian Marussi, Rafael J . Wysocki, Viresh Kumar
Cc: arm-scmi, linux-arm-kernel, linux-pm, linux-kernel, Mike Tipton
Currently, all SCMI devices with performance domains attempt to register
a cpufreq driver, 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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] cpufreq: scmi: Skip SCMI devices that aren't used by the CPUs
2025-04-14 8:38 ` Peng Fan
@ 2025-04-14 8:23 ` Sudeep Holla
2025-04-14 10:28 ` Peng Fan
0 siblings, 1 reply; 7+ messages in thread
From: Sudeep Holla @ 2025-04-14 8:23 UTC (permalink / raw)
To: Peng Fan
Cc: Mike Tipton, Cristian Marussi, Sudeep Holla, Rafael J . Wysocki,
Viresh Kumar, arm-scmi, linux-arm-kernel, linux-pm, linux-kernel
Hi Peng,
On Mon, Apr 14, 2025 at 04:38:32PM +0800, Peng Fan wrote:
> 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?
>
IIUC, this is on a system with multiple SCMI servers/providers some of
which don't deal with CPU performance domains at all.
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] cpufreq: scmi: Skip SCMI devices that aren't used by the CPUs
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
2025-04-14 8:23 ` Sudeep Holla
2025-04-15 9:06 ` Peng Fan
1 sibling, 1 reply; 7+ messages in thread
From: Peng Fan @ 2025-04-14 8:38 UTC (permalink / raw)
To: Mike Tipton
Cc: Sudeep Holla, Cristian Marussi, Rafael J . Wysocki, Viresh Kumar,
arm-scmi, linux-arm-kernel, linux-pm, linux-kernel
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
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] cpufreq: scmi: Skip SCMI devices that aren't used by the CPUs
2025-04-14 8:23 ` Sudeep Holla
@ 2025-04-14 10:28 ` Peng Fan
2025-04-14 15:34 ` Mike Tipton
0 siblings, 1 reply; 7+ messages in thread
From: Peng Fan @ 2025-04-14 10:28 UTC (permalink / raw)
To: Sudeep Holla
Cc: Mike Tipton, Cristian Marussi, Rafael J . Wysocki, Viresh Kumar,
arm-scmi, linux-arm-kernel, linux-pm, linux-kernel
Hi Sudeep,
On Mon, Apr 14, 2025 at 09:23:24AM +0100, Sudeep Holla wrote:
>Hi Peng,
>
>On Mon, Apr 14, 2025 at 04:38:32PM +0800, Peng Fan wrote:
>> 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?
>>
>
>IIUC, this is on a system with multiple SCMI servers/providers some of
>which don't deal with CPU performance domains at all.
Yeah. This sounds valid case.
CPU perf only needs to be managed by one server, the other server
also has performance domains that only for peripherals.
Thanks,
Peng
>
>--
>Regards,
>Sudeep
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] cpufreq: scmi: Skip SCMI devices that aren't used by the CPUs
2025-04-14 10:28 ` Peng Fan
@ 2025-04-14 15:34 ` Mike Tipton
0 siblings, 0 replies; 7+ messages in thread
From: Mike Tipton @ 2025-04-14 15:34 UTC (permalink / raw)
To: Peng Fan
Cc: Sudeep Holla, Cristian Marussi, Rafael J . Wysocki, Viresh Kumar,
arm-scmi, linux-arm-kernel, linux-pm, linux-kernel
On Mon, Apr 14, 2025 at 06:28:14PM +0800, Peng Fan wrote:
> Hi Sudeep,
> On Mon, Apr 14, 2025 at 09:23:24AM +0100, Sudeep Holla wrote:
> >Hi Peng,
> >
> >On Mon, Apr 14, 2025 at 04:38:32PM +0800, Peng Fan wrote:
> >> 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?
> >>
> >
> >IIUC, this is on a system with multiple SCMI servers/providers some of
> >which don't deal with CPU performance domains at all.
>
> Yeah. This sounds valid case.
> CPU perf only needs to be managed by one server, the other server
> also has performance domains that only for peripherals.
Yeah, this is the case we're trying to fix.
>
> Thanks,
> Peng
>
> >
> >--
> >Regards,
> >Sudeep
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] cpufreq: scmi: Skip SCMI devices that aren't used by the CPUs
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
@ 2025-04-15 9:06 ` Peng Fan
2025-04-15 16:44 ` Mike Tipton
1 sibling, 1 reply; 7+ messages in thread
From: Peng Fan @ 2025-04-15 9:06 UTC (permalink / raw)
To: Mike Tipton
Cc: Sudeep Holla, Cristian Marussi, Rafael J . Wysocki, Viresh Kumar,
arm-scmi, linux-arm-kernel, linux-pm, linux-kernel
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, 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;
Should 'return -ENOTSUPP' be used here?
There is no need to mark the probe success.
Regards,
Peng
>+
> scmi_cpufreq_driver.driver_data = sdev;
>
> perf_ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_PERF, &ph);
>--
>2.34.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] cpufreq: scmi: Skip SCMI devices that aren't used by the CPUs
2025-04-15 9:06 ` Peng Fan
@ 2025-04-15 16:44 ` Mike Tipton
0 siblings, 0 replies; 7+ messages in thread
From: Mike Tipton @ 2025-04-15 16:44 UTC (permalink / raw)
To: Peng Fan
Cc: Sudeep Holla, Cristian Marussi, Rafael J . Wysocki, Viresh Kumar,
arm-scmi, linux-arm-kernel, linux-pm, linux-kernel
On Tue, Apr 15, 2025 at 05:06:55PM +0800, Peng Fan wrote:
> 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, 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;
>
> Should 'return -ENOTSUPP' be used here?
> There is no need to mark the probe success.
Returning -ENOTSUPP will add noise in the logs from probe failures, for
example:
scmi-cpufreq scmi_dev.4: probe with driver scmi-cpufreq failed with error -524
These are "expected" failures, so this would be misleading. However, we
could return -ENODEV instead which doesn't log anything by default. It
uses a dev_dbg() in that case:
scmi-cpufreq scmi_dev.4: probe with driver scmi-cpufreq rejects match -19
Returning -ENODEV seems more appropriate. I can make that change.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-04-15 17:08 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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).