Lines Matching +full:cpu +full:- +full:nr
1 // SPDX-License-Identifier: GPL-2.0-or-later
17 #include <linux/cpu.h>
31 #include <asm/code-patching.h>
34 #include <asm/ppc-opcode.h>
49 static void pnv_smp_setup_cpu(int cpu) in pnv_smp_setup_cpu() argument
60 else if (cpu != boot_cpuid) in pnv_smp_setup_cpu()
64 static int pnv_smp_kick_cpu(int nr) in pnv_smp_kick_cpu() argument
72 if (nr < 0 || nr >= nr_cpu_ids) in pnv_smp_kick_cpu()
73 return -EINVAL; in pnv_smp_kick_cpu()
75 pcpu = get_hard_smp_processor_id(nr); in pnv_smp_kick_cpu()
78 * kick the CPU via the PACA in pnv_smp_kick_cpu()
80 if (paca_ptrs[nr]->cpu_start || !firmware_has_feature(FW_FEATURE_OPAL)) in pnv_smp_kick_cpu()
84 * At this point, the CPU can either be spinning on the way in in pnv_smp_kick_cpu()
91 pr_warn("OPAL Error %ld querying CPU %d state\n", rc, nr); in pnv_smp_kick_cpu()
92 return -ENODEV; in pnv_smp_kick_cpu()
106 pr_devel("OPAL: Starting CPU %d (HW 0x%x)...\n", nr, pcpu); in pnv_smp_kick_cpu()
109 pr_warn("OPAL Error %ld starting CPU %d\n", rc, nr); in pnv_smp_kick_cpu()
110 return -ENODEV; in pnv_smp_kick_cpu()
114 * An unavailable CPU (or any other unknown status) in pnv_smp_kick_cpu()
119 pr_devel("OPAL: CPU %d (HW 0x%x) is unavailable" in pnv_smp_kick_cpu()
120 " (status %d)...\n", nr, pcpu, status); in pnv_smp_kick_cpu()
121 return -ENODEV; in pnv_smp_kick_cpu()
125 return smp_generic_kick_cpu(nr); in pnv_smp_kick_cpu()
132 int cpu = smp_processor_id(); in pnv_smp_cpu_disable() local
136 * the generic fixup_irqs. --BenH. in pnv_smp_cpu_disable()
138 set_cpu_online(cpu, false); in pnv_smp_cpu_disable()
139 vdso_data->processorCount--; in pnv_smp_cpu_disable()
140 if (cpu == boot_cpuid) in pnv_smp_cpu_disable()
167 unsigned int cpu; in pnv_cpu_offline_self() local
173 cpu = smp_processor_id(); in pnv_cpu_offline_self()
174 DBG("CPU%d offline\n", cpu); in pnv_cpu_offline_self()
175 generic_set_cpu_dead(cpu); in pnv_cpu_offline_self()
183 * This turns the irq soft-disabled state we're called with, into a in pnv_cpu_offline_self()
184 * hard-disabled state with pending irq_happened interrupts cleared. in pnv_cpu_offline_self()
186 * PACA_IRQ_DEC - Decrementer should be ignored. in pnv_cpu_offline_self()
187 * PACA_IRQ_HMI - Can be ignored, processing is done in real mode. in pnv_cpu_offline_self()
188 * PACA_IRQ_DBELL, EE, PMI - Unexpected. in pnv_cpu_offline_self()
191 if (generic_check_cpu_restart(cpu)) in pnv_cpu_offline_self()
195 if (local_paca->irq_happened & unexpected_mask) { in pnv_cpu_offline_self()
196 if (local_paca->irq_happened & PACA_IRQ_EE) in pnv_cpu_offline_self()
198 DBG("CPU%d Unexpected exit while offline irq_happened=%lx!\n", in pnv_cpu_offline_self()
199 cpu, local_paca->irq_happened); in pnv_cpu_offline_self()
201 local_paca->irq_happened = PACA_IRQ_HARD_DIS; in pnv_cpu_offline_self()
208 * If the CPU gets woken up by a special wakeup, ensure that in pnv_cpu_offline_self()
210 * the CPU will come back to the kernel due to a spurious in pnv_cpu_offline_self()
214 pnv_program_cpu_hotplug_lpcr(cpu, lpcr_val); in pnv_cpu_offline_self()
216 while (!generic_check_cpu_restart(cpu)) { in pnv_cpu_offline_self()
219 * offline, except for those when changing micro-threading in pnv_cpu_offline_self()
224 kvmppc_clear_host_ipi(cpu); in pnv_cpu_offline_self()
226 srr1 = pnv_cpu_offline(cpu); in pnv_cpu_offline_self()
237 * just as some other cpu is sending us an interrupt. in pnv_cpu_offline_self()
277 if (srr1 && !generic_check_cpu_restart(cpu)) in pnv_cpu_offline_self()
278 DBG("CPU%d Unexpected exit while offline srr1=%lx!\n", in pnv_cpu_offline_self()
279 cpu, srr1); in pnv_cpu_offline_self()
284 * Re-enable decrementer interrupts in LPCR. in pnv_cpu_offline_self()
287 * for non-hotplug cases. So program the LPCR via stop api as in pnv_cpu_offline_self()
291 pnv_program_cpu_hotplug_lpcr(cpu, lpcr_val); in pnv_cpu_offline_self()
293 DBG("CPU%d coming online...\n", cpu); in pnv_cpu_offline_self()
298 static int pnv_cpu_bootable(unsigned int nr) in pnv_cpu_bootable() argument
304 * setting (smt-enabled on the kernel command line). in pnv_cpu_bootable()
309 return smp_generic_cpu_bootable(nr); in pnv_cpu_bootable()
312 static int pnv_smp_prepare_cpu(int cpu) in pnv_smp_prepare_cpu() argument
315 return xive_smp_prepare_cpu(cpu); in pnv_smp_prepare_cpu()
320 static void (*ic_cause_ipi)(int cpu);
322 static void pnv_cause_ipi(int cpu) in pnv_cause_ipi() argument
324 if (doorbell_try_core_ipi(cpu)) in pnv_cause_ipi()
327 ic_cause_ipi(cpu); in pnv_cause_ipi()
338 ic_cause_ipi = smp_ops->cause_ipi; in pnv_smp_probe()
342 smp_ops->cause_ipi = doorbell_global_ipi; in pnv_smp_probe()
344 smp_ops->cause_ipi = pnv_cause_ipi; in pnv_smp_probe()
355 static int pnv_cause_nmi_ipi(int cpu) in pnv_cause_nmi_ipi() argument
359 if (cpu >= 0) { in pnv_cause_nmi_ipi()
360 int h = get_hard_smp_processor_id(cpu); in pnv_cause_nmi_ipi()
374 } else if (cpu == NMI_IPI_ALL_OTHERS) { in pnv_cause_nmi_ipi()
379 opal_quiesce(QUIESCE_HOLD, -1); in pnv_cause_nmi_ipi()
397 opal_quiesce(QUIESCE_RESUME, -1); in pnv_cause_nmi_ipi()