Message ID | 20230601182801.2622044-6-arjan@linux.intel.com (mailing list archive) |
---|---|
State | Changes Requested, archived |
Headers | show |
Series | [1/7] intel_idle: refactor state->enter manipulation into its own function | expand |
On Thu, Jun 1, 2023 at 8:28 PM <arjan@linux.intel.com> wrote: > > From: Arjan van de Ven <arjan.van.de.ven@intel.com> > > Currently, intel_idle verifies that the cpuid instruction enumerates > that the mwait value for a state is actually supported by the CPU. > > Going forward, when running in a VM guest, that check will not work > and we're going to need a way to turn it off. > > Add a global bool for this, and uses this in the check > function to short circuit this cpuid check. > > Signed-off-by: Arjan van de Ven <arjan@linux.intel.com> > --- > drivers/idle/intel_idle.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c > index 66d262fd267e..55c3e6ece3dd 100644 > --- a/drivers/idle/intel_idle.c > +++ b/drivers/idle/intel_idle.c > @@ -69,6 +69,7 @@ static int max_cstate = CPUIDLE_STATE_MAX - 1; > static unsigned int disabled_states_mask __read_mostly; > static unsigned int preferred_states_mask __read_mostly; > static bool force_irq_on __read_mostly; > +static bool skip_mwait_check __read_mostly; > > static struct cpuidle_device __percpu *intel_idle_cpuidle_devices; > > @@ -1866,6 +1867,9 @@ static bool __init intel_idle_verify_cstate(unsigned int mwait_hint) > unsigned int num_substates = (mwait_substates >> mwait_cstate * 4) & > MWAIT_SUBSTATE_MASK; > > + if (skip_mwait_check) > + return true; > + I don't think that the static variable is needed here. This function is only called from intel_idle_init_cstates_icpu() which in turn is only called by intel_idle_cpuidle_driver_init(). The latter is called directly by intel_idle_vminit() in the next patch and so it can be passed a bool arg indicating whether or not to skip the mwait checks. I would even check this arg in intel_idle_init_cstates_icpu() so it is not necessary to look into intel_idle_verify_cstate() to see what it is for. > /* Ignore the C-state if there are NO sub-states in CPUID for it. */ > if (num_substates == 0) > return false; > --
> I don't think that the static variable is needed here. > > This function is only called from intel_idle_init_cstates_icpu() which > in turn is only called by intel_idle_cpuidle_driver_init(). > > The latter is called directly by intel_idle_vminit() in the next patch > and so it can be passed a bool arg indicating whether or not to skip > the mwait checks. > I think I found a nicer solution; will be in the next rev shortly
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index 66d262fd267e..55c3e6ece3dd 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c @@ -69,6 +69,7 @@ static int max_cstate = CPUIDLE_STATE_MAX - 1; static unsigned int disabled_states_mask __read_mostly; static unsigned int preferred_states_mask __read_mostly; static bool force_irq_on __read_mostly; +static bool skip_mwait_check __read_mostly; static struct cpuidle_device __percpu *intel_idle_cpuidle_devices; @@ -1866,6 +1867,9 @@ static bool __init intel_idle_verify_cstate(unsigned int mwait_hint) unsigned int num_substates = (mwait_substates >> mwait_cstate * 4) & MWAIT_SUBSTATE_MASK; + if (skip_mwait_check) + return true; + /* Ignore the C-state if there are NO sub-states in CPUID for it. */ if (num_substates == 0) return false;