Skip to content

Commit f65ee09

Browse files
committed
cpuidle: Do not return from cpuidle_play_dead() on callback failures
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. Signed-off-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Mario Limonciello <[email protected]> Tested-by: Mario Limonciello <[email protected]> # 6.12-rc7 Reviewed-by: Gautham R. Shenoy <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent ad52c55 commit f65ee09

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/cpuidle/cpuidle.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,15 @@ int cpuidle_play_dead(void)
6969
if (!drv)
7070
return -ENODEV;
7171

72-
/* Find lowest-power state that supports long-term idle */
73-
for (i = drv->state_count - 1; i >= 0; i--)
72+
for (i = drv->state_count - 1; i >= 0; i--) {
7473
if (drv->states[i].enter_dead)
75-
return drv->states[i].enter_dead(dev, i);
74+
drv->states[i].enter_dead(dev, i);
75+
}
7676

77+
/*
78+
* If :enter_dead() is successful, it will never return, so reaching
79+
* here means that all of them failed above or were not present.
80+
*/
7781
return -ENODEV;
7882
}
7983

0 commit comments

Comments
 (0)