From: sashiko-bot@kernel.org
To: "Juan Manuel López Carrillo" <juanmanuellopezcarrillo@gmail.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org,
linux-sunxi@lists.linux.dev
Subject: Re: [PATCH v2 1/3] clk: sunxi-ng: add cycle-masking divider (maskdiv) clock type
Date: Mon, 03 Aug 2026 18:18:45 +0000 [thread overview]
Message-ID: <20260803181846.57E031F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260803180755.288793-2-juanmanuellopezcarrillo@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] `ccu_maskdiv_set_rate` recalculates a different mask factor (`M`) than what `ccu_maskdiv_determine_rate` initially chose, silently programming the hardware to a lower frequency than negotiated.
- [High] `ccu_maskdiv_determine_rate` ignores the `CLK_SET_RATE_NO_REPARENT` flag, potentially causing unintended clock reparenting.
--
--- Patch [1]: [PATCH v2 1/3] clk: sunxi-ng: add cycle-masking divider (maskdiv) clock type ---
commit cf0833bab086c6beae6c2b221f361043441cc718
Author: Juan Manuel López Carrillo <juanmanuellopezcarrillo@gmail.com>
clk: sunxi-ng: add cycle-masking divider (maskdiv) clock type
This commit adds a cycle-masking divider for the A523/T527 GPU clock.
It masks M pulses out of every 2^width parent cycles instead of using a
linear divider. It also adds custom determine_rate and set_rate functions
to support this behavior.
> diff --git a/drivers/clk/sunxi-ng/ccu_maskdiv.c b/drivers/clk/sunxi-ng/ccu_maskdiv.c
> new file mode 100644
> index 0000000000000..4ad49d51405b3
> --- /dev/null
> +++ b/drivers/clk/sunxi-ng/ccu_maskdiv.c
[ ... ]
> +static int ccu_maskdiv_determine_rate(struct clk_hw *hw,
> + struct clk_rate_request *req)
> +{
> + struct ccu_maskdiv *cmd = hw_to_ccu_maskdiv(hw);
> + unsigned long best_rate = 0, best_parent_rate = 0;
> + struct clk_hw *best_parent = NULL;
> + unsigned int best_m = UINT_MAX;
> + unsigned int i;
> +
> + for (i = 0; i < clk_hw_get_num_parents(hw); i++) {
> + struct clk_hw *parent = clk_hw_get_parent_by_index(hw, i);
[Severity: High]
Does this iteration need to respect the CLK_SET_RATE_NO_REPARENT flag?
Unlike other sunxi-ng multiplexers that use ccu_mux_helper_determine_rate(),
this loops unconditionally across all available parents. If a driver specifies
CLK_SET_RATE_NO_REPARENT, would this silently ignore it and potentially cause
unintended clock reparenting?
> + unsigned long parent_rate, new_rate;
> + unsigned int m;
[ ... ]
> +static int ccu_maskdiv_set_rate(struct clk_hw *hw, unsigned long rate,
> + unsigned long parent_rate)
> +{
> + struct ccu_maskdiv *cmd = hw_to_ccu_maskdiv(hw);
> + unsigned int m;
> + unsigned long flags;
> + u32 reg;
> +
> + m = ccu_maskdiv_find_m(parent_rate, rate, cmd->width);
[Severity: High]
Does ccu_maskdiv_set_rate() end up programming a different mask factor (M)
than what ccu_maskdiv_determine_rate() initially chose?
Because ccu_maskdiv_calc_rate() truncates the remainder (e.g. 1000 * 13 / 16
= 812), feeding the result back into ccu_maskdiv_find_m() evaluates this
truncated output again. For example, 812 * 16 / 1000 = 12, instead of the
original 13.
Could this inappropriately increase M and silently program the hardware to
a lower frequency than what was negotiated?
> +
> + spin_lock_irqsave(cmd->common.lock, flags);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260803180755.288793-1-juanmanuellopezcarrillo@gmail.com?part=1
next prev parent reply other threads:[~2026-08-03 18:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 18:07 [PATCH v2 0/3] clk: sunxi-ng: fix the A523/T527 GPU clock model, enable GPU DVFS Juan Manuel López Carrillo
2026-08-03 18:07 ` [PATCH v2 1/3] clk: sunxi-ng: add cycle-masking divider (maskdiv) clock type Juan Manuel López Carrillo
2026-08-03 18:18 ` sashiko-bot [this message]
2026-08-03 18:07 ` [PATCH v2 2/3] clk: sunxi-ng: sun55i-a523: GPU clock divider is fractional, not linear Juan Manuel López Carrillo
2026-08-03 18:25 ` sashiko-bot
2026-08-03 18:07 ` [PATCH v2 3/3] arm64: dts: allwinner: a523: add GPU OPP table Juan Manuel López Carrillo
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=20260803181846.57E031F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=juanmanuellopezcarrillo@gmail.com \
--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