Skip to contentSkip to conversation

arch:x86:pci:irq.c: Improve log message when IRQ cannot be identified

PATCH Superseded Brent Spillner 3 participants 5 messages Jan 28, 2022 – Jan 31, 2022

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arch:x86:pci:irq.c: Improve log message when IRQ cannot be identified

The existing code always suggests trying the pci=biosirq kernel parameter, but this option is only recognized when CONFIG_PCI_BIOS is set, which in turn depends on CONFIG_X86_32, so it is never appropriate on x86_64.

The new version tries to form a more useful message when pci=biosirq is not available, including by suggesting different acpi= options if appropriate (probably the most common cause of failed IRQ discovery).

See arch/x86/pci/common.c:535 for the interpretation of pci=biosirq, and arch/x86/Kconfig:2633 for the dependencies of CONFIG_PCI_BIOS.

---
 arch/x86/pci/irq.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
arch/x86/pci/irq.c +14 -0
index 97b63e35e152..bc4aaaa74832 100644
@@ -1522,7 +1522,21 @@ static int pirq_enable_irq(struct pci_dev *dev)
 		} else if (pci_probe & PCI_BIOS_IRQ_SCAN)
 			msg = "";
 		else
+#ifdef CONFIG_PCI_BIOS
 			msg = "; please try using pci=biosirq";
+#else
+			/* pci=biosirq is not a valid option */
+#ifdef CONFIG_ACPI
+			if (acpi_noirq)
+				msg = "; consider removing acpi=noirq";
+			else
+#endif
+				msg = "; recommend verifying UEFI/BIOS IRQ options"
+#ifndef CONFIG_ACPI
+					" or enabling ACPI"
+#endif
+					;
+#endif
 
 		/*
 		 * With IDE legacy devices the IRQ lookup failure is not
Signature · 1 line
2.34.1
#1 lore raw

Please fix up that subject. We don't tend to use ":" to separate things. Second, the prefix isn't a filename. It's really a subsystem.
Take a look at:

git log arch/x86/pci/irq.c

for some other examples.

Quoted 11 lines · Brent Spillner

The existing code always suggests trying the pci=biosirq kernel parameter, but this option is only recognized when CONFIG_PCI_BIOS is set, which in turn depends on CONFIG_X86_32, so it is never appropriate on x86_64.

The new version tries to form a more useful message when pci=biosirq is not available, including by suggesting different acpi= options if appropriate (probably the most common cause of failed IRQ discovery).

See arch/x86/pci/common.c:535 for the interpretation of pci=biosirq, and arch/x86/Kconfig:2633 for the dependencies of CONFIG_PCI_BIOS.

Shockingly enough, that parameter is in the documentation:

Documentation/admin-guide/kernel-parameters.txt

and double-shockingly, it's even called out as X86-32-only:

biosirq [X86-32] Use PCI BIOS calls to get the interrupt

Given that, do we really need to refer to the line numbers of the implementation which will probably be stale by the time this is merged anyway?

Quoted 16 lines
 arch/x86/pci/irq.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
arch/x86/pci/irq.c +4 -0
index 97b63e35e152..bc4aaaa74832 100644
@@ -1522,7 +1522,21 @@ static int pirq_enable_irq(struct pci_dev *dev)
 		} else if (pci_probe & PCI_BIOS_IRQ_SCAN)
 			msg = "";
 		else
+#ifdef CONFIG_PCI_BIOS
 			msg = "; please try using pci=biosirq";
+#else
+			/* pci=biosirq is not a valid option */
+#ifdef CONFIG_ACPI

arch/x86/pci/irq.c static int pirq_enable_irq(struct pci_dev *dev) · line 1539

Quoted 10 lines
arch/x86/pci/irq.c +10 -0
+			if (acpi_noirq)
+				msg = "; consider removing acpi=noirq";
+			else
+#endif
+				msg = "; recommend verifying UEFI/BIOS IRQ options"
+#ifndef CONFIG_ACPI
+					" or enabling ACPI"
+#endif
+					;
+#endif

Any chance you could make that, um, a bit more readable? It's OK to add brackets to the else{} for readability even if they're not *strictly* necessary.

It might also be nice to use

	if (IS_ENABLED(CONFIG_FOO))
		...

rather than the #ifdefs.

I'd also be perfectly OK having two different strings rather than relying on string concatenation and the #ifdefs.

Is the "or enabling ACPI" message really necessary?

#2 lore raw
Quoted 2 lines · Dave Hansen

Shockingly enough, that parameter is in the documentation:
and double-shockingly, it's even called out as X86-32-only:

