Re: PCI Interrupt

Previous thread: alternatives in modules by Denys Vlasenko on Tuesday, September 18, 2007 - 5:36 am. (2 messages)

Next thread: [PATCH] Consolidate sleeping routines in file locking code by Pavel Emelyanov on Tuesday, September 18, 2007 - 6:41 am. (5 messages)
From: Duncan.Perrett
Subject: PCI Interrupt
Date: Tuesday, September 18, 2007 - 6:17 am

I have a CAN PCI card installed on my Ubuntu box.
I understand that PCI interrupts should be level rather than edge
triggered.

The output of cat /proc/interrupts is :-

           CPU0
  0:    1614601    IO-APIC-edge  timer
  1:        164    IO-APIC-edge  i8042
  8:          3    IO-APIC-edge  rtc
  9:          1   IO-APIC-level  acpi
 12:          0    IO-APIC-edge  CAN-ACx-PCI_01
 14:      65786    IO-APIC-edge  ide0
169:       3220   IO-APIC-level  eth0, i915@pci:0000:00:02.0
177:      46459   IO-APIC-level  eth1
209:          0   IO-APIC-level  uhci_hcd:usb3, eth2
217:          2   IO-APIC-level  uhci_hcd:usb1, ehci_hcd:usb4
225:        697   IO-APIC-level  uhci_hcd:usb2
NMI:          0
LOC:    1614399
ERR:          0
MIS:          0

You see that irq 12 CAN-ACx-PCI_01 is edge triggered.
Is there any way of forcing the BIOS to see the interrupt as a
level-triggered one?


*******************Internet Email Confidentiality Footer*******************
The contents of this e-mail message (including any attachments hereto) are
confidential to and are intended to be conveyed for the use of the
recipient to whom it is addressed only. If you receive this transmission in
error, please notify the sender of this immediately and delete the message
from your system. Any distribution, reproduction or use of this message by
someone other than recipient is not authorized and may be unlawful.
Elekta Limited is a company registered in England and Wales whose
registered number is 3244454 and whose registered address is Linac House,
Fleming Way, Crawley, West Sussex, RH10 9RR

-

From: linux-os (Dick Johnson)
Date: Tuesday, September 18, 2007 - 6:57 am

It's done in the driver. IRQ12 can be shared, so the driver
needs to request the IRQ as a shared interrupt.


Cheers,
Dick Johnson
Penguin : Linux version 2.6.22.1 on an i686 machine (5588.30 BogoMips).
My book : http://www.AbominableFirebug.com/
_


****************************************************************
The information transmitted in this message is confidential and may be privileged.  Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited.  If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to DeliveryErrors@analogic.com - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.
-

From: Duncan.Perrett
Date: Tuesday, September 18, 2007 - 7:08 am

The driver already does that ...

result =
        request_irq(irq, can_pci_interrupt, SA_INTERRUPT | SA_SHIRQ,
                    pDevice->au8IrqName, pDevice);


Any other ideas?

Duncan



                                                                           
             "linux-os \(Dick                                              
             Johnson\)"                                                    
             <linux-os@analogi                                          To 
             c.com>                    <Duncan.Perrett@elekta.com>         
                                                                        cc 
             18/09/2007 14:57          "Linux kernel"                      
                                       <linux-kernel@vger.kernel.org>      
                                                                   Subject 
             Please respond to         Re: PCI Interrupt                   
             "linux-os \(Dick                                              
                Johnson\)"                                                 
             <linux-os@analogi                                             
                  c.com>                                                   
                                                                           
                                                                           






It's done in the driver. IRQ12 can be shared, so the driver
needs to request the IRQ as a shared interrupt.


Cheers,
Dick Johnson
Penguin : Linux version 2.6.22.1 on an i686 machine (5588.30 BogoMips).
My book : http://www.AbominableFirebug.com/
_


****************************************************************
The information transmitted in this message is confidential and may be
privileged.  Any review, retransmission, dissemination, or other use of
this information by persons or entities other than the intended recipient
is prohibited.  If you are not the intended ...
From: Lennart Sorensen
Date: Tuesday, September 18, 2007 - 7:25 am

Maybe the system thinks a ps2 mouse port owns irq 12 and messes it up as
a result.

--
Len Sorensen
-

From: linux-os (Dick Johnson)
Date: Tuesday, September 18, 2007 - 7:34 am

Okay, then in the BIOS, make sure that IRQ12 is not assigned to
a specific device. In other words, set it to PnP (if available).
As you well know, PCI requires sharable interrupts and edges
are not sharable so something is broken. As a last resort,
move your PCI board to abother slot which should pick up another
interrupt, which may not be broken. If that doesn't work, see
if a new BIOS is available for download.


Cheers,
Dick Johnson
Penguin : Linux version 2.6.22.1 on an i686 machine (5588.30 BogoMips).
My book : http://www.AbominableFirebug.com/
_


****************************************************************
The information transmitted in this message is confidential and may be privileged.  Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited.  If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to DeliveryErrors@analogic.com - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.
-

From: Duncan.Perrett
Date: Tuesday, September 18, 2007 - 8:14 am

Sorted.

A setting in the BIOS meant it was storing old configuration data.
After disabling this option, it became a level triggered interrupt and
everything now works!

Thanks.



                                                                           
             "linux-os \(Dick                                              
             Johnson\)"                                                    
             <linux-os@analogi                                          To 
             c.com>                    <Duncan.Perrett@elekta.com>         
                                                                        cc 
             18/09/2007 15:34          "Linux kernel"                      
                                       <linux-kernel@vger.kernel.org>      
                                                                   Subject 
             Please respond to         Re: PCI Interrupt                   
             "linux-os \(Dick                                              
                Johnson\)"                                                 
             <linux-os@analogi                                             
                  c.com>                                                   
                                                                           
                                                                           






