cpuidle: Do not return from cpuidle_play_dead() on callback failures
Subsystems (2)
v2 cover cpuidle: Do not return from cpuidle_play_dead() on callback failures
Hi Everyone,
This series of 2 patches supersedes
https://lore.kernel.org/linux-pm/[email protected]/
in order to address review feedback.
Patch [1/2] modifies cpuidle_play_dead() as per the subject and patch [2/2] changes the :enter_dead() cpuidle state callback return type to void.
Thanks!
PATCH v2 1/2 cpuidle: Do not return from cpuidle_play_dead() on callback failures
From: Rafael J. Wysocki <[email protected]>
If the :enter_dead() idle state callback fails for a certain state, there may be still a shallower state for which it will work.
Because the only caller of cpuidle_play_dead(), native_play_dead(), falls back to hlt_play_dead() if it returns an error, it should better try all of the idle states for which :enter_dead() is present before failing, so change it accordingly.
Also notice that the :enter_dead() state callback is not expected to return on success (the CPU should be "dead" then), so make cpuidle_play_dead() ignore its return value.
---
v1 -> v2:
* Make cpuidle_play_dead() never return 0.
* Add tags from Mario (I have added them because the change of the patch should not make a practical difference, but if you want them to be dropped, please let me know).
--- drivers/cpuidle/cpuidle.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/cpuidle/cpuidle.c +7 -3
@@ -69,11 +69,15 @@ int cpuidle_play_dead(void)if (!drv)return -ENODEV ; -/* Find lowest-power state that supports long-term idle */ -for (i = drv->state_count -1 ; i >=0 ; i--) +for (i = drv->state_count -1 ; i >=0 ; i--) {if (drv->states[i].enter_dead) -return drv->states[i].enter_dead (dev, i); + drv->states[i].enter_dead (dev, i); + } +/* +* If :enter_dead() is successful, it will never return, so reaching +* here means that all of them failed above or were not present. +*/ return -ENODEV ; }
Hello Rafael,
Quoted 10 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
If the :enter_dead() idle state callback fails for a certain state, there may be still a shallower state for which it will work.
Because the only caller of
cpuidle_play_dead(),native_play_dead(), falls back tohlt_play_dead()if it returns an error, it should better try all of the idle states for which :enter_dead() is present before failing, so change it accordingly.
Quoted 7 lines
Also notice that the :enter_dead() state callback is not expected to return on success (the CPU should be "dead" then), so make
cpuidle_play_dead()ignore its return value.Signed-off-by Rafael J. Wysocki <[email protected]>Reviewed-by Mario Limonciello <[email protected]>
Thanks for fixing this.
--
Thanks and Regards
gautham.
Quoted 38 lines
---
v1 -> v2:
* Makecpuidle_play_dead()never return 0.
* Add tags from Mario (I have added them because the change of the patch should not make a practical difference, but if you want them to be dropped, please let me know).--- drivers/cpuidle/cpuidle.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)Index:
linux-pm/drivers/cpuidle/cpuidle.c
===================================================================drivers/cpuidle/cpuidle.c +7
-3@@ -69,11 +69,15 @@ int cpuidle_play_dead(void)if (!drv)return -ENODEV ; -/* Find lowest-power state that supports long-term idle */ -for (i = drv->state_count -1 ; i >=0 ; i--) +for (i = drv->state_count -1 ; i >=0 ; i--) {if (drv->states[i].enter_dead) -return drv->states[i].enter_dead (dev, i); + drv->states[i].enter_dead (dev, i); + } +/* +* If :enter_dead() is successful, it will never return, so reaching +* here means that all of them failed above or were not present. +*/ return -ENODEV ; }
PATCH v2 2/2 cpuidle: Change :enter_dead() driver callback return type to void
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
After a previous change, cpuidle_play_dead(), which is the only caller of idle state :enter_dead() callbacks, ignores their return values, so they may as well be void.
---
v1 -> v2: New patch
Interestingly enough, the only user of :enter_dead() idle state callbacks in the current mainline turns out to be ACPI idle.
--- drivers/acpi/processor_idle.c | 7 ++----- include/linux/cpuidle.h | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-)
include/linux/cpuidle.h +1 -1
@@ -61,7 +61,7 @@ struct cpuidle_state {struct cpuidle_driver *drv, int index); -int (*enter_dead) (struct cpuidle_device *dev,int index); +void (*enter_dead) (struct cpuidle_device *dev,int index);/* * CPUs execute ->enter_s2idle with the local tick or entire timekeeping
drivers/acpi/processor_idle.c +2 -5
@@ -578,7 +578,7 @@ static void __cpuidle acpi_idle_do_entry* @dev: the target CPU * @index: the index of suggested state */ -static int acpi_idle_play_dead (struct cpuidle_device *dev,int index) +static void acpi_idle_play_dead (struct cpuidle_device *dev,int index) {struct acpi_processor_cx *cx =per_cpu (acpi_cstate[index], dev->cpu);
@@ -591,11 +591,8 @@ static int acpi_idle_play_dead(struct cpelse if (cx->entry_method ==ACPI_CSTATE_SYSTEMIO ) {io_idle (cx->address); }else -return -ENODEV ; +return ; } - -/* Never reached */ -return 0 ; } static __always_inline bool acpi_idle_fallback_to_c1(struct acpi_processor *pr)
Re: [PATCH v2 2/2] cpuidle: Change :enter_dead() driver callback return type to void
Hello Rafael,
Quoted 9 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
After a previous change,
cpuidle_play_dead(), which is the only caller of idle state :enter_dead() callbacks, ignores their return values, so they may as well be void.Suggested-by Peter Zijlstra <[email protected]>Signed-off-by Rafael J. Wysocki <[email protected]>
Quoted 6 lines
---
v1 -> v2: New patch
Interestingly enough, the only user of :enter_dead() idle state callbacks in the current mainline turns out to be ACPI idle.
For that matter, the only user of cpuidle_play_dead() is the native_play_dead(). Was that always the case?
Some of the other architectures select the deepest available idle state at boot time, and enter that state when a CPU is offlined.
In any case I am ok with this.
--
Thanks and Regards
gautham.
Quoted 48 lines
--- drivers/acpi/processor_idle.c | 7 ++----- include/linux/cpuidle.h | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-)Index:
linux-pm/include/linux/cpuidle.h
===================================================================include/linux/cpuidle.h +1
-1@@ -61,7 +61,7 @@ struct cpuidle_state {struct cpuidle_driver *drv, int index); -int (*enter_dead) (struct cpuidle_device *dev,int index); +void (*enter_dead) (struct cpuidle_device *dev,int index);/* * CPUs execute ->enter_s2idle with the local tick or entire timekeeping Index:
linux-pm/drivers/acpi/processor_idle.c
===================================================================drivers/acpi/processor_idle.c +2
-5@@ -578,7 +578,7 @@ static void __cpuidle acpi_idle_do_entry* @dev: the target CPU * @index: the index of suggested state */ -static int acpi_idle_play_dead (struct cpuidle_device *dev,int index) +static void acpi_idle_play_dead (struct cpuidle_device *dev,int index) {struct acpi_processor_cx *cx =per_cpu (acpi_cstate[index], dev->cpu);@@ -591,11 +591,8 @@ static int acpi_idle_play_dead(struct cpelse if (cx->entry_method ==ACPI_CSTATE_SYSTEMIO ) {io_idle (cx->address); }else -return -ENODEV ; +return ; } - -/* Never reached */ -return 0 ; } static __always_inline bool acpi_idle_fallback_to_c1(struct acpi_processor *pr)
Mario Limonciello
Reviewed-byRe: [PATCH v2 2/2] cpuidle: Change :enter_dead() driver callback return type to void
Quoted 22 lines · Gautham R. Shenoy
Hello Rafael,
Quoted 9 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
After a previous change,
cpuidle_play_dead(), which is the only caller of idle state :enter_dead() callbacks, ignores their return values, so they may as well be void.Suggested-by Peter Zijlstra <[email protected]>Signed-off-by Rafael J. Wysocki <[email protected]>Quoted 6 lines
---
v1 -> v2: New patch
Interestingly enough, the only user of :enter_dead() idle state callbacks in the current mainline turns out to be ACPI idle.
For that matter, the only user of
cpuidle_play_dead()is thenative_play_dead(). Was that always the case?
Quoted 6 lines
Some of the other architectures select the deepest available idle state at boot time, and enter that state when a CPU is offlined.
In any case I am ok with this.
Reviewed-by Gautham R. Shenoy <[email protected]>
Quoted 51 lines
--
Thanks and Regards
gautham.Quoted 48 lines
--- drivers/acpi/processor_idle.c | 7 ++----- include/linux/cpuidle.h | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-)Index:
linux-pm/include/linux/cpuidle.h
===================================================================include/linux/cpuidle.h +1
-1@@ -61,7 +61,7 @@ struct cpuidle_state {struct cpuidle_driver *drv, int index); -int (*enter_dead) (struct cpuidle_device *dev,int index); +void (*enter_dead) (struct cpuidle_device *dev,int index);/* * CPUs execute ->enter_s2idle with the local tick or entire timekeeping Index:
linux-pm/drivers/acpi/processor_idle.c
===================================================================drivers/acpi/processor_idle.c +2
-5@@ -578,7 +578,7 @@ static void __cpuidle acpi_idle_do_entry* @dev: the target CPU * @index: the index of suggested state */ -static int acpi_idle_play_dead (struct cpuidle_device *dev,int index) +static void acpi_idle_play_dead (struct cpuidle_device *dev,int index) {struct acpi_processor_cx *cx =per_cpu (acpi_cstate[index], dev->cpu);@@ -591,11 +591,8 @@ static int acpi_idle_play_dead(struct cpelse if (cx->entry_method ==ACPI_CSTATE_SYSTEMIO ) {io_idle (cx->address); }else -return -ENODEV ; +return ; } - -/* Never reached */ -return 0 ; } static __always_inline bool acpi_idle_fallback_to_c1(struct acpi_processor *pr)
Rafael J. Wysocki
maintainerRe: [PATCH v2 2/2] cpuidle: Change :enter_dead() driver callback return type to void
In reply to Gautham R. ShenoyHi Gautham,
Quoted 15 lines · Gautham R. Shenoy
Hello Rafael,
Quoted 11 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
After a previous change,
cpuidle_play_dead(), which is the only caller of idle state :enter_dead() callbacks, ignores their return values, so they may as well be void.Suggested-by Peter Zijlstra <[email protected]>Signed-off-by Rafael J. Wysocki <[email protected]>---
Quoted 7 lines
Quoted 4 lines
v1 -> v2: New patch
Interestingly enough, the only user of :enter_dead() idle state callbacks in the current mainline turns out to be ACPI idle.
For that matter, the only user of
cpuidle_play_dead()is thenative_play_dead(). Was that always the case?
At least as long ago as of 4.20.
Quoted 2 lines
Some of the other architectures select the deepest available idle state at boot time, and enter that state when a CPU is offlined.
That's fine as long as the state to use is already known at that time.
Quoted 55 lines
In any case I am ok with this.
Reviewed-by Gautham R. Shenoy <[email protected]>--
Thanks and Regards
gautham.Quoted 48 lines
--- drivers/acpi/processor_idle.c | 7 ++----- include/linux/cpuidle.h | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-)Index:
linux-pm/include/linux/cpuidle.h
===================================================================include/linux/cpuidle.h +1
-1@@ -61,7 +61,7 @@ struct cpuidle_state {struct cpuidle_driver *drv, int index); -int (*enter_dead) (struct cpuidle_device *dev,int index); +void (*enter_dead) (struct cpuidle_device *dev,int index);/* * CPUs execute ->enter_s2idle with the local tick or entire timekeeping Index:
linux-pm/drivers/acpi/processor_idle.c
===================================================================drivers/acpi/processor_idle.c +2
-5@@ -578,7 +578,7 @@ static void __cpuidle acpi_idle_do_entry* @dev: the target CPU * @index: the index of suggested state */ -static int acpi_idle_play_dead (struct cpuidle_device *dev,int index) +static void acpi_idle_play_dead (struct cpuidle_device *dev,int index) {struct acpi_processor_cx *cx =per_cpu (acpi_cstate[index], dev->cpu);@@ -591,11 +591,8 @@ static int acpi_idle_play_dead(struct cpelse if (cx->entry_method ==ACPI_CSTATE_SYSTEMIO ) {io_idle (cx->address); }else -return -ENODEV ; +return ; } - -/* Never reached */ -return 0 ; } static __always_inline bool acpi_idle_fallback_to_c1(struct acpi_processor *pr)