* [PATCH] cpuidle: Fix panic in CPU off-lining with no idle driver
@ 2012-04-01 3:37 Toshi Kani
2012-04-03 14:08 ` Srivatsa S. Bhat
0 siblings, 1 reply; 4+ messages in thread
From: Toshi Kani @ 2012-04-01 3:37 UTC (permalink / raw)
To: len.brown; +Cc: linux-acpi, linux-kernel, Toshi Kani, Boris Ostrovsky
Fix a NULL pointer dereference panic in cpuidle_play_dead() during
CPU off-lining when no cpuidle driver is registered. A cpuidle
driver may be registered at boot-time based on CPU type. This patch
allows an off-lined CPU to enter HLT-based idle in this condition.
Signed-off-by: Toshi Kani <toshi.kani@hp.com>
Cc: Boris Ostrovsky <boris.ostrovsky@amd.com>
---
drivers/cpuidle/cpuidle.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 87411ce..2f0083a 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -74,7 +74,7 @@ static cpuidle_enter_t cpuidle_enter_ops;
/**
* cpuidle_play_dead - cpu off-lining
*
- * Only returns in case of an error
+ * Returns in case of an error or no driver
*/
int cpuidle_play_dead(void)
{
@@ -83,6 +83,9 @@ int cpuidle_play_dead(void)
int i, dead_state = -1;
int power_usage = -1;
+ if (!drv)
+ return -ENODEV;
+
/* Find lowest-power state that supports long-term idle */
for (i = CPUIDLE_DRIVER_STATE_START; i < drv->state_count; i++) {
struct cpuidle_state *s = &drv->states[i];
--
1.7.7.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] cpuidle: Fix panic in CPU off-lining with no idle driver
2012-04-01 3:37 [PATCH] cpuidle: Fix panic in CPU off-lining with no idle driver Toshi Kani
@ 2012-04-03 14:08 ` Srivatsa S. Bhat
2012-04-03 16:10 ` Toshi Kani
0 siblings, 1 reply; 4+ messages in thread
From: Srivatsa S. Bhat @ 2012-04-03 14:08 UTC (permalink / raw)
To: Toshi Kani
Cc: len.brown, linux-acpi, linux-kernel, Boris Ostrovsky, lenb,
Daniel Lezcano, amit.kucheria, linux-pm
On 04/01/2012 09:07 AM, Toshi Kani wrote:
> Fix a NULL pointer dereference panic in cpuidle_play_dead() during
> CPU off-lining when no cpuidle driver is registered. A cpuidle
> driver may be registered at boot-time based on CPU type. This patch
> allows an off-lined CPU to enter HLT-based idle in this condition.
>
> Signed-off-by: Toshi Kani <toshi.kani@hp.com>
> Cc: Boris Ostrovsky <boris.ostrovsky@amd.com>
> ---
> drivers/cpuidle/cpuidle.c | 5 ++++-
> 1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
> index 87411ce..2f0083a 100644
> --- a/drivers/cpuidle/cpuidle.c
> +++ b/drivers/cpuidle/cpuidle.c
> @@ -74,7 +74,7 @@ static cpuidle_enter_t cpuidle_enter_ops;
> /**
> * cpuidle_play_dead - cpu off-lining
> *
> - * Only returns in case of an error
> + * Returns in case of an error or no driver
> */
> int cpuidle_play_dead(void)
> {
> @@ -83,6 +83,9 @@ int cpuidle_play_dead(void)
> int i, dead_state = -1;
> int power_usage = -1;
>
> + if (!drv)
> + return -ENODEV;
> +
> /* Find lowest-power state that supports long-term idle */
> for (i = CPUIDLE_DRIVER_STATE_START; i < drv->state_count; i++) {
> struct cpuidle_state *s = &drv->states[i];
Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Tested-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
[The machine I tested on did support mwait. So, to disable mwait and ensure
that no idle driver is registered, I applied my fix for "idle=" parameters
(https://lkml.org/lkml/2012/4/3/158) and then passed idle=halt in the kernel
command line. Then the machine crashed during CPU offline. Then I tried your
patch and it fixed the issue.]
Regards,
Srivatsa S. Bhat
IBM Linux Technology Center
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] cpuidle: Fix panic in CPU off-lining with no idle driver
2012-04-03 14:08 ` Srivatsa S. Bhat
@ 2012-04-03 16:10 ` Toshi Kani
2012-04-06 18:58 ` Len Brown
0 siblings, 1 reply; 4+ messages in thread
From: Toshi Kani @ 2012-04-03 16:10 UTC (permalink / raw)
To: Srivatsa S. Bhat
Cc: len.brown, linux-acpi, linux-kernel, Boris Ostrovsky, lenb,
Daniel Lezcano, amit.kucheria, linux-pm
On 4/3/2012 8:08 AM, Srivatsa S. Bhat wrote:
> On 04/01/2012 09:07 AM, Toshi Kani wrote:
>
>> Fix a NULL pointer dereference panic in cpuidle_play_dead() during
>> CPU off-lining when no cpuidle driver is registered. A cpuidle
>> driver may be registered at boot-time based on CPU type. This patch
>> allows an off-lined CPU to enter HLT-based idle in this condition.
>>
>> Signed-off-by: Toshi Kani<toshi.kani@hp.com>
>> Cc: Boris Ostrovsky<boris.ostrovsky@amd.com>
>> ---
>> drivers/cpuidle/cpuidle.c | 5 ++++-
>> 1 files changed, 4 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
>> index 87411ce..2f0083a 100644
>> --- a/drivers/cpuidle/cpuidle.c
>> +++ b/drivers/cpuidle/cpuidle.c
>> @@ -74,7 +74,7 @@ static cpuidle_enter_t cpuidle_enter_ops;
>> /**
>> * cpuidle_play_dead - cpu off-lining
>> *
>> - * Only returns in case of an error
>> + * Returns in case of an error or no driver
>> */
>> int cpuidle_play_dead(void)
>> {
>> @@ -83,6 +83,9 @@ int cpuidle_play_dead(void)
>> int i, dead_state = -1;
>> int power_usage = -1;
>>
>> + if (!drv)
>> + return -ENODEV;
>> +
>> /* Find lowest-power state that supports long-term idle */
>> for (i = CPUIDLE_DRIVER_STATE_START; i< drv->state_count; i++) {
>> struct cpuidle_state *s =&drv->states[i];
>
>
> Reviewed-by: Srivatsa S. Bhat<srivatsa.bhat@linux.vnet.ibm.com>
> Tested-by: Srivatsa S. Bhat<srivatsa.bhat@linux.vnet.ibm.com>
>
>
> [The machine I tested on did support mwait. So, to disable mwait and ensure
> that no idle driver is registered, I applied my fix for "idle=" parameters
> (https://lkml.org/lkml/2012/4/3/158) and then passed idle=halt in the kernel
> command line. Then the machine crashed during CPU offline. Then I tried your
> patch and it fixed the issue.]
Great! Thanks a lot Srivatsa for reviewing and testing!
-Toshi
> Regards,
> Srivatsa S. Bhat
> IBM Linux Technology Center
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] cpuidle: Fix panic in CPU off-lining with no idle driver
2012-04-03 16:10 ` Toshi Kani
@ 2012-04-06 18:58 ` Len Brown
0 siblings, 0 replies; 4+ messages in thread
From: Len Brown @ 2012-04-06 18:58 UTC (permalink / raw)
To: Toshi Kani
Cc: Srivatsa S. Bhat, linux-acpi, linux-kernel, Boris Ostrovsky,
Daniel Lezcano, amit.kucheria, linux-pm
applied.
thanks,
Len Brown, Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-04-06 18:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-01 3:37 [PATCH] cpuidle: Fix panic in CPU off-lining with no idle driver Toshi Kani
2012-04-03 14:08 ` Srivatsa S. Bhat
2012-04-03 16:10 ` Toshi Kani
2012-04-06 18:58 ` Len Brown
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).