From: David Laight <david.laight.linux@gmail.com>
To: Brian Masney <masneyb@kernel.org>
Cc: Carlo Caione <ccaione@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
Brian Masney <bmasney+clk@redhat.com>,
Jerome Brunet <jbrunet+clk@baylibre.com>,
Brian Norris <computersforpeace@gmail.com>,
Brian Norris <briannorris@chromium.org>,
Sebastian Reichel <sebastian.reichel@collabora.com>,
linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
Stephen Boyd <sboyd@codeaurora.org>
Subject: Re: [PATCH 1/2] clk: divider: Fix the divisor for rates above 4.29 GHz
Date: Wed, 4 Nov 2026 23:10:55 +0000 [thread overview]
Message-ID: <20261104231055.5b566adb@pumpkin> (raw)
In-Reply-To: <179382912410.620422.14715602424648962218.b4-review@b4>
On Wed, 04 Nov 2026 16:52:04 -0500
Brian Masney <masneyb@kernel.org> wrote:
> > DIV_ROUND_UP_ULL() takes a 32-bit divisor, so on 64-bit platforms a
> > requested rate above 4.29 GHz is truncated. A divider fed by a 5.94 GHz
> > PLL then computes a divisor of 7, not 1, for 5.94 GHz.
> >
> > Use DIV64_U64_ROUND_UP(), which takes a 64-bit divisor.
> >
> > Fixes: 9556f9dad8f5 ("clk: divider: handle integer overflow when dividing large clock rates")
> > Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> > Signed-off-by: Carlo Caione <ccaione@baylibre.com>
>
> Reviewed-by: Brian Masney <masneyb@kernel.org>
>
> Since this is a core change to the framework, I'd also like to see what
> Jerome thinks before we merge this.
I've wondered about whether using 'unsigned long' for clock frequencies
was ever right.
Clearly the type should be the same size for 32 bit and 64 bit, and I'm
pretty sure the choice of long predates 64bit (I guess someone was worried
'int' might only be 16 bits?).
But if frequencies can be over 4GHz (which no one would have imagined a few
years back) they can be that high on 32 bit systems as well as 64bit ones.
So there is a big 'bag of worms' being opened.
Changing the type to 64 bits is hard to check (unless you manage to build
a kernel with the value embedded in a structure using accessor functions)
and will be a lot of bloat for most uses on 32 bit.
Alternatively you enforce a different api for clocks that might exceed 4GHz.
David
>
> Brian
>
next prev parent reply other threads:[~2026-11-04 23:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 21:07 [PATCH 0/2] Fix clk-divider rates above 4.29 GHz on 64-bit Carlo Caione
2026-11-02 21:07 ` [PATCH 1/2] clk: divider: Fix the divisor for rates above 4.29 GHz Carlo Caione
2026-11-04 21:52 ` Brian Masney
2026-11-04 23:10 ` David Laight [this message]
2026-11-02 21:07 ` [PATCH 2/2] clk: divider: test: Add tests " Carlo Caione
2026-11-04 21:52 ` Brian Masney
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=20261104231055.5b566adb@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=bmasney+clk@redhat.com \
--cc=briannorris@chromium.org \
--cc=ccaione@baylibre.com \
--cc=computersforpeace@gmail.com \
--cc=jbrunet+clk@baylibre.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masneyb@kernel.org \
--cc=sboyd@codeaurora.org \
--cc=sboyd@kernel.org \
--cc=sebastian.reichel@collabora.com \
/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
all inboxes | Powered by JetHome®