Skip to contentSkip to conversation

the cause of spurious interrupt problem

DISCUSSION Zhang Fuxin 2 participants 2 messages Dec 9, 2001 – Dec 10, 2001 MIPS

lore
Share & tools
lore
#0 lore raw

hi,Chris,

days ago you said,

Quoted 8 lines

The spurious interrupts are caused by posted writes to PCI devices.
The sequence is usually something like:
o write device to clear interrupt (write gets posted)
o enable CPU interrupts (interrupt is still pending)
o CPU enters interrupt handler and reads 8259 which causes posted
write
to be flushed and so now there is no interrupt...

Quoted 4 lines

The only fix is to do an explicit PCI (eg ISA port) before reenabling
interrupts. The 2.4.x kernel reenables interrupts more quickly than the older kernel which is why it is more noticeable.

I am trying to find a better way to work around according to your analyse these days.But things are not working as expected at all.If spurious interrupts are caused by posted writes,then define SLOW_DOWN_IO or even REALLY_SLOW_IO in io.h should help; or,from bonito manual, i find read pciMSTAT register can ensure write is actually performed. but they all failed.
Then all at a suddenly i find the REAL reason: the way we use to
determine which interrupt happens has severe flaw.That code simply does this:

       isr = inb(0x20);
       irq = ffz(~isr); /* found first non zero bit,*/
       if (irq == 2) {
           isr = inb(0xa0);
           irq = 8 + ffz(~isr);
       }
       ...

In fact this interrupt is probably not triggered by IRQ'irq'.the
IRR register has multiple bits set!On x86(including some non-x86 platform), the interrupting vector is fetched from the controller via bus, so it is accurate. But p6032 does not provide us such a vector and we use the above and fail:(

Most popular sequence should look like this:

irq A happens,
mask A,send EOI
IRQ B happens(A<B)
because A hasn't been serviced,the IRR bit for A is still set,our code report A irq happens!
---> oops,spurious interrupt happens
service A
i have make a patch,now it leaves kernel/i8259.c untouched and working well(previous inb(0x60) hack suffer from characters lost).I have updated patch on my site.Pretty simple,just skip irqs with IRQ_INPROGRESS set.

Also i notice that after new patch,all interrupt should be programed into
edge trigger mode(with level trigger mode i've seen a IRQ7 spurious interrupt and the machine locked up during boot).
Am i right?

Regards
Zhang Fuxin
[email protected]

#1 lore raw
Quoted 1 line · Zhang Fuxin

Then all at a suddenly i find the REAL reason...

I don't know whether you read the section "Tips on Programming South Bridge Interrupt Controllers" in our P-6032 user manual. It goes like this:

* * * *

The interrupt controllers inside the south bridge chip have to be software-compatible with the dual Intel 8259 controllers fitted to very old PCs. There are two 8-bit controllers inside the south bridge, a slave whose interrupt output becomes one of the eight inputs of the master controller.

The 8259 is a very old device, dating from around 1980. Under the influence of contemporary minicomputer designs, the 8259 made a brave attempt to build an interrupt priority system in hardware for Intel 8-bit and 8086 CPUs. With the benefit of 20 years hindsight, we can see this was pretty silly (but that's a lot of hindsight, and the people who did it were much younger then).

When separated from its Intel CPU, the 8259 is unable to do exciting things like automatically causing the CPU to vector to an appropriate interrupt vector location. Experience shows that allowing it to do anything complicated is likely to lead to trouble, so we suggest:

1. Don't use the 8259's priority logic. Instead, place both the master and slave controller into what the Intel manuals call Special Mask Mode. This disables all interrupt prioritisation; now any active and unmasked interrupt input will activate the interrupt output, which is enough.

2. Do not ever read the ISR (``in-service'') registers. They don't make sense outside of the priority scheme. If you want to know what individual interrupt lines are doing, look in the IRR (``interrupt request'') registers instead. (You'll have to use soft copies of the current mask values to tell which of these bits to attend to).

3. Conclude each interrupt service routine with a ``Specific end-of- interrupt (EOI)'' command to the 8259. In special mask mode this doesn't do anything to the priority, but it does serve to clear a latched interrupt, if there is one. (There are other ways of doing this).

* * * *

One or two of the PC interrupts must, I think, be edge-triggered: but most of them should not be.

I know, it's a pain, you want to maximise compatibility with x86 drivers. But I suspect you're just burying problems which will surely rise again.

Signature · 5 lines
Dominic Sweetman
Algorithmics Ltd
The Fruit Farm, Ely Road, Chittering, CAMBS CB5 9PH, ENGLAND
phone: +44 1223 706200 / fax: +44 1223 706250 / home: +44 20 7226 0032
http://www.algor.co.uk