From b2d5c6bc2aa8c4728acf4f5741f51c3dcc96a3b0 Mon Sep 17 00:00:00 2001 From: jfv Date: Tue, 6 Aug 2013 21:01:38 +0000 Subject: 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 --- sys/dev/e1000/if_igb.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'sys/dev/e1000/if_igb.c') 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); } -- cgit v1.1