Messages in this thread Patch in this message | | | From | Qais Yousef <> | Subject | [PATCH 02/12] x86: Replace cpu_up/down with devcie_online/offline | Date | Wed, 30 Oct 2019 15:38:27 +0000 |
| |
The core device API performs extra housekeeping bits that are missing from directly calling cpu_up/down.
See commit a6717c01ddc2 ("powerpc/rtas: use device model APIs and serialization during LPM") for an example description of what might go wrong.
This also prepares to make cpu_up/down a private interface for anything but the cpu subsystem.
Signed-off-by: Qais Yousef <qais.yousef@arm.com> CC: Thomas Gleixner <tglx@linutronix.de> CC: Ingo Molnar <mingo@redhat.com> CC: Borislav Petkov <bp@alien8.de> CC: "H. Peter Anvin" <hpa@zytor.com> CC: x86@kernel.org CC: linux-kernel@vger.kernel.org --- arch/x86/kernel/topology.c | 4 ++-- arch/x86/mm/mmio-mod.c | 8 ++++++-- arch/x86/xen/smp.c | 4 +++- 3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kernel/topology.c b/arch/x86/kernel/topology.c index be5bc2e47c71..3b253088615e 100644 --- a/arch/x86/kernel/topology.c +++ b/arch/x86/kernel/topology.c @@ -69,7 +69,7 @@ int _debug_hotplug_cpu(int cpu, int action) switch (action) { case 0: - ret = cpu_down(cpu); + ret = device_offline(get_cpu_device(cpu)); if (!ret) { pr_info("DEBUG_HOTPLUG_CPU0: CPU %u is now offline\n", cpu); dev->offline = true; @@ -78,7 +78,7 @@ int _debug_hotplug_cpu(int cpu, int action) pr_debug("Can't offline CPU%d.\n", cpu); break; case 1: - ret = cpu_up(cpu); + ret = device_online(get_cpu_device(cpu)); if (!ret) { dev->offline = false; kobject_uevent(&dev->kobj, KOBJ_ONLINE); diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c index b8ef8557d4b3..7ec7d05335ce 100644 --- a/arch/x86/mm/mmio-mod.c +++ b/arch/x86/mm/mmio-mod.c @@ -385,13 +385,15 @@ static void enter_uniprocessor(void) pr_notice("Disabling non-boot CPUs...\n"); put_online_cpus(); + lock_device_hotplug(); for_each_cpu(cpu, downed_cpus) { - err = cpu_down(cpu); + err = device_offline(get_cpu_device(cpu)); if (!err) pr_info("CPU%d is down.\n", cpu); else pr_err("Error taking CPU%d down: %d\n", cpu, err); } + unlock_device_hotplug(); out: if (num_online_cpus() > 1) pr_warning("multiple CPUs still online, may miss events.\n"); @@ -405,13 +407,15 @@ static void leave_uniprocessor(void) if (downed_cpus == NULL || cpumask_weight(downed_cpus) == 0) return; pr_notice("Re-enabling CPUs...\n"); + lock_device_hotplug(); for_each_cpu(cpu, downed_cpus) { - err = cpu_up(cpu); + err = device_online(get_cpu_device(cpu)); if (!err) pr_info("enabled CPU%d.\n", cpu); else pr_err("cannot re-enable CPU%d: %d\n", cpu, err); } + unlock_device_hotplug(); } #else /* !CONFIG_HOTPLUG_CPU */ diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c index 7a43b2ae19f1..aaa31100a31e 100644 --- a/arch/x86/xen/smp.c +++ b/arch/x86/xen/smp.c @@ -128,11 +128,12 @@ void __init xen_smp_cpus_done(unsigned int max_cpus) if (xen_have_vcpu_info_placement) return; + lock_device_hotplug(); for_each_online_cpu(cpu) { if (xen_vcpu_nr(cpu) < MAX_VIRT_CPUS) continue; - rc = cpu_down(cpu); + rc = device_offline(get_cpu_device(cpu)); if (rc == 0) { /* @@ -145,6 +146,7 @@ void __init xen_smp_cpus_done(unsigned int max_cpus) __func__, cpu, rc); } } + unlock_device_hotplug(); WARN(count, "%s: brought %d CPUs offline\n", __func__, count); } -- 2.17.1
| |