Commit 8564ae09 authored by Alexander Gordeev's avatar Alexander Gordeev Committed by David S. Miller

qlcnic: Fix MSI-X initialization code

Function qlcnic_setup_tss_rss_intr() might enter endless
loop in case pci_enable_msix() contiguously returns a
positive number of MSI-Xs that could have been allocated.
Besides, the function contains 'err = -EIO;' assignment
that never could be reached. This update fixes the
aforementioned issues.

Cc: Shahed Shaikh <shahed.shaikh@qlogic.com>
Cc: Dept-HSGLinuxNICDev@qlogic.com
Cc: netdev@vger.kernel.org
Cc: linux-pci@vger.kernel.org
Signed-off-by: default avatarAlexander Gordeev <agordeev@redhat.com>
Acked-by: default avatarShahed Shaikh <shahed.shaikh@qlogic.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 54d63f78
...@@ -686,19 +686,15 @@ int qlcnic_setup_tss_rss_intr(struct qlcnic_adapter *adapter) ...@@ -686,19 +686,15 @@ int qlcnic_setup_tss_rss_intr(struct qlcnic_adapter *adapter)
return -ENOMEM; return -ENOMEM;
} }
restore:
for (vector = 0; vector < num_msix; vector++) for (vector = 0; vector < num_msix; vector++)
adapter->msix_entries[vector].entry = vector; adapter->msix_entries[vector].entry = vector;
restore:
err = pci_enable_msix(pdev, adapter->msix_entries, num_msix); err = pci_enable_msix(pdev, adapter->msix_entries, num_msix);
if (err == 0) { if (err > 0) {
adapter->ahw->num_msix = num_msix; if (!adapter->drv_tss_rings && !adapter->drv_rss_rings)
if (adapter->drv_tss_rings > 0) return -ENOSPC;
adapter->drv_tx_rings = adapter->drv_tss_rings;
if (adapter->drv_rss_rings > 0)
adapter->drv_sds_rings = adapter->drv_rss_rings;
} else {
netdev_info(adapter->netdev, netdev_info(adapter->netdev,
"Unable to allocate %d MSI-X vectors, Available vectors %d\n", "Unable to allocate %d MSI-X vectors, Available vectors %d\n",
num_msix, err); num_msix, err);
...@@ -716,12 +712,20 @@ int qlcnic_setup_tss_rss_intr(struct qlcnic_adapter *adapter) ...@@ -716,12 +712,20 @@ int qlcnic_setup_tss_rss_intr(struct qlcnic_adapter *adapter)
"Restoring %d Tx, %d SDS rings for total %d vectors.\n", "Restoring %d Tx, %d SDS rings for total %d vectors.\n",
adapter->drv_tx_rings, adapter->drv_sds_rings, adapter->drv_tx_rings, adapter->drv_sds_rings,
num_msix); num_msix);
goto restore;
err = -EIO; goto restore;
} else if (err < 0) {
return err;
} }
return err; adapter->ahw->num_msix = num_msix;
if (adapter->drv_tss_rings > 0)
adapter->drv_tx_rings = adapter->drv_tss_rings;
if (adapter->drv_rss_rings > 0)
adapter->drv_sds_rings = adapter->drv_rss_rings;
return 0;
} }
int qlcnic_enable_msix(struct qlcnic_adapter *adapter, u32 num_msix) int qlcnic_enable_msix(struct qlcnic_adapter *adapter, u32 num_msix)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment