Skip to contentSkip to conversation

intel_idle: Fixups and new module parameter prefer_cst

PATCH In review Rafael J. Wysocki 3 participants 7 messages Nov 25 – Nov 27

Subsystems (3)
lore
Share & tools
lore

Rafael J. Wysocki

author maintainer
#0 lore raw

cover intel_idle: Fixups and new module parameter prefer_cst

Hi All,

This series makes the following changes in the intel_idle driver:

* Update outdated module parameter descriptions (first patch)
* Avoid using empty C-state tables coming from _CST (second patch)
* Add new module parameter "prefer_cst" to force preferring _CST to _LPI (last patch)

Thanks!

author maintainer
#1 lore raw

PATCH 1/3 intel_idle: Update no_acpi and use_acpi module parameter descriptions

From: "Rafael J. Wysocki" <[email protected]>

The descriptions of the no_acpi and use_acpi module parameters of intel_idle only mention ACPI _CST which is inaccurate after adding ACPI _LPI support to the driver.

Update them to mention ACPI in general to avoid confusion.

Fixes abc5c103c66d ("intel_idle: Add ACPI _LPI support")
---
 drivers/idle/intel_idle.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/idle/intel_idle.c +2 -2
index 9f5e1c47aba2..b8f58da277a4 100644
@@ -1769,11 +1769,11 @@ static bool __init intel_idle_state_needs_timer_stop(struct cpuidle_state *state
 
 static bool no_acpi __read_mostly;
 module_param(no_acpi, bool, 0444);
-MODULE_PARM_DESC(no_acpi, "Do not use ACPI _CST for building the idle states list");
+MODULE_PARM_DESC(no_acpi, "Do not use ACPI for building the idle state list");
 
 static bool force_use_acpi __read_mostly; /* No effect if no_acpi is set. */
 module_param_named(use_acpi, force_use_acpi, bool, 0444);
-MODULE_PARM_DESC(use_acpi, "Use ACPI _CST for building the idle states list");
+MODULE_PARM_DESC(use_acpi, "Force using ACPI for building the idle state list");
 
 static bool no_native __read_mostly; /* No effect if no_acpi is set. */
 module_param_named(no_native, no_native, bool, 0444);
Signature · 1 line
2.51.0
author maintainer
#2 lore raw

PATCH 2/3 intel_idle: Disregard ACPI _CST evaluation returning no states

In reply to Rafael J. Wysocki

From: "Rafael J. Wysocki" <[email protected]>

Success is returned by acpi_processor_evaluate_cst() after producing an empty idle state table which is useless.

Avoid attempting to use an empty idle state table coming from _CST by checking the number of states in the idle state table produced by acpi_processor_evaluate_cst().

---
 drivers/idle/intel_idle.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/idle/intel_idle.c +2 -1
index b8f58da277a4..fc0aea26db50 100644
@@ -1837,7 +1837,8 @@ static bool __init intel_idle_acpi_extract_cst_cstates(void)
 		if (!pr)
 			continue;
 
-		if (acpi_processor_evaluate_cst(pr->handle, cpu, &acpi_state_table))
+		if (acpi_processor_evaluate_cst(pr->handle, cpu, &acpi_state_table) ||
+		    !acpi_state_table.count)
 			continue;
 
 		acpi_state_table.count++;
Signature · 1 line
2.51.0
author maintainer
#3 lore raw

PATCH 3/3 intel_idle: Allow ACPI _CST to be preferred to ACPI _LPI

In reply to Rafael J. Wysocki

From: "Rafael J. Wysocki" <[email protected]>

Add a new module parameter called "prefer_cst" to intel_idle for making it prefer _CST for building the idle state list when using ACPI, even if _LPI (preferred by default) is available.

This may be useful for diagnostics during platform bringup and as a fallback mechanism on platforms with broken ACPI _LPI and functional ACPI _CST.

Update the documentation accordingly.

---
 Documentation/admin-guide/pm/intel_idle.rst | 15 ++++++++++-----
 drivers/idle/intel_idle.c                   | 15 +++++++++------
 2 files changed, 19 insertions(+), 11 deletions(-)
Documentation/admin-guide/pm/intel_idle.rst +10 -5
index d1a6251790b8..8092807d446b 100644
@@ -94,7 +94,9 @@ objects representing the CPUs in the system and ``_LPI`` processing produces a
 non-empty list of valid idle states, it will be used.  Otherwise, ``_CST`` will
 be used so long as it is present under at least one of the ACPI objects
 representing the CPUs in the system and it returns a non-empty list of valid
-idle states.  In either case, since the ``CPUIdle`` subsystem expects that the
+idle states.  [There is a module parameter that can be used to tell the driver
+to prefer ``_CST`` to ``_LPI`` and reverse the order in which they are tried.]
+In either case, since the ``CPUIdle`` subsystem expects that the
 list of idle states supplied by the driver will be suitable for all of the CPUs
 handled by it and ``intel_idle`` is registered as the ``CPUIdle`` driver for all
 of the CPUs in the system, ``intel_idle`` looks for the first CPU where the
@@ -223,10 +225,10 @@ even if they have been enumerated (see :ref:`cpu-pm-qos` in
 Documentation/admin-guide/pm/cpuidle.rst).
 Setting ``max_cstate`` to 0 causes the ``intel_idle`` initialization to fail.
 
-The ``no_acpi``, ``use_acpi`` and ``no_native`` module parameters are
-recognized by ``intel_idle`` if the kernel has been configured with ACPI
-support.  In the case that ACPI is not configured these flags have no impact
-on functionality.
+The ``no_acpi``, ``use_acpi``, ``no_native``, and ``prefer_cst`` module
+parameters are recognized by ``intel_idle`` if the kernel has been configured
+with ACPI support.  If ACPI is not configured, these flags have no impact on
+functionality.
 
 ``no_acpi`` - Do not use ACPI at all.  Only native mode is available, no
 ACPI mode.
@@ -237,6 +239,9 @@ C-states on/off status in native mode.
 ``no_native`` - Work only in ACPI mode, no native mode available (ignore
 all custom tables).
 
+``prefer_cst`` - When using ACPI, prefer idle states coming from ``_CST`` to
+idle states coming from ``_LPI`` (which is preferred by default).
+
 The value of the ``states_off`` module parameter (0 by default) represents a
 list of idle states to be disabled by default in the form of a bitmask.
 
drivers/idle/intel_idle.c +9 -6
index fc0aea26db50..3c07469586f7 100644
@@ -1779,6 +1779,10 @@ static bool no_native __read_mostly; /* No effect if no_acpi is set. */
 module_param_named(no_native, no_native, bool, 0444);
 MODULE_PARM_DESC(no_native, "Ignore cpu specific (native) idle states in lieu of ACPI idle states");
 
+static bool prefer_cst __read_mostly; /* No effect if no_acpi is set. */
+module_param(prefer_cst, bool, 0444);
+MODULE_PARM_DESC(prefer_cst, "Prefer ACPI _CST idle states to ACPI _LPI idle states");
+
 static struct acpi_processor_power acpi_state_table __initdata;
 static bool acpi_lpi_available __initdata;
 
@@ -1855,13 +1859,12 @@ static bool __init intel_idle_acpi_extract_cst_cstates(void)
 
 static bool __init intel_idle_acpi_extract_cstates(void)
 {
-	if (intel_idle_acpi_extract_lpi_cstates())
-		return true;
+	if (prefer_cst)
+		return intel_idle_acpi_extract_cst_cstates() ||
+			intel_idle_acpi_extract_lpi_cstates();
 
-	if (intel_idle_acpi_extract_cst_cstates())
-		return true;
-
-	return false;
+	return intel_idle_acpi_extract_lpi_cstates() ||
+		intel_idle_acpi_extract_cst_cstates();
 }
 
 static bool __init intel_idle_acpi_probe(void)
Signature · 1 line
2.51.0
maintainer Reviewed-by on v1 3/3
#4 lore raw

Re: [PATCH v1 3/3] intel_idle: Allow ACPI _CST to be preferred to ACPI _LPI

All patches look good to me, there is only doc nitpicks below.

So my nitpick is to make it crystal clear this option is not about never trying _LPI, it is about trying _CST first (reversing the default).

Quoted 2 lines · Rafael J. Wysocki

+``prefer_cst`` - When using ACPI, prefer idle states coming from ``_CST`` to +idle states coming from ``_LPI`` (which is preferred by default).

``prefer_cst`` - When using ACPI, try ``_CST`` first and fall back to ``_LPI`` only if ``_CST`` does not provide usable idle states (by default, ``_LPI`` is tried first and ``_CST`` is the fallback).

Quoted 9 lines
Documentation/admin-guide/pm/intel_idle.rst +1 -0
+
 The value of the ``states_off`` module parameter (0 by default) represents a
 list of idle states to be disabled by default in the form of a bitmask.
drivers/idle/intel_idle.c +0 -0
index fc0aea26db50..3c07469586f7 100644

drivers/idle/intel_idle.c static bool no_native __read_mostly; /* No effect if no_acpi is set. */ · line 1784

Quoted 6 lines
drivers/idle/intel_idle.c +3 -0
@@ -1779,6 +1779,10 @@ static bool no_native __read_mostly; /* No effect if no_acpi is set. */
 module_param_named(no_native, no_native, bool, 0444);
 MODULE_PARM_DESC(no_native, "Ignore cpu specific (native) idle states in lieu of ACPI idle states");
 
+static bool prefer_cst __read_mostly; /* No effect if no_acpi is set. */
+module_param(prefer_cst, bool, 0444);
+MODULE_PARM_DESC(prefer_cst, "Prefer ACPI _CST idle states to ACPI _LPI idle states");

May be even something like this

MODULE_PARM_DESC(prefer_cst, "Try ACPI _CST before ACPI _LPI (default: "

                             "_LPI first)");

But this is very minor, your call.

Artem.

author maintainer
#5 lore raw

Re: [PATCH v1 3/3] intel_idle: Allow ACPI _CST to be preferred to ACPI _LPI

Quoted 4 lines · Artem Bityutskiy

All patches look good to me, there is only doc nitpicks below.

Thanks!

Quoted 3 lines

So my nitpick is to make it crystal clear this option is not about never trying _LPI, it is about trying _CST first (reversing the default).

That's what "prefer" means.

Quoted 7 lines · Rafael J. Wysocki
Quoted 2 lines

+``prefer_cst`` - When using ACPI, prefer idle states coming from ``_CST`` to +idle states coming from ``_LPI`` (which is preferred by default).

``prefer_cst`` - When using ACPI, try ``_CST`` first and fall back to ``_LPI`` only if ``_CST`` does not provide usable idle states (by default, ``_LPI`` is tried first and ``_CST`` is the fallback).

This is more precise, so I'll use it, but honestly it doesn't make a lot of a difference to me.

Quoted 18 lines
Quoted 9 lines
Documentation/admin-guide/pm/intel_idle.rst +1 -0
+
 The value of the ``states_off`` module parameter (0 by default) represents a
 list of idle states to be disabled by default in the form of a bitmask.
drivers/idle/intel_idle.c +0 -0
index fc0aea26db50..3c07469586f7 100644

drivers/idle/intel_idle.c static bool no_native __read_mostly; /* No effect if no_acpi is set. */ · line 1784

Quoted 6 lines
drivers/idle/intel_idle.c +3 -0
@@ -1779,6 +1779,10 @@ static bool no_native __read_mostly; /* No effect if no_acpi is set. */
 module_param_named(no_native, no_native, bool, 0444);
 MODULE_PARM_DESC(no_native, "Ignore cpu specific (native) idle states in lieu of ACPI idle states");
 
+static bool prefer_cst __read_mostly; /* No effect if no_acpi is set. */
+module_param(prefer_cst, bool, 0444);
+MODULE_PARM_DESC(prefer_cst, "Prefer ACPI _CST idle states to ACPI _LPI idle states");

May be even something like this

Quoted 4 lines

MODULE_PARM_DESC(prefer_cst, "Try ACPI _CST before ACPI _LPI (default: "

                             "_LPI first)");

But this is very minor, your call.

I'm going to use mine.

Tested-by on v1 3/3
#6 lore raw

Re: [PATCH v1 3/3] intel_idle: Allow ACPI _CST to be preferred to ACPI _LPI

In reply to Rafael J. Wysocki
Quoted 7 lines · Rafael J. Wysocki

From: "Rafael J. Wysocki" <[email protected]>

Add a new module parameter called "prefer_cst" to intel_idle for making
it prefer _CST for building the idle state list when using ACPI, even if _LPI (preferred by default) is available.

Quoted 7 lines

This may be useful for diagnostics during platform bringup and as a fallback mechanism on platforms with broken ACPI _LPI and functional ACPI _CST.

Update the documentation accordingly.

Tested the full series on top of v7.4-rc2 on a _LPI capable platform, and it works as expected both with and without the prefer_cst parameter.

thanks,
rui

Quoted 108 lines

---
 Documentation/admin-guide/pm/intel_idle.rst | 15 ++++++++++----- drivers/idle/intel_idle.c                   | 15 +++++++++------

 2 files changed, 19 insertions(+), 11 deletions(-)
Documentation/admin-guide/pm/intel_idle.rst +0 -0
index d1a6251790b8..8092807d446b 100644
@@ -94,7 +94,9 @@ objects representing the CPUs in the system and

``_LPI`` processing produces a
 non-empty list of valid idle states, it will be used.  Otherwise, ``_CST`` will
 be used so long as it is present under at least one of the ACPI objects
 representing the CPUs in the system and it returns a non-empty list of valid
-idle states.  In either case, since the ``CPUIdle`` subsystem expects that the
+idle states.  [There is a module parameter that can be used to tell the driver
+to prefer ``_CST`` to ``_LPI`` and reverse the order in which they are tried.]
+In either case, since the ``CPUIdle`` subsystem expects that the list of idle states supplied by the driver will be suitable for all of the CPUs
 handled by it and ``intel_idle`` is registered as the ``CPUIdle`` driver for all
 of the CPUs in the system, ``intel_idle`` looks for the first CPU where the

Documentation/admin-guide/pm/intel_idle.rst +0 -0
@@ -223,10 +225,10 @@ even if they have been enumerated (see

:ref:cpu-pm-qos in Documentation/admin-guide/pm/cpuidle.rst).
 Setting ``max_cstate`` to 0 causes the ``intel_idle`` initialization to fail.

-The ``no_acpi``, ``use_acpi`` and ``no_native`` module parameters are
-recognized by ``intel_idle`` if the kernel has been configured with ACPI
-support.  In the case that ACPI is not configured these flags have no impact

Documentation/admin-guide/pm/intel_idle.rst +1 -1
-on functionality.
+The ``no_acpi``, ``use_acpi``, ``no_native``, and ``prefer_cst``

module
+parameters are recognized by ``intel_idle`` if the kernel has been configured
+with ACPI support.  If ACPI is not configured, these flags have no impact on
+functionality.

 ``no_acpi`` - Do not use ACPI at all.  Only native mode is available, no
 ACPI mode.

Documentation/admin-guide/pm/intel_idle.rst +0 -0
@@ -237,6 +239,9 @@ C-states on/off status in native mode.

 ``no_native`` - Work only in ACPI mode, no native mode available (ignore
 all custom tables).

+``prefer_cst`` - When using ACPI, prefer idle states coming from ``_CST`` to

Documentation/admin-guide/pm/intel_idle.rst +2 -0
+idle states coming from ``_LPI`` (which is preferred by default).
+

 The value of the ``states_off`` module parameter (0 by default) represents a
 list of idle states to be disabled by default in the form of a bitmask.

drivers/idle/intel_idle.c +0 -0
index fc0aea26db50..3c07469586f7 100644
@@ -1779,6 +1779,10 @@ static bool no_native __read_mostly; /* No

effect if no_acpi is set. */ module_param_named(no_native, no_native, bool, 0444); MODULE_PARM_DESC(no_native, "Ignore cpu specific (native) idle states in lieu of ACPI idle states");

+static bool prefer_cst __read_mostly; /* No effect if no_acpi is set. */

drivers/idle/intel_idle.c +2 -0
+module_param(prefer_cst, bool, 0444);
+MODULE_PARM_DESC(prefer_cst, "Prefer ACPI _CST idle states to ACPI

_LPI idle states");
+
 static struct acpi_processor_power acpi_state_table __initdata; static bool acpi_lpi_available __initdata;

drivers/idle/intel_idle.c +0 -0
@@ -1855,13 +1859,12 @@ static bool __init
 intel_idle_acpi_extract_cst_cstates(void)


 static bool __init intel_idle_acpi_extract_cstates(void) {

drivers/idle/intel_idle.c +3 -2
-	if (intel_idle_acpi_extract_lpi_cstates())
-		return true;
+	if (prefer_cst)
+		return intel_idle_acpi_extract_cst_cstates() ||
+			intel_idle_acpi_extract_lpi_cstates();

drivers/idle/intel_idle.c +2 -4
-	if (intel_idle_acpi_extract_cst_cstates())
-		return true;
-
-	return false;
+	return intel_idle_acpi_extract_lpi_cstates() ||
+		intel_idle_acpi_extract_cst_cstates();

 }

 static bool __init intel_idle_acpi_probe(void)