2014-10-27 13:48:25

by Geert Uytterhoeven

[permalink] [raw]
Subject: [PATCH] cpufreq: cpufreq-dt: Restore default cpumask_setall(policy->cpus)

Commit 34e5a5273d6aa0ee ("cpufreq: cpufreq-dt: extend with
platform_data") changed cpufreq_init() to only call
cpumask_setall(policy->cpus) if the platform data indicates that all
CPUs share the same clock. Before, cpufreq_generic_init() did this
unconditionally.

This causes a crash on r8a7791/koelsch when resuming from s2ram:

Enabling non-boot CPUs ...
CPU1: Booted secondary processor
Unable to handle kernel NULL pointer dereference at virtual address 0000003c
pgd = ee71f980
[0000003c] *pgd=6eeb6003, *pmd=6e0e9003, *pte=00000000
Internal error: Oops: a07 [#1] SMP ARM
Modules linked in:
CPU: 0 PID: 1397 Comm: s2ram Tainted: G W 3.18.0-rc2-koelsch-00762-g7eed2a4e61d2d978 #581
task: ee6b76c0 ti: ee7f0000 task.ti: ee7f0000
PC is at __cpufreq_add_dev.isra.24+0x24c/0x77c
LR is at __cpufreq_add_dev.isra.24+0x244/0x77c
pc : [<c029e084>] lr : [<c029e07c>] psr: 60000153
sp : ee7f1d48 ip : ee7f1d48 fp : ee7f1d84
r10: c04e8448 r9 : 00000000 r8 : 00000001
r7 : c054a8c4 r6 : 00000001 r5 : 00000001 r4 : 00000000
r3 : 00000000 r2 : 00000000 r1 : 20000153 r0 : c054a950
Flags: nZCv IRQs on FIQs off Mode SVC_32 ISA ARM Segment user
Control: 30c5307d Table: 6e71f980 DAC: fffffffd
Process s2ram (pid: 1397, stack limit = 0xee7f0240)

...

Backtrace:
[<c029de38>] (__cpufreq_add_dev.isra.24) from [<c029e620>] (cpufreq_cpu_callback+0x6c/0x74)
r10:eec75240 r9:c04e8448 r8:c04ef3a0 r7:00000001 r6:00000012 r5:00000000
r4:00000012
[<c029e5b4>] (cpufreq_cpu_callback) from [<c003f20c>] (notifier_call_chain+0x48/0x70)
r4:ffffffdd r3:c029e5b4
[<c003f1c4>] (notifier_call_chain) from [<c003f2cc>] (__raw_notifier_call_chain+0x1c/0x24)
r8:00000001 r7:00000010 r6:00000000 r5:00000000 r4:00000012 r3:ffffffff
[<c003f2b0>] (__raw_notifier_call_chain) from [<c0026a00>] (__cpu_notify+0x34/0x50)
[<c00269cc>] (__cpu_notify) from [<c0026a34>] (cpu_notify+0x18/0x1c)
r4:00000001
[<c0026a1c>] (cpu_notify) from [<c0026c44>] (_cpu_up+0x108/0x144)
[<c0026b3c>] (_cpu_up) from [<c0381c68>] (enable_nonboot_cpus+0x68/0xb8)
r10:00000000 r9:c04e8ee6 r8:00000000 r7:00000003 r6:c04e8528 r5:c0506248
r4:00000001
[<c0381c00>] (enable_nonboot_cpus) from [<c0059038>] (suspend_devices_and_enter+0x29c/0x3e8)
r6:c0506e70 r5:00000000 r4:00000000 r3:60000153

Restore the old default of calling cpumask_setall(policy->cpus) if no
platform data is available to fix this.

Fixes: 34e5a5273d6aa0ee ("cpufreq: cpufreq-dt: extend with
platform_data")
Signed-off-by: Geert Uytterhoeven <[email protected]>
---
drivers/cpufreq/cpufreq-dt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
index 2f25958053778ad1..3bfc1175a548c49c 100644
--- a/drivers/cpufreq/cpufreq-dt.c
+++ b/drivers/cpufreq/cpufreq-dt.c
@@ -293,7 +293,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)
policy->cpuinfo.transition_latency = transition_latency;

pd = cpufreq_get_driver_data();
- if (pd && !pd->independent_clocks)
+ if (!pd || !pd->independent_clocks)
cpumask_setall(policy->cpus);

of_node_put(np);
--
1.9.1


2014-10-27 14:23:16

by Thomas Petazzoni

[permalink] [raw]
Subject: Re: [PATCH] cpufreq: cpufreq-dt: Restore default cpumask_setall(policy->cpus)

Dear Geert Uytterhoeven,

On Mon, 27 Oct 2014 14:44:40 +0100, Geert Uytterhoeven wrote:
> Commit 34e5a5273d6aa0ee ("cpufreq: cpufreq-dt: extend with
> platform_data") changed cpufreq_init() to only call
> cpumask_setall(policy->cpus) if the platform data indicates that all
> CPUs share the same clock. Before, cpufreq_generic_init() did this
> unconditionally.
>
> This causes a crash on r8a7791/koelsch when resuming from s2ram:
>
> Enabling non-boot CPUs ...
> CPU1: Booted secondary processor
> Unable to handle kernel NULL pointer dereference at virtual address 0000003c
> pgd = ee71f980
> [0000003c] *pgd=6eeb6003, *pmd=6e0e9003, *pte=00000000
> Internal error: Oops: a07 [#1] SMP ARM
> Modules linked in:
> CPU: 0 PID: 1397 Comm: s2ram Tainted: G W 3.18.0-rc2-koelsch-00762-g7eed2a4e61d2d978 #581
> task: ee6b76c0 ti: ee7f0000 task.ti: ee7f0000
> PC is at __cpufreq_add_dev.isra.24+0x24c/0x77c
> LR is at __cpufreq_add_dev.isra.24+0x244/0x77c
> pc : [<c029e084>] lr : [<c029e07c>] psr: 60000153
> sp : ee7f1d48 ip : ee7f1d48 fp : ee7f1d84
> r10: c04e8448 r9 : 00000000 r8 : 00000001
> r7 : c054a8c4 r6 : 00000001 r5 : 00000001 r4 : 00000000
> r3 : 00000000 r2 : 00000000 r1 : 20000153 r0 : c054a950
> Flags: nZCv IRQs on FIQs off Mode SVC_32 ISA ARM Segment user
> Control: 30c5307d Table: 6e71f980 DAC: fffffffd
> Process s2ram (pid: 1397, stack limit = 0xee7f0240)
>
> ...
>
> Backtrace:
> [<c029de38>] (__cpufreq_add_dev.isra.24) from [<c029e620>] (cpufreq_cpu_callback+0x6c/0x74)
> r10:eec75240 r9:c04e8448 r8:c04ef3a0 r7:00000001 r6:00000012 r5:00000000
> r4:00000012
> [<c029e5b4>] (cpufreq_cpu_callback) from [<c003f20c>] (notifier_call_chain+0x48/0x70)
> r4:ffffffdd r3:c029e5b4
> [<c003f1c4>] (notifier_call_chain) from [<c003f2cc>] (__raw_notifier_call_chain+0x1c/0x24)
> r8:00000001 r7:00000010 r6:00000000 r5:00000000 r4:00000012 r3:ffffffff
> [<c003f2b0>] (__raw_notifier_call_chain) from [<c0026a00>] (__cpu_notify+0x34/0x50)
> [<c00269cc>] (__cpu_notify) from [<c0026a34>] (cpu_notify+0x18/0x1c)
> r4:00000001
> [<c0026a1c>] (cpu_notify) from [<c0026c44>] (_cpu_up+0x108/0x144)
> [<c0026b3c>] (_cpu_up) from [<c0381c68>] (enable_nonboot_cpus+0x68/0xb8)
> r10:00000000 r9:c04e8ee6 r8:00000000 r7:00000003 r6:c04e8528 r5:c0506248
> r4:00000001
> [<c0381c00>] (enable_nonboot_cpus) from [<c0059038>] (suspend_devices_and_enter+0x29c/0x3e8)
> r6:c0506e70 r5:00000000 r4:00000000 r3:60000153
>
> Restore the old default of calling cpumask_setall(policy->cpus) if no
> platform data is available to fix this.
>
> Fixes: 34e5a5273d6aa0ee ("cpufreq: cpufreq-dt: extend with
> platform_data")
> Signed-off-by: Geert Uytterhoeven <[email protected]>
> ---
> drivers/cpufreq/cpufreq-dt.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
> index 2f25958053778ad1..3bfc1175a548c49c 100644
> --- a/drivers/cpufreq/cpufreq-dt.c
> +++ b/drivers/cpufreq/cpufreq-dt.c
> @@ -293,7 +293,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)
> policy->cpuinfo.transition_latency = transition_latency;
>
> pd = cpufreq_get_driver_data();
> - if (pd && !pd->independent_clocks)
> + if (!pd || !pd->independent_clocks)
> cpumask_setall(policy->cpus);
>
> of_node_put(np);

Aah, yes, indeed.

Reviewed-by: Thomas Petazzoni <[email protected]>

Thanks for spotting the issue and fixing it!

Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

2014-10-27 23:56:56

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH] cpufreq: cpufreq-dt: Restore default cpumask_setall(policy->cpus)

On Monday, October 27, 2014 03:22:51 PM Thomas Petazzoni wrote:
> Dear Geert Uytterhoeven,
>
> On Mon, 27 Oct 2014 14:44:40 +0100, Geert Uytterhoeven wrote:
> > Commit 34e5a5273d6aa0ee ("cpufreq: cpufreq-dt: extend with
> > platform_data") changed cpufreq_init() to only call
> > cpumask_setall(policy->cpus) if the platform data indicates that all
> > CPUs share the same clock. Before, cpufreq_generic_init() did this
> > unconditionally.
> >
> > This causes a crash on r8a7791/koelsch when resuming from s2ram:
> >
> > Enabling non-boot CPUs ...
> > CPU1: Booted secondary processor
> > Unable to handle kernel NULL pointer dereference at virtual address 0000003c
> > pgd = ee71f980
> > [0000003c] *pgd=6eeb6003, *pmd=6e0e9003, *pte=00000000
> > Internal error: Oops: a07 [#1] SMP ARM
> > Modules linked in:
> > CPU: 0 PID: 1397 Comm: s2ram Tainted: G W 3.18.0-rc2-koelsch-00762-g7eed2a4e61d2d978 #581
> > task: ee6b76c0 ti: ee7f0000 task.ti: ee7f0000
> > PC is at __cpufreq_add_dev.isra.24+0x24c/0x77c
> > LR is at __cpufreq_add_dev.isra.24+0x244/0x77c
> > pc : [<c029e084>] lr : [<c029e07c>] psr: 60000153
> > sp : ee7f1d48 ip : ee7f1d48 fp : ee7f1d84
> > r10: c04e8448 r9 : 00000000 r8 : 00000001
> > r7 : c054a8c4 r6 : 00000001 r5 : 00000001 r4 : 00000000
> > r3 : 00000000 r2 : 00000000 r1 : 20000153 r0 : c054a950
> > Flags: nZCv IRQs on FIQs off Mode SVC_32 ISA ARM Segment user
> > Control: 30c5307d Table: 6e71f980 DAC: fffffffd
> > Process s2ram (pid: 1397, stack limit = 0xee7f0240)
> >
> > ...
> >
> > Backtrace:
> > [<c029de38>] (__cpufreq_add_dev.isra.24) from [<c029e620>] (cpufreq_cpu_callback+0x6c/0x74)
> > r10:eec75240 r9:c04e8448 r8:c04ef3a0 r7:00000001 r6:00000012 r5:00000000
> > r4:00000012
> > [<c029e5b4>] (cpufreq_cpu_callback) from [<c003f20c>] (notifier_call_chain+0x48/0x70)
> > r4:ffffffdd r3:c029e5b4
> > [<c003f1c4>] (notifier_call_chain) from [<c003f2cc>] (__raw_notifier_call_chain+0x1c/0x24)
> > r8:00000001 r7:00000010 r6:00000000 r5:00000000 r4:00000012 r3:ffffffff
> > [<c003f2b0>] (__raw_notifier_call_chain) from [<c0026a00>] (__cpu_notify+0x34/0x50)
> > [<c00269cc>] (__cpu_notify) from [<c0026a34>] (cpu_notify+0x18/0x1c)
> > r4:00000001
> > [<c0026a1c>] (cpu_notify) from [<c0026c44>] (_cpu_up+0x108/0x144)
> > [<c0026b3c>] (_cpu_up) from [<c0381c68>] (enable_nonboot_cpus+0x68/0xb8)
> > r10:00000000 r9:c04e8ee6 r8:00000000 r7:00000003 r6:c04e8528 r5:c0506248
> > r4:00000001
> > [<c0381c00>] (enable_nonboot_cpus) from [<c0059038>] (suspend_devices_and_enter+0x29c/0x3e8)
> > r6:c0506e70 r5:00000000 r4:00000000 r3:60000153
> >
> > Restore the old default of calling cpumask_setall(policy->cpus) if no
> > platform data is available to fix this.
> >
> > Fixes: 34e5a5273d6aa0ee ("cpufreq: cpufreq-dt: extend with
> > platform_data")
> > Signed-off-by: Geert Uytterhoeven <[email protected]>
> > ---
> > drivers/cpufreq/cpufreq-dt.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
> > index 2f25958053778ad1..3bfc1175a548c49c 100644
> > --- a/drivers/cpufreq/cpufreq-dt.c
> > +++ b/drivers/cpufreq/cpufreq-dt.c
> > @@ -293,7 +293,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)
> > policy->cpuinfo.transition_latency = transition_latency;
> >
> > pd = cpufreq_get_driver_data();
> > - if (pd && !pd->independent_clocks)
> > + if (!pd || !pd->independent_clocks)
> > cpumask_setall(policy->cpus);
> >
> > of_node_put(np);
>
> Aah, yes, indeed.
>
> Reviewed-by: Thomas Petazzoni <[email protected]>
>
> Thanks for spotting the issue and fixing it!

Applied, thanks!