Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: yy-Local-LLM <yogo.0917.sabu@gmail.com>, devicetree@vger.kernel.org
Cc: linux-input@vger.kernel.org, robh@kernel.org,
	conor+dt@kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH RFC 3/6] clocksource: add the SiRF AT550 counter and match timer
Date: Tue, 17 Nov 2026 13:43:23 +0000	[thread overview]
Message-ID: <sashiko-outbox-218896@kernel.org> (raw)
In-Reply-To: <20261117-at550-rfc-v1-v1-3-5879573cb825@gmail.com>

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 <yogo.0917.sabu@gmail.com>

> 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 <yogo.0917.sabu@gmail.com>

[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.

> 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
[ ... ]
> +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.

[ ... ]
> +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.

[ ... ]
> +	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

  reply	other threads:[~2026-11-17 13:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 13:06 [PATCH RFC 0/6] SiRF AT550 / YPL514si initial RAM-boot platform support yy-Local-LLM via B4 Relay
2026-11-17 13:06 ` [PATCH RFC 1/6] dt-bindings: add SiRF AT550 and Yupiteru YPL514si descriptions yy-Local-LLM via B4 Relay
2026-11-17 13:21   ` sashiko-bot
2026-11-17 13:06 ` [PATCH RFC 2/6] irqchip: add the SiRF AT550 interrupt controller yy-Local-LLM via B4 Relay
2026-11-17 13:27   ` sashiko-bot
2026-11-17 13:06 ` [PATCH RFC 3/6] clocksource: add the SiRF AT550 counter and match timer yy-Local-LLM via B4 Relay
2026-11-17 13:43   ` sashiko-bot [this message]
2026-11-17 13:06 ` [PATCH RFC 4/6] Input: add polled SiRF AT550 resistive touch support yy-Local-LLM via B4 Relay
2026-11-17 13:38   ` sashiko-bot
2026-11-17 13:06 ` [PATCH RFC 5/6] mmc: sdhci: add SiRF AT550 programmed-I/O support yy-Local-LLM via B4 Relay
2026-11-17 13:46   ` sashiko-bot
2026-11-17 13:06 ` [PATCH RFC 6/6] ARM: add the SiRF AT550 platform and YPL514si board yy-Local-LLM via B4 Relay
2026-11-17 13:17   ` Arnd Bergmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-218896@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=yogo.0917.sabu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox