* [Intel-wired-lan] [PATCH iwl-next v1 1/1] igc: Refactor runtime power management flow
@ 2024-02-11 7:30 Sasha Neftin
2024-02-20 11:06 ` naamax.meir
0 siblings, 1 reply; 2+ messages in thread
From: Sasha Neftin @ 2024-02-11 7:30 UTC (permalink / raw)
To: intel-wired-lan; +Cc: Sasha Neftin
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>
---
drivers/net/ethernet/intel/igc/igc_main.c | 32 +++++++++++------------
1 file changed, 15 insertions(+), 17 deletions(-)
diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
index ba8d3fe186ae..7bd69a4d1ef0 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -5943,15 +5943,6 @@ static int __igc_open(struct net_device *netdev, bool resuming)
if (err)
goto err_req_irq;
- /* Notify the stack of the actual queue counts. */
- err = netif_set_real_num_tx_queues(netdev, adapter->num_tx_queues);
- if (err)
- goto err_set_queues;
-
- err = netif_set_real_num_rx_queues(netdev, adapter->num_rx_queues);
- if (err)
- goto err_set_queues;
-
clear_bit(__IGC_DOWN, &adapter->state);
for (i = 0; i < adapter->num_q_vectors; i++)
@@ -5972,8 +5963,6 @@ static int __igc_open(struct net_device *netdev, bool resuming)
return IGC_SUCCESS;
-err_set_queues:
- igc_free_irq(adapter);
err_req_irq:
igc_release_hw_control(adapter);
igc_power_down_phy_copper_base(&adapter->hw);
@@ -5990,6 +5979,17 @@ static int __igc_open(struct net_device *netdev, bool resuming)
int igc_open(struct net_device *netdev)
{
+ struct igc_adapter *adapter = netdev_priv(netdev);
+ int err;
+
+ /* Notify the stack of the actual queue counts. */
+ err = netif_set_real_num_queues(netdev, adapter->num_tx_queues,
+ adapter->num_rx_queues);
+ if (err) {
+ netdev_err(netdev, "error setting real queue count\n");
+ return err;
+ }
+
return __igc_open(netdev, false);
}
@@ -7191,13 +7191,11 @@ static int __maybe_unused igc_resume(struct device *dev)
wr32(IGC_WUS, ~0);
- rtnl_lock();
- if (!err && netif_running(netdev))
+ if (netif_running(netdev)) {
err = __igc_open(netdev, true);
-
- if (!err)
- netif_device_attach(netdev);
- rtnl_unlock();
+ if (!err)
+ netif_device_attach(netdev);
+ }
return err;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Intel-wired-lan] [PATCH iwl-next v1 1/1] igc: Refactor runtime power management flow
2024-02-11 7:30 [Intel-wired-lan] [PATCH iwl-next v1 1/1] igc: Refactor runtime power management flow Sasha Neftin
@ 2024-02-20 11:06 ` naamax.meir
0 siblings, 0 replies; 2+ messages in thread
From: naamax.meir @ 2024-02-20 11:06 UTC (permalink / raw)
To: Sasha Neftin, intel-wired-lan
On 2/11/2024 09:30, Sasha Neftin wrote:
> 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>
> ---
> drivers/net/ethernet/intel/igc/igc_main.c | 32 +++++++++++------------
> 1 file changed, 15 insertions(+), 17 deletions(-)
Tested-by: Naama Meir <naamax.meir@linux.intel.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-02-20 11:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-11 7:30 [Intel-wired-lan] [PATCH iwl-next v1 1/1] igc: Refactor runtime power management flow Sasha Neftin
2024-02-20 11:06 ` naamax.meir
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox