From: Andre Przywara <andre.przywara@arm.com>
To: Enzo Adriano <enzo.adriano.code@gmail.com>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>
Cc: Brian Masney <bmasney@redhat.com>, Chen-Yu Tsai <wens@kernel.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>,
Junhui Liu <junhui.liu@pigmoral.tech>,
linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] clk: sunxi-ng: ccu_mp: fix clocks without P dividers
Date: Wed, 22 Jul 2026 11:24:02 +0200 [thread overview]
Message-ID: <2fa7bd81-0091-4001-856f-e21096023f0e@arm.com> (raw)
In-Reply-To: <20260722005643.1208942-1-enzo.adriano.code@gmail.com>
Hi,
On 7/22/26 02:56, Enzo Adriano wrote:
> Some sunxi-ng MP clocks have an M divider but no P divider. The A523
> MBUS, IOMMU and DRAM clocks use this layout and also require the update
> bit when changing their rate.
>
> ccu_mp_set_rate() unconditionally builds and applies a mask for the P
> field. With a zero-width P field this produces an invalid GENMASK()
> range and can clear bits outside a P divider, including the clock gate.
>
> The callback also ignores CCU_FEATURE_UPDATE_BIT, so hardware that
> requires the update bit may not latch the new divider value.
>
> Only update the P field when it exists, and set CCU_SUNXI_UPDATE_BIT for
> MP clocks carrying the feature. This matches the existing sunxi-ng div,
> mux and gate helper behavior.
>
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://lore.kernel.org/r/20260712081341.9D1431F00A3D@smtp.kernel.org
> Fixes: 6702d17f54a8 ("clk: sunxi-ng: a523: add video mod clocks")
> Assisted-by: Codex:gpt-5
> Signed-off-by: Enzo Adriano <enzo.adriano.code@gmail.com>
> ---
> Based on clk-next 8cdeaa50eae8 (Linux 7.2-rc2).
> Tested with strict checkpatch and an arm64 W=1 build of ccu_mp.o.
> No hardware runtime claim is made.
Does that mean it's not tested on hardware?
>
> drivers/clk/sunxi-ng/ccu_mp.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/clk/sunxi-ng/ccu_mp.c b/drivers/clk/sunxi-ng/ccu_mp.c
> index 7cdb0eedc69b..aa6cb20447f1 100644
> --- a/drivers/clk/sunxi-ng/ccu_mp.c
> +++ b/drivers/clk/sunxi-ng/ccu_mp.c
> @@ -237,12 +237,17 @@ static int ccu_mp_set_rate(struct clk_hw *hw, unsigned long rate,
>
> reg = readl(cmp->common.base + cmp->common.reg);
> reg &= ~GENMASK(cmp->m.width + cmp->m.shift - 1, cmp->m.shift);
> - reg &= ~GENMASK(cmp->p.width + cmp->p.shift - 1, cmp->p.shift);
> + if (cmp->p.width)
> + reg &= ~GENMASK(cmp->p.width + cmp->p.shift - 1, cmp->p.shift);
> + if (cmp->common.features & CCU_FEATURE_UPDATE_BIT)
> + reg |= CCU_SUNXI_UPDATE_BIT;
> reg |= (m - cmp->m.offset) << cmp->m.shift;
> - if (shift)
> - reg |= ilog2(p) << cmp->p.shift;
> - else
> - reg |= (p - cmp->p.offset) << cmp->p.shift;
> + if (cmp->p.width) {
Can you merge that into the upper conditional branch? So that it's just
one if statement?
And then apply the same treatment to the M divider, which is set to 0 by
some A523 clocks (hstimer and r-timer).
Cheers,
Andre
> + if (shift)
> + reg |= ilog2(p) << cmp->p.shift;
> + else
> + reg |= (p - cmp->p.offset) << cmp->p.shift;
> + }
>
> writel(reg, cmp->common.base + cmp->common.reg);
>
next prev parent reply other threads:[~2026-07-22 9:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 0:56 [PATCH] clk: sunxi-ng: ccu_mp: fix clocks without P dividers Enzo Adriano
2026-07-22 1:09 ` sashiko-bot
2026-07-22 9:24 ` Andre Przywara [this message]
2026-07-22 13:27 ` Chen-Yu Tsai
2026-07-22 17:37 ` Enzo Adriano
2026-07-22 17:43 ` Chen-Yu Tsai
2026-07-22 22:48 ` Andre Przywara
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=2fa7bd81-0091-4001-856f-e21096023f0e@arm.com \
--to=andre.przywara@arm.com \
--cc=bmasney@redhat.com \
--cc=enzo.adriano.code@gmail.com \
--cc=jernej.skrabec@gmail.com \
--cc=junhui.liu@pigmoral.tech \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=mturquette@baylibre.com \
--cc=samuel@sholland.org \
--cc=sboyd@kernel.org \
--cc=wens@kernel.org \
/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.