[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240117095714.1524808-4-lukasz.luba@arm.com>
Date: Wed, 17 Jan 2024 09:56:54 +0000
From: Lukasz Luba <lukasz.luba@....com>
To: linux-kernel@...r.kernel.org,
linux-pm@...r.kernel.org,
rafael@...nel.org
Cc: lukasz.luba@....com,
dietmar.eggemann@....com,
rui.zhang@...el.com,
amit.kucheria@...durent.com,
amit.kachhap@...il.com,
daniel.lezcano@...aro.org,
viresh.kumar@...aro.org,
len.brown@...el.com,
pavel@....cz,
mhiramat@...nel.org,
qyousef@...alina.io,
wvw@...gle.com,
xuewen.yan94@...il.com
Subject: [PATCH v7 03/23] PM: EM: Find first CPU active while updating OPP efficiency
The Energy Model might be updated at runtime and the energy efficiency
for each OPP may change. Thus, there is a need to update also the
cpufreq framework and make it aligned to the new values. In order to
do that, use a first active CPU from the Performance Domain. This is
needed since the first CPU in the cpumask might be offline when we
run this code path.
Signed-off-by: Lukasz Luba <lukasz.luba@....com>
---
kernel/power/energy_model.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c
index 42486674b834..aa7c89f9e115 100644
--- a/kernel/power/energy_model.c
+++ b/kernel/power/energy_model.c
@@ -243,12 +243,19 @@ em_cpufreq_update_efficiencies(struct device *dev, struct em_perf_state *table)
struct em_perf_domain *pd = dev->em_pd;
struct cpufreq_policy *policy;
int found = 0;
- int i;
+ int i, cpu;
if (!_is_cpu_device(dev) || !pd)
return;
- policy = cpufreq_cpu_get(cpumask_first(em_span_cpus(pd)));
+ /* Try to get a CPU which is active and in this PD */
+ cpu = cpumask_first_and(em_span_cpus(pd), cpu_active_mask);
+ if (cpu >= nr_cpu_ids) {
+ dev_warn(dev, "EM: No online CPU for CPUFreq policy\n");
+ return;
+ }
+
+ policy = cpufreq_cpu_get(cpu);
if (!policy) {
dev_warn(dev, "EM: Access to CPUFreq policy failed\n");
return;
--
2.25.1
Powered by blists - more mailing lists