Skip to contentSkip to conversation

Ignore bad graph port nodes on Dell XPS 9315

PATCH Superseded Sakari Ailus 2 participants 5 messages Feb 12, 2024 ACPI

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Ignore bad graph port nodes on Dell XPS 9315

Hi Rafael,

These two patches skip instantiating bad port nodes on Dell XPS 9315.

The ACPI firmware contains Linux specific camera declarations but they are missing the IVSC which sits between the camera and the IPU. The IPU bridge can be instead used to obtain a configuration that is usable in the system.

I presume there are other models that have the same issue.

Sakari Ailus (2):
ACPI: utils: Make acpi_handle_path() not static
ACPI: property: Ignore bad data nodes

 drivers/acpi/internal.h       |  1 +
 drivers/acpi/mipi-disco-img.c | 71 +++++++++++++++++++++++++++++++++++
 drivers/acpi/property.c       |  3 ++
 drivers/acpi/utils.c          |  2 +-
 include/linux/acpi.h          |  1 +
 5 files changed, 77 insertions(+), 1 deletion(-)
Signature · 1 line
2.39.2
#1 lore raw

PATCH 1/2 ACPI: utils: Make acpi_handle_path() not static

acpi_handle_path() will soon be required for node name comparison elsewhere in ACPI framework. Remove the static keyword and add the prototype to include/linux/acpi.h.

---
 drivers/acpi/utils.c | 2 +-
 include/linux/acpi.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/acpi/utils.c +1 -1
index abac5cc25477..202234ba54bd 100644
@@ -559,7 +559,7 @@ EXPORT_SYMBOL(acpi_evaluate_ost);
  *
  * Caller must free the returned buffer
  */
