1 From d730192ff0246356a2d7e63ff5bd501060670eec Mon Sep 17 00:00:00 2001
2 From: Hans de Goede <hdegoede@redhat.com>
3 Date: Sat, 6 Apr 2024 13:40:52 +0200
4 Subject: ACPI: scan: Do not increase dep_unmet for already met dependencies
6 From: Hans de Goede <hdegoede@redhat.com>
8 commit d730192ff0246356a2d7e63ff5bd501060670eec upstream.
10 On the Toshiba Encore WT10-A tablet the BATC battery ACPI device depends
13 Name (_DEP, Package (0x03) // _DEP: Dependencies
20 acpi_scan_check_dep() adds all 3 of these to the acpi_dep_list and then
21 before an acpi_device is created for the BATC handle (and thus before
22 acpi_scan_dep_init() runs) acpi_scan_clear_dep() gets called for both
23 GPIO depenencies, with free_when_met not set for the dependencies.
25 Since there is no adev for BATC yet, there also is no dep_unmet to
26 decrement. The only result of acpi_scan_clear_dep() in this case is
29 Soon after acpi_scan_clear_dep() has been called for the GPIO dependencies
30 the acpi_device gets created for the BATC handle and acpi_scan_dep_init()
31 runs, this sees 3 dependencies on the acpi_dep_list and initializes
32 unmet_dep to 3. Later when the dependency for I2C1 is met unmet_dep
33 becomes 2, but since the 2 GPIO deps where already met it never becomes 0
34 causing battery monitoring to not work.
36 Fix this by modifying acpi_scan_dep_init() to not increase dep_met for
37 dependencies which have already been marked as being met.
39 Fixes: 3ba12d8de3fa ("ACPI: scan: Reduce overhead related to devices with dependencies")
40 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
41 Cc: 6.5+ <stable@vger.kernel.org> # 6.5+
42 Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
43 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
45 drivers/acpi/scan.c | 3 ++-
46 1 file changed, 2 insertions(+), 1 deletion(-)
48 --- a/drivers/acpi/scan.c
49 +++ b/drivers/acpi/scan.c
50 @@ -1802,7 +1802,8 @@ static void acpi_scan_dep_init(struct ac
52 adev->flags.honor_deps = 1;