mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] Convert MediaTek GPT timers to OF probing
@ 2026-10-02  7:19 Luca Leonardo Scorcia
  2026-10-02  7:19 ` [PATCH 1/3] clocksource/drivers/timer-mediatek: Fix random crash at boot Luca Leonardo Scorcia
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Luca Leonardo Scorcia @ 2026-10-02  7:19 UTC (permalink / raw)
  To: linux-mediatek
  Cc: Luca Leonardo Scorcia, Daniel Lezcano, Thomas Gleixner,
	Matthias Brugger, AngeloGioacchino Del Regno, Stanley Chu,
	linux-kernel, linux-arm-kernel

While chasing a kernel freeze on the Lenovo Tab E7 TB-7104F (mt8167), I
stumbled on the MediaTek GPT timer driver. This driver is currently early
loaded via TIMER_OF_DECLARE. I noticed that on mt8167 (and I guess mt8516
too), this driver actually fails to probe because its device tree
declaration depends on two HW clocks, CLK_TOP_CLK26M_D2 (13 MHz) and
CLK_TOP_APXGPT (bus clock). However the driver providing those clocks is
loaded later in the boot process, leading TIMER_OF_DECLARE to fail with
-EDEFER.

Patch #2 converts this driver to OF probe, fixing this initial issue.

I noticed that other devices avoid this by connecting the timer to
fixed clocks instead of referring to an actual clock. This approach
may work on mt8167 too, but I think referring to the actual clock is
cleaner.

Once the driver probed successfully I noticed that even if it was enabled
by the boot loader, the kernel would quickly turn off its bus clock as
the driver wasn't actually requesting it.

Patch #3 enables it and attaches it to the timer device. I wondered how
other platforms made it actually work, and noticed that mt6735 declares it
as a critical clock. This approach might work for mt8167 too, but same
reasoning as before applies.

After those fixes the driver probes and works correctly, but I would
occasionally notice a crash at boot inside the timer interrupt handler.
It turned out to be a side effect of the bootloader enabling the GPT
timer at boot: an interrupt may arrive and be handled while the driver is
not completely initialized.

Patch #1 fixes it by requesting the IRQ but keeping it disabled and
enabling it after the clock source initialization completes. I sorted this
patch before the others because it's actually independent of the latter
two and may fix (rare) random crashes on other devices.

Please note that all the changes apply both to GPT timers and the SYST
timers, but I have no device to test the SYST ones.

The series was tested on the Sony PlayStation Classic Mini (mt8167).

Re: patch #1, credits for issue discovery and suggested fix go to
matemiller992 on postmarketOS forums. I am submitting it upstream with
permission. Not adding Reported-by or Suggested-by tags because it was
requested not to share real name.

Unfortunately, this series did not fix the tablet randomly freezing during
boot. Any idea on how to better troubleshoot this is more than welcome!

Luca Leonardo Scorcia (3):
  clocksource/drivers/timer-mediatek: Fix random crash at boot
  clocksource/drivers/timer-mediatek: Convert to OF probing
  clocksource/drivers/timer-mediatek: Request and enable the bus clock

 drivers/clocksource/timer-mediatek.c | 47 +++++++++++++++++++++++-----
 1 file changed, 40 insertions(+), 7 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-10-02  7:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-02  7:19 [PATCH 0/3] Convert MediaTek GPT timers to OF probing Luca Leonardo Scorcia
2026-10-02  7:19 ` [PATCH 1/3] clocksource/drivers/timer-mediatek: Fix random crash at boot Luca Leonardo Scorcia
2026-10-02  7:19 ` [PATCH 2/3] clocksource/drivers/timer-mediatek: Convert to OF probing Luca Leonardo Scorcia
2026-10-02  7:19 ` [PATCH 3/3] clocksource/drivers/timer-mediatek: Request and enable the bus clock Luca Leonardo Scorcia
2026-10-02  7:46 ` [PATCH 0/3] Convert MediaTek GPT timers to OF probing Roman Vivchar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®