-static char *acpi_handle_path(acpi_handle handle)
+char *acpi_handle_path(acpi_handle handle)
 {
 	struct acpi_buffer buffer = {
 		.length = ACPI_ALLOCATE_BUFFER,
include/linux/acpi.h +1 -0
index b7165e52b3c6..a170c389dd74 100644
@@ -1170,6 +1170,7 @@ static inline void acpi_ec_set_gpe_wake_mask(u8 action) {}
 #endif
 
 #ifdef CONFIG_ACPI
+char *acpi_handle_path(acpi_handle handle);
 __printf(3, 4)
 void acpi_handle_printk(const char *level, acpi_handle handle,
 			const char *fmt, ...);
Signature · 1 line
2.39.2
#2 lore raw

PATCH 2/2 ACPI: property: Ignore bad data nodes

In reply to Sakari Ailus

Some systems were shipped with both Windows and Linux camera descriptions. In general, if Linux description exist, they will be used and Windows description ignored.

In this case the Linux descriptions were buggy so use Windows definition instead. The corresponding information has been added to ipu-bridge to cover the missing bits.

---
 drivers/acpi/internal.h       |  1 +
 drivers/acpi/mipi-disco-img.c | 71 +++++++++++++++++++++++++++++++++++
 drivers/acpi/property.c       |  3 ++
 3 files changed, 75 insertions(+)
drivers/acpi/internal.h +1 -0
index 6588525c45ef..e0145df519bd 100644
@@ -301,5 +301,6 @@ void acpi_mipi_check_crs_csi2(acpi_handle handle);
 void acpi_mipi_scan_crs_csi2(void);
 void acpi_mipi_init_crs_csi2_swnodes(void);
 void acpi_mipi_crs_csi2_cleanup(void);
+bool acpi_graph_ignore_port(acpi_handle handle);
 
 #endif /* _ACPI_INTERNAL_H_ */
drivers/acpi/mipi-disco-img.c +71 -0

80 lines not on this page · raw message

drivers/acpi/property.c +3 -0
index a6ead5204046..2b73580c9f36 100644
@@ -80,6 +80,9 @@ static bool acpi_nondev_subnode_extract(union acpi_object *desc,
 	struct acpi_data_node *dn;
 	bool result;
 
+	if (acpi_graph_ignore_port(handle))
+		return false;
+
 	dn = kzalloc(sizeof(*dn), GFP_KERNEL);
 	if (!dn)
 		return false;
Signature · 1 line
2.39.2
#3 lore raw

Re: [PATCH 2/2] ACPI: property: Ignore bad data nodes

There is a bit too little information in the subject, it may as well be the same as the series title.

Quoted 68 lines · Sakari Ailus

Some systems were shipped with both Windows and Linux camera descriptions. In general, if Linux description exist, they will be used and Windows description ignored.

In this case the Linux descriptions were buggy so use Windows definition instead. The corresponding information has been added to ipu-bridge to cover the missing bits.

---
 drivers/acpi/internal.h       |  1 +
 drivers/acpi/mipi-disco-img.c | 71 +++++++++++++++++++++++++++++++++++
 drivers/acpi/property.c       |  3 ++
 3 files changed, 75 insertions(+)
drivers/acpi/internal.h +1 -0
index 6588525c45ef..e0145df519bd 100644
@@ -301,5 +301,6 @@ void acpi_mipi_check_crs_csi2(acpi_handle handle);
 void acpi_mipi_scan_crs_csi2(void);
 void acpi_mipi_init_crs_csi2_swnodes(void);
 void acpi_mipi_crs_csi2_cleanup(void);
+bool acpi_graph_ignore_port(acpi_handle handle);
 
 #endif /* _ACPI_INTERNAL_H_ */
drivers/acpi/mipi-disco-img.c +26 -0
index 7286cf4579bc..2b806112a05a 100644
@@ -19,6 +19,7 @@
  */
 
 #include <linux/acpi.h>
+#include <linux/dmi.h>
 #include <linux/limits.h>
 #include <linux/list.h>
 #include <linux/module.h>
@@ -723,3 +724,73 @@ void acpi_mipi_crs_csi2_cleanup(void)
        list_for_each_entry_safe(csi2, csi2_tmp, &acpi_mipi_crs_csi2_list, entry)
                acpi_mipi_del_crs_csi2(csi2);
 }
+
+static const struct dmi_system_id dmi_ignore_port_nodes[] = {
+       {
+               .matches = {
+                       DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
+                       DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "XPS 9315"),
+               },
+       },
+       { 0 }
+};
+
+static const char *strnext(const char *s1, const char *s2)
+{
+       s1 = strstr(s1, s2);
+
+       if (!s1)
+               return NULL;
+
+       return s1 + strlen(s2);
+}
+
+/**
+ * acpi_graph_ignore_port - Tell whether a port node should be ignored
+ * @handle: The ACPI handle of the node (which may be a port node)
+ *

drivers/acpi/mipi-disco-img.c void acpi_mipi_crs_csi2_cleanup(void) · line 761

Quoted 10 lines
drivers/acpi/mipi-disco-img.c +10 -0
+ * Returns true if a port node should be ignored and the data to that should
+ * come from other sources instead (Windows ACPI definitions and
+ * ipu-bridge). This is currently used to ignore bad port nodes related to IPU6
+ * ("IPU?") and camera sensor devices ("LNK?") in certain Dell systems with
+ * Intel VSC.
+ */
+bool acpi_graph_ignore_port(acpi_handle handle)
+{
+       const char *path = NULL, *orig_path;
+       static bool dmi_tested = false, ignore_port;

It is not necessary to initialize static variables to false.

Quoted 52 lines
drivers/acpi/mipi-disco-img.c +35 -0
+
+       if (!dmi_tested) {
+               ignore_port = dmi_first_match(dmi_ignore_port_nodes);
+               dmi_tested = true;
+       }
+
+       if (!ignore_port)
+               return false;
+
+       /* Check if the device is either "IPU" or "LNK" (sensor). */
+       orig_path = acpi_handle_path(handle);
+       if (!orig_path)
+               return false;
+       path = strnext(orig_path, "IPU");
+       if (!path)
+               path = strnext(orig_path, "LNK");
+       if (!path)
+               goto out_free;
+
+       if (!(path[0] >= '0' && path[0] <= '9' && path[1] == '.'))
+               goto out_free;
+
+       /* Check if the node has a "PRT" prefix. */
+       path = strnext(path, "PRT");
+       if (path && path[0] >= '0' && path[0] <= '9' && !path[1]) {
+               acpi_handle_debug(handle, "ignoring data node\n");
+
+               kfree(orig_path);
+               return true;
+       }
+
+out_free:
+       kfree(orig_path);
+       return false;
+}
drivers/acpi/property.c +3 -1
index a6ead5204046..2b73580c9f36 100644
@@ -80,6 +80,9 @@ static bool acpi_nondev_subnode_extract(union acpi_object *desc,
        struct acpi_data_node *dn;
        bool result;
 
+       if (acpi_graph_ignore_port(handle))
+               return false;
+
        dn = kzalloc(sizeof(*dn), GFP_KERNEL);
        if (!dn)
                return false;
--

2.39.2

#4 lore raw

Re: [PATCH 2/2] ACPI: property: Ignore bad data nodes

Hi Rafael,

Thanks for the review.

Quoted 3 lines · Rafael J. Wysocki

There is a bit too little information in the subject, it may as well be the same as the series title.

...

Quoted 3 lines
Quoted 1 line

+ static bool dmi_tested = false, ignore_port;

It is not necessary to initialize static variables to false.

I'll address these in v2.

Signature · 1 line
Sakari Ailus