public inbox for linux-newbie@vger.kernel.org
 help / color / mirror / Atom feed
From: Rene Herman <rene.herman@keyaccess.nl>
To: Rajat Jain <Rajat.Jain@infogain.com>
Cc: kernelnewbies@nl.linux.org, linux-newbie@vger.kernel.org
Subject: Re: PCI interrupt queries
Date: Tue, 19 Aug 2008 22:34:04 +0200	[thread overview]
Message-ID: <48AB2E3C.2070600@keyaccess.nl> (raw)
In-Reply-To: <C86899CCB10A6C4E93D5978DCB232D4B091A399F@GDCMX01.igglobal.com>

On 19-08-08 07:11, Rajat Jain wrote:

> I want to understand who decides the IRQ number that a agiven PCI
> card will use. I understand that from a PCI device drivers point of
> view, it'll find the IRQ vector that it needs to attach by reading it
> from the configuration space of the device.

Actually, a quick look at struct pci_dev suggests you should be using 
pci_dev->irq. Note sure why that is; maybe odd bridged setups.

Greg might know if he's reading this :-)

> 1) My first question is WHO writes that IRQ value in the device 
> configuration space? Is it hardwired on the card? Is it written by
> the PCI controller driver or some other kernel component? Or some
> other piece of software takes care of it?

The thing hardwired on the card is the interrupt PIN(s) it uses; A, B, C 
and/or D (one pin per device and thus per config space). The thing that 
writes the LINE value into the register is generally the BIOS; being 
motherboard specific it knows which IRQ line it is that pin X (A, B, C 
or D) from slot N is routed to and it writes those values back into the 
device.

Well, basically at least. It knows as long as it has programmed the 
interrupt router itself as well:

> 2) Secondly, irrespective of whoever writes it, what determines the irq
> vector VALUE that will be written? So given that a PCI card uses PCI
> INTA, what determines the IRQ vector associated with it? My
> understanding is that the board specifications say something like "The
> INTA from this PCI slot goes to IRQx input of interrupt controller". And
> then from interrupt controller dosument we can find out which IRQ vector
> is associated with input IRQx. Is this right?

That's the basic form but in reality things are not hardwired on the 
motherboard either; there's a programmable interrupt router (part of the 
PCI chipset) between the lines coming from the bus and the lines going 
into the interrupt controller that enables software control of the routing.

So the answer is -- whoever sets up the interrupt routing. In your dmesg 
you will see things like:

ACPI: PCI Interrupt Routing Table [\_SB_.PCI0._PRT]
ACPI: PCI Interrupt Link [LNKA] (IRQs 3 4 5 6 7 *9 10 11 12 14 15)
ACPI: PCI Interrupt Link [LNKB] (IRQs 3 4 5 6 7 9 10 *11 12 14 15)
ACPI: PCI Interrupt Link [LNKC] (IRQs 3 4 5 6 7 9 *10 11 12 14 15)
ACPI: PCI Interrupt Link [LNKD] (IRQs 3 4 5 6 7 9 10 11 *12 14 15)

which lists the routing as setup by the BIOS. Linux _could_ change the 
routing although I'm not sure if it ever does. What it certainly can do 
is enable devices that the BIOS left disabled (wish it couldn't so it 
would butt out already!) and then it is running the show.

> 3) Lastly, if we boot linux and a different OS, on the same board with
> the same PCI card plugged in, are they bound to use the same IRQ number?
> Why or why not?

Not bound then. The programmable interrupt router could be set up 
differently.

Also see the nice daisy-chaining diagram in

	Documentation/x86/i386/IO-APIC.txt

The programmable interrupt router is to the left, between the PIRQ lines 
and the IRQ input lines on the PIC.

Rene.

--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

  reply	other threads:[~2008-08-19 20:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-19  5:11 PCI interrupt queries Rajat Jain
2008-08-19 20:34 ` Rene Herman [this message]
2008-08-20  4:50   ` Rajat Jain
2008-08-20 18:04     ` Rene Herman
2008-08-21  9:31     ` Welch, Martyn (GE EntSol, Intelligent Platforms)
2008-08-21 11:10       ` Rene Herman
2008-08-21 11:12         ` Welch, Martyn (GE EntSol, Intelligent Platforms)
2008-08-21 17:14       ` Om
2008-08-21  5:42 ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48AB2E3C.2070600@keyaccess.nl \
    --to=rene.herman@keyaccess.nl \
    --cc=Rajat.Jain@infogain.com \
    --cc=kernelnewbies@nl.linux.org \
    --cc=linux-newbie@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox