pci irq conflicts

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Shaun
Member
Member
Posts: 43
Joined: Mon Sep 17, 2012 3:14 am
Contact:

pci irq conflicts

Post 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!
Last edited by Shaun on Wed Dec 18, 2013 1:52 am, edited 1 time in total.
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: pci irq conficts

Post 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).
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
User avatar
Shaun
Member
Member
Posts: 43
Joined: Mon Sep 17, 2012 3:14 am
Contact:

Re: pci irq conficts

Post 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?
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: pci irq conflicts

Post 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).
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Post Reply