Skip to contentSkip to conversation

ACPI: Fix selecting the wrong ACPI fwnode for the iGPU on some Dell laptops

PATCH Superseded Hans de Goede 3 participants 5 messages Jan 9, 2023 – Jan 10, 2023

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI: Fix selecting the wrong ACPI fwnode for the iGPU on some Dell laptops

The Dell Latitude E6430 both with and without the optional NVidia dGPU has a bug in its ACPI tables which is causing Linux to assign the wrong ACPI fwnode / companion to the pci_device for the i915 iGPU.

Specifically under the PCI root bridge there are these 2 ACPI Device()s :

Scope (_SB.PCI0)

 {
     Device (GFX0)
     {
         Name (_ADR, 0x00020000)  // _ADR: Address
     }

     ...

     Device (VID)
     {
         Name (_ADR, 0x00020000)  // _ADR: Address
         ...

         Method (_DOS, 1, NotSerialized)  // _DOS: Disable Output Switching
         {
             VDP8 = Arg0
             VDP1 (One, VDP8)
         }

         Method (_DOD, 0, NotSerialized)  // _DOD: Display Output Devices
         {
             ...
         }
         ...
     }

}

The non-functional GFX0 ACPI device is a problem, because this gets returned as ACPI companion-device by acpi_find_child_device() for the iGPU.

This is a long standing problem and the i915 driver does use the ACPI companion for some things, but works fine without it.

However since commit 63f534b8bad9 ("ACPI: PCI: Rework acpi_get_pci_dev()") acpi_get_pci_dev() relies on the physical-node pointer in the acpi_device and that is set on the wrong acpi_device because of the wrong acpi_find_child_device() return. This breaks the ACPI video code, leading to non working backlight control in some cases.

Make find_child_checks() return a higher score for children which have pnp-ids set by various scan helpers like acpi_is_video_device(), so that it picks the right companion-device.

An alternative approach would be to directly call acpi_is_video_device() from find_child_checks() but that would be somewhat computationally expensive given that acpi_find_child_device() iterates over all the PCI0 children every time it is called.

Fixes 63f534b8bad9 ("ACPI: PCI: Rework acpi_get_pci_dev()")
---
 drivers/acpi/glue.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/acpi/glue.c +12 -2
index 204fe94c7e45..2055dfd7678b 100644
@@ -75,7 +75,7 @@ static struct acpi_bus_type *acpi_get_bus_type(struct device *dev)
 }
 
 #define FIND_CHILD_MIN_SCORE	1
-#define FIND_CHILD_MAX_SCORE	2
+#define FIND_CHILD_MAX_SCORE	3
 
 static int match_any(struct acpi_device *adev, void *not_used)
 {
@@ -89,15 +89,25 @@ static bool acpi_dev_has_children(struct acpi_device *adev)
 
 static int find_child_checks(struct acpi_device *adev, bool check_children)
 {
+	int score = FIND_CHILD_MIN_SCORE;
 	unsigned long long sta;
 	acpi_status status;
 
 	if (check_children && !acpi_dev_has_children(adev))
 		return -ENODEV;
 
+	/*
+	 * For devices without a _STA method, prefer devices without a _HID
+	 * (which conflicts with having an _ADR) but which have been matched
+	 * in some other way, like e.g. by acpi_is_video_device() over devices
+	 * with no ids at all.
+	 */
+	if (!adev->pnp.type.platform_id && adev->pnp.type.hardware_id)
+		score++;
+
 	status = acpi_evaluate_integer(adev->handle, "_STA", NULL, &sta);
 	if (status == AE_NOT_FOUND)
-		return FIND_CHILD_MIN_SCORE;
+		return score;
 
 	if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_ENABLED))
 		return -ENODEV;
Signature · 1 line
2.39.0
#1 lore raw

p.s.

This fixes a regression in 6.1, adding the regressions list to the Cc.

Once we figure out the best way to fix this (this patch is more of a proposal how to fix this rather then a definitive fix), we should also backport the fix to 6.1.y.

Quoted 101 lines · Hans de Goede

The Dell Latitude E6430 both with and without the optional NVidia dGPU has a bug in its ACPI tables which is causing Linux to assign the wrong ACPI fwnode / companion to the pci_device for the i915 iGPU.

Specifically under the PCI root bridge there are these 2 ACPI Device()s :

