Re: [PATCH v2] clocksource/drivers/timer-mediatek: Enable the GPT irq before registering

From: Chen-Yu Tsai

Date: Thu Nov 26 2026 - 03:48:13 EST


On Thu, Nov 26, 2026 at 1:14 PM Ryan Brue <ryanbrue.dev@xxxxxxxxx> wrote:
>
> 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>

Reviewed-by: Chen-Yu Tsai <wenst@xxxxxxxxxxxx>
Tested-by: Chen-Yu Tsai <wenst@xxxxxxxxxxxx> # MT8173 Hana (Telesu)