1 |
From f64e4275ef7407d5c3eca20436519bbd1f796e40 Mon Sep 17 00:00:00 2001 |
2 |
From: Hans de Goede <hdegoede@redhat.com> |
3 |
Date: Tue, 10 Jan 2023 16:30:28 +0100 |
4 |
Subject: ACPI: Fix selecting wrong ACPI fwnode for the iGPU on some Dell laptops |
5 |
|
6 |
From: Hans de Goede <hdegoede@redhat.com> |
7 |
|
8 |
commit f64e4275ef7407d5c3eca20436519bbd1f796e40 upstream. |
9 |
|
10 |
The Dell Latitude E6430 both with and without the optional NVidia dGPU |
11 |
has a bug in its ACPI tables which is causing Linux to assign the wrong |
12 |
ACPI fwnode / companion to the pci_device for the i915 iGPU. |
13 |
|
14 |
Specifically under the PCI root bridge there are these 2 ACPI Device()s : |
15 |
|
16 |
Scope (_SB.PCI0) |
17 |
{ |
18 |
Device (GFX0) |
19 |
{ |
20 |
Name (_ADR, 0x00020000) // _ADR: Address |
21 |
} |
22 |
|
23 |
... |
24 |
|
25 |
Device (VID) |
26 |
{ |
27 |
Name (_ADR, 0x00020000) // _ADR: Address |
28 |
... |
29 |
|
30 |
Method (_DOS, 1, NotSerialized) // _DOS: Disable Output Switching |
31 |
{ |
32 |
VDP8 = Arg0 |
33 |
VDP1 (One, VDP8) |
34 |
} |
35 |
|
36 |
Method (_DOD, 0, NotSerialized) // _DOD: Display Output Devices |
37 |
{ |
38 |
... |
39 |
} |
40 |
... |
41 |
} |
42 |
} |
43 |
|
44 |
The non-functional GFX0 ACPI device is a problem, because this gets |
45 |
returned as ACPI companion-device by acpi_find_child_device() for the iGPU. |
46 |
|
47 |
This is a long standing problem and the i915 driver does use the ACPI |
48 |
companion for some things, but works fine without it. |
49 |
|
50 |
However since commit 63f534b8bad9 ("ACPI: PCI: Rework acpi_get_pci_dev()") |
51 |
acpi_get_pci_dev() relies on the physical-node pointer in the acpi_device |
52 |
and that is set on the wrong acpi_device because of the wrong |
53 |
acpi_find_child_device() return. This breaks the ACPI video code, |
54 |
leading to non working backlight control in some cases. |
55 |
|
56 |
Add a type.backlight flag, mark ACPI video bus devices with this and make |
57 |
find_child_checks() return a higher score for children with this flag set, |
58 |
so that it picks the right companion-device. |
59 |
|
60 |
Fixes: 63f534b8bad9 ("ACPI: PCI: Rework acpi_get_pci_dev()") |
61 |
Co-developed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> |
62 |
Signed-off-by: Hans de Goede <hdegoede@redhat.com> |
63 |
Cc: 6.1+ <stable@vger.kernel.org> # 6.1+ |
64 |
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> |
65 |
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
66 |
--- |
67 |
drivers/acpi/glue.c | 14 ++++++++++++-- |
68 |
drivers/acpi/scan.c | 7 +++++-- |
69 |
include/acpi/acpi_bus.h | 3 ++- |
70 |
3 files changed, 19 insertions(+), 5 deletions(-) |
71 |
|
72 |
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c |
73 |
index 204fe94c7e45..a194f30876c5 100644 |
74 |
--- a/drivers/acpi/glue.c |
75 |
+++ b/drivers/acpi/glue.c |
76 |
@@ -75,7 +75,8 @@ static struct acpi_bus_type *acpi_get_bus_type(struct device *dev) |
77 |
} |
78 |
|
79 |
#define FIND_CHILD_MIN_SCORE 1 |
80 |
-#define FIND_CHILD_MAX_SCORE 2 |
81 |
+#define FIND_CHILD_MID_SCORE 2 |
82 |
+#define FIND_CHILD_MAX_SCORE 3 |
83 |
|
84 |
static int match_any(struct acpi_device *adev, void *not_used) |
85 |
{ |
86 |
@@ -96,8 +97,17 @@ static int find_child_checks(struct acpi_device *adev, bool check_children) |
87 |
return -ENODEV; |
88 |
|
89 |
status = acpi_evaluate_integer(adev->handle, "_STA", NULL, &sta); |
90 |
- if (status == AE_NOT_FOUND) |
91 |
+ if (status == AE_NOT_FOUND) { |
92 |
+ /* |
93 |
+ * Special case: backlight device objects without _STA are |
94 |
+ * preferred to other objects with the same _ADR value, because |
95 |
+ * it is more likely that they are actually useful. |
96 |
+ */ |
97 |
+ if (adev->pnp.type.backlight) |
98 |
+ return FIND_CHILD_MID_SCORE; |
99 |
+ |
100 |
return FIND_CHILD_MIN_SCORE; |
101 |
+ } |
102 |
|
103 |
if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_ENABLED)) |
104 |
return -ENODEV; |
105 |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c |
106 |
index 274344434282..0c6f06abe3f4 100644 |
107 |
--- a/drivers/acpi/scan.c |
108 |
+++ b/drivers/acpi/scan.c |
109 |
@@ -1370,9 +1370,12 @@ static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp, |
110 |
* Some devices don't reliably have _HIDs & _CIDs, so add |
111 |
* synthetic HIDs to make sure drivers can find them. |
112 |
*/ |
113 |
- if (acpi_is_video_device(handle)) |
114 |
+ if (acpi_is_video_device(handle)) { |
115 |
acpi_add_id(pnp, ACPI_VIDEO_HID); |
116 |
- else if (acpi_bay_match(handle)) |
117 |
+ pnp->type.backlight = 1; |
118 |
+ break; |
119 |
+ } |
120 |
+ if (acpi_bay_match(handle)) |
121 |
acpi_add_id(pnp, ACPI_BAY_HID); |
122 |
else if (acpi_dock_match(handle)) |
123 |
acpi_add_id(pnp, ACPI_DOCK_HID); |
124 |
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h |
125 |
index cd3b75e08ec3..e44be31115a6 100644 |
126 |
--- a/include/acpi/acpi_bus.h |
127 |
+++ b/include/acpi/acpi_bus.h |
128 |
@@ -230,7 +230,8 @@ struct acpi_pnp_type { |
129 |
u32 hardware_id:1; |
130 |
u32 bus_address:1; |
131 |
u32 platform_id:1; |
132 |
- u32 reserved:29; |
133 |
+ u32 backlight:1; |
134 |
+ u32 reserved:28; |
135 |
}; |
136 |
|
137 |
struct acpi_device_pnp { |
138 |
-- |
139 |
2.39.0 |
140 |
|