Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powercap: DTPM: Fix suspend failure and kernel warning

When the ENERGY_MODEL and DTPM_CPU are enabled but actually without
any energy model, at cpu hotplug time, the dead cpuhp callback fails
leading to the warning.

Actually, the check could be simplified and we only do an action if
the dtpm cpu is enabled, otherwise we bail out without error.

Fixes: 7a89d7eacf8e ("powercap/drivers/dtpm: Simplify the dtpm table")
Reported-by: Kenneth R. Crudup <kenny@panix.com>
Tested-by: Kenneth R. Crudup <kenny@panix.com>
Reported-by: kernel test robot <oliver.sang@intel.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Daniel Lezcano and committed by
Rafael J. Wysocki
4d1cd144 88100752

+3 -6
+3 -6
drivers/powercap/dtpm_cpu.c
··· 166 166 167 167 static int cpuhp_dtpm_cpu_offline(unsigned int cpu) 168 168 { 169 - struct em_perf_domain *pd; 170 169 struct dtpm_cpu *dtpm_cpu; 171 170 172 - pd = em_cpu_get(cpu); 173 - if (!pd) 174 - return -EINVAL; 175 - 176 171 dtpm_cpu = per_cpu(dtpm_per_cpu, cpu); 172 + if (dtpm_cpu) 173 + dtpm_update_power(&dtpm_cpu->dtpm); 177 174 178 - return dtpm_update_power(&dtpm_cpu->dtpm); 175 + return 0; 179 176 } 180 177 181 178 static int cpuhp_dtpm_cpu_online(unsigned int cpu)