Scope (_SB.PCI0)

 {
     Device (GFX0)
     {
         Name (_ADR, 0x00020000)  // _ADR: Address
     }

     ...

     Device (VID)
     {
         Name (_ADR, 0x00020000)  // _ADR: Address
         ...

         Method (_DOS, 1, NotSerialized)  // _DOS: Disable Output Switching
         {
             VDP8 = Arg0
             VDP1 (One, VDP8)
         }

         Method (_DOD, 0, NotSerialized)  // _DOD: Display Output Devices
         {
             ...
         }
         ...
     }

}

The non-functional GFX0 ACPI device is a problem, because this gets returned as ACPI companion-device by acpi_find_child_device() for the iGPU.

This is a long standing problem and the i915 driver does use the ACPI companion for some things, but works fine without it.

However since commit 63f534b8bad9 ("ACPI: PCI: Rework acpi_get_pci_dev()") acpi_get_pci_dev() relies on the physical-node pointer in the acpi_device and that is set on the wrong acpi_device because of the wrong acpi_find_child_device() return. This breaks the ACPI video code, leading to non working backlight control in some cases.

Make find_child_checks() return a higher score for children which have pnp-ids set by various scan helpers like acpi_is_video_device(), so that it picks the right companion-device.

An alternative approach would be to directly call acpi_is_video_device() from find_child_checks() but that would be somewhat computationally expensive given that acpi_find_child_device() iterates over all the PCI0 children every time it is called.

Fixes 63f534b8bad9 ("ACPI: PCI: Rework acpi_get_pci_dev()")
---
 drivers/acpi/glue.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/acpi/glue.c +12 -2
index 204fe94c7e45..2055dfd7678b 100644
@@ -75,7 +75,7 @@ static struct acpi_bus_type *acpi_get_bus_type(struct device *dev)
 }
 
 #define FIND_CHILD_MIN_SCORE	1
-#define FIND_CHILD_MAX_SCORE	2
+#define FIND_CHILD_MAX_SCORE	3
 
 static int match_any(struct acpi_device *adev, void *not_used)
 {
@@ -89,15 +89,25 @@ static bool acpi_dev_has_children(struct acpi_device *adev)
 
 static int find_child_checks(struct acpi_device *adev, bool check_children)
 {
+	int score = FIND_CHILD_MIN_SCORE;
 	unsigned long long sta;
 	acpi_status status;
 
 	if (check_children && !acpi_dev_has_children(adev))
 		return -ENODEV;
 
+	/*
+	 * For devices without a _STA method, prefer devices without a _HID
+	 * (which conflicts with having an _ADR) but which have been matched
+	 * in some other way, like e.g. by acpi_is_video_device() over devices
+	 * with no ids at all.
+	 */
+	if (!adev->pnp.type.platform_id && adev->pnp.type.hardware_id)
+		score++;
+
 	status = acpi_evaluate_integer(adev->handle, "_STA", NULL, &sta);
 	if (status == AE_NOT_FOUND)
-		return FIND_CHILD_MIN_SCORE;
+		return score;
 
 	if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_ENABLED))
 		return -ENODEV;
#2 lore raw

[Intel-gfx] ✗ Fi.CI.BAT: failure for ACPI: Fix selecting the wrong ACPI fwnode for the iGPU on some Dell laptops

In reply to Hans de Goede
== Series Details ==

== Series Details ==

Series: ACPI: Fix selecting the wrong ACPI fwnode for the iGPU on some Dell laptops
URL : https://patchwork.freedesktop.org/series/112572/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_12560 -> Patchwork_112572v1
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_112572v1 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_112572v1, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/index.html

Participating hosts (37 -> 39)
------------------------------

Additional (3): fi-kbl-soraka fi-rkl-11600 fi-bsw-kefka
Missing (1): fi-snb-2520m

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in Patchwork_112572v1:

### IGT changes ###

#### Possible regressions ####

* igt@i915_selftest@live@guc:
- fi-kbl-soraka: NOTRUN -> [INCOMPLETE][1]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/fi-kbl-soraka/igt@i915_selftest@[email protected]

#### Suppressed ####

The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.

* igt@gem_exec_suspend@basic-s0@smem:
- {bat-rpls-1}: NOTRUN -> [DMESG-WARN][2]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/bat-rpls-1/igt@gem_exec_suspend@[email protected]

* {igt@kms_chamelium_hpd@common-hpd-after-suspend}:
- {bat-rpls-2}: NOTRUN -> [SKIP][3]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/bat-rpls-2/igt@[email protected]

* {igt@kms_chamelium_hpd@dp-hpd-fast}:
- fi-rkl-11600: NOTRUN -> [SKIP][4] +7 similar issues
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/fi-rkl-11600/igt@[email protected]