Right, seeing that is what convinced me that not customizing the log message for x86_64 could be considered a (admittedly very minor) bug, and perhaps worth fixing.

Quoted 3 lines

Given that, do we really need to refer to the line numbers of the implementation which will probably be stale by the time this is merged anyway?

Understood, will change the commit message to just refer to the command line documentation.

Quoted 10 lines

Any chance you could make that, um, a bit more readable? It's OK to add brackets to the else{} for readability even if they're not *strictly* necessary.

It might also be nice to use

        if (IS_ENABLED(CONFIG_FOO))
                ...

rather than the #ifdefs.

I don't mind doing either of those if that's the maintainer consensus, but would note that neither would be consistent with the surrounding code. Prior to the patch, the .c files in arch/x86/pci contain a total of 33 #ifdefs and just one IS_ENABLED(), and systematically avoid superfluous braces around single-statement if/else/for bodies. Granted, the code has other style problems and triggers a number of checkpatch.pl warnings (although not in the region affected by this patch), but I was trying to be as light a touch as possible.

Quoted 4 lines

I'd also be perfectly OK having two different strings rather than relying on string concatenation and the #ifdefs.

Is the "or enabling ACPI" message really necessary?

Not strictly necessary--- it seems fair to assume that anyone disabling ACPI does so intentionally and with good reason--- but I thought it might stimulate the right thought process for someone who doesn't understand why their hardware isn't being properly detected, as ACPI triggers some very different code paths through this driver.

It seems like the multiline string literal is your main pain point--- would

+#ifdef CONFIG_ACPI
+ if (acpi_noirq)
+ msg = "; consider removing acpi=noirq";
+ else
+ msg = "; recommend verifying UEFI/BIOS
IRQ options";
+#else
+ msg = "; recommend verifying UEFI/BIOS IRQ
options or enabling ACPI";
+#endif

be OK without going to IS_ENABLED()? (Personally, I think the #ifdef style is more readable.)

#3 lore raw
Quoted 13 lines · Brent Spillner

It seems like the multiline string literal is your main pain point--- would

arch/x86/pci/irq.c +5 -0
+#ifdef CONFIG_ACPI
+                       if (acpi_noirq)
+                               msg = "; consider removing acpi=noirq";
+                       else
+                               msg = "; recommend verifying UEFI/BIOS

IRQ options";

(quoted diff) +2 -0
+#else
+                       msg = "; recommend verifying UEFI/BIOS IRQ

options or enabling ACPI";
+#endif

Quoted 2 lines

be OK without going to IS_ENABLED()? (Personally, I think the #ifdef style is more readable.)

I think that's _better_ than what was in the patch. But, even with it, I still think the #ifdef mess borders on unreadable.

But, if Bjorn likes it, then go for it. :)

#4 lore raw
Quoted 14 lines · Dave Hansen
Quoted 13 lines · Brent Spillner

It seems like the multiline string literal is your main pain point--- would

arch/x86/pci/irq.c +5 -0
+#ifdef CONFIG_ACPI
+                       if (acpi_noirq)
+                               msg = "; consider removing acpi=noirq";
+                       else
+                               msg = "; recommend verifying UEFI/BIOS

IRQ options";

(quoted diff) +2 -0
+#else
+                       msg = "; recommend verifying UEFI/BIOS IRQ

options or enabling ACPI";
+#endif

Quoted 7 lines
Quoted 2 lines

be OK without going to IS_ENABLED()? (Personally, I think the #ifdef style is more readable.)

I think that's _better_ than what was in the patch. But, even with it, I still think the #ifdef mess borders on unreadable.

But, if Bjorn likes it, then go for it. :)

I was hoping to avoid commenting at all ;)

I'm a little bit averse to suggesting *any* command-line options because users shouldn't have to use options like these. It would be better if we got a bug report and could fix the bug or add a quirk to work around a firmware issue automatically.

If a user finds a command-line option that "works," the problem is solved as far as they are concerned, but it doesn't help the next person who trips over it.

I think pci_acpi_init() should warn when "acpi=noirq" was used because the only reason to use it should be to work around a firmware defect, and ideally, we could make a quirk to do that. Maybe the doc should suggest a bug report.

What does "verifying UEFI/BIOS IRQ options" mean? I could go look at the BIOS setup menu, but I would have no idea what to look for, so the only thing I could do would be to try randomly changing IRQ-related things. If that happens to hit on a working configuration, I might be happy, but it wouldn't help the next person at all. I'd rather see a bug report. Then we could at least try to make a quirk so no command line option would be needed.

Bjorn