[PATCH] Tweak re-routing of PCI interrupts

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Fri, 06 Jun 2003 14:13:31 -0400 (EDT)
I have a small tweak to the PCI code that re-routes PCI interrupts.
Basically, it does two things, 1) make the comment less ia64-specific
and 2) if the interrupt route returns an invalid IRQ (i.e. 255), then
we don't change the intline.  In other words, if we can't route the
interrupt, we just assume that the firmware knows more than we do and
go with the value it stuck in the register.  1) is a no-brainer, but
I wonder what people think about 2).  Patch below:

Index: pci.c
===================================================================
RCS file: /usr/cvs/src/sys/dev/pci/pci.c,v
retrieving revision 1.216
diff -u -r1.216 pci.c
--- pci.c       4 Jun 2003 21:10:15 -0000       1.216
+++ pci.c       6 Jun 2003 18:10:14 -0000
_at__at_ -782,7 +782,7 _at__at_
        pcicfgregs *cfg = &dinfo->cfg;
        struct resource_list *rl = &dinfo->resources;
        struct pci_quirk *q;
-       int b, i, f, s;
+       int b, i, irq, f, s;
 
        b = cfg->bus;
        s = cfg->slot;
_at__at_ -800,14 +800,18 _at__at_
        if (cfg->intpin > 0 && PCI_INTERRUPT_VALID(cfg->intline)) {
 #if defined(__ia64__) || (defined(__i386__) && !defined(SMP))
                /*
-                * Re-route interrupts on ia64 so that we can get the
-                * I/O SAPIC interrupt numbers (the BIOS leaves legacy
-                * PIC interrupt numbers in the intline registers).
+                * Try to re-route interrupts. Sometimes the BIOS or
+                * firmware may leave bogus values in these registers.
+                * If the re-route fails, then just stick with what we
+                * have.
                 */
-               cfg->intline = PCIB_ROUTE_INTERRUPT(pcib, dev, cfg->intpin);
+               irq = PCIB_ROUTE_INTERRUPT(pcib, dev, cfg->intpin);
+               if (PCI_INTERRUPT_VALID(irq))
+                       cfg->intline = irq;
+               else
 #endif
-               resource_list_add(rl, SYS_RES_IRQ, 0, cfg->intline,
-                 cfg->intline, 1);
+                       irq = cfg->intline;
+               resource_list_add(rl, SYS_RES_IRQ, 0, irq, irq, 1);
        }
 }
 


-- 

John Baldwin <jhb_at_FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/
Received on Fri Jun 06 2003 - 09:13:36 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:10 UTC