Skip to contentSkip to conversation

Revert "ACPI: power: Turn off unused power resources unconditionally"

PATCH In review Shujun Wang 3 participants 9 messages Apr 30, 2021 – May 17, 2021 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Revert "ACPI: power: Turn off unused power resources unconditionally"

This reverts commit 7e4fdeafa61f2b653fcf9678f09935e55756aed2. It may cause some NVMe device probes to fail, and the system may get stuck when using an NVMe device as the root filesystem.

In the function nvme_pci_enable(struct nvme_dev *dev), as shown below, readl(NVME_REG_CSTS) always returns -1 with the commit, which results in the probe failed.

  if (readl(dev->bar + NVME_REG_CSTS) == -1) {
	result = -ENODEV;
	goto disable;

}

dmesg:

  [    1.106280] nvme 0000:04:00.0: platform quirk: setting simple suspend
  [    1.109111] nvme nvme0: pci function 0000:04:00.0
  [    1.113066] nvme 0000:04:00.0: enabling device (0000 -> 0002)
  [    1.121040] nvme nvme0: Removing after probe failure status: -19

lspci:
Non-Volatile memory controller: KIOXIA Corporation Device 0001

device uevent:
DRIVER=nvme
PCI_CLASS=10802
PCI_ID=1E0F:0001
PCI_SUBSYS_ID=1E0F:0001
PCI_SLOT_NAME=0000:04:00.0 MODALIAS=pci:v00001E0Fd00000001sv00001E0Fsd00000001bc01sc08i02

This patch was tested in Lenovo Thinkpad X1.

---
 drivers/acpi/power.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/acpi/power.c +10 -1
