From 495cd696b0448d20336701a4233c2021003f3930 Mon Sep 17 00:00:00 2001 From: Dave Aldridge Date: Fri, 24 Mar 2017 06:01:00 -0600 Subject: [PATCH] sparc64: fix an issue when trying to bring hotplug cpus online When booting the kernel with maxcpus= on the command line and then subsequently trying to bring cpus online using: echo 1 > /sys/devices/system/cpu/cpu[n]/online messages of the form: ldom_startcpu_cpuid: sun4v_cpu_start() gives error 6 Processor[n] is stuck were being reported on the console. This commit fixes this issue by ensuring that any cpus not booted during initial kernel boot are explicitly stopped. This then allows them to be successfully brought online later if required. Orabug: 25667277 Signed-off-by: Dave Aldridge Reviewed-by: Shannon Nelson Reviewed-by: Allen Pais Signed-off-by: Allen Pais --- arch/sparc/kernel/smp_64.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c index 8b18c56717ba..6db80e106ab0 100644 --- a/arch/sparc/kernel/smp_64.c +++ b/arch/sparc/kernel/smp_64.c @@ -1462,6 +1462,30 @@ void __cpu_die(unsigned int cpu) void __init smp_cpus_done(unsigned int max_cpus) { +#if defined(CONFIG_SUN_LDOMS) && defined(CONFIG_HOTPLUG_CPU) + unsigned long hv_err; + int cpu; + + if (num_present_cpus() == num_online_cpus()) { + /* All present cpus are online, + * nothing to do here + */ + return; + } + + /* Stop the cpus currently not online, so that we + * can bring them online later if required + */ + for_each_present_cpu(cpu) { + if (!cpu_online(cpu) && + (sun4v_cpu_state(cpu) != HV_CPU_STATE_STOPPED)) { + hv_err = sun4v_cpu_stop(cpu); + if (hv_err) + pr_err("%s: sun4v_cpu_stop() fails err=%lu\n", + __func__, hv_err); + } + } +#endif } void smp_send_reschedule(int cpu) -- 2.50.1