Skip to contentSkip to conversation

ACPI: processor: Do not use C3 w/o ARB_DIS=1

PATCH Superseded Ville Syrjala 3 participants 6 messages Apr 20, 2022 – Apr 21, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ACPI: processor: Do not use C3 w/o ARB_DIS=1

From: Ville Syrjälä <[email protected]>

commit d6b88ce2eb9d ("ACPI: processor idle: Allow playing dead in C3 state") was supposedly just trying to enable C3 when the CPU is offlined, but it also mistakenly enabled C3 usage without setting ARB_DIS=1 in normal idle scenarios.

This results in a machine that won't boot past the point when it first enters C3. Restore the correct behaviour (either demote to C1/C2, or use C3 but also set ARB_DIS=1).

I hit this on a Fujitsu Siemens Lifebook S6010 (P3) machine.

Cc Woody Suwalski <[email protected]>
Cc Mario Limonciello <[email protected]>
Cc Richard Gong <[email protected]>
Cc Rafael J. Wysocki <[email protected]>
Fixes d6b88ce2eb9d ("ACPI: processor idle: Allow playing dead in C3 state")
---
 drivers/acpi/processor_idle.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/processor_idle.c +2 -2
index 4556c86c3465..54f0a1915025 100644
@@ -793,10 +793,10 @@ static int acpi_processor_setup_cstates(struct acpi_processor *pr)
 
 		state->flags = 0;
 		if (cx->type == ACPI_STATE_C1 || cx->type == ACPI_STATE_C2 ||
-		    cx->type == ACPI_STATE_C3) {
+		    cx->type == ACPI_STATE_C3)
 			state->enter_dead = acpi_idle_play_dead;
+		if (cx->type == ACPI_STATE_C1 || cx->type == ACPI_STATE_C2)
 			drv->safe_state_index = count;
-		}
 		/*
 		 * Halt-induced C1 is not good for ->enter_s2idle, because it
 		 * re-enables interrupts on exit.  Moreover, C1 is generally not
Signature · 1 line
2.35.1
#1 lore raw

PATCH 2/2 Revert "ACPI: processor: idle: fix lockup regression on 32-bit ThinkPad T40"

From: Ville Syrjälä <[email protected]>

This reverts commit bfe55a1f7fd6bfede16078bf04c6250fbca11588.

This was presumably misdiagnosed as an inability to use C3 at all when I suspect the real problem is just misconfiguration of C3 vs. ARB_DIS.

Cc Woody Suwalski <[email protected]>
Cc Mario Limonciello <[email protected]>
Cc Richard Gong <[email protected]>
Cc Rafael J. Wysocki <[email protected]>
---
 drivers/acpi/processor_idle.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/acpi/processor_idle.c +0 -5
index 54f0a1915025..d4632b8adbc5 100644
@@ -96,11 +96,6 @@ static const struct dmi_system_id processor_power_dmi_table[] = {
 	  DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
 	  DMI_MATCH(DMI_PRODUCT_NAME,"L8400B series Notebook PC")},
 	 (void *)1},
-	/* T40 can not handle C3 idle state */
-	{ set_max_cstate, "IBM ThinkPad T40", {
-	  DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
-	  DMI_MATCH(DMI_PRODUCT_NAME, "23737CU")},
-	 (void *)2},
 	{},
 };
 
Signature · 1 line
2.35.1
#2 lore raw
In reply to Ville Syrjala
Quoted 33 lines · Ville Syrjala

From: Ville Syrjälä <[email protected]>

commit d6b88ce2eb9d ("ACPI: processor idle: Allow playing dead in C3 state") was supposedly just trying to enable C3 when the CPU is offlined, but it also mistakenly enabled C3 usage without setting ARB_DIS=1 in normal idle scenarios.

This results in a machine that won't boot past the point when it first enters C3. Restore the correct behaviour (either demote to C1/C2, or use C3 but also set ARB_DIS=1).

I hit this on a Fujitsu Siemens Lifebook S6010 (P3) machine.

Cc Woody Suwalski <[email protected]>
Cc Mario Limonciello <[email protected]>
Cc Richard Gong <[email protected]>
Cc Rafael J. Wysocki <[email protected]>
Fixes d6b88ce2eb9d ("ACPI: processor idle: Allow playing dead in C3 state")
---
 drivers/acpi/processor_idle.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/processor_idle.c +0 -0
