[clocksource: timers/drivers/next] clocksource/drivers/timer-mediatek: Enable the GPT irq before registering
From: clocksource-bot for Ryan Brue
Date: Fri Nov 27 2026 - 04:28:08 EST
The following commit has been merged into the timers/drivers/next branch of clocksource:
Commit-ID: a3c327ed541199b2ab2bec6d6f130b56cba767ee
Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/daniel.lezcano/linux.git//a3c327ed541199b2ab2bec6d6f130b56cba767ee
Author: Ryan Brue <ryanbrue.dev@xxxxxxxxx>
AuthorDate: Wed, 25 Nov 2026 23:13:50 -06:00
Committer: Daniel Lezcano <daniel.lezcano@xxxxxxxxxx>
CommitterDate: Thu, 26 Nov 2026 10:47:12 +01:00
clocksource/drivers/timer-mediatek: Enable the GPT irq before registering
Since the driver probes as a platform device, the GPT clock event is
registered late in boot, when PSCI CPU idle may already have put CPUs
into a state that stops their local timer. Those CPUs wait in the
oneshot broadcast mask on the hrtimer broadcast, and
tick_install_broadcast_device() arms the new broadcast device to expire
at once so that it wakes them.
mtk_gpt_init() sets the timer's bit in GPT_IRQ_EN only after
clockevents_config_and_register(). The forced event fires while the bit
is clear, the status register stays clear, and the waiting CPUs are
never woken. On an MT8173 tablet with the CPU_SLEEP_0 idle state in
use, this hung the boot in 20 of 40 boots; with this change it booted
16 of 16.
Enable the interrupt before registering the clock event. The IRQ line
stays disabled until enable_irq(), so the handler still can't run before
the clock event is set up. With the bit set, the timer that
mtk_gpt_setup() leaves running could latch an interrupt that
registration doesn't acknowledge, the kind of pending interrupt that
commit fc686d0037d7 ("clockevents/drivers/mtk: Fix spurious interrupt
leading to crash") acknowledges in mtk_gpt_enable_irq(). So stop the
timer before enabling the interrupt, until the core programs an event.
Fixes: 7a097aba7255 ("clocksource/drivers/timer-mediatek: Convert to OF probing")
Signed-off-by: Ryan Brue <ryanbrue.dev@xxxxxxxxx>
Signed-off-by: Daniel Lezcano <daniel.lezcano@xxxxxxxxxx>
Reviewed-by: Chen-Yu Tsai <wenst@xxxxxxxxxxxx>
Tested-by: Luca Leonardo Scorcia <l.scorcia@xxxxxxxxx> # MT8167 Sony PSC Mini
Tested-by: Chen-Yu Tsai <wenst@xxxxxxxxxxxx> # MT8173 Hana (Telesu)
Link: https://patch.msgid.link/20261125-timer-mediatek-gpt-irq-order-v2-1-e9e793bd87d4@xxxxxxxxx
---
drivers/clocksource/timer-mediatek.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/clocksource/timer-mediatek.c b/drivers/clocksource/timer-mediatek.c
index 764c30c..48a9ebf 100644
--- a/drivers/clocksource/timer-mediatek.c
+++ b/drivers/clocksource/timer-mediatek.c
@@ -352,10 +352,12 @@ static int mtk_gpt_init(struct platform_device *pdev)
/* Configure clock event */
mtk_gpt_setup(&to, TIMER_CLK_EVT, GPT_CTRL_OP_REPEAT);
+ /* Stop it so that nothing is pending when its irq is enabled */
+ mtk_gpt_clkevt_time_stop(&to, TIMER_CLK_EVT);
+ mtk_gpt_enable_irq(&to, TIMER_CLK_EVT);
clockevents_config_and_register(&to.clkevt, timer_of_rate(&to),
TIMER_SYNC_TICKS, 0xffffffff);
- mtk_gpt_enable_irq(&to, TIMER_CLK_EVT);
enable_irq(timer_of_irq(&to));
return 0;