[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <6nihw4k2vdtmjpvbei5ahb7cmtmuyi2w5m4pwhjrmdqi2yp7v6@vdpg5kwa7trl>
Date: Wed, 14 Jun 2023 12:28:14 +0200
From: Maxime Ripard <maxime@...no.tech>
To: Stephen Boyd <sboyd@...nel.org>
Cc: Michael Turquette <mturquette@...libre.com>,
Sebastian Reichel <sebastian.reichel@...labora.com>,
linux-clk@...r.kernel.org, linux-kernel@...r.kernel.org,
Christopher Obbard <chris.obbard@...labora.com>,
David Laight <David.Laight@...lab.com>, kernel@...labora.com,
stable@...r.kernel.org
Subject: Re: [PATCH v2 1/2] clk: composite: Fix handling of high clock rates
On Tue, Jun 13, 2023 at 11:25:12AM -0700, Stephen Boyd wrote:
> 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.
I had a quick grep for 'req->max_rate' under drivers/clk and there's no
driver using abs on that field.
Maxime
Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)
Powered by blists - more mailing lists