From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Stephen Boyd <sboyd@codeaurora.org>, Joel Stanley <joel@jms.id.au>
Cc: Lee Jones <lee.jones@linaro.org>,
Michael Turquette <mturquette@baylibre.com>,
linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Andrew Jeffery <andrew@aj.id.au>, Jeremy Kerr <jk@ozlabs.org>,
Rick Altherr <raltherr@google.com>,
Ryan Chen <ryan_chen@aspeedtech.com>,
Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH v6 4/5] clk: aspeed: Register gated clocks
Date: Fri, 22 Dec 2017 13:36:31 +1100 [thread overview]
Message-ID: <1513910191.2743.77.camel@kernel.crashing.org> (raw)
In-Reply-To: <20171221233927.GE7997@codeaurora.org>
On Thu, 2017-12-21 at 15:39 -0800, Stephen Boyd wrote:
> On 11/28, Joel Stanley wrote:
> > diff --git a/drivers/clk/clk-aspeed.c b/drivers/clk/clk-aspeed.c
> > index 839243691b26..b5dc3e298693 100644
> > --- a/drivers/clk/clk-aspeed.c
> > +++ b/drivers/clk/clk-aspeed.c
> > @@ -202,6 +202,107 @@ static const struct aspeed_clk_soc_data ast2400_data = {
> > .calc_pll = aspeed_ast2400_calc_pll,
> > };
> >
> > +static int aspeed_clk_enable(struct clk_hw *hw)
> > +{
> > + struct aspeed_clk_gate *gate = to_aspeed_clk_gate(hw);
> > + unsigned long flags;
> > + u32 clk = BIT(gate->clock_idx);
> > + u32 rst = BIT(gate->reset_idx);
> > +
> > + spin_lock_irqsave(gate->lock, flags);
> > +
> > + if (gate->reset_idx >= 0) {
> > + /* Put IP in reset */
> > + regmap_update_bits(gate->map, ASPEED_RESET_CTRL, rst, rst);
> > +
> > + /* Delay 100us */
> > + udelay(100);
> > + }
> > +
> > + /* Enable clock */
> > + regmap_update_bits(gate->map, ASPEED_CLK_STOP_CTRL, clk, 0);
> > +
> > + if (gate->reset_idx >= 0) {
> > + /* Delay 10ms */
> > + /* TODO: can we sleep here? */
> > + msleep(10);
>
> No you can't sleep here. It needs to delay because this is inside
> spinlock_irqsave.
Additionally you really don't want to delay for 10ms with interrupts
off :-(
Sadly, it looks like the clk framework already calls you with spinlock
irqsafe, which is a rather major suckage.
Stephen, why is that so ? That pretty much makes it impossible to
do sleeping things, which prevents things like i2c based clock
controllers etc...
I think the clk framework needs to be overhauled to use sleeping
mutexes instead. Doing clock enable/disable at interrupt time is
a bad idea anyway.
In the meantime, Joel, you have little choice but do an mdelay
though that really sucks.
> > + /* Take IP out of reset */
> > + regmap_update_bits(gate->map, ASPEED_RESET_CTRL, rst, 0);
> > + }
> > +
> > + spin_unlock_irqrestore(gate->lock, flags);
> > +
> > + return 0;
> > +}
WARNING: multiple messages have this Message-ID (diff)
From: benh@kernel.crashing.org (Benjamin Herrenschmidt)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v6 4/5] clk: aspeed: Register gated clocks
Date: Fri, 22 Dec 2017 13:36:31 +1100 [thread overview]
Message-ID: <1513910191.2743.77.camel@kernel.crashing.org> (raw)
In-Reply-To: <20171221233927.GE7997@codeaurora.org>
On Thu, 2017-12-21 at 15:39 -0800, Stephen Boyd wrote:
> On 11/28, Joel Stanley wrote:
> > diff --git a/drivers/clk/clk-aspeed.c b/drivers/clk/clk-aspeed.c
> > index 839243691b26..b5dc3e298693 100644
> > --- a/drivers/clk/clk-aspeed.c
> > +++ b/drivers/clk/clk-aspeed.c
> > @@ -202,6 +202,107 @@ static const struct aspeed_clk_soc_data ast2400_data = {
> > .calc_pll = aspeed_ast2400_calc_pll,
> > };
> >
> > +static int aspeed_clk_enable(struct clk_hw *hw)
> > +{
> > + struct aspeed_clk_gate *gate = to_aspeed_clk_gate(hw);
> > + unsigned long flags;
> > + u32 clk = BIT(gate->clock_idx);
> > + u32 rst = BIT(gate->reset_idx);
> > +
> > + spin_lock_irqsave(gate->lock, flags);
> > +
> > + if (gate->reset_idx >= 0) {
> > + /* Put IP in reset */
> > + regmap_update_bits(gate->map, ASPEED_RESET_CTRL, rst, rst);
> > +
> > + /* Delay 100us */
> > + udelay(100);
> > + }
> > +
> > + /* Enable clock */
> > + regmap_update_bits(gate->map, ASPEED_CLK_STOP_CTRL, clk, 0);
> > +
> > + if (gate->reset_idx >= 0) {
> > + /* Delay 10ms */
> > + /* TODO: can we sleep here? */
> > + msleep(10);
>
> No you can't sleep here. It needs to delay because this is inside
> spinlock_irqsave.
Additionally you really don't want to delay for 10ms with interrupts
off :-(
Sadly, it looks like the clk framework already calls you with spinlock
irqsafe, which is a rather major suckage.
Stephen, why is that so ? That pretty much makes it impossible to
do sleeping things, which prevents things like i2c based clock
controllers etc...
I think the clk framework needs to be overhauled to use sleeping
mutexes instead. Doing clock enable/disable at interrupt time is
a bad idea anyway.
In the meantime, Joel, you have little choice but do an mdelay
though that really sucks.
> > + /* Take IP out of reset */
> > + regmap_update_bits(gate->map, ASPEED_RESET_CTRL, rst, 0);
> > + }
> > +
> > + spin_unlock_irqrestore(gate->lock, flags);
> > +
> > + return 0;
> > +}
next prev parent reply other threads:[~2017-12-22 2:36 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-28 7:19 [PATCH v6 0/5] clk: Add Aspeed clock driver Joel Stanley
2017-11-28 7:19 ` Joel Stanley
2017-11-28 7:19 ` [PATCH v6 1/5] clk: Add clock driver for ASPEED BMC SoCs Joel Stanley
2017-11-28 7:19 ` Joel Stanley
2017-12-20 3:42 ` Joel Stanley
2017-12-20 3:42 ` Joel Stanley
2017-11-28 7:19 ` [PATCH v6 2/5] clk: aspeed: Register core clocks Joel Stanley
2017-11-28 7:19 ` Joel Stanley
2017-11-28 7:19 ` [PATCH v6 3/5] clk: aspeed: Add platform driver and register PLLs Joel Stanley
2017-11-28 7:19 ` Joel Stanley
2017-11-28 7:19 ` [PATCH v6 4/5] clk: aspeed: Register gated clocks Joel Stanley
2017-11-28 7:19 ` Joel Stanley
2017-12-21 23:39 ` Stephen Boyd
2017-12-21 23:39 ` Stephen Boyd
2017-12-22 2:36 ` Benjamin Herrenschmidt [this message]
2017-12-22 2:36 ` Benjamin Herrenschmidt
2017-12-22 2:43 ` Benjamin Herrenschmidt
2017-12-22 2:43 ` Benjamin Herrenschmidt
2017-12-27 1:32 ` Stephen Boyd
2017-12-27 1:32 ` Stephen Boyd
2017-12-29 22:03 ` Benjamin Herrenschmidt
2017-12-29 22:03 ` Benjamin Herrenschmidt
2018-01-02 5:46 ` Benjamin Herrenschmidt
2018-01-02 5:46 ` Benjamin Herrenschmidt
2018-01-02 18:16 ` Stephen Boyd
2018-01-02 18:16 ` Stephen Boyd
2017-11-28 7:19 ` [PATCH v6 5/5] clk: aspeed: Add reset controller Joel Stanley
2017-11-28 7:19 ` Joel Stanley
2017-12-06 7:56 ` [PATCH v6 0/5] clk: Add Aspeed clock driver Joel Stanley
2017-12-06 7:56 ` Joel Stanley
2017-12-21 23:40 ` Stephen Boyd
2017-12-21 23:40 ` Stephen Boyd
2017-12-22 1:42 ` Joel Stanley
2017-12-22 1:42 ` Joel Stanley
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=1513910191.2743.77.camel@kernel.crashing.org \
--to=benh@kernel.crashing.org \
--cc=andrew@aj.id.au \
--cc=arnd@arndb.de \
--cc=jk@ozlabs.org \
--cc=joel@jms.id.au \
--cc=lee.jones@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=raltherr@google.com \
--cc=ryan_chen@aspeedtech.com \
--cc=sboyd@codeaurora.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 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.