Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] clocksource/drivers/at550: non-real-name handle in
Signed-off-by trailer
- [Medium] clocksource/drivers/at550: MMIO read before clock enable in
at550_timer_init()
- [Medium] clocksource/drivers/at550: missing set_state_oneshot_stopped
in at550_timer_init()
- [Medium] clocksource/drivers/at550: stale match race in
at550_next_event() status clear
--
commit b350bccc2b4d4235b5ab2d214012109afb381252
Author: yy-Local-LLM [off-list ref]
clocksource: add the SiRF AT550 counter and match timer
Use the low 32-bit counter as clocksource/sched_clock and match zero as
a one-shot clockevent. Obtain its rate through the common clock
framework. Preserve the firmware counter/divider and refuse a running
watchdog. Unwind IRQ, clock and I/O resources if initialization fails.
Signed-off-by: yy-Local-LLM <redacted>
[Severity: High]
Under Documentation/process/submitting-patches.rst, the Developer's
Certificate of Origin requires a real human name (known identity) in the
Author header and Signed-off-by trailer rather than a handle or LLM
identifier.
quoted hunk ↗ jump to hunk
diff --git a/drivers/clocksource/timer-at550.c b/drivers/clocksource/timer-at550.c
new file mode 100644
index 0000000000000..a47dadfb9554f
--- /dev/null
+++ b/drivers/clocksource/timer-at550.c
[ ... ]
quoted hunk ↗ jump to hunk
+static int at550_next_event(unsigned long delta,
+ struct clock_event_device *event)
+{
+ u32 target = readl(at550_timer) + delta;
+
+ writel(0, at550_timer + AT550_ENABLE);
+ writel(1, at550_timer + AT550_STATUS);
+ writel(target, at550_timer + AT550_MATCH0);
+ writel(1, at550_timer + AT550_ENABLE);
[Severity: Medium]
Can a stale value in AT550_MATCH0 fire a premature interrupt when
at550_next_event() clears AT550_STATUS before updating AT550_MATCH0?
Because the counter is free-running and AT550_MATCH0 still holds the
previous comparator value when writel(1, at550_timer + AT550_STATUS)
runs, the counter reaching that old comparator value before the new
target is written to AT550_MATCH0 re-latches bit 0 in AT550_STATUS.
Setting AT550_ENABLE to 1 then immediately triggers an interrupt even
though the new target is still in the future. Disabling AT550_ENABLE
first, computing target and writing AT550_MATCH0 before clearing
AT550_STATUS avoids latching a match from the old comparator value.
[ ... ]
quoted hunk ↗ jump to hunk
+static int __init at550_timer_init(struct device_node *node)
+{
+ struct clk *clk;
+ unsigned long rate;
+ unsigned int irq;
+ int ret;
+
+ if (at550_timer)
+ return -EINVAL;
+ at550_timer = of_iomap(node, 0);
+ if (!at550_timer)
+ return -ENOMEM;
+ /* Do not disturb a running firmware watchdog or unknown divider bits. */
+ if (readl(at550_timer + AT550_WATCHDOG) ||
+ readl(at550_timer + AT550_DIVIDER) > 0xffff) {
+ ret = -EBUSY;
+ goto unmap;
+ }
+ clk = of_clk_get(node, 0);
+ if (IS_ERR(clk)) {
+ ret = PTR_ERR(clk);
+ goto unmap;
+ }
+ ret = clk_prepare_enable(clk);
[Severity: Medium]
Does at550_timer_init() read AT550_WATCHDOG and AT550_DIVIDER before
enabling the timer clock? If the peripheral clock is gated prior to
clk_prepare_enable(), reading those registers can cause a bus hang or
synchronous external abort during boot.
[ ... ]
quoted hunk ↗ jump to hunk
+ at550_event.name = "at550-match0";
+ at550_event.features = CLOCK_EVT_FEAT_ONESHOT;
+ at550_event.rating = 200;
+ at550_event.set_next_event = at550_next_event;
+ at550_event.set_state_shutdown = at550_shutdown;
+ at550_event.set_state_oneshot = at550_shutdown;
+ at550_event.tick_resume = at550_shutdown;
[Severity: Medium]
Should at550_event.set_state_oneshot_stopped also be set to
at550_shutdown?
When the last pending timer event is cancelled and tick_program_event()
is called with expires == KTIME_MAX, it switches the device to
CLOCK_EVT_STATE_ONESHOT_STOPPED without calling set_next_event().
Without set_state_oneshot_stopped, __clockevents_switch_state() returns
-ENOSYS and leaves AT550_ENABLE set, causing the previous AT550_MATCH0
value to fire a spurious interrupt when the counter reaches it.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117-at550-rfc-v1-v1-0-5879573cb825@gmail.com?part=3