diff options
author | Jack F Vogel <jfv@FreeBSD.org> | 2013-08-06 21:01:38 +0000 |
---|---|---|
committer | Jack F Vogel <jfv@FreeBSD.org> | 2013-08-06 21:01:38 +0000 |
commit | d0913b7f25a79ca21528c5abb4f3b796e5195583 (patch) | |
tree | beb42fd601350ce40c8c5b11ba59224708400ec5 /sys/dev/ixgbe | |
parent | 0cfcfc19187b534c65dd6bf1c4573933f80d78a3 (diff) | |
download | src-d0913b7f25a79ca21528c5abb4f3b796e5195583.tar.gz src-d0913b7f25a79ca21528c5abb4f3b796e5195583.zip |
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
Notes
Notes:
svn path=/head/; revision=254008
Diffstat (limited to 'sys/dev/ixgbe')
-rw-r--r-- | sys/dev/ixgbe/ixgbe.c | 35 | ||||
-rw-r--r-- | sys/dev/ixgbe/ixv.c | 18 |
2 files changed, 26 insertions, 27 deletions
diff --git a/sys/dev/ixgbe/ixgbe.c b/sys/dev/ixgbe/ixgbe.c index 9ac585aca2c5..ca4aa660ad9d 100644 --- a/sys/dev/ixgbe/ixgbe.c +++ b/sys/dev/ixgbe/ixgbe.c @@ -2415,29 +2415,24 @@ ixgbe_setup_msix(struct adapter *adapter) goto msi; /* First try MSI/X */ + msgs = pci_msix_count(dev); + if (msgs == 0) + goto msi; rid = PCIR_BAR(MSIX_82598_BAR); adapter->msix_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); - if (!adapter->msix_mem) { + if (adapter->msix_mem == NULL) { rid += 4; /* 82599 maps in higher 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, - rid, 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; @@ -2459,21 +2454,27 @@ ixgbe_setup_msix(struct adapter *adapter) "MSIX Configuration Problem, " "%d vectors but %d queues wanted!\n", msgs, want); - return (0); /* Will go to Legacy setup */ + 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); } 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, + rid, adapter->msix_mem); + adapter->msix_mem = NULL; + } + msgs = 1; + if (pci_alloc_msi(dev, &msgs) == 0) { device_printf(adapter->dev,"Using an MSI interrupt\n"); - else - device_printf(adapter->dev,"Using a Legacy interrupt\n"); - return (msgs); + return (msgs); + } + device_printf(adapter->dev,"Using a Legacy interrupt\n"); + return (0); } diff --git a/sys/dev/ixgbe/ixv.c b/sys/dev/ixgbe/ixv.c index e51cdb3066eb..20131aa41cb9 100644 --- a/sys/dev/ixgbe/ixv.c +++ b/sys/dev/ixgbe/ixv.c @@ -1686,37 +1686,35 @@ static int ixv_setup_msix(struct adapter *adapter) { device_t dev = adapter->dev; - int rid, vectors, want = 2; + int rid, want; /* First try MSI/X */ rid = PCIR_BAR(3); adapter->msix_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); - if (!adapter->msix_mem) { + if (adapter->msix_mem == NULL) { device_printf(adapter->dev, "Unable to map MSIX table \n"); goto out; } - vectors = pci_msix_count(dev); - if (vectors < 2) { - bus_release_resource(dev, SYS_RES_MEMORY, - rid, adapter->msix_mem); - adapter->msix_mem = NULL; - goto out; - } - /* ** Want two vectors: one for a queue, ** plus an additional for mailbox. */ + want = 2; if (pci_alloc_msix(dev, &want) == 0) { device_printf(adapter->dev, "Using MSIX interrupts with %d vectors\n", want); return (want); } out: + if (adapter->msix_mem != NULL) { + bus_release_resource(dev, SYS_RES_MEMORY, + rid, adapter->msix_mem); + adapter->msix_mem = NULL; + } device_printf(adapter->dev,"MSIX config error\n"); return (ENXIO); } |