Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 Dec 2005 09:01:45 -0500
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-current@freebsd.org
Cc:        julian@elischer.org, "M. Warner Losh" <imp@bsdimp.com>
Subject:   Re: can someone explain...[ PCI interrupts]
Message-ID:  <200512070901.47271.jhb@freebsd.org>
In-Reply-To: <20051206.231644.34762139.imp@bsdimp.com>
References:  <43961758.4020407@elischer.org> <20051206.231644.34762139.imp@bsdimp.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wednesday 07 December 2005 01:16 am, M. Warner Losh wrote:
> In message: <43961758.4020407@elischer.org>
>
>             Julian Elischer <julian@elischer.org> writes:
> : How much is set up by the BIOS and how much is set up by the OS (4.x and
> : -current).
>
> On 4.x, the BIOS (PCI BIOS) is called to route interrupts from the PIR
> table when such a table exists.  On current, ACPI routines are called
> (if acpi is enabled), with a fallback to the PIR.  Both use the
> MPTABLE when an APIC i in voled.

Actually, the MP Table is only used for !ACPI.  For ACPI + APIC, you enumer=
ate=20
APICs (both local and I/O) via the MADT, and for each I/O APIC, the MADT=20
specifies the IRQ cookie value of the first intpin.  Then, you call the _PI=
C=20
method to tell the BIOS you are using the APICs.  Then, all the _PRT method=
s=20
check a saved copy of that argument to _PIC and return different arrays=20
(packages in ACPI parlance) based on that, so that the _PRT's basically=20
return two different things for the two different modes.  The MP Table isn'=
t=20
used at all.

> : In this world of multiple PCI to PCI bridges, how much latitude doe the
> : OS have in
> : deciding where an interrupt turns up?
> : (in 4.x and -current)
>
> Somehwere between none and a bunch.  It all has to do with what
> interrupt controllers are available and how the interrupt lines are
> wired.  Some systems force you to use the 'barberpole' for interrupts,
> while others wire them all to the same interrupts while others allow
> smome limited sleections.

Well, links have limited selection, everything else is hard-wired. :)

> : Who is making those decisions? Is it the BIOS and 4.x is just playing
> : along?
>
> Kinda, except when it isn't.  The BIOS usually assigns an interrupt,
> and we play along.  However, usually is a lot less often than it used
> to be so we're now more typically routing ourselves.

Well, we use the BIOS set IRQs for heuristics.  For example, $PIR has no wa=
y=20
of telling you what IRQ given link is already routed to, so when we probe t=
he=20
$PIR, we do a bunch of PCI config accesses to the IRQ register to sniff out=
=20
what it looks like the BIOS has done and then use those IRQs for link=20
devices.  For ACPI we do the same thing as a fallback for when _CRS on a li=
nk=20
device doesn't work.  This approach only works for links routed via ISA IRQ=
s=20
though.  For APIC routing (except for the early SMP boxes that still used=20
only ISA IRQs), the BIOS IRQ values are worthless so we ignore them.

> : Linux and -current on teh same box a;;ocate way different irqs, and
> : they agree about it.. i.e. Linux and -current assign my 4 port card IRQs
> : 18,19,19,16.
>
> Resources are alloacted differently between the OS and the BIOS.
> Looks like Linux has a slightly different algorithm for assigning
> interrupts to free APIC pins.  Notice that in all cases the middle two
> are shared.  That detail is likely in the MPTables for the device in
> question.

Linux is doing what FreeBSD 5.2+ does. :)   Here what is happening is that =
we=20
are doing the swizzle across the PCI-PCI bridge on the 4-port card and=20
routing on the parent sideof the bridge via ACPI or MP Table.  It sounds li=
ke=20
this 4-port card does something brain damaged such that the middle two=20
devices swizzle to the same INTx on the parent side of the bridge.  (E.g.,=
=20
the devices are at "slots" 0, 1, 5, 6 on the card instead of the more typic=
al=20
0, 1, 2, 3.  It could also be that it is 0, 1, 2, 3, but device 2 is using=
=20
INTD rather than INTA.)

=2D-=20
John Baldwin <jhb@FreeBSD.org> =A0<>< =A0http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve" =A0=3D =A0http://www.FreeBSD.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200512070901.47271.jhb>