Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 06 Jun 2003 14:13:31 -0400 (EDT)
From:      John Baldwin <jhb@FreeBSD.org>
To:        current@FreeBSD.org, imp@FreeBSD.org
Subject:   [PATCH] Tweak re-routing of PCI interrupts
Message-ID:  <XFMail.20030606141331.jhb@FreeBSD.org>

next in thread | raw e-mail | index | archive | help
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
@@ -782,7 +782,7 @@
        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;
@@ -800,14 +800,18 @@
        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@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/



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