From: sashiko-bot@kernel.org
To: "Alastair D'Silva" <alastair@d-silva.org>
Cc: linux-clk@vger.kernel.org, linux-sunxi@lists.linux.dev
Subject: Re: [PATCH] clk: sunxi-ng: ccu_common: Replace ktime-dependent lock wait loop with udelay
Date: Wed, 16 Sep 2026 04:22:06 +0000 [thread overview]
Message-ID: <20260916042206.D16331F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260916041104.239999-1-alastair@d-silva.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] clk: sunxi-ng: custom udelay loop instead of readl_relaxed_poll_timeout_atomic()
--
commit 303433ce9fcf08821cef4553ec1030effcdd3fb9
Author: Alastair D'Silva <alastair@d-silva.org>
clk: sunxi-ng: ccu_common: Replace ktime-dependent lock wait loop with udelay
This commit replaces the use of readl_relaxed_poll_timeout() in the sunxi-ng
CCU driver with a custom udelay() loop. The goal is to avoid system freezes
caused by timekeeping suspensions during early boot or CPUfreq DVFS scaling
when waiting for PLLs to lock.
> diff --git a/drivers/clk/sunxi-ng/ccu_common.c b/drivers/clk/sunxi-ng/ccu_common.c
> index 43d8eca6abeed..00daedadb5c83 100644
> --- a/drivers/clk/sunxi-ng/ccu_common.c
> +++ b/drivers/clk/sunxi-ng/ccu_common.c
[ ... ]
> @@ -35,7 +36,14 @@ void ccu_helper_wait_for_lock(struct ccu_common *common, u32 lock)
> else
> addr = common->base + common->reg;
>
> - WARN_ON(readl_relaxed_poll_timeout(addr, reg, reg & lock, 100, 70000));
> + for (i = 0; i < 100000; i++) {
> + if (readl_relaxed(addr) & lock)
> + return;
> + udelay(1);
> + }
[Severity: Low]
Does this custom busy-wait loop unnecessarily reinvent the kernel's standard
polling abstractions?
Since ccu_helper_wait_for_lock() executes whenever a PLL lock is waited upon
during clock configuration, such as early boot or CPUfreq transitions, avoiding
ktime dependencies is definitely necessary. However, the kernel already natively
provides readl_relaxed_poll_timeout_atomic() in <linux/iopoll.h> which is
designed specifically to perform timekeeping-independent hardware polling.
Would it be better to use readl_relaxed_poll_timeout_atomic() here instead of
circumventing the standard I/O polling macros with a hand-rolled loop?
> +
> + if (!(readl_relaxed(addr) & lock))
> + pr_warn("%s: clock lock timeout\n", clk_hw_get_name(&common->hw));
> }
> EXPORT_SYMBOL_NS_GPL(ccu_helper_wait_for_lock, "SUNXI_CCU");
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260916041104.239999-1-alastair@d-silva.org?part=1
next prev parent reply other threads:[~2026-09-16 4:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 4:11 [PATCH] clk: sunxi-ng: ccu_common: Replace ktime-dependent lock wait loop with udelay Alastair D'Silva
2026-09-16 4:22 ` sashiko-bot [this message]
2026-09-16 4:29 ` [PATCH v2] clk: sunxi-ng: ccu_common: Use readl_relaxed_poll_timeout_atomic for PLL lock Alastair D'Silva
2026-09-21 15:52 ` Chen-Yu Tsai
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=20260916042206.D16331F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alastair@d-silva.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/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