1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2020 Western Digital Corporation or its affiliates.
6 #include <linux/kernel.h>
8 #include <linux/sched.h>
10 #include <linux/irq.h>
11 #include <linux/cpuhotplug.h>
12 #include <linux/cpu.h>
13 #include <linux/sched/hotplug.h>
15 #include <asm/cpu_ops.h>
19 bool cpu_has_hotplug(unsigned int cpu)
21 if (cpu_ops[cpu]->cpu_stop)
28 * __cpu_disable runs on the processor to be shutdown.
30 int __cpu_disable(void)
33 unsigned int cpu = smp_processor_id();
35 if (!cpu_ops[cpu] || !cpu_ops[cpu]->cpu_stop)
38 if (cpu_ops[cpu]->cpu_disable)
39 ret = cpu_ops[cpu]->cpu_disable(cpu);
44 remove_cpu_topology(cpu);
46 set_cpu_online(cpu, false);
48 irq_migrate_all_off_this_cpu();
53 #ifdef CONFIG_HOTPLUG_CPU
55 * Called on the thread which is asking for a CPU to be shutdown, if the
56 * CPU reported dead to the hotplug core.
58 void arch_cpuhp_cleanup_dead_cpu(unsigned int cpu)
62 pr_notice("CPU%u: off\n", cpu);
64 /* Verify from the firmware if the cpu is really stopped*/
65 if (cpu_ops[cpu]->cpu_is_stopped)
66 ret = cpu_ops[cpu]->cpu_is_stopped(cpu);
68 pr_warn("CPU%d may not have stopped: %d\n", cpu, ret);
72 * Called from the idle thread for the CPU which has been shutdown.
74 void __noreturn arch_cpu_idle_dead(void)
78 cpuhp_ap_report_dead();
80 cpu_ops[smp_processor_id()]->cpu_stop();
81 /* It should never reach here */