clocksource/drivers/timer-rtl-otto: Work around dying timers
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Mon, 4 Aug 2025 08:03:25 +0000 (04:03 -0400)
committerDaniel Lezcano <daniel.lezcano@linaro.org>
Tue, 23 Sep 2025 10:32:49 +0000 (12:32 +0200)
commite7a25106335041aeca4fdf50a84804c90142c886
treed04c79b8f9e9aad42d7e1c8c346dae6cc5d59315
parent0494fc345b377d1207c2cbfef67dc51f6ec874c0
clocksource/drivers/timer-rtl-otto: Work around dying timers

The OpenWrt distribution has switched from kernel longterm 6.6 to
6.12. Reports show that devices with the Realtek Otto switch platform
die during operation and are rebooted by the watchdog. Sorting out
other possible reasons the Otto timer is to blame. The platform
currently consists of 4 targets with different hardware revisions.
It is not 100% clear which devices and revisions are affected.

Analysis shows:

A more aggressive sched/deadline handling leads to more timer starts
with small intervals. This increases the bug chances. See
https://marc.info/?l=linux-kernel&m=175276556023276&w=2

Focusing on the real issue a hardware limitation on some devices was
found. There is a minimal chance that a timer ends without firing an
interrupt if it is reprogrammed within the 5us before its expiration
time. Work around this issue by introducing a bounce() function. It
restarts the timer directly before the normal restart functions as
follows:

- Stop timer
- Restart timer with a slow frequency.
- Target time will be >5us
- The subsequent normal restart is outside the critical window

Downstream has already tested and confirmed a patch. See
https://github.com/openwrt/openwrt/pull/19468
https://forum.openwrt.org/t/support-for-rtl838x-based-managed-switches/57875/3788

Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Tested-by: Stephen Howell <howels@allthatwemight.be>
Tested-by: Bjørn Mork <bjorn@mork.no>
Link: https://lore.kernel.org/r/20250804080328.2609287-2-markus.stockhausen@gmx.de
drivers/clocksource/timer-rtl-otto.c