Skip to contentSkip to conversation

x86 supports NO_IRQ convention

PATCH In review David Brownell 4 participants 8 messages Jun 23, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86 supports NO_IRQ convention

Hmm, x86 doesn't seem to support the NO_IRQ convention. This means that portable code can't use it. Which in turn means that there's no portable way for drivers to know whether they have been handed a valid IRQ number (zero usually being valid). Double-plus ungood.

---
I suspect this has been discussed before, but I can't find any written resolution ...

 include/asm-x86/irq.h |    4 ++++
 1 file changed, 4 insertions(+)
include/asm-x86/irq.h +4 -0
@@ -3,3 +3,7 @@
 #else
 # include "irq_64.h"
 #endif
+
+#ifndef NO_IRQ
+#define NO_IRQ	((unsigned int)(-1))
+#endif
#1 lore raw
Quoted 4 lines · On Sun, 22 Jun 2008 19:53:18 -0700 David Brownell <[email protected]> wrote:

Hmm, x86 doesn't seem to support the NO_IRQ convention. This means that portable code can't use it. Which in turn means that there's no portable way for drivers to know whether they have been handed a valid IRQ number (zero usually being valid). Double-plus ungood.

NAK. It was discussed before repeatedly as you suspected and settled by Linus ultimately.

Zero is not a valid IRQ in the kernel mapping of things. If you have a physical IRQ 0 remap it. That way you can write the more natural

	if (dev->irq)
		setup_for_irq(dev);
	else
		poll(dev);

type stuff.

NO_IRQ was intentionally removed from various platforms and really wants kicking out of some others.

Alan

#2 lore raw
Quoted 1 line · Alan Cox

Zero is not a valid IRQ in the kernel mapping of things.

That's counter-factual:

CPU0 CPU1

  0:   42851354    6500253   IO-APIC-edge      timer
  1:     475459      45904   IO-APIC-edge      i8042
  8:          0          1   IO-APIC-edge      rtc0
  9:        135         18   IO-APIC-fasteoi   acpi
 12:    5232181     495206   IO-APIC-edge      i8042

...

That's on x86. A quick survey of other boards around here shows many that use IRQ 0 too.

I certainly agree it'd be convenient to be able to just test for IRQ being nonzero. Presumably only one driver would ever end up using IRQ 0 on x86, so other drivers could ignore the fact that testing for nonzero would mean "not the timer irq" rather than "no irq assigned".

- Dave

#3 lore raw
Quoted 4 lines · On Mon, 23 Jun 2008 04:29:36 -0700 David Brownell <[email protected]> wrote:
Quoted 1 line · Alan Cox

Zero is not a valid IRQ in the kernel mapping of things.

That's counter-factual:

There are historical reasons for the timer tick (which isn't visible outside arch code) being 0 on x86.

Quoted 2 lines

I certainly agree it'd be convenient to be able to just test for IRQ being nonzero.

0 means "no IRQ" in things like dev->irq. Lots of driver code assumes this and it has been decreed 'correct'.

Alan

#4 lore raw
In reply to Alan Cox
Quoted 3 lines · Alan Cox

Zero is not a valid IRQ in the kernel mapping of things. If you have a physical IRQ 0 remap it.

I'm confused. On my Thinkpad with kernel 2.6.25 I get:

$ cat /proc/interrupts
           CPU0
  0:    4398925    XT-PIC-XT        timer
  1:     287065    XT-PIC-XT        i8042
  2:          0    XT-PIC-XT        cascade
...

Johannes

#5 lore raw
In reply to David Brownell
Quoted 16 lines · David Brownell

Hmm, x86 doesn't seem to support the NO_IRQ convention. This means that portable code can't use it. Which in turn means that there's no portable way for drivers to know whether they have been handed a valid IRQ number (zero usually being valid). Double-plus ungood.

---
I suspect this has been discussed before, but I can't find any written resolution ...

 include/asm-x86/irq.h |    4 ++++
 1 file changed, 4 insertions(+)

include/asm-x86/irq.h line 9

Quoted 7 lines
include/asm-x86/irq.h +4 -0
@@ -3,3 +3,7 @@
 #else
 # include "irq_64.h"
 #endif
+
+#ifndef NO_IRQ
+#define NO_IRQ	((unsigned int)(-1))
+#endif

NO_IRQ on x86 is 0

In fact, we explicitely changed powerpc to do the same :-) (It became easy after I made all linux irqs be virtual, and dynamically mapped to physical numbers).

I think Linus wants everybody to follow...

Cheers,
Ben.

#6 lore raw
Quoted 1 line · Benjamin Herrenschmidt

NO_IRQ on x86 is 0

There is no such #define for it.
And since zero is used for timer IRQs, it's not invalid.

#7 lore raw
Quoted 5 lines · David Brownell
Quoted 1 line · Benjamin Herrenschmidt

NO_IRQ on x86 is 0

There is no such #define for it.
And since zero is used for timer IRQs, it's not invalid.

I'll refer you to past discussions with Linus here. 0 is invalid to drivers for all intend and purposes.

Cheers,
Ben.