* clk-lpc18xx-creg - scheduling while atomic
@ 2016-05-05 11:53 Joachim Eastwood
2016-05-05 15:11 ` Vladimir Zapolskiy
0 siblings, 1 reply; 6+ messages in thread
From: Joachim Eastwood @ 2016-05-05 11:53 UTC (permalink / raw)
To: Mike Turquette, Stephen Boyd; +Cc: linux-clk
Hi,
I just tried next/master on my lpc18xx platform and got a 'scheduling
while atomic' on the msleep in clk_creg_32k_prepare. This does not
occur on 4.6-rc1. See below for backtrace.
According to Documentation/clk.txt, Part 6 - Locking, sleeping is
allowed in prepare functions. Changing the msleep to an mdelay makes
the problem go away.
So any ideas to what is going on?
regards,
Joachim Eastwood
BUG: scheduling while atomic: swapper/0/0x00000002
CPU: 0 PID: 0 Comm: swapper Not tainted
4.6.0-rc6-next-20160505-00001-g5c8320450d1c #826
Hardware name: NXP LPC18xx/43xx (Device Tree)
[<2800be81>] (unwind_backtrace) from [<2800b22f>] (show_stack+0xb/0xc)
[<2800b22f>] (show_stack) from [<2801ea21>] (__schedule_bug+0x2d/0x44)
[<2801ea21>] (__schedule_bug) from [<281dc937>] (__schedule+0x3b/0x268)
[<281dc937>] (__schedule) from [<281dcbbb>] (schedule+0x57/0x64)
[<281dcbbb>] (schedule) from [<281de8ef>] (schedule_timeout+0xfb/0x120)
[<281de8ef>] (schedule_timeout) from [<28030fcd>] (msleep+0xf/0x12)
[<28030fcd>] (msleep) from [<28165a6d>] (clk_creg_32k_prepare+0x1f/0x24)
[<28165a6d>] (clk_creg_32k_prepare) from [<281620d5>]
(clk_core_prepare+0x1d/0x36)
[<281620d5>] (clk_core_prepare) from [<2816340b>] (clk_register+0x22f/0x318)
[<2816340b>] (clk_register) from [<282b06c9>] (lpc18xx_creg_clk_init+0x55/0x84)
[<282b06c9>] (lpc18xx_creg_clk_init) from [<282b0149>] (of_clk_init+0xc1/0x12c)
[<282b0149>] (of_clk_init) from [<282a665d>] (time_init+0x15/0x20)
[<282a665d>] (time_init) from [<282a457d>] (start_kernel+0x169/0x274)
[<282a457d>] (start_kernel) from [<28008025>] (0x28008025)
bad: scheduling from the idle thread!
CPU: 0 PID: 0 Comm: swapper Tainted: G W
4.6.0-rc6-next-20160505-00001-g5c8320450d1c #826
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: clk-lpc18xx-creg - scheduling while atomic
2016-05-05 11:53 clk-lpc18xx-creg - scheduling while atomic Joachim Eastwood
@ 2016-05-05 15:11 ` Vladimir Zapolskiy
2016-05-05 16:00 ` Joachim Eastwood
0 siblings, 1 reply; 6+ messages in thread
From: Vladimir Zapolskiy @ 2016-05-05 15:11 UTC (permalink / raw)
To: Joachim Eastwood; +Cc: Mike Turquette, Stephen Boyd, linux-clk
Hi Joachim,
On 05.05.2016 14:53, Joachim Eastwood wrote:
> Hi,
>
> I just tried next/master on my lpc18xx platform and got a 'scheduling
> while atomic' on the msleep in clk_creg_32k_prepare. This does not
> occur on 4.6-rc1. See below for backtrace.
>
> According to Documentation/clk.txt, Part 6 - Locking, sleeping is
> allowed in prepare functions. Changing the msleep to an mdelay makes
> the problem go away.
>
> So any ideas to what is going on?
>
the bug description resembles a recent problem on iMX7, you may find
details from "clk: imx: do not sleep if IRQ's are still disabled"
thread, the same sleeping clk_core_prepare() from time_init(), while
sleeping is not allowed until the timer is ready.
With best wishes,
Vladimir
>
> BUG: scheduling while atomic: swapper/0/0x00000002
> CPU: 0 PID: 0 Comm: swapper Not tainted
> 4.6.0-rc6-next-20160505-00001-g5c8320450d1c #826
> Hardware name: NXP LPC18xx/43xx (Device Tree)
> [<2800be81>] (unwind_backtrace) from [<2800b22f>] (show_stack+0xb/0xc)
> [<2800b22f>] (show_stack) from [<2801ea21>] (__schedule_bug+0x2d/0x44)
> [<2801ea21>] (__schedule_bug) from [<281dc937>] (__schedule+0x3b/0x268)
> [<281dc937>] (__schedule) from [<281dcbbb>] (schedule+0x57/0x64)
> [<281dcbbb>] (schedule) from [<281de8ef>] (schedule_timeout+0xfb/0x120)
> [<281de8ef>] (schedule_timeout) from [<28030fcd>] (msleep+0xf/0x12)
> [<28030fcd>] (msleep) from [<28165a6d>] (clk_creg_32k_prepare+0x1f/0x24)
> [<28165a6d>] (clk_creg_32k_prepare) from [<281620d5>]
> (clk_core_prepare+0x1d/0x36)
> [<281620d5>] (clk_core_prepare) from [<2816340b>] (clk_register+0x22f/0x318)
> [<2816340b>] (clk_register) from [<282b06c9>] (lpc18xx_creg_clk_init+0x55/0x84)
> [<282b06c9>] (lpc18xx_creg_clk_init) from [<282b0149>] (of_clk_init+0xc1/0x12c)
> [<282b0149>] (of_clk_init) from [<282a665d>] (time_init+0x15/0x20)
> [<282a665d>] (time_init) from [<282a457d>] (start_kernel+0x169/0x274)
> [<282a457d>] (start_kernel) from [<28008025>] (0x28008025)
> bad: scheduling from the idle thread!
> CPU: 0 PID: 0 Comm: swapper Tainted: G W
> 4.6.0-rc6-next-20160505-00001-g5c8320450d1c #826
> --
> To unsubscribe from this list: send the line "unsubscribe linux-clk" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: clk-lpc18xx-creg - scheduling while atomic
2016-05-05 15:11 ` Vladimir Zapolskiy
@ 2016-05-05 16:00 ` Joachim Eastwood
2016-05-06 17:17 ` Stephen Boyd
0 siblings, 1 reply; 6+ messages in thread
From: Joachim Eastwood @ 2016-05-05 16:00 UTC (permalink / raw)
To: Stephen Boyd; +Cc: Mike Turquette, linux-clk, Vladimir Zapolskiy
Hi Stephen,
On 5 May 2016 at 17:11, Vladimir Zapolskiy <vz@mleia.com> wrote:
> Hi Joachim,
>
> On 05.05.2016 14:53, Joachim Eastwood wrote:
>> Hi,
>>
>> I just tried next/master on my lpc18xx platform and got a 'scheduling
>> while atomic' on the msleep in clk_creg_32k_prepare. This does not
>> occur on 4.6-rc1. See below for backtrace.
>>
>> According to Documentation/clk.txt, Part 6 - Locking, sleeping is
>> allowed in prepare functions. Changing the msleep to an mdelay makes
>> the problem go away.
>>
>> So any ideas to what is going on?
>>
>
> the bug description resembles a recent problem on iMX7, you may find
> details from "clk: imx: do not sleep if IRQ's are still disabled"
> thread, the same sleeping clk_core_prepare() from time_init(), while
> sleeping is not allowed until the timer is ready.
Thanks alot, Vladimir!
That sheed more light on the problem.
Doing a partial revert of 32b9b10961860 ("clk: Allow clocks to be
marked as CRITICAL") also fixes the problem. 32b9b10961860 makes it
possible to call clk prepare, which is allowed to sleep, when clocks
are first created from of_clk_init(). of_clk_init() is called very
early where it's not allow to sleep at all[1].
What do you suggest, Stephen?
Calling prepare() from __clk_core_init() doesn't seem like a good idea
to me. I think the core clk handing of critical clocks needs to change
here.
regards,
Joachim Eastwood
[1] https://lkml.org/lkml/2016/4/27/233
>> BUG: scheduling while atomic: swapper/0/0x00000002
>> CPU: 0 PID: 0 Comm: swapper Not tainted
>> 4.6.0-rc6-next-20160505-00001-g5c8320450d1c #826
>> Hardware name: NXP LPC18xx/43xx (Device Tree)
>> [<2800be81>] (unwind_backtrace) from [<2800b22f>] (show_stack+0xb/0xc)
>> [<2800b22f>] (show_stack) from [<2801ea21>] (__schedule_bug+0x2d/0x44)
>> [<2801ea21>] (__schedule_bug) from [<281dc937>] (__schedule+0x3b/0x268)
>> [<281dc937>] (__schedule) from [<281dcbbb>] (schedule+0x57/0x64)
>> [<281dcbbb>] (schedule) from [<281de8ef>] (schedule_timeout+0xfb/0x120)
>> [<281de8ef>] (schedule_timeout) from [<28030fcd>] (msleep+0xf/0x12)
>> [<28030fcd>] (msleep) from [<28165a6d>] (clk_creg_32k_prepare+0x1f/0x24)
>> [<28165a6d>] (clk_creg_32k_prepare) from [<281620d5>]
>> (clk_core_prepare+0x1d/0x36)
>> [<281620d5>] (clk_core_prepare) from [<2816340b>] (clk_register+0x22f/0x318)
>> [<2816340b>] (clk_register) from [<282b06c9>] (lpc18xx_creg_clk_init+0x55/0x84)
>> [<282b06c9>] (lpc18xx_creg_clk_init) from [<282b0149>] (of_clk_init+0xc1/0x12c)
>> [<282b0149>] (of_clk_init) from [<282a665d>] (time_init+0x15/0x20)
>> [<282a665d>] (time_init) from [<282a457d>] (start_kernel+0x169/0x274)
>> [<282a457d>] (start_kernel) from [<28008025>] (0x28008025)
>> bad: scheduling from the idle thread!
>> CPU: 0 PID: 0 Comm: swapper Tainted: G W
>> 4.6.0-rc6-next-20160505-00001-g5c8320450d1c #826
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-clk" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: clk-lpc18xx-creg - scheduling while atomic
2016-05-05 16:00 ` Joachim Eastwood
@ 2016-05-06 17:17 ` Stephen Boyd
2016-05-06 17:28 ` Joachim Eastwood
0 siblings, 1 reply; 6+ messages in thread
From: Stephen Boyd @ 2016-05-06 17:17 UTC (permalink / raw)
To: Joachim Eastwood; +Cc: Mike Turquette, linux-clk, Vladimir Zapolskiy
On 05/05, Joachim Eastwood wrote:
> Hi Stephen,
>
> On 5 May 2016 at 17:11, Vladimir Zapolskiy <vz@mleia.com> wrote:
> > Hi Joachim,
> >
> > On 05.05.2016 14:53, Joachim Eastwood wrote:
> >> Hi,
> >>
> >> I just tried next/master on my lpc18xx platform and got a 'scheduling
> >> while atomic' on the msleep in clk_creg_32k_prepare. This does not
> >> occur on 4.6-rc1. See below for backtrace.
> >>
> >> According to Documentation/clk.txt, Part 6 - Locking, sleeping is
> >> allowed in prepare functions. Changing the msleep to an mdelay makes
> >> the problem go away.
> >>
> >> So any ideas to what is going on?
> >>
> >
> > the bug description resembles a recent problem on iMX7, you may find
> > details from "clk: imx: do not sleep if IRQ's are still disabled"
> > thread, the same sleeping clk_core_prepare() from time_init(), while
> > sleeping is not allowed until the timer is ready.
>
> Thanks alot, Vladimir!
> That sheed more light on the problem.
>
> Doing a partial revert of 32b9b10961860 ("clk: Allow clocks to be
> marked as CRITICAL") also fixes the problem. 32b9b10961860 makes it
> possible to call clk prepare, which is allowed to sleep, when clocks
> are first created from of_clk_init(). of_clk_init() is called very
> early where it's not allow to sleep at all[1].
>
> What do you suggest, Stephen?
> Calling prepare() from __clk_core_init() doesn't seem like a good idea
> to me. I think the core clk handing of critical clocks needs to change
> here.
Yeah we need to figure out something for people who are using
critical clks in of_clk_init() path because that's just not going
to work if they sleep in their prepare callbacks.
Regardless, is your driver using critical clks? It seems more
like we need to apply this patch so that the flags member of
clk_init_data isn't full of junk that might match against the
critical flag?
---8<----
diff --git a/drivers/clk/nxp/clk-lpc18xx-creg.c b/drivers/clk/nxp/clk-lpc18xx-creg.c
index d44b61afa2dc..9e35749dafdf 100644
--- a/drivers/clk/nxp/clk-lpc18xx-creg.c
+++ b/drivers/clk/nxp/clk-lpc18xx-creg.c
@@ -147,6 +147,7 @@ static struct clk *clk_register_creg_clk(struct device *dev,
init.name = creg_clk->name;
init.parent_names = parent_name;
init.num_parents = 1;
+ init.flags = 0;
creg_clk->reg = syscon;
creg_clk->hw.init = &init;
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: clk-lpc18xx-creg - scheduling while atomic
2016-05-06 17:17 ` Stephen Boyd
@ 2016-05-06 17:28 ` Joachim Eastwood
2016-05-06 17:32 ` Stephen Boyd
0 siblings, 1 reply; 6+ messages in thread
From: Joachim Eastwood @ 2016-05-06 17:28 UTC (permalink / raw)
To: Stephen Boyd; +Cc: Mike Turquette, linux-clk, Vladimir Zapolskiy
Hi Stephen,
On 6 May 2016 at 19:17, Stephen Boyd <sboyd@codeaurora.org> wrote:
> On 05/05, Joachim Eastwood wrote:
>> Hi Stephen,
>>
>> On 5 May 2016 at 17:11, Vladimir Zapolskiy <vz@mleia.com> wrote:
>> > Hi Joachim,
>> >
>> > On 05.05.2016 14:53, Joachim Eastwood wrote:
>> >> Hi,
>> >>
>> >> I just tried next/master on my lpc18xx platform and got a 'scheduling
>> >> while atomic' on the msleep in clk_creg_32k_prepare. This does not
>> >> occur on 4.6-rc1. See below for backtrace.
>> >>
>> >> According to Documentation/clk.txt, Part 6 - Locking, sleeping is
>> >> allowed in prepare functions. Changing the msleep to an mdelay makes
>> >> the problem go away.
>> >>
>> >> So any ideas to what is going on?
>> >>
>> >
>> > the bug description resembles a recent problem on iMX7, you may find
>> > details from "clk: imx: do not sleep if IRQ's are still disabled"
>> > thread, the same sleeping clk_core_prepare() from time_init(), while
>> > sleeping is not allowed until the timer is ready.
>>
>> Thanks alot, Vladimir!
>> That sheed more light on the problem.
>>
>> Doing a partial revert of 32b9b10961860 ("clk: Allow clocks to be
>> marked as CRITICAL") also fixes the problem. 32b9b10961860 makes it
>> possible to call clk prepare, which is allowed to sleep, when clocks
>> are first created from of_clk_init(). of_clk_init() is called very
>> early where it's not allow to sleep at all[1].
>>
>> What do you suggest, Stephen?
>> Calling prepare() from __clk_core_init() doesn't seem like a good idea
>> to me. I think the core clk handing of critical clocks needs to change
>> here.
>
> Yeah we need to figure out something for people who are using
> critical clks in of_clk_init() path because that's just not going
> to work if they sleep in their prepare callbacks.
>
> Regardless, is your driver using critical clks? It seems more
> like we need to apply this patch so that the flags member of
> clk_init_data isn't full of junk that might match against the
> critical flag?
I was wondering why it triggered on my driver indeed :)
But we did notice a problem that would have popped up sooner or later
in some other driver.
Thanks for spotting the bug in lpc18xx-creg. Are you going to apply it directly?
> ---8<----
> diff --git a/drivers/clk/nxp/clk-lpc18xx-creg.c b/drivers/clk/nxp/clk-lpc18xx-creg.c
> index d44b61afa2dc..9e35749dafdf 100644
> --- a/drivers/clk/nxp/clk-lpc18xx-creg.c
> +++ b/drivers/clk/nxp/clk-lpc18xx-creg.c
> @@ -147,6 +147,7 @@ static struct clk *clk_register_creg_clk(struct device *dev,
> init.name = creg_clk->name;
> init.parent_names = parent_name;
> init.num_parents = 1;
> + init.flags = 0;
>
> creg_clk->reg = syscon;
> creg_clk->hw.init = &init;
In case you want to take it directly:
Acked-by: Joachim Eastwood <manabian@gmail.com>
regards,
Joachim Eastwood
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: clk-lpc18xx-creg - scheduling while atomic
2016-05-06 17:28 ` Joachim Eastwood
@ 2016-05-06 17:32 ` Stephen Boyd
0 siblings, 0 replies; 6+ messages in thread
From: Stephen Boyd @ 2016-05-06 17:32 UTC (permalink / raw)
To: Joachim Eastwood; +Cc: Mike Turquette, linux-clk, Vladimir Zapolskiy
On 05/06, Joachim Eastwood wrote:
>
> Thanks for spotting the bug in lpc18xx-creg. Are you going to apply it directly?
Yes I'll fix it up today, thanks.
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-05-06 17:32 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-05 11:53 clk-lpc18xx-creg - scheduling while atomic Joachim Eastwood
2016-05-05 15:11 ` Vladimir Zapolskiy
2016-05-05 16:00 ` Joachim Eastwood
2016-05-06 17:17 ` Stephen Boyd
2016-05-06 17:28 ` Joachim Eastwood
2016-05-06 17:32 ` Stephen Boyd
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).