Okay, then in the BIOS, make sure that IRQ12 is not assigned to
a specific device. In other words, set it to PnP (if available).
As you well know, PCI requires sharable interrupts and edges
are not sharable so something is broken. As a last resort,
move your PCI board to abother slot which should pick up another
interrupt, which may not be broken. If that doesn't work, see
if a new BIOS is available for download.


Cheers,
Dick Johnson
Penguin : Linux version 2.6.22.1 on an i686 machine (5588.30 BogoMips).
My book : ...
From: linux-os (Dick Johnson)
Date: Tuesday, September 18, 2007 - 9:04 am

Good!



Cheers,
Dick Johnson
Penguin : Linux version 2.6.22.1 on an i686 machine (5588.30 BogoMips).
My book : http://www.AbominableFirebug.com/
_


****************************************************************
The information transmitted in this message is confidential and may be privileged.  Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited.  If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to DeliveryErrors@analogic.com - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.
-

From: Rafael J. Wysocki
Date: Tuesday, September 18, 2007 - 7:42 am

Hm, edge-triggered interrupts cannot be shared, AFAIK.

Greetings,
Rafael
-

From: Jarek Poplawski
Date: Wednesday, September 19, 2007 - 3:14 am

On 18-09-2007 16:42, Rafael J. Wysocki wrote:

Let's agree it's only a superstition...

http://en.wikipedia.org/wiki/Edge_triggered_interrupt

Regards,
Jarek P.
-

From: Rafael J. Wysocki
Date: Wednesday, September 19, 2007 - 5:32 am

Well, if this is an MSI (which is edge-triggered), for example, it cannot be
shared.

Also, you must use a level-triggered interrupt for SCI, because that has to be
shareable.

Greetings,
Rafael
-

From: Jarek Poplawski
Date: Wednesday, September 19, 2007 - 5:50 am

O.K. Let's agree we differ here a bit...

Cheers,
Jarek P.
-

From: Frantisek Rysanek
Date: Wednesday, September 19, 2007 - 4:21 am

Superstition? Depends on how stringent your requirements are.

On IBM PC compatible hardware, there's always a risky "window of 
opportunity" that a shared edge-triggered interrupt line gets 
electrically re-triggered before your ISR manages to service all the 
devices and ACK the interrupt (I believe RTAI does that in reverse 
order). In that case, you get a missed interrupt, and your 
peripherial device may wait for service indefinitely.

I don't recall if the i8259 AT-pic has some useable "retrigger while 
in service" register, maybe the APIC does. (I do recall that the 
8259's two-register IO footprint is rather convoluted.) I seriously 
doubt that the presence of such a register would completely eliminate 
the critical window of time.

On PC hardware or in general, sharing edge-triggered interrupts can 
be perfectly allright under very specific conditions, if you know 
exactly what you're doing, e.g. you know that the collision of 
interrupt sources simply cannot occur (due to some characteristic 
sequencing of interrupt-generating events in the specific peripherial 
hardware), or you don't quite bother (in that case, why use an 
interrupt at all?).

You can certainly try to re-check your string of devices before 
finally ACKing, or set up supplemental timer-based periodic polling, 
but those are all kludgey workarounds that converge towards not using 
interrupts at all. I believe this is one of the reasons why e.g. ISA 
multi-port serial boards with a shared interrupt have been dropped 
from Linux 2.6 (vs. 2.4).

The fact that some ISA peripherials do respect the open-collector
convention, so that electrical sharing of the IRQ line is possible, 
doesn't help the ISR do the job in time. Even at the electric level, 
this rule is far from notorious. I've had the opportunity to write a 
driver for a special-purpose ISA board, where two different 
generations of the hardware treated the IRQ line very differently. If 
you use OC+pullup combined with active-low pulses of ...
From: Jarek Poplawski
Date: Wednesday, September 19, 2007 - 6:25 am

My requirements aren't stringent at all. They are general like the
sentence: "edge-triggered interrupts cannot be shared", which, IMHO,
could mislead somebody. So, it's only about "cannot" vs. "cannot (or
is not recommended/implemented) with some kind of hardware (like PC)".

Regards,
Jarek P.
-

From: Maciej W. Rozycki
Date: Wednesday, September 19, 2007 - 7:13 am

That's because the 8259A does not support truly edge-triggered interrupts 
-- what it supports is a signalling model where the rising edge asserts 
the interrupt and the falling edge negates it if unhandled.  So in some 
sense it is a level-triggered interrupt with no retrigger before the 

 The APIC can support truly edge-triggered interrupts as it only records 
one of the edges (which one of the two it is, depends on the polarity 
setting).  It also records another edge happening between an ACK and an 
EOI and signals another interrupt immediately after the EOI, so nothing is 
lost if pulses are short (assuming there is a reasonably small number of 
sources so that overlapping pulses do not continue for too long).  There 
are subtle differences, as usually with Intel, between APIC 
implementations that may have to be taken into account here.

 Also sharing at the vector level poses interesting issues, but that's 
different matter.

  Maciej
-

Previous thread: alternatives in modules by Denys Vlasenko on Tuesday, September 18, 2007 - 5:36 am. (2 messages)

Next thread: [PATCH] Consolidate sleeping routines in file locking code by Pavel Emelyanov on Tuesday, September 18, 2007 - 6:41 am. (5 messages)