Skip to content

Commit 0c2cc02

Browse files
Alexander DuyckJeff Kirsher
authored andcommitted
igb: Move the calls to set the Tx and Rx queues into igb_open
This change helps to address locking issues seen with netif_set_real_num_tx_queues and netif_set_real_num_rx_queues when used in the igb_set_interrupt_capability function. To resolve these locking issues I have moved the two function calls into __igb_open so that they can be called while the RTNL lock is held. An added advantage to this is that the number of queues is not updated until the last possible moment so if there are any issues in allocating MSI-X interrupts or resources for the rings we have time to change the values prior to updating the netdev. Signed-off-by: Alexander Duyck <[email protected]> Tested-by: Aaron Brown <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 5536d21 commit 0c2cc02

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

drivers/net/ethernet/intel/igb/igb_main.c

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ static void igb_clear_interrupt_scheme(struct igb_adapter *adapter)
948948
* Attempt to configure interrupts using the best available
949949
* capabilities of the hardware and kernel.
950950
**/
951-
static int igb_set_interrupt_capability(struct igb_adapter *adapter)
951+
static void igb_set_interrupt_capability(struct igb_adapter *adapter)
952952
{
953953
int err;
954954
int numvecs, i;
@@ -985,7 +985,7 @@ static int igb_set_interrupt_capability(struct igb_adapter *adapter)
985985
adapter->msix_entries,
986986
numvecs);
987987
if (err == 0)
988-
goto out;
988+
return;
989989

990990
igb_reset_interrupt_capability(adapter);
991991

@@ -1015,14 +1015,6 @@ static int igb_set_interrupt_capability(struct igb_adapter *adapter)
10151015
adapter->num_q_vectors = 1;
10161016
if (!pci_enable_msi(adapter->pdev))
10171017
adapter->flags |= IGB_FLAG_HAS_MSI;
1018-
out:
1019-
/* Notify the stack of the (possibly) reduced queue counts. */
1020-
rtnl_lock();
1021-
netif_set_real_num_tx_queues(adapter->netdev, adapter->num_tx_queues);
1022-
err = netif_set_real_num_rx_queues(adapter->netdev,
1023-
adapter->num_rx_queues);
1024-
rtnl_unlock();
1025-
return err;
10261018
}
10271019

10281020
static void igb_add_ring(struct igb_ring *ring,
@@ -1212,9 +1204,7 @@ static int igb_init_interrupt_scheme(struct igb_adapter *adapter)
12121204
struct pci_dev *pdev = adapter->pdev;
12131205
int err;
12141206

1215-
err = igb_set_interrupt_capability(adapter);
1216-
if (err)
1217-
return err;
1207+
igb_set_interrupt_capability(adapter);
12181208

12191209
err = igb_alloc_q_vectors(adapter);
12201210
if (err) {
@@ -2543,6 +2533,17 @@ static int __igb_open(struct net_device *netdev, bool resuming)
25432533
if (err)
25442534
goto err_req_irq;
25452535

2536+
/* Notify the stack of the actual queue counts. */
2537+
err = netif_set_real_num_tx_queues(adapter->netdev,
2538+
adapter->num_tx_queues);
2539+
if (err)
2540+
goto err_set_queues;
2541+
2542+
err = netif_set_real_num_rx_queues(adapter->netdev,
2543+
adapter->num_rx_queues);
2544+
if (err)
2545+
goto err_set_queues;
2546+
25462547
/* From here on the code is the same as igb_up() */
25472548
clear_bit(__IGB_DOWN, &adapter->state);
25482549

@@ -2572,6 +2573,8 @@ static int __igb_open(struct net_device *netdev, bool resuming)
25722573

25732574
return 0;
25742575

2576+
err_set_queues:
2577+
igb_free_irq(adapter);
25752578
err_req_irq:
25762579
igb_release_hw_control(adapter);
25772580
igb_power_down_link(adapter);
@@ -6841,7 +6844,9 @@ static int igb_resume(struct device *dev)
68416844
wr32(E1000_WUS, ~0);
68426845

68436846
if (netdev->flags & IFF_UP) {
6847+
rtnl_lock();
68446848
err = __igb_open(netdev, true);
6849+
rtnl_unlock();
68456850
if (err)
68466851
return err;
68476852
}

0 commit comments

Comments
 (0)