pci intr config: Fix an off by one bug
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 4 Feb 2009 10:39:27 +0000 (18:39 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 6 Feb 2009 10:42:53 +0000 (18:42 +0800)
FreeBSD pci_pir.c rev1.105
  We represent PCI intpin's two different ways.  One is the way that the
  intpin register is expressed in hardware where 0 means none, 1 means INTA,
  2 INTB, etc.  The other way is commonly used in loops where 0 means INTA,
  1 means INTB, etc.  The matchpin argument to pci_cfgintr_search() is
  supposed to be the first form, but we passsed in a loop index of the
  second.  This fix adds one to the loop index to convert to the first form.

  Reported by: Pavlin Radoslavov <pavlin@icir.org>

sys/bus/pci/amd64/pci_cfgreg.c
sys/bus/pci/i386/pci_cfgreg.c

index 03f7a05..0502b7a 100644 (file)
@@ -459,7 +459,7 @@ pci_cfgintr_linked(struct PIR_entry *pe, int pin)
                         * table entry
                         */
                        irq = pci_cfgintr_search(pe, oe->pe_bus, oe->pe_device,
-                                                j, pin);
+                                                j + 1, pin);
                        if (irq != PCI_INVALID_IRQ)
                                return (irq);
                }
index 596dd9e..db58834 100644 (file)
@@ -440,7 +440,7 @@ pci_cfgintr_linked(struct PIR_entry *pe, int pin)
                         * table entry
                         */
                        irq = pci_cfgintr_search(pe, oe->pe_bus, oe->pe_device,
-                                                j, pin);
+                                                j + 1, pin);
                        if (irq != PCI_INVALID_IRQ)
                                return (irq);
                }