Skip to content

Commit 6f31d6b

Browse files
Sasha Neftinanguy11
authored andcommitted
igc: Refactor runtime power management flow
Following the corresponding discussion [1] and [2] refactor the 'igc_open' method and avoid taking the rtnl_lock() during the 'igc_resume' method. The rtnl_lock is held by the upper layer and could lead to the deadlock during resuming from a runtime power management flow. Notify the stack of the actual queue counts 'netif_set_real_num_*_queues' outside the '_igc_open' wrapper. This notification doesn't have to be called on each resume. Test: 1. Disconnect the ethernet cable 2. Enable the runtime power management via file system: echo auto > /sys/devices/pci0000\.../power/control 3. Check the device state (lspci -s <device> -vvv | grep -i Status) Link: https://lore.kernel.org/netdev/20231206113934.8d7819857574.I2deb5804 ef1739a2af307283d320ef7d82456494@changeid/#r [1] Link: https://lore.kernel.org/netdev/20211125074949.5f897431@kicinski-fedo ra-pc1c0hjn.dhcp.thefacebook.com/t/ [2] Signed-off-by: Sasha Neftin <sasha.neftin@intel.com> Tested-by: Naama Meir <naamax.meir@linux.intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent 75a3f93 commit 6f31d6b

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

drivers/net/ethernet/intel/igc/igc_main.c

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5929,15 +5929,6 @@ static int __igc_open(struct net_device *netdev, bool resuming)
59295929
if (err)
59305930
goto err_req_irq;
59315931

5932-
/* Notify the stack of the actual queue counts. */
5933-
err = netif_set_real_num_tx_queues(netdev, adapter->num_tx_queues);
5934-
if (err)
5935-
goto err_set_queues;
5936-
5937-
err = netif_set_real_num_rx_queues(netdev, adapter->num_rx_queues);
5938-
if (err)
5939-
goto err_set_queues;
5940-
59415932
clear_bit(__IGC_DOWN, &adapter->state);
59425933

59435934
for (i = 0; i < adapter->num_q_vectors; i++)
@@ -5958,8 +5949,6 @@ static int __igc_open(struct net_device *netdev, bool resuming)
59585949

59595950
return IGC_SUCCESS;
59605951

5961-
err_set_queues:
5962-
igc_free_irq(adapter);
59635952
err_req_irq:
59645953
igc_release_hw_control(adapter);
59655954
igc_power_down_phy_copper_base(&adapter->hw);
@@ -5976,6 +5965,17 @@ static int __igc_open(struct net_device *netdev, bool resuming)
59765965

59775966
int igc_open(struct net_device *netdev)
59785967
{
5968+
struct igc_adapter *adapter = netdev_priv(netdev);
5969+
int err;
5970+
5971+
/* Notify the stack of the actual queue counts. */
5972+
err = netif_set_real_num_queues(netdev, adapter->num_tx_queues,
5973+
adapter->num_rx_queues);
5974+
if (err) {
5975+
netdev_err(netdev, "error setting real queue count\n");
5976+
return err;
5977+
}
5978+
59795979
return __igc_open(netdev, false);
59805980
}
59815981

@@ -7181,13 +7181,11 @@ static int igc_resume(struct device *dev)
71817181

71827182
wr32(IGC_WUS, ~0);
71837183

7184-
rtnl_lock();
7185-
if (!err && netif_running(netdev))
7184+
if (netif_running(netdev)) {
71867185
err = __igc_open(netdev, true);
7187-
7188-
if (!err)
7189-
netif_device_attach(netdev);
7190-
rtnl_unlock();
7186+
if (!err)
7187+
netif_device_attach(netdev);
7188+
}
71917189

71927190
return err;
71937191
}

0 commit comments

Comments
 (0)