[PATCH 2/8] clocksource/drivers/timer-goldfish: Fix oneshot mode spurious interrupt
Kuan-Wei Chiu
visitorckw at gmail.com
Thu Nov 5 08:16:56 PST 2026
goldfish_timer_set_oneshot() writes 0 to TIMER_ALARM_HIGH and
TIMER_ALARM_LOW. Writing TIMER_ALARM_LOW arms the alarm for timestamp 0,
which immediately triggers a spurious interrupt when TIMER_IRQ_ENABLED
is set. Meanwhile, goldfish_timer_shutdown() disables interrupts without
disarming the alarm.
Use TIMER_CLEAR_ALARM to disarm the alarm in both functions.
Fixes: c92e7ef16400 ("clocksource/drivers: Add a goldfish-timer clocksource")
Signed-off-by: Kuan-Wei Chiu <visitorckw at gmail.com>
---
drivers/clocksource/timer-goldfish.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/clocksource/timer-goldfish.c b/drivers/clocksource/timer-goldfish.c
index cc02b012ff76..b1dc8b388470 100644
--- a/drivers/clocksource/timer-goldfish.c
+++ b/drivers/clocksource/timer-goldfish.c
@@ -55,8 +55,7 @@ static int goldfish_timer_set_oneshot(struct clock_event_device *evt)
struct goldfish_timer *timerdrv = ced_to_gf(evt);
void __iomem *base = timerdrv->base;
- gf_iowrite32(0, base + TIMER_ALARM_HIGH);
- gf_iowrite32(0, base + TIMER_ALARM_LOW);
+ gf_iowrite32(1, base + TIMER_CLEAR_ALARM);
gf_iowrite32(1, base + TIMER_IRQ_ENABLED);
return 0;
@@ -68,6 +67,7 @@ static int goldfish_timer_shutdown(struct clock_event_device *evt)
void __iomem *base = timerdrv->base;
gf_iowrite32(0, base + TIMER_IRQ_ENABLED);
+ gf_iowrite32(1, base + TIMER_CLEAR_ALARM);
return 0;
}
--
2.56.0.398.g882cbad275-goog
More information about the linux-riscv
mailing list