]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
cpuidle: Warn instead of bailing out if target residency check fails
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 25 Nov 2025 16:23:12 +0000 (17:23 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 25 Nov 2025 18:06:38 +0000 (19:06 +0100)
It turns out that the change in commit 76934e495cdc ("cpuidle: Add
sanity check for exit latency and target residency") goes too far
because there are systems in the field on which the check introduced
by that commit does not pass.

For this reason, change __cpuidle_driver_init() return type back to void
and make it print a warning when the check mentioned above does not
pass.

Fixes: 76934e495cdc ("cpuidle: Add sanity check for exit latency and target residency")
Reported-by: Val Packett <val@packett.cool>
Closes: https://lore.kernel.org/linux-pm/20251121010756.6687-1-val@packett.cool/
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Christian Loehle <christian.loehle@arm.com>
Link: https://patch.msgid.link/2808566.mvXUDI8C0e@rafael.j.wysocki
drivers/cpuidle/driver.c

index 1c295a93d5829b5a3068ffd9934c1bbe694de793..370664c47e6593f02b37eda18e464e8c6054d82a 100644 (file)
@@ -8,6 +8,8 @@
  * This code is licenced under the GPL.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/mutex.h>
 #include <linux/module.h>
 #include <linux/sched.h>
@@ -152,7 +154,7 @@ static void cpuidle_setup_broadcast_timer(void *arg)
  * __cpuidle_driver_init - initialize the driver's internal data
  * @drv: a valid pointer to a struct cpuidle_driver
  */
-static int __cpuidle_driver_init(struct cpuidle_driver *drv)
+static void __cpuidle_driver_init(struct cpuidle_driver *drv)
 {
        int i;
 
@@ -195,15 +197,13 @@ static int __cpuidle_driver_init(struct cpuidle_driver *drv)
                        s->exit_latency = div_u64(s->exit_latency_ns, NSEC_PER_USEC);
 
                /*
-                * Ensure that the exit latency of a CPU idle state does not
-                * exceed its target residency which is assumed in cpuidle in
-                * multiple places.
+                * Warn if the exit latency of a CPU idle state exceeds its
+                * target residency which is assumed to never happen in cpuidle
+                * in multiple places.
                 */
                if (s->exit_latency_ns > s->target_residency_ns)
-                       return -EINVAL;
+                       pr_warn("Idle state %d target residency too low\n", i);
        }
-
-       return 0;
 }
 
 /**
@@ -233,9 +233,7 @@ static int __cpuidle_register_driver(struct cpuidle_driver *drv)
        if (cpuidle_disabled())
                return -ENODEV;
 
-       ret = __cpuidle_driver_init(drv);
-       if (ret)
-               return ret;
+       __cpuidle_driver_init(drv);
 
        ret = __cpuidle_set_driver(drv);
        if (ret)