From: Stephen Boyd <sboyd@kernel.org>
To: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: u.kleine-koenig@pengutronix.de,
Nicolas Ferre <nicolas.ferre@microchip.com>,
Claudiu Beznea <claudiu.beznea@microchip.com>,
Michael Turquette <mturquette@baylibre.com>,
linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] clk: at91: avoid sleeping early
Date: Mon, 28 Oct 2019 07:54:55 -0700 [thread overview]
Message-ID: <20191028145455.ECD1C208C0@mail.kernel.org> (raw)
In-Reply-To: <20191005200521.GB4254@piout.net>
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.
WARNING: multiple messages have this Message-ID (diff)
From: Stephen Boyd <sboyd@kernel.org>
To: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: linux-kernel@vger.kernel.org,
Michael Turquette <mturquette@baylibre.com>,
Claudiu Beznea <claudiu.beznea@microchip.com>,
u.kleine-koenig@pengutronix.de, linux-clk@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] clk: at91: avoid sleeping early
Date: Mon, 28 Oct 2019 07:54:55 -0700 [thread overview]
Message-ID: <20191028145455.ECD1C208C0@mail.kernel.org> (raw)
In-Reply-To: <20191005200521.GB4254@piout.net>
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.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-10-28 14:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-20 15:39 [PATCH] clk: at91: avoid sleeping early Alexandre Belloni
2019-09-20 15:39 ` Alexandre Belloni
2019-09-23 16:58 ` Stephen Boyd
2019-09-23 21:34 ` Alexandre Belloni
2019-09-23 21:34 ` Alexandre Belloni
2019-09-24 12:21 ` Uwe Kleine-König
2019-09-24 12:21 ` Uwe Kleine-König
2019-09-24 20:20 ` Stephen Boyd
2019-09-24 20:20 ` Stephen Boyd
2019-10-05 20:05 ` Alexandre Belloni
2019-10-05 20:05 ` Alexandre Belloni
2019-10-28 14:54 ` Stephen Boyd [this message]
2019-10-28 14:54 ` Stephen Boyd
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=20191028145455.ECD1C208C0@mail.kernel.org \
--to=sboyd@kernel.org \
--cc=alexandre.belloni@bootlin.com \
--cc=claudiu.beznea@microchip.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=nicolas.ferre@microchip.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.