[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20241126201539.477448-4-patryk.wlazlyn@linux.intel.com>
Date: Tue, 26 Nov 2024 21:15:39 +0100
From: Patryk Wlazlyn <patryk.wlazlyn@...ux.intel.com>
To: x86@...nel.org
Cc: linux-kernel@...r.kernel.org,
linux-pm@...r.kernel.org,
rafael.j.wysocki@...el.com,
peterz@...radead.org,
dave.hansen@...ux.intel.com,
gautham.shenoy@....com,
tglx@...utronix.de,
len.brown@...el.com,
artem.bityutskiy@...ux.intel.com,
patryk.wlazlyn@...ux.intel.com
Subject: [PATCH v5 3/3] intel_idle: Provide the default enter_dead() handler
The recent mwait_play_dead code relies on cpuidle driver to call the
function with the right mwait hint, for the deepest cstate for which the
driver provides the enter_dead handler.
Signed-off-by: Patryk Wlazlyn <patryk.wlazlyn@...ux.intel.com>
---
drivers/idle/intel_idle.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index ac4d8faa3886..c6874a6dbe95 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -56,6 +56,7 @@
#include <asm/mwait.h>
#include <asm/spec-ctrl.h>
#include <asm/fpu/api.h>
+#include <asm/smp.h>
#define INTEL_IDLE_VERSION "0.5.1"
@@ -227,6 +228,16 @@ static __cpuidle int intel_idle_s2idle(struct cpuidle_device *dev,
return 0;
}
+static __cpuidle void intel_idle_enter_dead(struct cpuidle_device *dev,
+ int index)
+{
+ struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev);
+ struct cpuidle_state *state = &drv->states[index];
+ unsigned long eax = flg2MWAIT(state->flags);
+
+ mwait_play_dead(eax);
+}
+
/*
* States are indexed by the cstate number,
* which is also the index into the MWAIT hint array.
@@ -1798,6 +1809,7 @@ static void __init intel_idle_init_cstates_acpi(struct cpuidle_driver *drv)
state->flags |= CPUIDLE_FLAG_TIMER_STOP;
state->enter = intel_idle;
+ state->enter_dead = intel_idle_enter_dead;
state->enter_s2idle = intel_idle_s2idle;
}
}
@@ -2143,10 +2155,12 @@ static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv)
if (intel_idle_max_cstate_reached(cstate))
break;
- if (!cpuidle_state_table[cstate].enter &&
- !cpuidle_state_table[cstate].enter_s2idle)
+ if (!cpuidle_state_table[cstate].enter)
break;
+ if (!cpuidle_state_table[cstate].enter_dead)
+ cpuidle_state_table[cstate].enter_dead = intel_idle_enter_dead;
+
/* If marked as unusable, skip this state. */
if (cpuidle_state_table[cstate].flags & CPUIDLE_FLAG_UNUSABLE) {
pr_debug("state %s is disabled\n",
--
2.47.1
Powered by blists - more mailing lists