lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250415090655.GA10243@nxa18884-linux>
Date: Tue, 15 Apr 2025 17:06:55 +0800
From: Peng Fan <peng.fan@....nxp.com>
To: Mike Tipton <quic_mdtipton@...cinc.com>
Cc: Sudeep Holla <sudeep.holla@....com>,
	Cristian Marussi <cristian.marussi@....com>,
	"Rafael J . Wysocki" <rafael@...nel.org>,
	Viresh Kumar <viresh.kumar@...aro.org>, arm-scmi@...r.kernel.org,
	linux-arm-kernel@...ts.infradead.org, linux-pm@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] cpufreq: scmi: Skip SCMI devices that aren't used by the
 CPUs

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@...cinc.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
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