A system-wakeup QoS limit may have been requested by user-space. To avoid
entering a too deep state during s2idle, let's start to take into account
the QoS limit when selecting a suitable low-power-state.
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
drivers/cpuidle/cpuidle.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 0835da449db8..5f6dacb5b134 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -190,14 +190,15 @@ static noinstr void enter_s2idle_proper(struct cpuidle_driver *drv,
*/
int cpuidle_enter_s2idle(struct cpuidle_driver *drv, struct cpuidle_device *dev)
{
+ u64 constraint_ns = system_wakeup_latency_qos_limit() * NSEC_PER_USEC;
int index;
/*
- * Find the deepest state with ->enter_s2idle present, which guarantees
- * that interrupts won't be enabled when it exits and allows the tick to
- * be frozen safely.
+ * Find the deepest state with ->enter_s2idle present that meets the
+ * system-wakeup QoS limit, which guarantees that interrupts won't be
+ * enabled when it exits and allows the tick to be frozen safely.
*/
- index = find_deepest_state(drv, dev, U64_MAX, 0, true);
+ index = find_deepest_state(drv, dev, constraint_ns, 0, true);
if (index > 0) {
enter_s2idle_proper(drv, dev, index);
local_irq_enable();
--
2.43.0
On Wed, Jul 16, 2025 at 2:33 PM Ulf Hansson <ulf.hansson@linaro.org> wrote: > > A system-wakeup QoS limit may have been requested by user-space. To avoid > entering a too deep state during s2idle, let's start to take into account > the QoS limit when selecting a suitable low-power-state. > > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> > --- > drivers/cpuidle/cpuidle.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c > index 0835da449db8..5f6dacb5b134 100644 > --- a/drivers/cpuidle/cpuidle.c > +++ b/drivers/cpuidle/cpuidle.c > @@ -190,14 +190,15 @@ static noinstr void enter_s2idle_proper(struct cpuidle_driver *drv, > */ > int cpuidle_enter_s2idle(struct cpuidle_driver *drv, struct cpuidle_device *dev) > { > + u64 constraint_ns = system_wakeup_latency_qos_limit() * NSEC_PER_USEC; > int index; > > /* > - * Find the deepest state with ->enter_s2idle present, which guarantees > - * that interrupts won't be enabled when it exits and allows the tick to > - * be frozen safely. > + * Find the deepest state with ->enter_s2idle present that meets the > + * system-wakeup QoS limit, which guarantees that interrupts won't be > + * enabled when it exits and allows the tick to be frozen safely. > */ > - index = find_deepest_state(drv, dev, U64_MAX, 0, true); > + index = find_deepest_state(drv, dev, constraint_ns, 0, true); > if (index > 0) { > enter_s2idle_proper(drv, dev, index); > local_irq_enable(); This is not the only place that needs to be patched this way. cpuidle_idle_call() is another one AFAICS.
© 2016 - 2025 Red Hat, Inc.