summaryrefslogtreecommitdiffstats
path: root/sys/dev/e1000/if_igb.c
diff options
context:
space:
mode:
authorjfv <jfv@FreeBSD.org>2013-08-06 21:01:38 +0000
committerjfv <jfv@FreeBSD.org>2013-08-06 21:01:38 +0000
commitb2d5c6bc2aa8c4728acf4f5741f51c3dcc96a3b0 (patch)
treebeb42fd601350ce40c8c5b11ba59224708400ec5 /sys/dev/e1000/if_igb.c
parent281e37952d1ff13b3d56914bf7e8c9a8dc15460a (diff)
downloadFreeBSD-src-b2d5c6bc2aa8c4728acf4f5741f51c3dcc96a3b0.zip
FreeBSD-src-b2d5c6bc2aa8c4728acf4f5741f51c3dcc96a3b0.tar.gz
Make the various driver MSIX setup routines fallback to MSI more
gracefully. This change was suggested by Marius Strobl, thank you. PR: kern/181016 MFC after: ASAP
Diffstat (limited to 'sys/dev/e1000/if_igb.c')
-rw-r--r--sys/dev/e1000/if_igb.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/sys/dev/e1000/if_igb.c b/sys/dev/e1000/if_igb.c
index 4e8bd0f..d524832 100644
--- a/sys/dev/e1000/if_igb.c
+++ b/sys/dev/e1000/if_igb.c
@@ -2842,24 +2842,19 @@ igb_setup_msix(struct adapter *adapter)
goto msi;
/* First try MSI/X */
+ msgs = pci_msix_count(dev);
+ if (msgs == 0)
+ goto msi;
rid = PCIR_BAR(IGB_MSIX_BAR);
adapter->msix_mem = bus_alloc_resource_any(dev,
SYS_RES_MEMORY, &rid, RF_ACTIVE);
- if (!adapter->msix_mem) {
+ if (adapter->msix_mem == NULL) {
/* May not be enabled */
device_printf(adapter->dev,
"Unable to map MSIX table \n");
goto msi;
}
- msgs = pci_msix_count(dev);
- if (msgs == 0) { /* system has msix disabled */
- bus_release_resource(dev, SYS_RES_MEMORY,
- PCIR_BAR(IGB_MSIX_BAR), adapter->msix_mem);
- adapter->msix_mem = NULL;
- goto msi;
- }
-
/* Figure out a reasonable auto config value */
queues = (mp_ncpus > (msgs-1)) ? (msgs-1) : mp_ncpus;
@@ -2902,20 +2897,27 @@ igb_setup_msix(struct adapter *adapter)
"MSIX Configuration Problem, "
"%d vectors configured, but %d queues wanted!\n",
msgs, want);
- return (0);
+ goto msi;
}
- if ((msgs) && pci_alloc_msix(dev, &msgs) == 0) {
+ if (pci_alloc_msix(dev, &msgs) == 0) {
device_printf(adapter->dev,
"Using MSIX interrupts with %d vectors\n", msgs);
adapter->num_queues = queues;
return (msgs);
}
+ /* Fallback to MSI configuration */
msi:
- msgs = pci_msi_count(dev);
- if (msgs == 1 && pci_alloc_msi(dev, &msgs) == 0) {
+ if (adapter->msix_mem != NULL) {
+ bus_release_resource(dev, SYS_RES_MEMORY,
+ PCIR_BAR(IGB_MSIX_BAR), adapter->msix_mem);
+ adapter->msix_mem = NULL;
+ }
+ msgs = 1;
+ if (pci_alloc_msi(dev, &msgs) == 0) {
device_printf(adapter->dev," Using MSI interrupt\n");
return (msgs);
}
+ /* Default to a legacy interrupt */
return (0);
}
OpenPOWER on IntegriCloud