lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20191028145455.ECD1C208C0@mail.kernel.org>
Date:   Mon, 28 Oct 2019 07:54:55 -0700
From:   Stephen Boyd <sboyd@...nel.org>
To:     Alexandre Belloni <alexandre.belloni@...tlin.com>
Cc:     u.kleine-koenig@...gutronix.de,
        Nicolas Ferre <nicolas.ferre@...rochip.com>,
        Claudiu Beznea <claudiu.beznea@...rochip.com>,
        Michael Turquette <mturquette@...libre.com>,
        linux-clk@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] clk: at91: avoid sleeping early

Quoting Alexandre Belloni (2019-10-05 13:05:21)
> On 24/09/2019 13:20:15-0700, Stephen Boyd wrote:
> > Quoting Uwe  (2019-09-24 05:21:47)
> > > On Fri, Sep 20, 2019 at 05:39:06PM +0200, Alexandre Belloni wrote:
> > > > Note that this was already discussed a while ago and Arnd said this approach was
> > > > reasonable:
> > > >   https://lore.kernel.org/lkml/6120818.MyeJZ74hYa@wuerfel/
> > > > 
> > > >  drivers/clk/at91/clk-main.c |  5 ++++-
> > > >  drivers/clk/at91/sckc.c     | 20 ++++++++++++++++----
> > > >  2 files changed, 20 insertions(+), 5 deletions(-)
> > > > 
> > > > diff --git a/drivers/clk/at91/clk-main.c b/drivers/clk/at91/clk-main.c
> > > > index f607ee702c83..ccd48e7a3d74 100644
> > > > --- a/drivers/clk/at91/clk-main.c
> > > > +++ b/drivers/clk/at91/clk-main.c
> > > > @@ -293,7 +293,10 @@ static int clk_main_probe_frequency(struct regmap *regmap)
> > > >               regmap_read(regmap, AT91_CKGR_MCFR, &mcfr);
> > > >               if (mcfr & AT91_PMC_MAINRDY)
> > > >                       return 0;
> > > > -             usleep_range(MAINF_LOOP_MIN_WAIT, MAINF_LOOP_MAX_WAIT);
> > > > +             if (system_state < SYSTEM_RUNNING)
> > > > +                     udelay(MAINF_LOOP_MIN_WAIT);
> > > > +             else
> > > > +                     usleep_range(MAINF_LOOP_MIN_WAIT, MAINF_LOOP_MAX_WAIT);
> > > 
> > > Given that this construct is introduced several times, I wonder if we
> > > want something like:
> > > 
> > >         static inline void early_usleep_range(unsigned long min, unsigned long max)
> > >         {
> > >                 if (system_state < SYSTEM_RUNNING)
> > >                         udelay(min);
> > >                 else
> > >                         usleep_range(min, max);
> > >         }
> > > 
> > 
> > Maybe, but I think the intent is to not encourage this behavior? So
> > providing a wrapper will make it "easy" and then we'll have to tell
> > users to stop calling it. Another idea would be to make usleep_range()
> > "do the right thing" and call udelay if the system isn't running. And
> > another idea from tlgx[1] is to pull the delay logic into another clk op
> > that we can call to see when the enable or prepare is done. That may be
> > possible by introducing another clk_ops callback that when present
> > indicates we should sleep or delay for so much time while waiting for
> > the prepare or enable to complete.
> > 
> > [1] https://lkml.kernel.org/r/alpine.DEB.2.11.1606061448010.28031@nanos
> > 
> 
> Do you want me to implement that now or are you planning to apply the
> patch in the meantime ?
> 
> 
 
I'll just apply this for now to clk-fixes and merge it up next week. It
would be great to do the other idea though, as a long term effort to
reduce all the busy loop code we have in clk drivers. No worries, I'll
put it on the todo list.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