index 4556c86c3465..54f0a1915025 100644
@@ -793,10 +793,10 @@ static int acpi_processor_setup_cstates(struct acpi_processor *pr)
 
                state->flags = 0;
                if (cx->type == ACPI_STATE_C1 || cx->type == ACPI_STATE_C2 ||

drivers/acpi/processor_idle.c static int acpi_processor_setup_cstates(struct acpi_processor *pr)

Quoted 10 lines
drivers/acpi/processor_idle.c +2 -3
-                   cx->type == ACPI_STATE_C3) {
+                   cx->type == ACPI_STATE_C3)
                        state->enter_dead = acpi_idle_play_dead;
+               if (cx->type == ACPI_STATE_C1 || cx->type == ACPI_STATE_C2)
                        drv->safe_state_index = count;
-               }
                /*
                 * Halt-induced C1 is not good for ->enter_s2idle, because it
                 * re-enables interrupts on exit.  Moreover, C1 is generally not
--

Good catch, but I would prefer doing the below which should be equivalent (modulo GMail-induced white space breakage):

---
 drivers/acpi/processor_idle.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/acpi/processor_idle.c +2 -1
Index: linux-pm/drivers/acpi/processor_idle.c
===================================================================
@@ -795,7 +795,8 @@ static int acpi_processor_setup_cstates(
         if (cx->type == ACPI_STATE_C1 || cx->type == ACPI_STATE_C2 ||
             cx->type == ACPI_STATE_C3) {
             state->enter_dead = acpi_idle_play_dead;
-            drv->safe_state_index = count;
+            if (cx->type != ACPI_STATE_C3)
+                drv->safe_state_index = count;
         }
         /*
          * Halt-induced C1 is not good for ->enter_s2idle, because it
#3 lore raw
Quoted 56 lines · Rafael J. Wysocki
Quoted 32 lines · Ville Syrjala

From: Ville Syrjälä <[email protected]>

commit d6b88ce2eb9d ("ACPI: processor idle: Allow playing dead in C3 state") was supposedly just trying to enable C3 when the CPU is offlined, but it also mistakenly enabled C3 usage without setting ARB_DIS=1 in normal idle scenarios.

This results in a machine that won't boot past the point when it first enters C3. Restore the correct behaviour (either demote to C1/C2, or use C3 but also set ARB_DIS=1).

I hit this on a Fujitsu Siemens Lifebook S6010 (P3) machine.

Cc Woody Suwalski <[email protected]>
Cc Mario Limonciello <[email protected]>
Cc Richard Gong <[email protected]>
Cc Rafael J. Wysocki <[email protected]>
Fixes d6b88ce2eb9d ("ACPI: processor idle: Allow playing dead in C3 state")
---
  drivers/acpi/processor_idle.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/processor_idle.c +0 -0
index 4556c86c3465..54f0a1915025 100644
@@ -793,10 +793,10 @@ static int acpi_processor_setup_cstates(struct acpi_processor *pr)
 
                 state->flags = 0;
                 if (cx->type == ACPI_STATE_C1 || cx->type == ACPI_STATE_C2 ||

drivers/acpi/processor_idle.c static int acpi_processor_setup_cstates(struct acpi_processor *pr)

Quoted 10 lines
drivers/acpi/processor_idle.c +2 -3
-                   cx->type == ACPI_STATE_C3) {
+                   cx->type == ACPI_STATE_C3)
                         state->enter_dead = acpi_idle_play_dead;
+               if (cx->type == ACPI_STATE_C1 || cx->type == ACPI_STATE_C2)
                         drv->safe_state_index = count;
-               }
                 /*
                  * Halt-induced C1 is not good for ->enter_s2idle, because it
                  * re-enables interrupts on exit.  Moreover, C1 is generally not
--

Good catch, but I would prefer doing the below which should be equivalent (modulo GMail-induced white space breakage):

---
  drivers/acpi/processor_idle.c |    3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

Index: linux-pm/drivers/acpi/processor_idle.c
===================================================================

drivers/acpi/processor_idle.c static int acpi_processor_setup_cstates( · line 802

Quoted 9 lines
drivers/acpi/processor_idle.c +2 -1
@@ -795,7 +795,8 @@ static int acpi_processor_setup_cstates(
          if (cx->type == ACPI_STATE_C1 || cx->type == ACPI_STATE_C2 ||
              cx->type == ACPI_STATE_C3) {
              state->enter_dead = acpi_idle_play_dead;
-            drv->safe_state_index = count;
+            if (cx->type != ACPI_STATE_C3)
+                drv->safe_state_index = count;
          }
          /*
           * Halt-induced C1 is not good for ->enter_s2idle, because it

I have tested both solutions from Ville and Rafael, and both work OK on T40.
Clearly, since Ville has duped the issue on a non-T40 machine, the processor_power_dmi_table[] solution is incorrect.

Rafael's solution seems simpler - so I also like it more :-)

Thanks, Woody

#4 lore raw

PATCH v2 1/2 ACPI: processor: Do not use C3 w/o ARB_DIS=1

In reply to Ville Syrjala

From: Ville Syrjälä <[email protected]>

commit d6b88ce2eb9d ("ACPI: processor idle: Allow playing dead in C3 state") was supposedly just trying to enable C3 when the CPU is offlined, but it also mistakenly enabled C3 usage without setting ARB_DIS=1 in normal idle scenarios.

This results in a machine that won't boot past the point when it first enters C3. Restore the correct behaviour (either demote to C1/C2, or use C3 but also set ARB_DIS=1).

I hit this on a Fujitsu Siemens Lifebook S6010 (P3) machine.

Cc Woody Suwalski <[email protected]>
Cc Mario Limonciello <[email protected]>
Cc Richard Gong <[email protected]>
Cc Rafael J. Wysocki <[email protected]>
Fixes d6b88ce2eb9d ("ACPI: processor idle: Allow playing dead in C3 state")

---
v2: Paint it in a different color (Rafael)

 drivers/acpi/processor_idle.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/acpi/processor_idle.c +2 -1
index 4556c86c3465..5f296e099bce 100644
@@ -795,7 +795,8 @@ static int acpi_processor_setup_cstates(struct acpi_processor *pr)
 		if (cx->type == ACPI_STATE_C1 || cx->type == ACPI_STATE_C2 ||
 		    cx->type == ACPI_STATE_C3) {
 			state->enter_dead = acpi_idle_play_dead;
-			drv->safe_state_index = count;
+			if (cx->type != ACPI_STATE_C3)
+				drv->safe_state_index = count;
 		}
 		/*
 		 * Halt-induced C1 is not good for ->enter_s2idle, because it
Signature · 1 line
2.35.1
#5 lore raw
Quoted 2 lines · Ville Syrjala

From: Ville Syrjälä <[email protected]>

Thanks for the updating!

I'm going to apply this for 5.18-rc along with the [2/2].

However, I'm going to change the subject of this patch to "ACPI:
processor: idle: Avoid falling back to C3 type C-states".

Quoted 4 lines

commit d6b88ce2eb9d ("ACPI: processor idle: Allow playing dead in C3 state") was supposedly just trying to enable C3 when the CPU is offlined, but it also mistakenly enabled C3 usage without setting ARB_DIS=1 in normal idle scenarios.

And I'm going to replace the above paragraph in the changelog with:

"The "safe state" index is used by acpi_idle_enter_bm() to avoid entering a C-state that may require bus mastering to be disabled on entry in the cases when this is not going to happen. For this reason, it should not be set to point to C3 type of C-states, because they may require bus mastering to be disabled on entry in principle.

This was broken by commit d6b88ce2eb9d ("ACPI: processor idle: Allow playing dead in C3 state") which inadvertently allowed the "safe state" index to point to C3 type of C-states."

Quoted 36 lines

This results in a machine that won't boot past the point when it first enters C3. Restore the correct behaviour (either demote to C1/C2, or use C3 but also set ARB_DIS=1).

I hit this on a Fujitsu Siemens Lifebook S6010 (P3) machine.

Cc Woody Suwalski <[email protected]>
Cc Mario Limonciello <[email protected]>
Cc Richard Gong <[email protected]>
Cc Rafael J. Wysocki <[email protected]>
Fixes d6b88ce2eb9d ("ACPI: processor idle: Allow playing dead in C3 state")

---
v2: Paint it in a different color (Rafael)

 drivers/acpi/processor_idle.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/acpi/processor_idle.c +2 -2
index 4556c86c3465..5f296e099bce 100644
@@ -795,7 +795,8 @@ static int acpi_processor_setup_cstates(struct acpi_processor *pr)
                if (cx->type == ACPI_STATE_C1 || cx->type == ACPI_STATE_C2 ||
                    cx->type == ACPI_STATE_C3) {
                        state->enter_dead = acpi_idle_play_dead;
-                       drv->safe_state_index = count;
+                       if (cx->type != ACPI_STATE_C3)
+                               drv->safe_state_index = count;
                }
                /*
                 * Halt-induced C1 is not good for ->enter_s2idle, because it
--

2.35.1