From: David Laight <David.Laight@ACULAB.COM>
To: 'Stephen Boyd' <sboyd@kernel.org>,
Michael Turquette <mturquette@baylibre.com>,
Sebastian Reichel <sebastian.reichel@collabora.com>,
"linux-clk@vger.kernel.org" <linux-clk@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: Christopher Obbard <chris.obbard@collabora.com>,
Sebastian Reichel <sebastian.reichel@collabora.com>,
"kernel@collabora.com" <kernel@collabora.com>
Subject: RE: [PATCH v2 2/2] clk: divider: Fix divisions
Date: Tue, 13 Jun 2023 08:05:27 +0000 [thread overview]
Message-ID: <919a361dd5f54e738d4824f8096d243c@AcuMS.aculab.com> (raw)
In-Reply-To: <5e9e776db6628d02d7081292b81ab102.sboyd@kernel.org>
From: Stephen Boyd
> Sent: 13 June 2023 01:42
>
> Quoting Sebastian Reichel (2023-05-26 10:10:57)
> > The clock framework handles clock rates as "unsigned long", so u32 on
> > 32-bit architectures and u64 on 64-bit architectures.
> >
> > The current code pointlessly casts the dividend to u64 on 32-bit
> > architectures and thus pointlessly reducing the performance.
>
> It looks like that was done to make the DIV_ROUND_UP() macro not
> overflow the dividend on 32-bit machines (from 9556f9dad8f5):
>
> DIV_ROUND_UP(3000000000, 1500000000) = (3.0G + 1.5G - 1) / 1.5G
> = OVERFLOW / 1.5G
Maybe add:
#define DIV_ROUND_UP_NZ(x, y) (((x) - 1)/(y) + 1)
which doesn't overflow but requires x != 0.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
prev parent reply other threads:[~2023-06-13 8:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-26 17:10 [PATCH v2 0/2] Fix 64 bit issues in common clock framework Sebastian Reichel
2023-05-26 17:10 ` [PATCH v2 1/2] clk: composite: Fix handling of high clock rates Sebastian Reichel
2023-05-29 8:50 ` AngeloGioacchino Del Regno
2023-06-13 0:10 ` Stephen Boyd
2023-06-13 12:14 ` Maxime Ripard
2023-06-13 18:25 ` Stephen Boyd
2023-06-14 10:28 ` Maxime Ripard
2023-05-26 17:10 ` [PATCH v2 2/2] clk: divider: Fix divisions Sebastian Reichel
2023-05-29 8:50 ` AngeloGioacchino Del Regno
2023-06-13 0:41 ` Stephen Boyd
2023-06-13 8:05 ` David Laight [this message]
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=919a361dd5f54e738d4824f8096d243c@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=chris.obbard@collabora.com \
--cc=kernel@collabora.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--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;
as well as URLs for NNTP newsgroup(s).