]> Git Repo - J-linux.git/commitdiff
cpuidle: Do not return from cpuidle_play_dead() on callback failures
authorRafael J. Wysocki <[email protected]>
Fri, 15 Nov 2024 20:58:31 +0000 (21:58 +0100)
committerRafael J. Wysocki <[email protected]>
Tue, 19 Nov 2024 20:46:51 +0000 (21:46 +0100)
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]
drivers/cpuidle/cpuidle.c

index 06ace16f9e71a7f199886f6f5085a6ace5157988..0835da449db8b4209f0686aef4818dfa3d1a308a 100644 (file)
@@ -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;
 }
 
This page took 0.044973 seconds and 4 git commands to generate.