pci/pir: Make sure that the IRQ is allowed to be configured
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Tue, 28 Aug 2012 04:46:20 +0000 (12:46 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Tue, 28 Aug 2012 04:46:20 +0000 (12:46 +0800)
If the IRQ is already configured into non-level/low mode, we should not
change the trigger and polarity

sys/bus/pci/i386/pci_pir.c
sys/bus/pci/x86_64/pci_pir.c

index 5c14d5b..225ce99 100644 (file)
@@ -36,6 +36,7 @@
 #include <sys/malloc.h>
 #include <sys/module.h>
 #include <sys/sysctl.h>
 #include <sys/malloc.h>
 #include <sys/module.h>
 #include <sys/sysctl.h>
+#include <sys/machintr.h>
 #include <vm/vm.h>
 #include <vm/pmap.h>
 #include <vm/vm_param.h>
 #include <vm/vm.h>
 #include <vm/pmap.h>
 #include <vm/vm_param.h>
@@ -537,6 +538,12 @@ pci_pir_route_interrupt(int bus, int device, int func, int pin)
 
        /* Ask the BIOS to route this IRQ if we haven't done so already. */
        if (!pci_link->pl_routed) {
 
        /* Ask the BIOS to route this IRQ if we haven't done so already. */
        if (!pci_link->pl_routed) {
+               if (machintr_legacy_intr_find(pci_link->pl_irq,
+                   INTR_TRIGGER_LEVEL, INTR_POLARITY_LOW) < 0) {
+                       kprintf("$PIR: can't find irq %d\n", pci_link->pl_irq);
+                       return PCI_INVALID_IRQ;
+               }
+
                error = pci_pir_biosroute(bus, device, func, pin - 1,
                    pci_link->pl_irq);
 
                error = pci_pir_biosroute(bus, device, func, pin - 1,
                    pci_link->pl_irq);
 
index 5c14d5b..225ce99 100644 (file)
@@ -36,6 +36,7 @@
 #include <sys/malloc.h>
 #include <sys/module.h>
 #include <sys/sysctl.h>
 #include <sys/malloc.h>
 #include <sys/module.h>
 #include <sys/sysctl.h>
+#include <sys/machintr.h>
 #include <vm/vm.h>
 #include <vm/pmap.h>
 #include <vm/vm_param.h>
 #include <vm/vm.h>
 #include <vm/pmap.h>
 #include <vm/vm_param.h>
@@ -537,6 +538,12 @@ pci_pir_route_interrupt(int bus, int device, int func, int pin)
 
        /* Ask the BIOS to route this IRQ if we haven't done so already. */
        if (!pci_link->pl_routed) {
 
        /* Ask the BIOS to route this IRQ if we haven't done so already. */
        if (!pci_link->pl_routed) {
+               if (machintr_legacy_intr_find(pci_link->pl_irq,
+                   INTR_TRIGGER_LEVEL, INTR_POLARITY_LOW) < 0) {
+                       kprintf("$PIR: can't find irq %d\n", pci_link->pl_irq);
+                       return PCI_INVALID_IRQ;
+               }
+
                error = pci_pir_biosroute(bus, device, func, pin - 1,
                    pci_link->pl_irq);
 
                error = pci_pir_biosroute(bus, device, func, pin - 1,
                    pci_link->pl_irq);