Page 1 of 1

pci irq conflicts

Posted: Wed Dec 18, 2013 1:16 am
by Shaun
hi,genius!

I have got a little bit trouble in my os driver these days.
My os currently support both ahci controller and e1000 NIC. The problem is that both these two devices are connected to pci bus, and when i use lspci in qemu, i see they use the same irq(11) :? . so, how could i figure out which device fire the irq in irq service routine.
I read on wiki and google, the solution is that i should use irq routing table, but god, how!!!

Any solution or pseudo-code code is appreciate. Thanks!

Re: pci irq conficts

Posted: Wed Dec 18, 2013 1:23 am
by thepowersgang
You don't even need to do that. When an IRQ fires, you run both interrupt handlers. The handlers then ask the devices "what events were raised" (by reading the devices interrupt status field) and then do work accordingly. If the interrupt wasn't actually from that device, it'll do nothing here (and the other device's handeler will do something).

Re: pci irq conficts

Posted: Wed Dec 18, 2013 1:47 am
by Shaun
thepowersgang wrote:You don't even need to do that. When an IRQ fires, you run both interrupt handlers. The handlers then ask the devices "what events were raised" (by reading the devices interrupt status field) and then do work accordingly. If the interrupt wasn't actually from that device, it'll do nothing here (and the other device's handeler will do something).
you mean that i should call both these two device interrupt handler in my irq 11 service routine? like:

isr_11_routine()
{
call ahci interrupt handler();
call e1000 interrupt handler();
}

this could solve my problem. Could this way may take pressure on system performance?

BTW, does this mean irq sharing?

i have another idea, could i solve the conflicts by changing the irq number in pci configuration to another one? Is this way reasonable?

Re: pci irq conflicts

Posted: Wed Dec 18, 2013 2:00 am
by thepowersgang
You could change the IRQ line used (there's four iirc), but sharing generally isn't much of a load issue. It's a good idea to minimise work done in interrupt handlers (either set a semaphore/event for a worker thread, or do trivial pointer manipulation if you can).