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

cpufreq: Bring CPUs up even if cpufreq_online() failed

There is a report that after commit 27622b061eb4 ("cpufreq: Convert
to hotplug state machine"), the normal CPU offline/online cycle
fails on some platforms.

According to the ftrace result, this problem was triggered on
platforms using acpi-cpufreq as the default cpufreq driver,
and due to the lack of some ACPI freq method (eg. _PCT),
cpufreq_online() failed and returned a negative value, so the CPU
hotplug state machine rolled back the CPU online process. Actually,
from the user's perspective, the failure of cpufreq_online() should
not prevent that CPU from being brought up, although cpufreq might
not work on that CPU.

BTW, during system startup cpufreq_online() is not invoked via CPU
online but by the cpufreq device creation process, so the APs can be
brought up even though cpufreq_online() fails in that stage.

This patch ignores the return value of cpufreq_online/offline() and
lets the cpufreq framework deal with the failure. cpufreq_online()
itself will do a proper rollback in that case and if _PCT is missing,
the ACPI cpufreq driver will print a warning if the corresponding
debug options have been enabled.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=194581
Fixes: 27622b061eb4 ("cpufreq: Convert to hotplug state machine")
Reported-and-tested-by: Tomasz Maciej Nowak <tmn505@gmail.com>
Signed-off-by: Chen Yu <yu.c.chen@intel.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Cc: 4.9+ <stable@vger.kernel.org> # 4.9+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Chen Yu and committed by
Rafael J. Wysocki
c4a3fa26 39da7c50

+16 -2
+16 -2
drivers/cpufreq/cpufreq.c
··· 2398 2398 *********************************************************************/ 2399 2399 static enum cpuhp_state hp_online; 2400 2400 2401 + static int cpuhp_cpufreq_online(unsigned int cpu) 2402 + { 2403 + cpufreq_online(cpu); 2404 + 2405 + return 0; 2406 + } 2407 + 2408 + static int cpuhp_cpufreq_offline(unsigned int cpu) 2409 + { 2410 + cpufreq_offline(cpu); 2411 + 2412 + return 0; 2413 + } 2414 + 2401 2415 /** 2402 2416 * cpufreq_register_driver - register a CPU Frequency driver 2403 2417 * @driver_data: A struct cpufreq_driver containing the values# ··· 2474 2460 } 2475 2461 2476 2462 ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "cpufreq:online", 2477 - cpufreq_online, 2478 - cpufreq_offline); 2463 + cpuhp_cpufreq_online, 2464 + cpuhp_cpufreq_offline); 2479 2465 if (ret < 0) 2480 2466 goto err_if_unreg; 2481 2467 hp_online = ret;