The firmware may need up to 8 seconds to move a CPU into the rendezvous state, and no other PDC calls may be made meanwhile. So __cpu_die() takes pdc_lock and arch_cpuhp_cleanup_dead_cpu() releases it after waiting with schedule_timeout(). pdc_lock is a spinlock, so this sleeps in atomic context, and when the task migrates while asleep the lock is released on a different CPU than the one whose preempt count it raised: BUG: scheduling while atomic: cr16-hp.sh/1660/0x00000002 ... Preemption disabled at: pdc_cpu_rendezvous_lock+0x38/0x4c ... Backtrace: ... schedule_timeout+0xd8/0x240 arch_cpuhp_cleanup_dead_cpu+0xc0/0xf4 takedown_cpu+0x2a4/0x3f0 cpuhp_invoke_callback+0x208/0x3d8 __cpuhp_invoke_callback_range+0xbc/0x19c _cpu_down.constprop.0+0x368/0x5dc cpu_device_down+0x90/0xe8 cpu_subsys_offline+0x30/0x44 device_offline+0x1a8/0x334 online_store+0xb4/0x274 ... DEBUG_LOCKS_WARN_ON(pc - uval > pc) WARNING: kernel/sched/core.c:6092 at preempt_count_sub+0xd0/0x15c, CPU#0: cr16-hp.sh/1660 ... Backtrace: _raw_spin_unlock+0x94/0xec pdc_cpu_rendezvous_unlock+0x38/0x4c arch_cpuhp_cleanup_dead_cpu+0xe0/0xf4 takedown_cpu+0x2a4/0x3f0 ... The second warning turns lockdep off. On a C8000 that ran CPU hotplug in a loop, the machine later hung in smp_call_function_many_cond(). Busy-wait with mdelay() instead. It keeps one CPU busy for the 8 seconds (2 on 32-bit) given to the firmware, but any other CPU wanting PDC already has to spin on pdc_lock for that long. Fixes: 88b3aac6228b ("parisc: Implement __cpu_die() and __cpu_disable() for CPU hotplugging") Cc: stable@vger.kernel.org # v5.18+ Signed-off-by: Matt Turner --- arch/parisc/kernel/smp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c index a7c67032389b..2fbe4b96e96a 100644 --- a/arch/parisc/kernel/smp.c +++ b/arch/parisc/kernel/smp.c @@ -493,9 +493,8 @@ void arch_cpuhp_cleanup_dead_cpu(unsigned int cpu) { pr_info("CPU%u: is shutting down\n", cpu); - /* set task's state to interruptible sleep */ - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout((IS_ENABLED(CONFIG_64BIT) ? 8:2) * HZ); + /* pdc_lock is held, so wait for the rendezvous without sleeping */ + mdelay((IS_ENABLED(CONFIG_64BIT) ? 8 : 2) * MSEC_PER_SEC); pdc_cpu_rendezvous_unlock(); } -- 2.56.1