From: Stephen Boyd <sboyd@kernel.org>
To: Maxime Ripard <maxime@cerno.tech>
Cc: Michael Turquette <mturquette@baylibre.com>,
Sebastian Reichel <sebastian.reichel@collabora.com>,
linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
Christopher Obbard <chris.obbard@collabora.com>,
David Laight <David.Laight@aculab.com>,
kernel@collabora.com, stable@vger.kernel.org
Subject: Re: [PATCH v2 1/2] clk: composite: Fix handling of high clock rates
Date: Tue, 13 Jun 2023 11:25:12 -0700 [thread overview]
Message-ID: <86d58c6b131028a71964a0bcb135f01f.sboyd@kernel.org> (raw)
In-Reply-To: <7s2xdk43a2lhyezgj6bbwxaekbtgym2rin7t432m4pos4j6v74@qaxm3htjak4a>
Quoting Maxime Ripard (2023-06-13 05:14:25)
> On Mon, Jun 12, 2023 at 05:10:35PM -0700, Stephen Boyd wrote:
> > Quoting Sebastian Reichel (2023-05-26 10:10:56)
> > > diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
> > > index edfa94641bbf..66759fe28fad 100644
> > > --- a/drivers/clk/clk-composite.c
> > > +++ b/drivers/clk/clk-composite.c
> > > @@ -119,7 +119,10 @@ static int clk_composite_determine_rate(struct clk_hw *hw,
> > > if (ret)
> > > continue;
> > >
> > > - rate_diff = abs(req->rate - tmp_req.rate);
> > > + if (req->rate >= tmp_req.rate)
> > > + rate_diff = req->rate - tmp_req.rate;
> > > + else
> > > + rate_diff = tmp_req.rate - req->rate;
> >
> > This problem is widespread
> >
> > $ git grep abs\(.*- -- drivers/clk/ | wc -l
> > 52
> >
> > so we may have a bigger problem here. Maybe some sort of coccinelle
> > script or smatch checker can be written to look for abs() usage with an
> > unsigned long type or a subtraction expression. This may also be worse
> > after converting drivers to clk_hw_forward_rate_request() and
> > clk_hw_init_rate_request() because those set the rate to ULONG_MAX.
> > +Maxime for that as an FYI.
>
> We set max_rate to ULONG_MAX in those functions, and I don't think we
> have a lot of driver that will call clk_round_rate on the max rate, so
> we should be somewhat ok?
Good point. I haven't looked to see if any drivers are using the
max_rate directly. Hopefully they aren't.
next prev parent reply other threads:[~2023-06-13 18:26 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 [this message]
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
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=86d58c6b131028a71964a0bcb135f01f.sboyd@kernel.org \
--to=sboyd@kernel.org \
--cc=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=maxime@cerno.tech \
--cc=mturquette@baylibre.com \
--cc=sebastian.reichel@collabora.com \
--cc=stable@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox