tick: Do not set device to detached state in tick_shutdown()
authorBibo Mao <maobibo@loongson.cn>
Sat, 6 Sep 2025 06:49:51 +0000 (14:49 +0800)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 9 Sep 2025 11:39:00 +0000 (13:39 +0200)
commitfe2a449a45b13df1562419e0104b4777b6ea5248
treef37875d3d9132b30ab521abeeb98fff852a6c15a
parent3c3af563b31766f67106c7549ad084a08ef613f2
tick: Do not set device to detached state in tick_shutdown()

tick_shutdown() sets the state of the clockevent device to detached
first and the invokes clockevents_exchange_device(), which in turn
invokes clockevents_switch_state().

But clockevents_switch_state() returns without invoking the device shutdown
callback as the device is already in detached state. As a consequence the
timer device is not shutdown when a CPU goes offline.

tick_shutdown() does this because it was originally invoked on a online CPU
and not on the outgoing CPU. It therefore could not access the clockevent
device of the already offlined CPU and just set the state.

Since commit 3b1596a21fbf tick_shutdown() is called on the outgoing CPU, so
the hardware device can be accessed.

Remove the state set before calling clockevents_exchange_device(), so that
the subsequent clockevents_switch_state() handles the state transition and
invokes the shutdown callback of the clockevent device.

[ tglx: Massaged change log ]

Fixes: 3b1596a21fbf ("clockevents: Shutdown and unregister current clockevents at CPUHP_AP_TICK_DYING")
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Link: https://lore.kernel.org/all/20250906064952.3749122-2-maobibo@loongson.cn
kernel/time/clockevents.c
kernel/time/tick-common.c
kernel/time/tick-internal.h