Known issues
------------

Here are the changes found in Patchwork_112572v1 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@debugfs_test@basic-hwmon:
- fi-rkl-11600: NOTRUN -> [SKIP][5] ([i915#7456])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/fi-rkl-11600/igt@[email protected]

* igt@gem_exec_gttfill@basic:
- fi-kbl-soraka: NOTRUN -> [SKIP][6] ([fdo#109271]) +7 similar issues
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/fi-kbl-soraka/igt@[email protected]

* igt@gem_huc_copy@huc-copy:
- fi-rkl-11600: NOTRUN -> [SKIP][7] ([i915#2190])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/fi-rkl-11600/igt@[email protected]
- fi-kbl-soraka: NOTRUN -> [SKIP][8] ([fdo#109271] / [i915#2190])
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/fi-kbl-soraka/igt@[email protected]

* igt@gem_lmem_swapping@basic:
- fi-kbl-soraka: NOTRUN -> [SKIP][9] ([fdo#109271] / [i915#4613]) +3 similar issues
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/fi-kbl-soraka/igt@[email protected]

* igt@gem_lmem_swapping@parallel-random-engines:
- fi-rkl-11600: NOTRUN -> [SKIP][10] ([i915#4613]) +3 similar issues
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/fi-rkl-11600/igt@[email protected]

* igt@gem_tiled_pread_basic:
- fi-rkl-11600: NOTRUN -> [SKIP][11] ([i915#3282])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/fi-rkl-11600/igt@gem_tiled_pread_basic.html

* igt@i915_pm_backlight@basic-brightness:
- fi-rkl-11600: NOTRUN -> [SKIP][12] ([i915#7561])
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/fi-rkl-11600/igt@[email protected]

* igt@i915_selftest@live@gt_heartbeat:
- fi-kbl-soraka: NOTRUN -> [DMESG-FAIL][13] ([i915#5334])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/fi-kbl-soraka/igt@i915_selftest@live@gt_heartbeat.html
- fi-apl-guc: [PASS][14] -> [DMESG-FAIL][15] ([i915#5334])
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12560/fi-apl-guc/igt@i915_selftest@live@gt_heartbeat.html
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/fi-apl-guc/igt@i915_selftest@live@gt_heartbeat.html

* igt@i915_selftest@live@gt_pm:
- fi-kbl-soraka: NOTRUN -> [DMESG-FAIL][16] ([i915#1886])
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/fi-kbl-soraka/igt@i915_selftest@live@gt_pm.html

* igt@i915_suspend@basic-s3-without-i915:
- fi-rkl-11600: NOTRUN -> [INCOMPLETE][17] ([i915#4817])
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/fi-rkl-11600/igt@[email protected]

* igt@kms_cursor_legacy@basic-busy-flip-before-cursor:
- fi-rkl-11600: NOTRUN -> [SKIP][18] ([i915#4103])
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/fi-rkl-11600/igt@[email protected]

* igt@kms_force_connector_basic@force-load-detect:
- fi-rkl-11600: NOTRUN -> [SKIP][19] ([fdo#109285] / [i915#4098])
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/fi-rkl-11600/igt@[email protected]

* igt@kms_psr@sprite_plane_onoff:
- fi-rkl-11600: NOTRUN -> [SKIP][20] ([i915#1072]) +3 similar issues
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/fi-rkl-11600/igt@kms_psr@sprite_plane_onoff.html

* igt@kms_setmode@basic-clone-single-crtc:
- fi-rkl-11600: NOTRUN -> [SKIP][21] ([i915#3555] / [i915#4098])
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/fi-rkl-11600/igt@[email protected]

* igt@prime_vgem@basic-fence-flip:
- fi-bsw-kefka: NOTRUN -> [SKIP][22] ([fdo#109271]) +17 similar issues
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/fi-bsw-kefka/igt@[email protected]

* igt@prime_vgem@basic-read:
- fi-rkl-11600: NOTRUN -> [SKIP][23] ([fdo#109295] / [i915#3291] / [i915#3708]) +2 similar issues
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/fi-rkl-11600/igt@[email protected]

* igt@prime_vgem@basic-userptr:
- fi-rkl-11600: NOTRUN -> [SKIP][24] ([fdo#109295] / [i915#3301] / [i915#3708])
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/fi-rkl-11600/igt@[email protected]

#### Possible fixes ####

* igt@i915_selftest@live@reset:
- {bat-rpls-2}: [DMESG-FAIL][25] ([i915#4983]) -> [PASS][26]
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12560/bat-rpls-2/igt@i915_selftest@[email protected]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/bat-rpls-2/igt@i915_selftest@[email protected]
- {bat-rpls-1}: [DMESG-FAIL][27] ([i915#4983]) -> [PASS][28]
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12560/bat-rpls-1/igt@i915_selftest@[email protected]
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/bat-rpls-1/igt@i915_selftest@[email protected]

* igt@kms_cursor_legacy@basic-busy-flip-before-cursor@atomic-transitions-varying-size:
- fi-bsw-n3050: [FAIL][29] ([i915#6298]) -> [PASS][30]
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12560/fi-bsw-n3050/igt@kms_cursor_legacy@basic-busy-flip-before-cursor@atomic-transitions-varying-size.html
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/fi-bsw-n3050/igt@kms_cursor_legacy@basic-busy-flip-before-cursor@atomic-transitions-varying-size.html

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[fdo#109295]: https://bugs.freedesktop.org/show_bug.cgi?id=109295
[i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
[i915#1845]: https://gitlab.freedesktop.org/drm/intel/issues/1845
[i915#1886]: https://gitlab.freedesktop.org/drm/intel/issues/1886
[i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
[i915#3282]: https://gitlab.freedesktop.org/drm/intel/issues/3282
[i915#3291]: https://gitlab.freedesktop.org/drm/intel/issues/3291
[i915#3301]: https://gitlab.freedesktop.org/drm/intel/issues/3301
[i915#3555]: https://gitlab.freedesktop.org/drm/intel/issues/3555
[i915#3708]: https://gitlab.freedesktop.org/drm/intel/issues/3708
[i915#4098]: https://gitlab.freedesktop.org/drm/intel/issues/4098
[i915#4103]: https://gitlab.freedesktop.org/drm/intel/issues/4103
[i915#4312]: https://gitlab.freedesktop.org/drm/intel/issues/4312
[i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
[i915#4817]: https://gitlab.freedesktop.org/drm/intel/issues/4817
[i915#4983]: https://gitlab.freedesktop.org/drm/intel/issues/4983
[i915#5334]: https://gitlab.freedesktop.org/drm/intel/issues/5334
[i915#6298]: https://gitlab.freedesktop.org/drm/intel/issues/6298
[i915#6997]: https://gitlab.freedesktop.org/drm/intel/issues/6997
[i915#7077]: https://gitlab.freedesktop.org/drm/intel/issues/7077
[i915#7456]: https://gitlab.freedesktop.org/drm/intel/issues/7456
[i915#7561]: https://gitlab.freedesktop.org/drm/intel/issues/7561
[i915#7654]: https://gitlab.freedesktop.org/drm/intel/issues/7654

Build changes
-------------

* Linux: CI_DRM_12560 -> Patchwork_112572v1

CI-20190529: 20190529
CI_DRM_12560: 0eccbe4822259a5e1a78bb7a4c027514d26a2b23 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7113: 15562e123ee6ed88163c7da2ef330dfe9bbd16a5 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_112572v1: 0eccbe4822259a5e1a78bb7a4c027514d26a2b23 @ git://anongit.freedesktop.org/gfx-ci/linux

### Linux commits

a76273d644d6 ACPI: Fix selecting the wrong ACPI fwnode for the iGPU on some Dell laptops

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_112572v1/index.html

#3 lore raw
In reply to Hans de Goede
Quoted 37 lines · CET Hans de Goede

The Dell Latitude E6430 both with and without the optional NVidia dGPU has a bug in its ACPI tables which is causing Linux to assign the wrong ACPI fwnode / companion to the pci_device for the i915 iGPU.

Specifically under the PCI root bridge there are these 2 ACPI Device()s :

Scope (_SB.PCI0)

 {
     Device (GFX0)
     {
         Name (_ADR, 0x00020000)  // _ADR: Address
     }

     ...

     Device (VID)
     {
         Name (_ADR, 0x00020000)  // _ADR: Address
         ...

         Method (_DOS, 1, NotSerialized)  // _DOS: Disable Output Switching
         {
             VDP8 = Arg0
             VDP1 (One, VDP8)
         }

         Method (_DOD, 0, NotSerialized)  // _DOD: Display Output Devices
         {
             ...
         }
         ...
     }

}

The non-functional GFX0 ACPI device is a problem, because this gets returned as ACPI companion-device by acpi_find_child_device() for the iGPU.

Quoted 8 lines

This is a long standing problem and the i915 driver does use the ACPI companion for some things, but works fine without it.

However since commit 63f534b8bad9 ("ACPI: PCI: Rework acpi_get_pci_dev()") acpi_get_pci_dev() relies on the physical-node pointer in the acpi_device and that is set on the wrong acpi_device because of the wrong acpi_find_child_device() return. This breaks the ACPI video code, leading to non working backlight control in some cases.

Interesting. Sorry for the trouble.

Quoted 3 lines

Make find_child_checks() return a higher score for children which have pnp-ids set by various scan helpers like acpi_is_video_device(), so that it picks the right companion-device.

This has a potential of changing the behavior in some cases that are not relevant here which is generally risky.

Quoted 4 lines

An alternative approach would be to directly call acpi_is_video_device() from find_child_checks() but that would be somewhat computationally expensive given that acpi_find_child_device() iterates over all the PCI0 children every time it is called.

I agree with the above, but my fix would be something like the patch below (not really tested, but it builds).

---
 drivers/acpi/glue.c     |   14 ++++++++++++--
 drivers/acpi/scan.c     |    7 +++++--
 include/acpi/acpi_bus.h |    3 ++-
 3 files changed, 19 insertions(+), 5 deletions(-)
include/acpi/acpi_bus.h +2 -1
Index: linux-pm/include/acpi/acpi_bus.h
===================================================================
@@ -230,7 +230,8 @@ struct acpi_pnp_type {
 	u32 hardware_id:1;
 	u32 bus_address:1;
 	u32 platform_id:1;
-	u32 reserved:29;
+	u32 backlight:1;
+	u32 reserved:28;
 };
 
 struct acpi_device_pnp {
drivers/acpi/scan.c +5 -2
Index: linux-pm/drivers/acpi/scan.c
===================================================================
@@ -1370,9 +1370,12 @@ static void acpi_set_pnp_ids(acpi_handle
 		 * Some devices don't reliably have _HIDs & _CIDs, so add
 		 * synthetic HIDs to make sure drivers can find them.
 		 */
-		if (acpi_is_video_device(handle))
+		if (acpi_is_video_device(handle)) {
 			acpi_add_id(pnp, ACPI_VIDEO_HID);
-		else if (acpi_bay_match(handle))
+			pnp->type.backlight = 1;
+			break;
+		}
+		if (acpi_bay_match(handle))
 			acpi_add_id(pnp, ACPI_BAY_HID);
 		else if (acpi_dock_match(handle))
 			acpi_add_id(pnp, ACPI_DOCK_HID);
drivers/acpi/glue.c +12 -2
Index: linux-pm/drivers/acpi/glue.c
===================================================================
@@ -75,7 +75,8 @@ static struct acpi_bus_type *acpi_get_bu
 }
 
 #define FIND_CHILD_MIN_SCORE	1
-#define FIND_CHILD_MAX_SCORE	2
+#define FIND_CHILD_MID_SCORE	2
+#define FIND_CHILD_MAX_SCORE	3
 
 static int match_any(struct acpi_device *adev, void *not_used)
 {
@@ -96,8 +97,17 @@ static int find_child_checks(struct acpi
 		return -ENODEV;
 
 	status = acpi_evaluate_integer(adev->handle, "_STA", NULL, &sta);
-	if (status == AE_NOT_FOUND)
+	if (status == AE_NOT_FOUND) {
+		/*
+		 * Special case: backlight device objects without _STA are
+		 * preferred to other objects with the same _ADR value, because
+		 * it is more likely that they are actually useful.
+		 */
+		if (adev->pnp.type.backlight)
+			return FIND_CHILD_MID_SCORE;
+
 		return FIND_CHILD_MIN_SCORE;
+	}
 
 	if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_ENABLED))
 		return -ENODEV;
#4 lore raw

Hi Rafael,

Quoted 41 lines · Rafael J. Wysocki
Quoted 40 lines · CET Hans de Goede

The Dell Latitude E6430 both with and without the optional NVidia dGPU has a bug in its ACPI tables which is causing Linux to assign the wrong ACPI fwnode / companion to the pci_device for the i915 iGPU.

Specifically under the PCI root bridge there are these 2 ACPI Device()s :

Scope (_SB.PCI0)

 {
     Device (GFX0)
     {
         Name (_ADR, 0x00020000)  // _ADR: Address
     }

     ...

     Device (VID)
     {
         Name (_ADR, 0x00020000)  // _ADR: Address
         ...

         Method (_DOS, 1, NotSerialized)  // _DOS: Disable Output Switching
         {
             VDP8 = Arg0
             VDP1 (One, VDP8)
         }

         Method (_DOD, 0, NotSerialized)  // _DOD: Display Output Devices
         {
             ...
         }
         ...
     }

}

The non-functional GFX0 ACPI device is a problem, because this gets returned as ACPI companion-device by acpi_find_child_device() for the iGPU.

This is a long standing problem and the i915 driver does use the ACPI companion for some things, but works fine without it.

Quoted 7 lines
Quoted 5 lines

However since commit 63f534b8bad9 ("ACPI: PCI: Rework acpi_get_pci_dev()") acpi_get_pci_dev() relies on the physical-node pointer in the acpi_device and that is set on the wrong acpi_device because of the wrong acpi_find_child_device() return. This breaks the ACPI video code, leading to non working backlight control in some cases.

Interesting. Sorry for the trouble.

No problem, as mentioned this is actually a long standing issue / bug in the ACPI tables, it just never surfaced before.

Quoted 7 lines
Quoted 3 lines

Make find_child_checks() return a higher score for children which have pnp-ids set by various scan helpers like acpi_is_video_device(), so that it picks the right companion-device.

This has a potential of changing the behavior in some cases that are not relevant here which is generally risky.

Quoted 7 lines
Quoted 4 lines

An alternative approach would be to directly call acpi_is_video_device() from find_child_checks() but that would be somewhat computationally expensive given that acpi_find_child_device() iterates over all the PCI0 children every time it is called.

I agree with the above, but my fix would be something like the patch below (not really tested, but it builds).

Thanks, I have just given this a spin on my E6430 and I can confirm it still fixes things.

I'll send out this version (re-using most of the v1 commitmsg) as a v2 right away.

Regards,

Hans

Quoted 76 lines
---
 drivers/acpi/glue.c     |   14 ++++++++++++--
 drivers/acpi/scan.c     |    7 +++++--
 include/acpi/acpi_bus.h |    3 ++-
 3 files changed, 19 insertions(+), 5 deletions(-)

Index: linux-pm/include/acpi/acpi_bus.h
===================================================================

include/acpi/acpi_bus.h +2 -1
@@ -230,7 +230,8 @@ struct acpi_pnp_type {
 	u32 hardware_id:1;
 	u32 bus_address:1;
 	u32 platform_id:1;
-	u32 reserved:29;
+	u32 backlight:1;
+	u32 reserved:28;
 };
 
 struct acpi_device_pnp {

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

drivers/acpi/scan.c +5 -2
@@ -1370,9 +1370,12 @@ static void acpi_set_pnp_ids(acpi_handle
 		 * Some devices don't reliably have _HIDs & _CIDs, so add
 		 * synthetic HIDs to make sure drivers can find them.
 		 */
-		if (acpi_is_video_device(handle))
+		if (acpi_is_video_device(handle)) {
 			acpi_add_id(pnp, ACPI_VIDEO_HID);
-		else if (acpi_bay_match(handle))
+			pnp->type.backlight = 1;
+			break;
+		}
+		if (acpi_bay_match(handle))
 			acpi_add_id(pnp, ACPI_BAY_HID);
 		else if (acpi_dock_match(handle))
 			acpi_add_id(pnp, ACPI_DOCK_HID);

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

drivers/acpi/glue.c +12 -2
@@ -75,7 +75,8 @@ static struct acpi_bus_type *acpi_get_bu
 }
 
 #define FIND_CHILD_MIN_SCORE	1
-#define FIND_CHILD_MAX_SCORE	2
+#define FIND_CHILD_MID_SCORE	2
+#define FIND_CHILD_MAX_SCORE	3
 
 static int match_any(struct acpi_device *adev, void *not_used)
 {
@@ -96,8 +97,17 @@ static int find_child_checks(struct acpi
 		return -ENODEV;
 
 	status = acpi_evaluate_integer(adev->handle, "_STA", NULL, &sta);
-	if (status == AE_NOT_FOUND)
+	if (status == AE_NOT_FOUND) {
+		/*
+		 * Special case: backlight device objects without _STA are
+		 * preferred to other objects with the same _ADR value, because
+		 * it is more likely that they are actually useful.
+		 */
+		if (adev->pnp.type.backlight)
+			return FIND_CHILD_MID_SCORE;
+
 		return FIND_CHILD_MIN_SCORE;
+	}
 
 	if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_ENABLED))
 		return -ENODEV;