From: sashiko-bot@kernel.org
To: "Junhui Liu" <junhui.liu@pigmoral.tech>
Cc: linux-sunxi@lists.linux.dev, conor+dt@kernel.org,
robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v2 6/8] clk: sunxi-ng: a733: Add mod clocks support
Date: Sun, 12 Jul 2026 08:13:42 +0000 [thread overview]
Message-ID: <20260712081343.1D52F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260711-a733-clk-v2-6-974d188cbe0c@pigmoral.tech>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Undefined Behavior in ccu_mp_set_rate() due to GENMASK(-1, 0) silently clears clock registers.
--
--- Patch [6]: [PATCH v2 6/8] clk: sunxi-ng: a733: Add mod clocks support ---
commit 9fae602071158ab4bb78bf12e40f53a7e4b2f550
Author: Junhui Liu <junhui.liu@pigmoral.tech>
clk: sunxi-ng: a733: Add mod clocks support
Add the module clocks found in the Allwinner A733 SoC, including video,
storage, interfaces and others. This implementation accounts for changes
in register offsets and introduces support for new modules.
> diff --git a/drivers/clk/sunxi-ng/ccu-sun60i-a733.c b/drivers/clk/sunxi-ng/ccu-sun60i-a733.c
> index c42619afb52e3..bf26e310f08a9 100644
> --- a/drivers/clk/sunxi-ng/ccu-sun60i-a733.c
> +++ b/drivers/clk/sunxi-ng/ccu-sun60i-a733.c
[ ... ]
> +static SUNXI_CCU_MP_DATA_WITH_MUX_GATE(timer0_clk, "timer0", timer_parents, 0x800,
> + 0, 0, /* no M */
> + 0, 3, /* P */
> + 24, 3, /* mux */
> + BIT(31), /* gate */
> + 0);
[Severity: Critical]
This is a pre-existing issue, but won't specifying a width of 0 for the
M divider cause undefined behavior in the CCU framework?
When a driver or the clock framework calls clk_set_rate() on these newly
introduced clocks (e.g., timer0_clk through timer9_clk, mbus_clk),
ccu_mp_set_rate() clears the M and P divider fields:
drivers/clk/sunxi-ng/ccu_mp.c:ccu_mp_set_rate() {
...
reg &= ~GENMASK(cmp->m.width + cmp->m.shift - 1, cmp->m.shift);
reg &= ~GENMASK(cmp->p.width + cmp->p.shift - 1, cmp->p.shift);
...
}
Because these clocks are instantiated with width = 0, this evaluates to
~GENMASK(-1, 0) at runtime. GENMASK(-1, 0) computes ~0UL >> 64. On ARM64
hardware, the dynamic shift amount is read from the bottom 6 bits of the
register (64 & 63 == 0), resulting in a shift of 0, leaving the value as
~0UL (all ones).
The ~GENMASK thus evaluates to 0, which completely zeroes the hardware
register, including the clock gate bit (BIT(31)).
[ ... ]
> +static SUNXI_CCU_MP_DATA_WITH_MUX_GATE_FEAT(dram0_clk, "dram0", dram_parents, 0xc00,
> + 0, 4, /* M */
> + 0, 0, /* no P */
> + 24, 3, /* mux */
> + BIT(31), /* gate */
> + CLK_IS_CRITICAL,
> + CCU_FEATURE_UPDATE_BIT);
[Severity: Critical]
This isn't a bug introduced by this patch, but dram0_clk is instantiated
with a P width of 0. Calling set_rate on it will trigger ~GENMASK(-1, 0)
and wipe its register. Since this is the DRAM clock, won't disabling it
instantly hang the system?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260711-a733-clk-v2-0-974d188cbe0c@pigmoral.tech?part=6
next prev parent reply other threads:[~2026-07-12 8:13 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-11 8:10 [PATCH v2 0/8] clk: sunxi-ng: Add support for Allwinner A733 CCU and PRCM Junhui Liu
2026-07-11 8:10 ` [PATCH v2 1/8] dt-bindings: clk: sun60i-a733-ccu: Add allwinner A733 support Junhui Liu
2026-07-12 8:13 ` sashiko-bot
2026-07-12 14:35 ` Krzysztof Kozlowski
2026-07-11 8:10 ` [PATCH v2 2/8] clk: sunxi-ng: sdm: Add dual patterns support Junhui Liu
2026-07-11 8:10 ` [PATCH v2 3/8] clk: sunxi-ng: a733: Add PRCM CCU Junhui Liu
2026-07-12 8:13 ` sashiko-bot
2026-07-11 8:10 ` [PATCH v2 4/8] clk: sunxi-ng: a733: Add PLL clocks support Junhui Liu
2026-07-12 8:13 ` sashiko-bot
2026-07-11 8:10 ` [PATCH v2 5/8] clk: sunxi-ng: a733: Add bus " Junhui Liu
2026-07-12 8:13 ` sashiko-bot
2026-07-11 8:10 ` [PATCH v2 6/8] clk: sunxi-ng: a733: Add mod " Junhui Liu
2026-07-12 8:13 ` sashiko-bot [this message]
2026-07-12 14:25 ` Junhui Liu
2026-07-11 8:10 ` [PATCH v2 7/8] clk: sunxi-ng: a733: Add bus clock gates Junhui Liu
2026-07-12 8:13 ` sashiko-bot
2026-07-12 14:29 ` Junhui Liu
2026-07-11 8:10 ` [PATCH v2 8/8] clk: sunxi-ng: a733: Add reset lines Junhui Liu
2026-07-12 8:13 ` sashiko-bot
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=20260712081343.1D52F1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=junhui.liu@pigmoral.tech \
--cc=linux-sunxi@lists.linux.dev \
--cc=robh@kernel.org \
--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