Skip to contentSkip to conversation

ACPI: PM: Avoid removing power from unused hardware too early

PATCH In review Rafael J. Wysocki 2 participants 2 messages Nov 10, 2021 – Nov 17, 2021 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI: PM: Avoid removing power from unused hardware too early

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

Commit c10383e8ddf4 ("ACPI: scan: Release PM resources blocked by unused objects") causes power to be removed from some hardware resources that appear to be unused too early, which leads to boot issues on some systems.

To address this, move putting the unused ACPI device objects into D3cold to a late initcall.

Fixes c10383e8ddf4 ("ACPI: scan: Release PM resources blocked by unused objects")
---
 drivers/acpi/scan.c |   22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
drivers/acpi/scan.c +16 -6
Index: linux-pm/drivers/acpi/scan.c
===================================================================
@@ -2559,12 +2559,6 @@ int __init acpi_scan_init(void)
 		}
 	}
 
-	/*
-	 * Make sure that power management resources are not blocked by ACPI
-	 * device objects with no users.
-	 */
-	bus_for_each_dev(&acpi_bus_type, NULL, NULL, acpi_dev_turn_off_if_unused);
-
 	acpi_turn_off_unused_power_resources();
 
 	acpi_scan_initialized = true;
@@ -2574,6 +2568,22 @@ int __init acpi_scan_init(void)
 	return result;
 }
 
+static int acpi_turn_off_unused_devices(void)
+{
+	mutex_lock(&acpi_scan_lock);
+
+	/*
+	 * Make sure that power management resources are not blocked by ACPI
+	 * device objects with no users.
+	 */
+	bus_for_each_dev(&acpi_bus_type, NULL, NULL, acpi_dev_turn_off_if_unused);
+
+	mutex_unlock(&acpi_scan_lock);
+
+	return 0;
+}
+late_initcall(acpi_turn_off_unused_devices);
+
 static struct acpi_probe_entry *ape;
 static int acpi_probe_count;
 static DEFINE_MUTEX(acpi_probe_mutex);
#1 lore raw
Quoted 8 lines · Rafael J. Wysocki

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

Commit c10383e8ddf4 ("ACPI: scan: Release PM resources blocked by unused objects") causes power to be removed from some hardware resources that appear to be unused too early, which leads to boot issues on some systems.

Quoted 7 lines

To address this, move putting the unused ACPI device objects into D3cold to a late initcall.

Fixes c10383e8ddf4 ("ACPI: scan: Release PM resources blocked by unused objects")

Unfortunately, this fix is not effective in some cases, so I'm going to revert commit c10383e8ddf4 for 5.16 and revisit this later.

Thanks!

Quoted 47 lines
---
 drivers/acpi/scan.c |   22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

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

drivers/acpi/scan.c +16 -6
@@ -2559,12 +2559,6 @@ int __init acpi_scan_init(void)
                }
        }
 
-       /*
-        * Make sure that power management resources are not blocked by ACPI
-        * device objects with no users.
-        */
-       bus_for_each_dev(&acpi_bus_type, NULL, NULL, acpi_dev_turn_off_if_unused);
-
        acpi_turn_off_unused_power_resources();
 
        acpi_scan_initialized = true;
@@ -2574,6 +2568,22 @@ int __init acpi_scan_init(void)
        return result;
 }
 
+static int acpi_turn_off_unused_devices(void)
+{
+       mutex_lock(&acpi_scan_lock);
+
+       /*
+        * Make sure that power management resources are not blocked by ACPI
+        * device objects with no users.
+        */
+       bus_for_each_dev(&acpi_bus_type, NULL, NULL, acpi_dev_turn_off_if_unused);
+
+       mutex_unlock(&acpi_scan_lock);
+
+       return 0;
+}
+late_initcall(acpi_turn_off_unused_devices);
+
 static struct acpi_probe_entry *ape;
 static int acpi_probe_count;
 static DEFINE_MUTEX(acpi_probe_mutex);