From: Stephen Boyd <sboyd@codeaurora.org>
To: Brian Norris <computersforpeace@gmail.com>
Cc: Michael Turquette <mturquette@baylibre.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Jim Quinlan <jim2101024@gmail.com>,
Gregory Fong <gregory.0xf0@gmail.com>,
linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
Sascha Hauer <s.hauer@pengutronix.de>,
Tomi Valkeinen <tomi.valkeinen@ti.com>,
u.kleine-koenig@pengutronix.de
Subject: Re: [PATCH] clk: divider: handle integer overflow when dividing large clock rates
Date: Mon, 14 Sep 2015 16:08:40 -0700 [thread overview]
Message-ID: <20150914230840.GI23081@codeaurora.org> (raw)
In-Reply-To: <20150914210839.GA60225@google.com>
On 09/14, Brian Norris wrote:
> (New address)
>
> Hi Mike,
>
> On Mon, Apr 27, 2015 at 08:49:10AM -0700, Michael Turquette wrote:
> > Quoting Michael Turquette (2015-04-14 15:11:37)
> > > Quoting Brian Norris (2015-04-13 16:03:21)
> > > > On 32-bit architectures, 'unsigned long' (the type used to hold clock
> > > > rates, in Hz) is often only 32 bits wide. DIV_ROUND_UP() (as used in,
> > > > e.g., commit b11d282dbea2 "clk: divider: fix rate calculation for
> > > > fractional rates") can yield an integer overflow on clock rates that are
> > > > not (by themselves) too large to fit in 32 bits, because it performs
> > > > addition before the division. See for example:
> > > >
> > > > DIV_ROUND_UP(3000000000, 1500000000) = (3.0G + 1.5G - 1) / 1.5G
> > > > = OVERFLOW / 1.5G
> > > >
> > > > This patch fixes such cases by always promoting the dividend to 64-bits
> > > > (unsigned long long) before doing the division. While this patch does
> > > > not resolve the issue with large clock rates across the common clock
> > > > framework nor address the problems with doing full 64-bit arithmetic on
> > > > a 32-bit architecture, it does fix some issues seen when using clock
> > > > dividers on a 3GHz reference clock to produce a 1.5GHz CPU clock for an
> > > > ARMv7 Brahma B15 SoC.
> > > >
> > > > Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> > > > Reference: lkml.kernel.org/g/20150413201433.GQ32500@ld-irv-0074
> > > > ---
> > > > I'll admit I only compile-tested this particular patch. I have tested a version
> > > > of this patch on top of a few backports on an older kernel, and everything
> > > > works fine. Unforunately, some of my SoC's clock drivers still rely on
> > > > out-of-tree code.
> > >
> > > I smoke tested this on some hardware and it seemed fine to me. I'll give
> > > some time for others to comment, otherwise I'll take this for 4.2 after
> > > -rc1 drops.
> >
> > Applied to clk-next.
>
> I was rebasing my old patches onto Linus' latest, and I noticed that
> this one never got in.
>
Odd. I've thrown it into clk-next.
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
prev parent reply other threads:[~2015-09-14 23:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-13 23:03 [PATCH] clk: divider: handle integer overflow when dividing large clock rates Brian Norris
[not found] ` <20150414221137.19585.91216@quantum>
[not found] ` <20150427154910.16410.11498@quantum>
2015-09-14 21:05 ` Brian Norris
2015-09-14 21:08 ` Brian Norris
2015-09-14 23:08 ` Stephen Boyd [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=20150914230840.GI23081@codeaurora.org \
--to=sboyd@codeaurora.org \
--cc=computersforpeace@gmail.com \
--cc=f.fainelli@gmail.com \
--cc=gregory.0xf0@gmail.com \
--cc=jim2101024@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=s.hauer@pengutronix.de \
--cc=tomi.valkeinen@ti.com \
--cc=u.kleine-koenig@pengutronix.de \
/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).