public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] cpuidle: Do not return from cpuidle_play_dead() on callback failures
@ 2024-11-14 17:46 Rafael J. Wysocki
  2024-11-15  3:22 ` Mario Limonciello
  2024-11-15 10:14 ` Peter Zijlstra
  0 siblings, 2 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2024-11-14 17:46 UTC (permalink / raw)
  To: Linux PM
  Cc: LKML, x86 Maintainers, Peter Zijlstra, Patryk Wlazlyn,
	Gautham R. Shenoy, Artem Bityutskiy, Mario Limonciello

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

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.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/cpuidle/cpuidle.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Index: linux-pm/drivers/cpuidle/cpuidle.c
===================================================================
--- linux-pm.orig/drivers/cpuidle/cpuidle.c
+++ linux-pm/drivers/cpuidle/cpuidle.c
@@ -70,9 +70,10 @@ int cpuidle_play_dead(void)
 		return -ENODEV;
 
 	/* Find lowest-power state that supports long-term idle */
-	for (i = drv->state_count - 1; i >= 0; i--)
-		if (drv->states[i].enter_dead)
-			return drv->states[i].enter_dead(dev, i);
+	for (i = drv->state_count - 1; i >= 0; i--) {
+		if (drv->states[i].enter_dead && !drv->states[i].enter_dead(dev, i))
+			return 0;
+	}
 
 	return -ENODEV;
 }




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-11-15 17:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-14 17:46 [PATCH v1] cpuidle: Do not return from cpuidle_play_dead() on callback failures Rafael J. Wysocki
2024-11-15  3:22 ` Mario Limonciello
2024-11-15 10:14 ` Peter Zijlstra
2024-11-15 12:46   ` Rafael J. Wysocki
2024-11-15 12:55     ` Peter Zijlstra
2024-11-15 13:25       ` Rafael J. Wysocki
2024-11-15 17:40         ` Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox