Skip to contentSkip to conversation

acpi,pci: warn about duplicate IRQ routing entries returned from _PRT

PATCH In review Mateusz Jończyk 5 participants 8 messages Dec 26, 2023 – Feb 20, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 acpi,pci: warn about duplicate IRQ routing entries returned from _PRT

On some platforms, the ACPI _PRT function returns duplicate interrupt routing entries. Linux uses the first matching entry, but sometimes the second matching entry contains the correct interrupt vector.

As a debugging aid, print a warning to dmesg if duplicate interrupt routing entries are present. This way, we could check how many models are affected.

This happens on a Dell Latitude E6500 laptop with the i2c-i801 Intel SMBus controller. This controller is nonfunctional unless its interrupt usage is disabled (using the "disable_features=0x10" module parameter).

After investigation, it turned out that the driver was using an incorrect interrupt vector: in lspci output for this device there was:
Interrupt: pin B routed to IRQ 19
but after running i2cdetect (without using any i2c-i801 module parameters) the following was logged to dmesg:

        [...]
        i801_smbus 0000:00:1f.3: Timeout waiting for interrupt!
        i801_smbus 0000:00:1f.3: Transaction timeout
        i801_smbus 0000:00:1f.3: Timeout waiting for interrupt!
        i801_smbus 0000:00:1f.3: Transaction timeout
        irq 17: nobody cared (try booting with the "irqpoll" option)

Existence of duplicate entries in a table returned by the _PRT method was confirmed by disassembling the ACPI DSDT table.

Windows XP is using IRQ3 (as reported by HWiNFO32 and in the Device Manager), which is neither of the two vectors returned by _PRT. As HWiNFO32 decoded contents of the SPD EEPROMs, the i2c-i801 device is working under Windows. It appears that Windows has reconfigured the chipset independently to use another interrupt vector for the device. This is possible, according to the chipset datasheet [1], page 436 for example (PIRQ[n]_ROUT—PIRQ[A,B,C,D] Routing Control Register).

[1] https://www.intel.com/content/dam/doc/datasheet/io-controller-hub-9-datasheet.pdf

Cc Bjorn Helgaas <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Len Brown <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Jean Delvare <[email protected]>
Previously-reviewed-by Jean Delvare <[email protected]>

---
Hello,

I'm resurrecting an older patch that was discussed back in January:

https://lore.kernel.org/lkml/[email protected]/T/#u

To consider: should we print a warning or an error in case of duplicate entries? This may not be serious enough to disturb the user with an error message at boot.

I'm also looking into modifying the i2c-i801 driver to disable its usage of interrupts if one did not fire.

v2: - add a newline at the end of the kernel log message,
- replace: "if (match == NULL)" -> "if (!match)"
- patch description tweaks.
v3: - fix C style issues pointed by Jean Delvare,
- switch severity from warning to error.
v3 RESEND: retested on top of v6.2-rc4
v4: - rebase and retest on top of v6.7-rc7
- switch severity back to warning,
- change pr_err() to dev_warn() and simplify the code,
- modify patch description (describe Windows behaviour etc.)

---
 drivers/acpi/pci_irq.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)
drivers/acpi/pci_irq.c +22 -3
index ff30ceca2203..1fcf72e335b0 100644
@@ -203,6 +203,8 @@ static int acpi_pci_irq_find_prt_entry(struct pci_dev *dev,
 	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
 	struct acpi_pci_routing_table *entry;
 	acpi_handle handle = NULL;
+	struct acpi_prt_entry *match = NULL;
+	const char *match_int_source = NULL;
 
 	if (dev->bus->bridge)
 		handle = ACPI_HANDLE(dev->bus->bridge);
@@ -219,13 +221,30 @@ static int acpi_pci_irq_find_prt_entry(struct pci_dev *dev,
 
 	entry = buffer.pointer;
 	while (entry && (entry->length > 0)) {
-		if (!acpi_pci_irq_check_entry(handle, dev, pin,
-						 entry, entry_ptr))
-			break;
+		struct acpi_prt_entry *curr;
+
+		if (!acpi_pci_irq_check_entry(handle, dev, pin, entry, &curr)) {
+			if (!match) {
+				match = curr;
+				match_int_source = entry->source;
+			} else {
+				dev_warn(&dev->dev, FW_BUG
+				       "ACPI _PRT returned duplicate IRQ routing entries for INT%c: %s[%d] and %s[%d]\n",
+				       pin_name(curr->pin),
+				       match_int_source, match->index,
+				       entry->source, curr->index);
+				/* We use the first matching entry nonetheless,
+				 * for compatibility with older kernels.
+				 */
+			}
+		}
+
 		entry = (struct acpi_pci_routing_table *)
 		    ((unsigned long)entry + entry->length);
 	}
 
+	*entry_ptr = match;
+
 	kfree(buffer.pointer);
 	return 0;
 }

base-commit: 861deac3b092f37b2c5e6871732f3e11486f7082

Signature · 1 line
2.25.1
Reviewed-by Tested-by on v4 1/1
#1 lore raw

Hi Mateusz,

Quoted 38 lines · Mateusz Jończyk

On some platforms, the ACPI _PRT function returns duplicate interrupt routing entries. Linux uses the first matching entry, but sometimes the second matching entry contains the correct interrupt vector.

As a debugging aid, print a warning to dmesg if duplicate interrupt routing entries are present. This way, we could check how many models are affected.

This happens on a Dell Latitude E6500 laptop with the i2c-i801 Intel SMBus controller. This controller is nonfunctional unless its interrupt usage is disabled (using the "disable_features=0x10" module parameter).

After investigation, it turned out that the driver was using an incorrect interrupt vector: in lspci output for this device there was:
Interrupt: pin B routed to IRQ 19
but after running i2cdetect (without using any i2c-i801 module parameters) the following was logged to dmesg:

        [...]
        i801_smbus 0000:00:1f.3: Timeout waiting for interrupt!
        i801_smbus 0000:00:1f.3: Transaction timeout
        i801_smbus 0000:00:1f.3: Timeout waiting for interrupt!
        i801_smbus 0000:00:1f.3: Transaction timeout
        irq 17: nobody cared (try booting with the "irqpoll" option)

Existence of duplicate entries in a table returned by the _PRT method was confirmed by disassembling the ACPI DSDT table.

Windows XP is using IRQ3 (as reported by HWiNFO32 and in the Device Manager), which is neither of the two vectors returned by _PRT. As HWiNFO32 decoded contents of the SPD EEPROMs, the i2c-i801 device is working under Windows. It appears that Windows has reconfigured the chipset independently to use another interrupt vector for the device. This is possible, according to the chipset datasheet [1], page 436 for example (PIRQ[n]_ROUT—PIRQ[A,B,C,D] Routing Control Register).

[1] https://www.intel.com/content/dam/doc/datasheet/io-controller-hub-9-datasheet.pdf

Quoted 8 lines
Cc Bjorn Helgaas <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Len Brown <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Jean Delvare <[email protected]>
Previously-reviewed-by Jean Delvare <[email protected]>

I'm still happy with this patch, so you can change that back to:

Thanks,

Signature · 2 lines
Jean Delvare
SUSE L3 Support
#2 lore raw
In reply to Mateusz Jończyk
Quoted 94 lines · Mateusz Jończyk

On some platforms, the ACPI _PRT function returns duplicate interrupt routing entries. Linux uses the first matching entry, but sometimes the second matching entry contains the correct interrupt vector.

As a debugging aid, print a warning to dmesg if duplicate interrupt routing entries are present. This way, we could check how many models are affected.

This happens on a Dell Latitude E6500 laptop with the i2c-i801 Intel SMBus controller. This controller is nonfunctional unless its interrupt usage is disabled (using the "disable_features=0x10" module parameter).

After investigation, it turned out that the driver was using an incorrect interrupt vector: in lspci output for this device there was:
Interrupt: pin B routed to IRQ 19
but after running i2cdetect (without using any i2c-i801 module parameters) the following was logged to dmesg:

        [...]
        i801_smbus 0000:00:1f.3: Timeout waiting for interrupt!
        i801_smbus 0000:00:1f.3: Transaction timeout
        i801_smbus 0000:00:1f.3: Timeout waiting for interrupt!
        i801_smbus 0000:00:1f.3: Transaction timeout
        irq 17: nobody cared (try booting with the "irqpoll" option)

Existence of duplicate entries in a table returned by the _PRT method was confirmed by disassembling the ACPI DSDT table.

Windows XP is using IRQ3 (as reported by HWiNFO32 and in the Device Manager), which is neither of the two vectors returned by _PRT. As HWiNFO32 decoded contents of the SPD EEPROMs, the i2c-i801 device is working under Windows. It appears that Windows has reconfigured the chipset independently to use another interrupt vector for the device. This is possible, according to the chipset datasheet [1], page 436 for example (PIRQ[n]_ROUT—PIRQ[A,B,C,D] Routing Control Register).

[1] https://www.intel.com/content/dam/doc/datasheet/io-controller-hub-9-datasheet.pdf

Cc Bjorn Helgaas <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Len Brown <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Jean Delvare <[email protected]>
Previously-reviewed-by Jean Delvare <[email protected]>

---
Hello,

I'm resurrecting an older patch that was discussed back in January:

https://lore.kernel.org/lkml/[email protected]/T/#u

To consider: should we print a warning or an error in case of duplicate entries? This may not be serious enough to disturb the user with an error message at boot.

I'm also looking into modifying the i2c-i801 driver to disable its usage of interrupts if one did not fire.

v2: - add a newline at the end of the kernel log message,
- replace: "if (match == NULL)" -> "if (!match)"
- patch description tweaks.
v3: - fix C style issues pointed by Jean Delvare,
- switch severity from warning to error.
v3 RESEND: retested on top of v6.2-rc4
v4: - rebase and retest on top of v6.7-rc7
- switch severity back to warning,
- change pr_err() to dev_warn() and simplify the code,
- modify patch description (describe Windows behaviour etc.)

---
 drivers/acpi/pci_irq.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)
drivers/acpi/pci_irq.c +2 -1
index ff30ceca2203..1fcf72e335b0 100644
@@ -203,6 +203,8 @@ static int acpi_pci_irq_find_prt_entry(struct pci_dev *dev,
        struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
        struct acpi_pci_routing_table *entry;
        acpi_handle handle = NULL;
+       struct acpi_prt_entry *match = NULL;
+       const char *match_int_source = NULL;
 
        if (dev->bus->bridge)
                handle = ACPI_HANDLE(dev->bus->bridge);
@@ -219,13 +221,30 @@ static int acpi_pci_irq_find_prt_entry(struct pci_dev *dev,
 
        entry = buffer.pointer;
        while (entry && (entry->length > 0)) {
-               if (!acpi_pci_irq_check_entry(handle, dev, pin,

drivers/acpi/pci_irq.c static int acpi_pci_irq_find_prt_entry(struct pci_dev *dev, · line 231

Quoted 10 lines
drivers/acpi/pci_irq.c +8 -2
-                                                entry, entry_ptr))
-                       break;
+               struct acpi_prt_entry *curr;
+
+               if (!acpi_pci_irq_check_entry(handle, dev, pin, entry, &curr)) {
+                       if (!match) {
+                               match = curr;
+                               match_int_source = entry->source;
+                       } else {
+                               dev_warn(&dev->dev, FW_BUG

dev_info() would be sufficient here IMV.

Quoted 20 lines
drivers/acpi/pci_irq.c +12 -0
+                                      "ACPI _PRT returned duplicate IRQ routing entries for INT%c: %s[%d] and %s[%d]\n",
+                                      pin_name(curr->pin),
+                                      match_int_source, match->index,
+                                      entry->source, curr->index);
+                               /* We use the first matching entry nonetheless,
+                                * for compatibility with older kernels.
+                                */
+                       }
+               }
+
                entry = (struct acpi_pci_routing_table *)
                    ((unsigned long)entry + entry->length);
        }
 
+       *entry_ptr = match;
+
        kfree(buffer.pointer);
        return 0;
 }
Quoted 2 lines

base-commit: 861deac3b092f37b2c5e6871732f3e11486f7082 --

Bjorn, any concerns regarding this one?

#3 lore raw
Quoted 92 lines · Rafael J. Wysocki
Quoted 91 lines · Mateusz Jończyk

On some platforms, the ACPI _PRT function returns duplicate interrupt routing entries. Linux uses the first matching entry, but sometimes the second matching entry contains the correct interrupt vector.

As a debugging aid, print a warning to dmesg if duplicate interrupt routing entries are present. This way, we could check how many models are affected.

This happens on a Dell Latitude E6500 laptop with the i2c-i801 Intel SMBus controller. This controller is nonfunctional unless its interrupt usage is disabled (using the "disable_features=0x10" module parameter).

After investigation, it turned out that the driver was using an incorrect interrupt vector: in lspci output for this device there was:
Interrupt: pin B routed to IRQ 19
but after running i2cdetect (without using any i2c-i801 module parameters) the following was logged to dmesg:

        [...]
        i801_smbus 0000:00:1f.3: Timeout waiting for interrupt!
        i801_smbus 0000:00:1f.3: Transaction timeout
        i801_smbus 0000:00:1f.3: Timeout waiting for interrupt!
        i801_smbus 0000:00:1f.3: Transaction timeout
        irq 17: nobody cared (try booting with the "irqpoll" option)

Existence of duplicate entries in a table returned by the _PRT method was confirmed by disassembling the ACPI DSDT table.

Windows XP is using IRQ3 (as reported by HWiNFO32 and in the Device Manager), which is neither of the two vectors returned by _PRT. As HWiNFO32 decoded contents of the SPD EEPROMs, the i2c-i801 device is working under Windows. It appears that Windows has reconfigured the chipset independently to use another interrupt vector for the device. This is possible, according to the chipset datasheet [1], page 436 for example (PIRQ[n]_ROUT—PIRQ[A,B,C,D] Routing Control Register).

[1] https://www.intel.com/content/dam/doc/datasheet/io-controller-hub-9-datasheet.pdf

Cc Bjorn Helgaas <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Len Brown <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Jean Delvare <[email protected]>
Previously-reviewed-by Jean Delvare <[email protected]>

---
Hello,

I'm resurrecting an older patch that was discussed back in January:

https://lore.kernel.org/lkml/[email protected]/T/#u

To consider: should we print a warning or an error in case of duplicate entries? This may not be serious enough to disturb the user with an error message at boot.

I'm also looking into modifying the i2c-i801 driver to disable its usage of interrupts if one did not fire.

v2: - add a newline at the end of the kernel log message,
- replace: "if (match == NULL)" -> "if (!match)"
- patch description tweaks.
v3: - fix C style issues pointed by Jean Delvare,
- switch severity from warning to error.
v3 RESEND: retested on top of v6.2-rc4
v4: - rebase and retest on top of v6.7-rc7
- switch severity back to warning,
- change pr_err() to dev_warn() and simplify the code,
- modify patch description (describe Windows behaviour etc.)

---
 drivers/acpi/pci_irq.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)
drivers/acpi/pci_irq.c +2 -0
index ff30ceca2203..1fcf72e335b0 100644
@@ -203,6 +203,8 @@ static int acpi_pci_irq_find_prt_entry(struct pci_dev *dev,
        struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
        struct acpi_pci_routing_table *entry;
        acpi_handle handle = NULL;
+       struct acpi_prt_entry *match = NULL;
+       const char *match_int_source = NULL;
 
        if (dev->bus->bridge)
                handle = ACPI_HANDLE(dev->bus->bridge);
@@ -219,13 +221,30 @@ static int acpi_pci_irq_find_prt_entry(struct pci_dev *dev,
 
Quoted 22 lines

drivers/acpi/pci_irq.c static int acpi_pci_irq_find_prt_entry(struct pci_dev *dev, · line 231

Quoted 13 lines
drivers/acpi/pci_irq.c +8 -3
        entry = buffer.pointer;
        while (entry && (entry->length > 0)) {
-               if (!acpi_pci_irq_check_entry(handle, dev, pin,
-                                                entry, entry_ptr))
-                       break;
+               struct acpi_prt_entry *curr;
+
+               if (!acpi_pci_irq_check_entry(handle, dev, pin, entry, &curr)) {
+                       if (!match) {
+                               match = curr;
+                               match_int_source = entry->source;
+                        } else {
+                               dev_warn(&dev->dev, FW_BUG

dev_info() would be sufficient here IMV.

Quoted 6 lines
drivers/acpi/pci_irq.c +6 -0
+                                      "ACPI _PRT returned duplicate IRQ routing entries for INT%c: %s[%d] and %s[%d]\n",
+                                      pin_name(curr->pin),
+                                      match_int_source, match->index,
+                                      entry->source, curr->index);
+                               /* We use the first matching entry nonetheless,
+                                * for compatibility with older kernels.

The usual comment style in this file is:

/*
* We use ...
*/

Quoted 14 lines
Quoted 14 lines
drivers/acpi/pci_irq.c +6 -0
+                                */
+                       }
+               }
+
                entry = (struct acpi_pci_routing_table *)
                    ((unsigned long)entry + entry->length);
        }
 
+       *entry_ptr = match;
+
        kfree(buffer.pointer);
        return 0;
 }
Quoted 4 lines
Quoted 2 lines

base-commit: 861deac3b092f37b2c5e6871732f3e11486f7082 --

Bjorn, any concerns regarding this one?

No concerns from me.

I guess this only adds a message, right? It doesn't actually fix anything or change any behavior?

This talks about "duplicate" entries, which suggests to me that they are identical, but I don't think they are. It sounds like it's two "matching" entries, i.e., two entries for the same (device, pin)?

And neither of the two _PRT entries yields a working i801 device?

Bjorn

#4 lore raw

W dniu 16.02.2024 o 19:49, Bjorn Helgaas pisze:

Quoted 133 lines · Rafael J. Wysocki
Quoted 91 lines · Mateusz Jończyk
Quoted 90 lines

On some platforms, the ACPI _PRT function returns duplicate interrupt routing entries. Linux uses the first matching entry, but sometimes the second matching entry contains the correct interrupt vector.

As a debugging aid, print a warning to dmesg if duplicate interrupt routing entries are present. This way, we could check how many models are affected.

This happens on a Dell Latitude E6500 laptop with the i2c-i801 Intel SMBus controller. This controller is nonfunctional unless its interrupt usage is disabled (using the "disable_features=0x10" module parameter).

After investigation, it turned out that the driver was using an incorrect interrupt vector: in lspci output for this device there was:
Interrupt: pin B routed to IRQ 19
but after running i2cdetect (without using any i2c-i801 module parameters) the following was logged to dmesg:

        [...]
        i801_smbus 0000:00:1f.3: Timeout waiting for interrupt!
        i801_smbus 0000:00:1f.3: Transaction timeout
        i801_smbus 0000:00:1f.3: Timeout waiting for interrupt!
        i801_smbus 0000:00:1f.3: Transaction timeout
        irq 17: nobody cared (try booting with the "irqpoll" option)

Existence of duplicate entries in a table returned by the _PRT method was confirmed by disassembling the ACPI DSDT table.

Windows XP is using IRQ3 (as reported by HWiNFO32 and in the Device Manager), which is neither of the two vectors returned by _PRT. As HWiNFO32 decoded contents of the SPD EEPROMs, the i2c-i801 device is working under Windows. It appears that Windows has reconfigured the chipset independently to use another interrupt vector for the device. This is possible, according to the chipset datasheet [1], page 436 for example (PIRQ[n]_ROUT—PIRQ[A,B,C,D] Routing Control Register).

[1] https://www.intel.com/content/dam/doc/datasheet/io-controller-hub-9-datasheet.pdf

Cc Bjorn Helgaas <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Len Brown <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Jean Delvare <[email protected]>
Previously-reviewed-by Jean Delvare <[email protected]>

---
Hello,

I'm resurrecting an older patch that was discussed back in January:

https://lore.kernel.org/lkml/[email protected]/T/#u

To consider: should we print a warning or an error in case of duplicate entries? This may not be serious enough to disturb the user with an error message at boot.

I'm also looking into modifying the i2c-i801 driver to disable its usage of interrupts if one did not fire.

v2: - add a newline at the end of the kernel log message,
- replace: "if (match == NULL)" -> "if (!match)"
- patch description tweaks.
v3: - fix C style issues pointed by Jean Delvare,
- switch severity from warning to error.
v3 RESEND: retested on top of v6.2-rc4
v4: - rebase and retest on top of v6.7-rc7
- switch severity back to warning,
- change pr_err() to dev_warn() and simplify the code,
- modify patch description (describe Windows behaviour etc.)

---
 drivers/acpi/pci_irq.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)
drivers/acpi/pci_irq.c +2 -0
index ff30ceca2203..1fcf72e335b0 100644
@@ -203,6 +203,8 @@ static int acpi_pci_irq_find_prt_entry(struct pci_dev *dev,
        struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
        struct acpi_pci_routing_table *entry;
        acpi_handle handle = NULL;
+       struct acpi_prt_entry *match = NULL;
+       const char *match_int_source = NULL;
 
        if (dev->bus->bridge)
                handle = ACPI_HANDLE(dev->bus->bridge);
@@ -219,13 +221,30 @@ static int acpi_pci_irq_find_prt_entry(struct pci_dev *dev,
 
Quoted 21 lines

drivers/acpi/pci_irq.c static int acpi_pci_irq_find_prt_entry(struct pci_dev *dev, · line 231

Quoted 13 lines
drivers/acpi/pci_irq.c +8 -3
        entry = buffer.pointer;
        while (entry && (entry->length > 0)) {
-               if (!acpi_pci_irq_check_entry(handle, dev, pin,
-                                                entry, entry_ptr))
-                       break;
+               struct acpi_prt_entry *curr;
+
+               if (!acpi_pci_irq_check_entry(handle, dev, pin, entry, &curr)) {
+                       if (!match) {
+                               match = curr;
+                               match_int_source = entry->source;
+                        } else {
+                               dev_warn(&dev->dev, FW_BUG

dev_info() would be sufficient here IMV.

Quoted 6 lines
drivers/acpi/pci_irq.c +6 -0
+                                      "ACPI _PRT returned duplicate IRQ routing entries for INT%c: %s[%d] and %s[%d]\n",
+                                      pin_name(curr->pin),
+                                      match_int_source, match->index,
+                                      entry->source, curr->index);
+                               /* We use the first matching entry nonetheless,
+                                * for compatibility with older kernels.

The usual comment style in this file is:

/*
* We use ...
*/

Quoted 14 lines
Quoted 14 lines
drivers/acpi/pci_irq.c +6 -0
+                                */
+                       }
+               }
+
                entry = (struct acpi_pci_routing_table *)
                    ((unsigned long)entry + entry->length);
        }
 
+       *entry_ptr = match;
+
        kfree(buffer.pointer);
        return 0;
 }
Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

base-commit: 861deac3b092f37b2c5e6871732f3e11486f7082 --

Bjorn, any concerns regarding this one?

No concerns from me.

I guess this only adds a message, right? It doesn't actually fix anything or change any behavior?

Exactly.

Quoted 3 lines

This talks about "duplicate" entries, which suggests to me that they are identical, but I don't think they are. It sounds like it's two "matching" entries, i.e., two entries for the same (device, pin)?

Right.

Quoted 1 line

And neither of the two _PRT entries yields a working i801 device?

Unpatched Linux uses the first matching entry, but the second one gives a working i801 device. The point is to print a warning message to see how many devices are affected and whether it is safe to switch the code to use the last matching entry in all instances.

Therefore I used dev_warn().

Quoted 1 line

Bjorn

Greetings,

Mateusz

#5 lore raw
Quoted 149 lines · Mateusz Jończyk

W dniu 16.02.2024 o 19:49, Bjorn Helgaas pisze:

Quoted 133 lines · Rafael J. Wysocki
Quoted 91 lines · Mateusz Jończyk
Quoted 90 lines

On some platforms, the ACPI _PRT function returns duplicate interrupt routing entries. Linux uses the first matching entry, but sometimes the second matching entry contains the correct interrupt vector.

As a debugging aid, print a warning to dmesg if duplicate interrupt routing entries are present. This way, we could check how many models are affected.

This happens on a Dell Latitude E6500 laptop with the i2c-i801 Intel SMBus controller. This controller is nonfunctional unless its interrupt usage is disabled (using the "disable_features=0x10" module parameter).

After investigation, it turned out that the driver was using an incorrect interrupt vector: in lspci output for this device there was:
Interrupt: pin B routed to IRQ 19
but after running i2cdetect (without using any i2c-i801 module parameters) the following was logged to dmesg:

        [...]
        i801_smbus 0000:00:1f.3: Timeout waiting for interrupt!
        i801_smbus 0000:00:1f.3: Transaction timeout
        i801_smbus 0000:00:1f.3: Timeout waiting for interrupt!
        i801_smbus 0000:00:1f.3: Transaction timeout
        irq 17: nobody cared (try booting with the "irqpoll" option)

Existence of duplicate entries in a table returned by the _PRT method was confirmed by disassembling the ACPI DSDT table.

Windows XP is using IRQ3 (as reported by HWiNFO32 and in the Device Manager), which is neither of the two vectors returned by _PRT. As HWiNFO32 decoded contents of the SPD EEPROMs, the i2c-i801 device is working under Windows. It appears that Windows has reconfigured the chipset independently to use another interrupt vector for the device. This is possible, according to the chipset datasheet [1], page 436 for example (PIRQ[n]_ROUT—PIRQ[A,B,C,D] Routing Control Register).

[1] https://www.intel.com/content/dam/doc/datasheet/io-controller-hub-9-datasheet.pdf

Cc Bjorn Helgaas <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Len Brown <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Jean Delvare <[email protected]>
Previously-reviewed-by Jean Delvare <[email protected]>

---
Hello,

I'm resurrecting an older patch that was discussed back in January:

https://lore.kernel.org/lkml/[email protected]/T/#u

To consider: should we print a warning or an error in case of duplicate entries? This may not be serious enough to disturb the user with an error message at boot.

I'm also looking into modifying the i2c-i801 driver to disable its usage of interrupts if one did not fire.

v2: - add a newline at the end of the kernel log message,
- replace: "if (match == NULL)" -> "if (!match)"
- patch description tweaks.
v3: - fix C style issues pointed by Jean Delvare,
- switch severity from warning to error.
v3 RESEND: retested on top of v6.2-rc4
v4: - rebase and retest on top of v6.7-rc7
- switch severity back to warning,
- change pr_err() to dev_warn() and simplify the code,
- modify patch description (describe Windows behaviour etc.)

---
 drivers/acpi/pci_irq.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)
drivers/acpi/pci_irq.c +2 -0
index ff30ceca2203..1fcf72e335b0 100644
@@ -203,6 +203,8 @@ static int acpi_pci_irq_find_prt_entry(struct pci_dev *dev,
        struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
        struct acpi_pci_routing_table *entry;
        acpi_handle handle = NULL;
+       struct acpi_prt_entry *match = NULL;
+       const char *match_int_source = NULL;
 
        if (dev->bus->bridge)
                handle = ACPI_HANDLE(dev->bus->bridge);
@@ -219,13 +221,30 @@ static int acpi_pci_irq_find_prt_entry(struct pci_dev *dev,
 
Quoted 21 lines

drivers/acpi/pci_irq.c static int acpi_pci_irq_find_prt_entry(struct pci_dev *dev, · line 231

Quoted 13 lines
drivers/acpi/pci_irq.c +8 -3
        entry = buffer.pointer;
        while (entry && (entry->length > 0)) {
-               if (!acpi_pci_irq_check_entry(handle, dev, pin,
-                                                entry, entry_ptr))
-                       break;
+               struct acpi_prt_entry *curr;
+
+               if (!acpi_pci_irq_check_entry(handle, dev, pin, entry, &curr)) {
+                       if (!match) {
+                               match = curr;
+                               match_int_source = entry->source;
+                        } else {
+                               dev_warn(&dev->dev, FW_BUG

dev_info() would be sufficient here IMV.

Quoted 6 lines
drivers/acpi/pci_irq.c +6 -0
+                                      "ACPI _PRT returned duplicate IRQ routing entries for INT%c: %s[%d] and %s[%d]\n",
+                                      pin_name(curr->pin),
+                                      match_int_source, match->index,
+                                      entry->source, curr->index);
+                               /* We use the first matching entry nonetheless,
+                                * for compatibility with older kernels.

The usual comment style in this file is:

/*
* We use ...
*/

Quoted 14 lines
Quoted 14 lines
drivers/acpi/pci_irq.c +6 -0
+                                */
+                       }
+               }
+
                entry = (struct acpi_pci_routing_table *)
                    ((unsigned long)entry + entry->length);
        }
 
+       *entry_ptr = match;
+
        kfree(buffer.pointer);
        return 0;
 }
Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

base-commit: 861deac3b092f37b2c5e6871732f3e11486f7082 --

Bjorn, any concerns regarding this one?

No concerns from me.

I guess this only adds a message, right? It doesn't actually fix anything or change any behavior?

Exactly.

Quoted 3 lines

This talks about "duplicate" entries, which suggests to me that they are identical, but I don't think they are. It sounds like it's two "matching" entries, i.e., two entries for the same (device, pin)?

Right.

Quoted 8 lines
Quoted 1 line

And neither of the two _PRT entries yields a working i801 device?

Unpatched Linux uses the first matching entry, but the second one gives a working i801 device. The point is to print a warning message to see how many devices are affected and whether it is safe to switch the code to use the last matching entry in all instances.

Therefore I used dev_warn().

I don't quite see a connection between the above and the log level.

#6 lore raw

W dniu 16.02.2024 o 21:51, Rafael J. Wysocki pisze:

Quoted 31 lines · Mateusz Jończyk
Quoted 30 lines

W dniu 16.02.2024 o 19:49, Bjorn Helgaas pisze:

Quoted 29 lines · Rafael J. Wysocki
Quoted 28 lines · Mateusz Jończyk
Quoted 27 lines

On some platforms, the ACPI _PRT function returns duplicate interrupt routing entries. Linux uses the first matching entry, but sometimes the second matching entry contains the correct interrupt vector.

As a debugging aid, print a warning to dmesg if duplicate interrupt routing entries are present. This way, we could check how many models are affected.

This happens on a Dell Latitude E6500 laptop with the i2c-i801 Intel SMBus controller. This controller is nonfunctional unless its interrupt usage is disabled (using the "disable_features=0x10" module parameter).

After investigation, it turned out that the driver was using an incorrect interrupt vector: in lspci output for this device there was:
Interrupt: pin B routed to IRQ 19
but after running i2cdetect (without using any i2c-i801 module parameters) the following was logged to dmesg:

        [...]
        i801_smbus 0000:00:1f.3: Timeout waiting for interrupt!
        i801_smbus 0000:00:1f.3: Transaction timeout
        i801_smbus 0000:00:1f.3: Timeout waiting for interrupt!
        i801_smbus 0000:00:1f.3: Transaction timeout
        irq 17: nobody cared (try booting with the "irqpoll" option)

Existence of duplicate entries in a table returned by the _PRT method was confirmed by disassembling the ACPI DSDT table.

[snip]

Quoted 8 lines
Quoted 7 lines
Quoted 1 line

And neither of the two _PRT entries yields a working i801 device?

Unpatched Linux uses the first matching entry, but the second one gives a working i801 device. The point is to print a warning message to see how many devices are affected and whether it is safe to switch the code to use the last matching entry in all instances.

Therefore I used dev_warn().

I don't quite see a connection between the above and the log level.

OK, so I'll use dev_info() then.

Greetings,
Mateusz

#7 lore raw
In reply to Mateusz Jończyk

Tue, Dec 26, 2023 at 01:42:54PM +0100, Mateusz Jończyk kirjoitti:

Quoted 36 lines

On some platforms, the ACPI _PRT function returns duplicate interrupt routing entries. Linux uses the first matching entry, but sometimes the second matching entry contains the correct interrupt vector.

As a debugging aid, print a warning to dmesg if duplicate interrupt routing entries are present. This way, we could check how many models are affected.

This happens on a Dell Latitude E6500 laptop with the i2c-i801 Intel SMBus controller. This controller is nonfunctional unless its interrupt usage is disabled (using the "disable_features=0x10" module parameter).

After investigation, it turned out that the driver was using an incorrect interrupt vector: in lspci output for this device there was:
Interrupt: pin B routed to IRQ 19
but after running i2cdetect (without using any i2c-i801 module parameters) the following was logged to dmesg:

        [...]
        i801_smbus 0000:00:1f.3: Timeout waiting for interrupt!
        i801_smbus 0000:00:1f.3: Transaction timeout
        i801_smbus 0000:00:1f.3: Timeout waiting for interrupt!
        i801_smbus 0000:00:1f.3: Transaction timeout
        irq 17: nobody cared (try booting with the "irqpoll" option)

Existence of duplicate entries in a table returned by the _PRT method was confirmed by disassembling the ACPI DSDT table.

Windows XP is using IRQ3 (as reported by HWiNFO32 and in the Device Manager), which is neither of the two vectors returned by _PRT. As HWiNFO32 decoded contents of the SPD EEPROMs, the i2c-i801 device is working under Windows. It appears that Windows has reconfigured the chipset independently to use another interrupt vector for the device. This is possible, according to the chipset datasheet [1], page 436 for example (PIRQ[n]_ROUT—PIRQ[A,B,C,D] Routing Control Register).

Quoted 2 lines

[1] https://www.intel.com/content/dam/doc/datasheet/io-controller-hub-9-datasheet.pdf

Can you convert this to be a Link tag?

Link ...URL... # [1]
Signed-off-by ...
Quoted 7 lines
Cc Bjorn Helgaas <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Len Brown <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Jean Delvare <[email protected]>

Please, move these (Cc lines) down after --- cutter line.

Quoted 2 lines
Previously-reviewed-by Jean Delvare <[email protected]>

This shouldn't be in the commit message, just use the comment block (after --- line) for this.

...

drivers/acpi/pci_irq.c static int acpi_pci_irq_find_prt_entry(struct pci_dev *dev, · line 207

Quoted 5 lines
drivers/acpi/pci_irq.c +2 -0
 	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
 	struct acpi_pci_routing_table *entry;
 	acpi_handle handle = NULL;
+	struct acpi_prt_entry *match = NULL;
+	const char *match_int_source = NULL;

Can you preserve reversed xmas tree ordering?

...

drivers/acpi/pci_irq.c static int acpi_pci_irq_find_prt_entry(struct pci_dev *dev,

Quoted 9 lines
drivers/acpi/pci_irq.c +4 -3
 	while (entry && (entry->length > 0)) {
-		if (!acpi_pci_irq_check_entry(handle, dev, pin,
-						 entry, entry_ptr))
-			break;
+		struct acpi_prt_entry *curr;
+
+		if (!acpi_pci_irq_check_entry(handle, dev, pin, entry, &curr)) {
 
+			if (!match) {

Why not positive condition?

Quoted 13 lines
drivers/acpi/pci_irq.c +13 -0
+				match = curr;
+				match_int_source = entry->source;
+			} else {
+				dev_warn(&dev->dev, FW_BUG
+				       "ACPI _PRT returned duplicate IRQ routing entries for INT%c: %s[%d] and %s[%d]\n",
+				       pin_name(curr->pin),
+				       match_int_source, match->index,
+				       entry->source, curr->index);
+				/* We use the first matching entry nonetheless,
+				 * for compatibility with older kernels.
+				 */
+			}
+		}
Signature · 2 lines
With Best Regards,
Andy Shevchenko