index 56102eaaa2da..8bf10abeb2e0 100644
@@ -1004,9 +1004,18 @@ void acpi_turn_off_unused_power_resources(void)
 	mutex_lock(&power_resource_list_lock);
 
 	list_for_each_entry_reverse(resource, &acpi_power_resource_list, list_node) {
+		int result, state;
+
 		mutex_lock(&resource->resource_lock);
 
-		if (!resource->ref_count) {
+		result = acpi_power_get_state(resource->device.handle, &state);
+		if (result) {
+			mutex_unlock(&resource->resource_lock);
+			continue;
+		}
+
+		if (state == ACPI_POWER_RESOURCE_STATE_ON
+		    && !resource->ref_count) {
 			dev_info(&resource->device.dev, "Turning OFF\n");
 			__acpi_power_off(resource);
 		}
Signature · 1 line
2.25.1
#1 lore raw
Quoted 2 lines · Shujun Wang

This reverts commit 7e4fdeafa61f2b653fcf9678f09935e55756aed2.

OK, I'll revert that commit, thanks!

Quoted 63 lines

It may cause some NVMe device probes to fail, and the system may get stuck when using an NVMe device as the root filesystem.

In the function nvme_pci_enable(struct nvme_dev *dev), as shown below, readl(NVME_REG_CSTS) always returns -1 with the commit, which results in the probe failed.

  if (readl(dev->bar + NVME_REG_CSTS) == -1) {
        result = -ENODEV;
        goto disable;
  }

dmesg:

  [    1.106280] nvme 0000:04:00.0: platform quirk: setting simple suspend
  [    1.109111] nvme nvme0: pci function 0000:04:00.0
  [    1.113066] nvme 0000:04:00.0: enabling device (0000 -> 0002)
  [    1.121040] nvme nvme0: Removing after probe failure status: -19

lspci:
Non-Volatile memory controller: KIOXIA Corporation Device 0001

device uevent:
DRIVER=nvme
PCI_CLASS=10802
PCI_ID=1E0F:0001
PCI_SUBSYS_ID=1E0F:0001
PCI_SLOT_NAME=0000:04:00.0 MODALIAS=pci:v00001E0Fd00000001sv00001E0Fsd00000001bc01sc08i02

This patch was tested in Lenovo Thinkpad X1.

---
 drivers/acpi/power.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/acpi/power.c +10 -2
index 56102eaaa2da..8bf10abeb2e0 100644
@@ -1004,9 +1004,18 @@ void acpi_turn_off_unused_power_resources(void)
        mutex_lock(&power_resource_list_lock);
 
        list_for_each_entry_reverse(resource, &acpi_power_resource_list, list_node) {
+               int result, state;
+
                mutex_lock(&resource->resource_lock);
 
-               if (!resource->ref_count) {
+               result = acpi_power_get_state(resource->device.handle, &state);
+               if (result) {
+                       mutex_unlock(&resource->resource_lock);
+                       continue;
+               }
+
+               if (state == ACPI_POWER_RESOURCE_STATE_ON
+                   && !resource->ref_count) {
                        dev_info(&resource->device.dev, "Turning OFF\n");
                        __acpi_power_off(resource);
                }
--

2.25.1

#3 lore raw
In reply to Shujun Wang

Hi, Shujun,

I'm experiencing similar problem, and it should be a BIOS problem, which can be fixed by a customized DSDT. Can you please attach the full acpidump output on this machine? I just want to make sure if it is the same problem.

Thanks,
rui

Quoted 75 lines

-----Original Message-----
From: Shujun Wang <[email protected]>
Sent: Friday, April 30, 2021 8:42 PM
To: [email protected]; [email protected]; [email protected]; linux- [email protected]
Cc: Shujun Wang <[email protected]>
Subject: [PATCH] Revert "ACPI: power: Turn off unused power resources unconditionally"

This reverts commit 7e4fdeafa61f2b653fcf9678f09935e55756aed2. It may cause some NVMe device probes to fail, and the system may get stuck when using an NVMe device as the root filesystem.

In the function nvme_pci_enable(struct nvme_dev *dev), as shown below, readl(NVME_REG_CSTS) always returns -1 with the commit, which results in the probe failed.

  if (readl(dev->bar + NVME_REG_CSTS) == -1) {
	result = -ENODEV;
	goto disable;

}

dmesg:

  [    1.106280] nvme 0000:04:00.0: platform quirk: setting simple suspend
  [    1.109111] nvme nvme0: pci function 0000:04:00.0
  [    1.113066] nvme 0000:04:00.0: enabling device (0000 -> 0002)
  [    1.121040] nvme nvme0: Removing after probe failure status: -19

lspci:
Non-Volatile memory controller: KIOXIA Corporation Device 0001

device uevent:
DRIVER=nvme
PCI_CLASS=10802
PCI_ID=1E0F:0001
PCI_SUBSYS_ID=1E0F:0001
PCI_SLOT_NAME=0000:04:00.0 MODALIAS=pci:v00001E0Fd00000001sv00001E0Fsd00000001bc01sc08i02

This patch was tested in Lenovo Thinkpad X1.

---
 drivers/acpi/power.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/acpi/power.c index renamed from drivers/acpi/power.c +0 -0

56102eaaa2da..8bf10abeb2e0 100644

drivers/acpi/power.c +10 -1
@@ -1004,9 +1004,18 @@ void
 acpi_turn_off_unused_power_resources(void)
 	mutex_lock(&power_resource_list_lock);
 
 	list_for_each_entry_reverse(resource, &acpi_power_resource_list,
 list_node) {
+		int result, state;
+
 		mutex_lock(&resource->resource_lock);
 
-		if (!resource->ref_count) {
+		result = acpi_power_get_state(resource->device.handle,
 &state);
+		if (result) {
+			mutex_unlock(&resource->resource_lock);
+			continue;
+		}
+
+		if (state == ACPI_POWER_RESOURCE_STATE_ON
+		    && !resource->ref_count) {
drivers/acpi/power.c +0 -1
 			dev_info(&resource->device.dev, "Turning OFF\n");
 			__acpi_power_off(resource);
 		}
--

2.25.1

#4 lore raw
Quoted 4 lines · Rui

Hi, Shujun,

I'm experiencing similar problem, and it should be a BIOS problem,

Right, and I confused things. Sorry about that.

If commit 7e4fdeafa61f2b653f ("ACPI: power: Turn off unused power resources unconditionally") causes problems to happen, this means that the platform firmware implementation doesn't follow the ACPI specification.

Quoted 2 lines

which can be fixed by a customized DSDT.
Can you please attach the full acpidump output on this machine? I just want to make sure if it is the same problem.

Yes, please.

Rui, can you create a BZ for this please and can you both attach dmidecode output from the affected systems?

I don't want to revert this commit completely, so the default behavior is spec-compliant, but there can be a DMI-based blacklist for systems having problems with it.

Quoted 76 lines
Quoted 75 lines

-----Original Message-----
From: Shujun Wang <[email protected]>
Sent: Friday, April 30, 2021 8:42 PM
To: [email protected]; [email protected]; [email protected]; linux- [email protected]
Cc: Shujun Wang <[email protected]>
Subject: [PATCH] Revert "ACPI: power: Turn off unused power resources unconditionally"

This reverts commit 7e4fdeafa61f2b653fcf9678f09935e55756aed2. It may cause some NVMe device probes to fail, and the system may get stuck when using an NVMe device as the root filesystem.

In the function nvme_pci_enable(struct nvme_dev *dev), as shown below, readl(NVME_REG_CSTS) always returns -1 with the commit, which results in the probe failed.

  if (readl(dev->bar + NVME_REG_CSTS) == -1) {
      result = -ENODEV;
      goto disable;
  }

dmesg:

  [    1.106280] nvme 0000:04:00.0: platform quirk: setting simple suspend
  [    1.109111] nvme nvme0: pci function 0000:04:00.0
  [    1.113066] nvme 0000:04:00.0: enabling device (0000 -> 0002)
  [    1.121040] nvme nvme0: Removing after probe failure status: -19

lspci:
Non-Volatile memory controller: KIOXIA Corporation Device 0001

device uevent:
DRIVER=nvme
PCI_CLASS=10802
PCI_ID=1E0F:0001
PCI_SUBSYS_ID=1E0F:0001
PCI_SLOT_NAME=0000:04:00.0 MODALIAS=pci:v00001E0Fd00000001sv00001E0Fsd00000001bc01sc08i02

This patch was tested in Lenovo Thinkpad X1.

---
 drivers/acpi/power.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/acpi/power.c index renamed from drivers/acpi/power.c +0 -0

56102eaaa2da..8bf10abeb2e0 100644

drivers/acpi/power.c +10 -1
@@ -1004,9 +1004,18 @@ void
 acpi_turn_off_unused_power_resources(void)
      mutex_lock(&power_resource_list_lock);
 
      list_for_each_entry_reverse(resource, &acpi_power_resource_list,
 list_node) {
+             int result, state;
+
              mutex_lock(&resource->resource_lock);
 
-             if (!resource->ref_count) {
+             result = acpi_power_get_state(resource->device.handle,
 &state);
+             if (result) {
+                     mutex_unlock(&resource->resource_lock);
+                     continue;
+             }
+
+             if (state == ACPI_POWER_RESOURCE_STATE_ON
+                 && !resource->ref_count) {
                      dev_info(&resource->device.dev, "Turning OFF\n");
                      __acpi_power_off(resource);
              }

--
2.25.1

#5 lore raw
Quoted 21 lines · Rafael J. Wysocki
Quoted 4 lines · Rui

Hi, Shujun,

I'm experiencing similar problem, and it should be a BIOS problem,

Right, and I confused things. Sorry about that.

If commit 7e4fdeafa61f2b653f ("ACPI: power: Turn off unused power resources unconditionally") causes problems to happen, this means that
the platform firmware implementation doesn't follow the ACPI specification.

Quoted 3 lines

which can be fixed by a customized DSDT.
Can you please attach the full acpidump output on this machine? I just want to make sure if it is the same problem.

Yes, please.

Quoted 8 lines

Rui, can you create a BZ for this please and can you both attach dmidecode output from the affected systems?

I don't want to revert this commit completely, so the default behavior
is spec-compliant, but there can be a DMI-based blacklist for systems having problems with it.

Done.
https://bugzilla.kernel.org/show_bug.cgi?id=213019

Shujun,
can you please attach the acpidump and dmidecode output in this bug report?

thanks,
rui

Quoted 86 lines
Quoted 86 lines
Quoted 86 lines

-----Original Message-----
From: Shujun Wang <[email protected]>
Sent: Friday, April 30, 2021 8:42 PM
To: [email protected]; [email protected]; [email protected]; linux- [email protected]
Cc: Shujun Wang <[email protected]>
Subject: [PATCH] Revert "ACPI: power: Turn off unused power resources
unconditionally"

This reverts commit 7e4fdeafa61f2b653fcf9678f09935e55756aed2. It may cause some NVMe device probes to fail, and the system may get stuck
when using an NVMe device as the root filesystem.

In the function nvme_pci_enable(struct nvme_dev *dev), as shown below,
readl(NVME_REG_CSTS) always returns -1 with the commit, which results in
the probe failed.

  if (readl(dev->bar + NVME_REG_CSTS) == -1) {
      result = -ENODEV;
      goto disable;
  }

dmesg:

  [    1.106280] nvme 0000:04:00.0: platform quirk: setting
simple suspend
  [    1.109111] nvme nvme0: pci function 0000:04:00.0
  [    1.113066] nvme 0000:04:00.0: enabling device (0000 ->
0002)
  [    1.121040] nvme nvme0: Removing after probe failure status:

-19

lspci:
Non-Volatile memory controller: KIOXIA Corporation Device 0001

device uevent:
DRIVER=nvme
PCI_CLASS=10802
PCI_ID=1E0F:0001
PCI_SUBSYS_ID=1E0F:0001
PCI_SLOT_NAME=0000:04:00.0 MODALIAS=pci:v00001E0Fd00000001sv00001E0Fsd00000001bc01sc08i02

This patch was tested in Lenovo Thinkpad X1.

---
 drivers/acpi/power.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/acpi/power.c index renamed from drivers/acpi/power.c +0 -0

56102eaaa2da..8bf10abeb2e0 100644

drivers/acpi/power.c +3 -1
@@ -1004,9 +1004,18 @@ void
 acpi_turn_off_unused_power_resources(void)
      mutex_lock(&power_resource_list_lock);
 
      list_for_each_entry_reverse(resource,
 &acpi_power_resource_list,
 list_node) {
+             int result, state;
+
              mutex_lock(&resource->resource_lock);
 
-             if (!resource->ref_count) {
+             result = acpi_power_get_state(resource-
Quoted 1 line

device.handle,

&state);

drivers/acpi/power.c +7 -0
+             if (result) {
+                     mutex_unlock(&resource->resource_lock);
+                     continue;
+             }
+
+             if (state == ACPI_POWER_RESOURCE_STATE_ON
+                 && !resource->ref_count) {
                      dev_info(&resource->device.dev, "Turning
OFF\n");
                      __acpi_power_off(resource);
              }

--
2.25.1

author
#6 lore raw
Quoted 33 lines · Zhang Rui
Quoted 21 lines · Rafael J. Wysocki
Quoted 4 lines · Rui

Hi, Shujun,

I'm experiencing similar problem, and it should be a BIOS problem,

Right, and I confused things. Sorry about that.

If commit 7e4fdeafa61f2b653f ("ACPI: power: Turn off unused power resources unconditionally") causes problems to happen, this means that
the platform firmware implementation doesn't follow the ACPI specification.

Quoted 3 lines

which can be fixed by a customized DSDT.
Can you please attach the full acpidump output on this machine? I just want to make sure if it is the same problem.

Yes, please.

Quoted 8 lines

Rui, can you create a BZ for this please and can you both attach dmidecode output from the affected systems?

I don't want to revert this commit completely, so the default behavior
is spec-compliant, but there can be a DMI-based blacklist for systems having problems with it.

Done.
https://bugzilla.kernel.org/show_bug.cgi?id=213019

Quoted 6 lines

Shujun,
can you please attach the acpidump and dmidecode output in this bug report?

thanks,
rui

Hi Rui:

Sorry for late, I have attached the acpidump and dmidecode in the https://bugzilla.kernel.org/show_bug.cgi?id=213019

BR
Shujun Wang

Quoted 87 lines
Quoted 87 lines
Quoted 87 lines
Quoted 87 lines

-----Original Message-----
From: Shujun Wang <[email protected]>
Sent: Friday, April 30, 2021 8:42 PM
To: [email protected]; [email protected]; [email protected]; linux- [email protected]
Cc: Shujun Wang <[email protected]>
Subject: [PATCH] Revert "ACPI: power: Turn off unused power resources
unconditionally"

This reverts commit 7e4fdeafa61f2b653fcf9678f09935e55756aed2. It may cause some NVMe device probes to fail, and the system may get stuck
when using an NVMe device as the root filesystem.

In the function nvme_pci_enable(struct nvme_dev *dev), as shown below,
readl(NVME_REG_CSTS) always returns -1 with the commit, which results in
the probe failed.

  if (readl(dev->bar + NVME_REG_CSTS) == -1) {
      result = -ENODEV;
      goto disable;
  }

dmesg:

  [    1.106280] nvme 0000:04:00.0: platform quirk: setting
simple suspend
  [    1.109111] nvme nvme0: pci function 0000:04:00.0
  [    1.113066] nvme 0000:04:00.0: enabling device (0000 ->
0002)
  [    1.121040] nvme nvme0: Removing after probe failure status:

-19

lspci:
Non-Volatile memory controller: KIOXIA Corporation Device 0001

device uevent:
DRIVER=nvme
PCI_CLASS=10802
PCI_ID=1E0F:0001
PCI_SUBSYS_ID=1E0F:0001
PCI_SLOT_NAME=0000:04:00.0 MODALIAS=pci:v00001E0Fd00000001sv00001E0Fsd00000001bc01sc08i02

This patch was tested in Lenovo Thinkpad X1.

---
 drivers/acpi/power.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/acpi/power.c index renamed from drivers/acpi/power.c +0 -0

56102eaaa2da..8bf10abeb2e0 100644

drivers/acpi/power.c +3 -1
@@ -1004,9 +1004,18 @@ void
 acpi_turn_off_unused_power_resources(void)
      mutex_lock(&power_resource_list_lock);
 
      list_for_each_entry_reverse(resource,
 &acpi_power_resource_list,
 list_node) {
+             int result, state;
+
              mutex_lock(&resource->resource_lock);
 
-             if (!resource->ref_count) {
+             result = acpi_power_get_state(resource-
Quoted 1 line

device.handle,

&state);

drivers/acpi/power.c +7 -0
+             if (result) {
+                     mutex_unlock(&resource->resource_lock);
+                     continue;
+             }
+
+             if (state == ACPI_POWER_RESOURCE_STATE_ON
+                 && !resource->ref_count) {
                      dev_info(&resource->device.dev, "Turning
OFF\n");
                      __acpi_power_off(resource);
              }

--
2.25.1

#7 lore raw
In reply to Shujun Wang
Quoted 31 lines · Shujun Wang

This reverts commit 7e4fdeafa61f2b653fcf9678f09935e55756aed2. It may cause some NVMe device probes to fail, and the system may get stuck when using an NVMe device as the root filesystem.

In the function nvme_pci_enable(struct nvme_dev *dev), as shown below, readl(NVME_REG_CSTS) always returns -1 with the commit, which results in the probe failed.

  if (readl(dev->bar + NVME_REG_CSTS) == -1) {
        result = -ENODEV;
        goto disable;
  }

dmesg:

  [    1.106280] nvme 0000:04:00.0: platform quirk: setting simple suspend
  [    1.109111] nvme nvme0: pci function 0000:04:00.0
  [    1.113066] nvme 0000:04:00.0: enabling device (0000 -> 0002)
  [    1.121040] nvme nvme0: Removing after probe failure status: -19

lspci:
Non-Volatile memory controller: KIOXIA Corporation Device 0001

device uevent:
DRIVER=nvme
PCI_CLASS=10802
PCI_ID=1E0F:0001
PCI_SUBSYS_ID=1E0F:0001
PCI_SLOT_NAME=0000:04:00.0 MODALIAS=pci:v00001E0Fd00000001sv00001E0Fsd00000001bc01sc08i02

Quoted 1 line

This patch was tested in Lenovo Thinkpad X1.

Please send me the dmidecode output from this machine or (better) attach it at https://bugzilla.kernel.org/show_bug.cgi?id=213019

Thanks!

author
#8 lore raw
Quoted 32 lines · Rafael J. Wysocki
Quoted 31 lines · Shujun Wang

This reverts commit 7e4fdeafa61f2b653fcf9678f09935e55756aed2. It may cause some NVMe device probes to fail, and the system may get stuck when using an NVMe device as the root filesystem.

In the function nvme_pci_enable(struct nvme_dev *dev), as shown below, readl(NVME_REG_CSTS) always returns -1 with the commit, which results in the probe failed.

  if (readl(dev->bar + NVME_REG_CSTS) == -1) {
        result = -ENODEV;
        goto disable;
  }

dmesg:

  [    1.106280] nvme 0000:04:00.0: platform quirk: setting simple suspend
  [    1.109111] nvme nvme0: pci function 0000:04:00.0
  [    1.113066] nvme 0000:04:00.0: enabling device (0000 -> 0002)
  [    1.121040] nvme nvme0: Removing after probe failure status: -19

lspci:
Non-Volatile memory controller: KIOXIA Corporation Device 0001

device uevent:
DRIVER=nvme
PCI_CLASS=10802
PCI_ID=1E0F:0001
PCI_SUBSYS_ID=1E0F:0001
PCI_SLOT_NAME=0000:04:00.0 MODALIAS=pci:v00001E0Fd00000001sv00001E0Fsd00000001bc01sc08i02

Quoted 6 lines
Quoted 1 line

This patch was tested in Lenovo Thinkpad X1.

Please send me the dmidecode output from this machine or (better) attach it at https://bugzilla.kernel.org/show_bug.cgi?id=213019

Thanks!

Hi Rafael:

Sorry for late, I have attached the acpidump and dmidecode in the https://bugzilla.kernel.org/show_bug.cgi?id=213019

BR
Shujun Wang