Skip to contentSkip to conversation

ACPI: PNP: Introduce list of known non-PNP devices

PATCH In review Rafael J. Wysocki 3 participants 4 messages Jan 10, 2023 – Jan 11, 2023 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI: PNP: Introduce list of known non-PNP devices

From: Rafael J. Wysocki <[email protected]>

In some cases, PNP device IDs from acpi_pnp_device_ids[] are returned by _CID for devices for which matching platform drivers are present in the kernel and should be bound to them. However, the IDs coming from _CID cause the PNP scan handler to attach to those devices which prevents platform device objects from being created for them.

Address this by introducing a list of known non-PNP device IDs into acpi_pnp.c such that if a device ID is there in that list, it cannot be attached to by the PNP scan handler and add the platform runtime update and telemetry device IDs to that list to start with.

---
 drivers/acpi/acpi_pnp.c |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/acpi/acpi_pnp.c +13 -1
Index: linux-pm/drivers/acpi/acpi_pnp.c
===================================================================
@@ -348,10 +348,22 @@ static bool acpi_pnp_match(const char *i
 	return false;
 }
 
+/*
+ * If one of the device IDs below is present in the list of device IDs of a
+ * given ACPI device object, the PNP scan handler will not attach to that
+ * object, because there is a proper non-PNP driver in the kernel for the
+ * device represented by it.
+ */
+static const struct acpi_device_id acpi_nonpnp_device_ids[] = {
+	{"INTC1080"},
+	{"INTC1081"},
+	{""},
+};
+
 static int acpi_pnp_attach(struct acpi_device *adev,
 			   const struct acpi_device_id *id)
 {
-	return 1;
+	return !!acpi_match_device_ids(adev, acpi_nonpnp_device_ids);
 }
 
 static struct acpi_scan_handler acpi_pnp_handler = {
#1 lore raw
Quoted 42 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

In some cases, PNP device IDs from acpi_pnp_device_ids[] are returned by
_CID for devices for which matching platform drivers are present in the
kernel and should be bound to them. However, the IDs coming from _CID
cause the PNP scan handler to attach to those devices which prevents platform device objects from being created for them.

Address this by introducing a list of known non-PNP device IDs into acpi_pnp.c such that if a device ID is there in that list, it cannot be
attached to by the PNP scan handler and add the platform runtime update
and telemetry device IDs to that list to start with.

---
 drivers/acpi/acpi_pnp.c |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

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

drivers/acpi/acpi_pnp.c +2 -0
@@ -348,10 +348,22 @@ static bool acpi_pnp_match(const char *i
 	return false;
 }
 
+/*
+ * If one of the device IDs below is present in the list of device

IDs of a
+ * given ACPI device object, the PNP scan handler will not attach to that
+ * object, because there is a proper non-PNP driver in the kernel for the
+ * device represented by it.
+ */

drivers/acpi/acpi_pnp.c +1 -0
+static const struct acpi_device_id acpi_nonpnp_device_ids[] = {

drivers/acpi/acpi_pnp.c static bool acpi_pnp_match(const char *i · line 366

Quoted 10 lines
drivers/acpi/acpi_pnp.c +6 -1
+	{"INTC1080"},
+	{"INTC1081"},
+	{""},
+};
+
 static int acpi_pnp_attach(struct acpi_device *adev,
 			   const struct acpi_device_id *id)
 {
-	return 1;
+	return !!acpi_match_device_ids(adev, acpi_nonpnp_device_ids);

acpi_match_device_ids() returns True if the id matches, and in this case, acpi_pnp_attach() should return false, right?

thanks,
rui

Quoted 6 lines

}

static struct acpi_scan_handler acpi_pnp_handler = {

#2 lore raw

CC Zhang Yang who has tested the patch.

Quoted 52 lines · Rui
Quoted 51 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

In some cases, PNP device IDs from acpi_pnp_device_ids[] are returned
by
_CID for devices for which matching platform drivers are present in the
kernel and should be bound to them. However, the IDs coming from _CID
cause the PNP scan handler to attach to those devices which prevents
platform device objects from being created for them.

Address this by introducing a list of known non-PNP device IDs into acpi_pnp.c such that if a device ID is there in that list, it cannot
be
attached to by the PNP scan handler and add the platform runtime update
and telemetry device IDs to that list to start with.

---
 drivers/acpi/acpi_pnp.c |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

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

drivers/acpi/acpi_pnp.c +2 -0
@@ -348,10 +348,22 @@ static bool acpi_pnp_match(const char *i
 	return false;
 }
 
+/*
+ * If one of the device IDs below is present in the list of device

IDs of a
+ * given ACPI device object, the PNP scan handler will not attach to
that
+ * object, because there is a proper non-PNP driver in the kernel for the
+ * device represented by it.
+ */

drivers/acpi/acpi_pnp.c +6 -0
+static const struct acpi_device_id acpi_nonpnp_device_ids[] = {
+	{"INTC1080"},
+	{"INTC1081"},
+	{""},
+};
+
Quoted 9 lines

drivers/acpi/acpi_pnp.c static bool acpi_pnp_match(const char *i · line 366

Quoted 5 lines

static int acpi_pnp_attach(struct acpi_device *adev,

drivers/acpi/acpi_pnp.c +1 -1
 			   const struct acpi_device_id *id)
 {
-	return 1;
+	return !!acpi_match_device_ids(adev, acpi_nonpnp_device_ids);

acpi_match_device_ids() returns True if the id matches, and in this case, acpi_pnp_attach() should return false, right?

It is __acpi_match_device() that returns True when matches, and acpi_match_device_ids() returns 0 in this case.
So this is not a bug, sorry for the noise.

thanks,
rui

Quoted 9 lines

thanks,
rui

Quoted 6 lines

}

static struct acpi_scan_handler acpi_pnp_handler = {

Tested-by
#3 lore raw

-----Original Message-----
From: Zhang, Rui <[email protected]>
Sent: Wednesday, January 11, 2023 4:02 PM
To: [email protected]; [email protected]
Cc: [email protected]; Chen, Yu C <[email protected]>; Zhang, Yang5 <[email protected]>
Subject: Re: [PATCH v1] ACPI: PNP: Introduce list of known non-PNP devices

CC Zhang Yang who has tested the patch.

Quoted 10 lines · Rui
Quoted 9 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

In some cases, PNP device IDs from acpi_pnp_device_ids[] are returned by _CID for devices for which matching platform drivers are present in the kernel and should be bound to them. However, the IDs coming from _CID cause the PNP scan handler to attach to those devices which prevents platform device objects from being created for them.

Quoted 7 lines
Quoted 7 lines

Address this by introducing a list of known non-PNP device IDs into acpi_pnp.c such that if a device ID is there in that list, it cannot be attached to by the PNP scan handler and add the platform runtime update and telemetry device IDs to that list to start with.

Thanks
Yang

Quoted 27 lines
Quoted 27 lines
---
 drivers/acpi/acpi_pnp.c |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

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

drivers/acpi/acpi_pnp.c +2 -0
@@ -348,10 +348,22 @@ static bool acpi_pnp_match(const char *i
 	return false;
 }
 
+/*
+ * If one of the device IDs below is present in the list of device

IDs of a
+ * given ACPI device object, the PNP scan handler will not attach to
that
+ * object, because there is a proper non-PNP driver in the kernel for the
+ * device represented by it.
+ */

drivers/acpi/acpi_pnp.c +5 -0
+static const struct acpi_device_id acpi_nonpnp_device_ids[] = {
+	{"INTC1080"},
+	{"INTC1081"},
+	{""},
+};
Quoted 9 lines

drivers/acpi/acpi_pnp.c static bool acpi_pnp_match(const char *i · line 366

Quoted 5 lines
drivers/acpi/acpi_pnp.c +2 -1
+
 static int acpi_pnp_attach(struct acpi_device *adev,
 			   const struct acpi_device_id *id)  {
-	return 1;
+	return !!acpi_match_device_ids(adev, acpi_nonpnp_device_ids);

acpi_match_device_ids() returns True if the id matches, and in this case, acpi_pnp_attach() should return false, right?

It is __acpi_match_device() that returns True when matches, and acpi_match_device_ids() returns 0 in this case.
So this is not a bug, sorry for the noise.

thanks,
rui

Quoted 9 lines

thanks,
rui

Quoted 6 lines

}

static struct acpi_scan_handler acpi_pnp_handler = {