msix: Make sure vectors are not allocated before setup/teardown
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Tue, 17 Jan 2012 07:56:06 +0000 (15:56 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Tue, 17 Jan 2012 07:56:06 +0000 (15:56 +0800)
sys/bus/pci/pci.c

index 86081ad..46a1cea 100644 (file)
@@ -1614,6 +1614,10 @@ pci_setup_msix(device_t dev)
            !pci_do_msix)
                return (ENODEV);
 
+       KASSERT(cfg->msix.msix_alloc == 0 &&
+           TAILQ_EMPTY(&cfg->msix.msix_vectors),
+           ("MSI-X vector has been allocated\n"));
+
        /* Make sure the appropriate BARs are mapped. */
        rle = resource_list_find(&dinfo->resources, SYS_RES_MEMORY,
            cfg->msix.msix_table_bar);
@@ -1646,6 +1650,8 @@ pci_teardown_msix(device_t dev)
 
        KASSERT(msix->msix_table_res != NULL &&
            msix->msix_pba_res != NULL, ("MSI-X is not setup yet\n"));
+       KASSERT(msix->msix_alloc == 0 && TAILQ_EMPTY(&msix->msix_vectors),
+           ("MSI-X vector is still allocated\n"));
 
        pci_mask_msix_allvectors(dev);