All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jerome Brunet" <jbrunet@baylibre.com>
Cc: conor+dt@kernel.org, robh@kernel.org, linux-rtc@vger.kernel.org,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	devicetree@vger.kernel.org, linux-sunxi@lists.linux.dev
Subject: Re: [PATCH v4 6/9] clk: sunxi-ng: div: add read-only operation support
Date: Mon, 06 Jul 2026 10:06:35 +0000	[thread overview]
Message-ID: <20260706100635.E5DC61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260706-a733-rtc-v4-6-f330728db3d3@baylibre.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Inconsistent rate calculation between `determine_rate` and `recalc_rate` due to division order.
--

commit 39f872462c04ad724c3624b152234160de56a47e
Author: Jerome Brunet <jbrunet@baylibre.com>

clk: sunxi-ng: div: add read-only operation support

Add support for sunxi-ng read-only dividers. This will be
useful to the a733 oscillator detection logic.

> diff --git a/drivers/clk/sunxi-ng/ccu_div.c b/drivers/clk/sunxi-ng/ccu_div.c
> index 62d680ccb524b..d1c8c7baa12dc 100644
> --- a/drivers/clk/sunxi-ng/ccu_div.c
> +++ b/drivers/clk/sunxi-ng/ccu_div.c
[ ... ]
> @@ -84,6 +84,36 @@ static int ccu_div_determine_rate(struct clk_hw *hw,
>  					     req, ccu_div_determine_rate_helper, cd);
>  }
>  
> +static int ccu_rodiv_determine_rate(struct clk_hw *hw,
> +				    struct clk_rate_request *req)
> +{
> +	struct ccu_div *cd = hw_to_ccu_div(hw);
> +	unsigned long val;
> +	u32 reg;
> +	int ret;
> +
> +	reg = readl(cd->common.base + cd->common.reg);
> +	val = reg >> cd->div.shift;
> +	val &= (1 << cd->div.width) - 1;
> +
> +	req->rate = ccu_mux_helper_unapply_prediv(&cd->common, &cd->mux, -1,
> +						  req->rate);
> +
> +	if (cd->common.features & CCU_FEATURE_FIXED_POSTDIV)
> +		req->rate *= cd->fixed_post_div;
> +
> +	ret = divider_ro_determine_rate(hw, req, cd->div.table,
> +					cd->div.width, cd->div.flags, val);
> +
> +	if (cd->common.features & CCU_FEATURE_FIXED_POSTDIV)
> +		req->rate /= cd->fixed_post_div;
> +
> +	req->rate = ccu_mux_helper_apply_prediv(&cd->common, &cd->mux, -1,
> +						req->rate);

[Severity: Medium]
Will this division order cause inconsistent rate calculations compared to
ccu_div_recalc_rate()?

The divider_ro_determine_rate() helper applies DIV_ROUND_UP() to the unadjusted
parent rate, and then this function divides that result by fixed_post_div and
prediv.

However, ccu_div_recalc_rate() applies prediv to the parent rate first, then
calculates the divider rate, and finally divides by fixed_post_div.

Since the Common Clock Framework requires determine_rate and recalc_rate to be
mathematically consistent, could this discrepancy cause rate mismatches or
warnings for clocks using a pre-divider or fixed post-divider?

> +
> +	return ret;
> +}
> +

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260706-a733-rtc-v4-0-f330728db3d3@baylibre.com?part=6

  reply	other threads:[~2026-07-06 10:06 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-06  9:32 [PATCH v4 0/9] clk: sun6i-rtc: Add support for Allwinner A733 SoC Jerome Brunet
2026-07-06  9:32 ` [PATCH v4 1/9] dt-bindings: rtc: sun6i: no clock-output-names on h616/r329 Jerome Brunet
2026-07-06  9:39   ` sashiko-bot
2026-07-06  9:32 ` [PATCH v4 2/9] dt-bindings: rtc: sun6i: add sun60i-a733 support Jerome Brunet
2026-07-06  9:41   ` sashiko-bot
2026-07-06  9:32 ` [PATCH v4 3/9] clk: sunxi-ng: fix ccu probe clock unregister on error Jerome Brunet
2026-07-06  9:43   ` sashiko-bot
2026-07-06  9:32 ` [PATCH v4 4/9] clk: sunxi-ng: sun6i-rtc: clean up DT usage Jerome Brunet
2026-07-06  9:49   ` sashiko-bot
2026-07-06  9:32 ` [PATCH v4 5/9] clk: sunxi-ng: sun6i-rtc: Add feature bit for IOSC calibration Jerome Brunet
2026-07-06  9:56   ` sashiko-bot
2026-07-06  9:32 ` [PATCH v4 6/9] clk: sunxi-ng: div: add read-only operation support Jerome Brunet
2026-07-06 10:06   ` sashiko-bot [this message]
2026-07-06 12:36     ` Jerome Brunet
2026-07-06 13:09       ` Chen-Yu Tsai
2026-07-06  9:32 ` [PATCH v4 7/9] clk: sunxi-ng: mux: remove unneeded export Jerome Brunet
2026-07-06 10:10   ` sashiko-bot
2026-07-06  9:32 ` [PATCH v4 8/9] clk: sunxi-ng: sun6i-rtc: split main oscillator div and gate Jerome Brunet
2026-07-06 10:18   ` sashiko-bot
2026-07-06 15:49   ` Chen-Yu Tsai
2026-07-06  9:32 ` [PATCH v4 9/9] clk: sunxi-ng: sun6i-rtc: add a733 support Jerome Brunet
2026-07-06 10:26   ` sashiko-bot
2026-07-06 16:47   ` Chen-Yu Tsai
2026-07-08 12:38     ` Jerome Brunet
2026-07-06 15:38 ` (subset) [PATCH v4 0/9] clk: sun6i-rtc: Add support for Allwinner A733 SoC 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=20260706100635.E5DC61F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jbrunet@baylibre.com \
    --cc=linux-rtc@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.