Skip to contentSkip to conversation

ACPI: scan: Do not increase dep_unmet for already met dependencies

PATCH Applied Hans de Goede 2 participants 2 messages Apr 6, 2024 – Apr 8, 2024 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI: scan: Do not increase dep_unmet for already met dependencies

On the Toshiba Encore WT10-A tablet the BATC battery ACPI device depends on 3 other devices:

            Name (_DEP, Package (0x03)  // _DEP: Dependencies
            {
                I2C1,
                GPO2,
                GPO0
            })

acpi_scan_check_dep() adds all 3 of these to the acpi_dep_list and then before an acpi_device is created for the BATC handle (and thus before acpi_scan_dep_init() runs) acpi_scan_clear_dep() gets called for both GPIO depenencies, with free_when_met not set for the dependencies.

Since there is no adev for BATC yet, there also is no dep_unmet to decrement. The only result of acpi_scan_clear_dep() in this case is dep->met getting set.

Soon after acpi_scan_clear_dep() has been called for the GPIO dependencies the acpi_device gets created for the BATC handle and acpi_scan_dep_init() runs, this sees 3 dependencies on the acpi_dep_list and initializes unmet_dep to 3. Later when the dependency for I2C1 is met unmet_dep becomes 2, but since the 2 GPIO deps where already met it never becomes 0 causing battery monitoring to not work.

Fix this by modifying acpi_scan_dep_init() to not increase dep_met for dependencies which have already been marked as being met.

Fixes 3ba12d8de3fa ("ACPI: scan: Reduce overhead related to devices with dependencies")
---
 drivers/acpi/scan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/acpi/scan.c +2 -1
index 7c157bf92695..d1464324de95 100644
@@ -1843,7 +1843,8 @@ static void acpi_scan_dep_init(struct acpi_device *adev)
 			if (dep->honor_dep)
 				adev->flags.honor_deps = 1;
 
-			adev->dep_unmet++;
+			if (!dep->met)
+				adev->dep_unmet++;
 		}
 	}
 }
Signature · 1 line
2.44.0
maintainer Applied
#1 lore raw
Quoted 41 lines · Hans de Goede

On the Toshiba Encore WT10-A tablet the BATC battery ACPI device depends on 3 other devices:

            Name (_DEP, Package (0x03)  // _DEP: Dependencies
            {
                I2C1,
                GPO2,
                GPO0
            })

acpi_scan_check_dep() adds all 3 of these to the acpi_dep_list and then before an acpi_device is created for the BATC handle (and thus before acpi_scan_dep_init() runs) acpi_scan_clear_dep() gets called for both GPIO depenencies, with free_when_met not set for the dependencies.

Since there is no adev for BATC yet, there also is no dep_unmet to decrement. The only result of acpi_scan_clear_dep() in this case is dep->met getting set.

Soon after acpi_scan_clear_dep() has been called for the GPIO dependencies the acpi_device gets created for the BATC handle and acpi_scan_dep_init() runs, this sees 3 dependencies on the acpi_dep_list and initializes unmet_dep to 3. Later when the dependency for I2C1 is met unmet_dep becomes 2, but since the 2 GPIO deps where already met it never becomes 0 causing battery monitoring to not work.

Fix this by modifying acpi_scan_dep_init() to not increase dep_met for dependencies which have already been marked as being met.

Fixes 3ba12d8de3fa ("ACPI: scan: Reduce overhead related to devices with dependencies")
---
 drivers/acpi/scan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/acpi/scan.c +0 -0
index 7c157bf92695..d1464324de95 100644

drivers/acpi/scan.c static void acpi_scan_dep_init(struct acpi_device *adev) · line 1847

Quoted 6 lines
drivers/acpi/scan.c +2 -1
@@ -1843,7 +1843,8 @@ static void acpi_scan_dep_init(struct acpi_device *adev)
                        if (dep->honor_dep)
                                adev->flags.honor_deps = 1;
 
-                       adev->dep_unmet++;
+                       if (!dep->met)
+                               adev->dep_unmet++;

Nice catch!

drivers/acpi/scan.c static void acpi_scan_dep_init(struct acpi_device *adev)

Quoted 4 lines
drivers/acpi/scan.c +0 -1
                }
        }
 }
--

Applied as 6.9-rc material, thanks!