Skip to contentSkip to conversation

iavf: fix deadlock in reset handling

PATCH In review Petr Oros 7 participants 17 messages Feb 2 – Feb 7

Subsystems (3)
lore
Share & tools
lore

Petr Oros

author
#0 lore raw

PATCH 1/1 iavf: fix deadlock in reset handling

Three driver callbacks schedule a reset and wait for its completion:
ndo_change_mtu(), ethtool set_ringparam(), and ethtool set_channels().

Waiting for reset in ndo_change_mtu() and set_ringparam() was added by commit c2ed2403f12c74 ("iavf: Wait for reset in callbacks which trigger it") to fix a race condition where adding an interface to bonding immediately after MTU or ring parameter change failed because the interface was still in __RESETTING state. The same commit also added waiting in iavf_set_priv_flags(), which was later removed by commit 53844673d55529 ("iavf: kill "legacy-rx" for good").

Waiting in set_channels() was introduced earlier by commit 4e5e6b5d9d13 ("iavf: Fix return of set the new channel count") to ensure the PF has enough time to complete the VF reset when changing channel count, and to return correct error codes to userspace.

Commit ef490bbb226702 ("iavf: Add net_shaper_ops support") added net_shaper_ops to iavf, which required reset_task to use _locked NAPI variants (napi_enable_locked, napi_disable_locked) that need the netdev instance lock.

Later, commit 7e4d784f5810 ("net: hold netdev instance lock during rtnetlink operations") and commit 2bcf4772e45adb ("net: ethtool: try to protect all callback with netdev instance lock") started holding the netdev instance lock during ndo and ethtool callbacks for drivers with net_shaper_ops.

The combination of waiting for reset and the new locking requirements creates a deadlock: the callback holds the lock and waits for reset_task, but reset_task is blocked waiting for the same lock:

Thread 1 (callback) Thread 2 (reset_task)
------------------- ---------------------
netdev_lock()
ndo_change_mtu() or ethtool op
iavf_schedule_reset()
iavf_wait_for_reset() iavf_reset_task()
waiting... netdev_lock() <- DEADLOCK

Reproducer:

  # echo 16 > /sys/class/net/$PF/device/sriov_numvfs
  # ip link set $VF up
  # ip link set $VF mtu 5000
  RTNETLINK answers: Device or resource busy
  # dmesg | tail -1
  iavf: MTU change interrupted waiting for reset

Fix this by temporarily releasing the lock while waiting for reset to complete. This follows the pattern used elsewhere in the kernel (e.g., do_set_master() releases rtnl_lock before calling ndo_add_slave()).

Fixes 7e4d784f5810 ("net: hold netdev instance lock during rtnetlink operations")
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +12 -3
index 8aa6e92c16431f..d7738fb8fa60bc 100644
@@ -189,13 +189,22 @@ static bool iavf_is_reset_in_progress(struct iavf_adapter *adapter)
  * iavf_wait_for_reset - Wait for reset to finish.
  * @adapter: board private structure
  *
+ * The iavf driver selects NET_SHAPER, so callbacks that trigger reset are
+ * always called with netdev instance lock held, while reset_task also needs
+ * this lock. Release the lock while waiting to avoid deadlock.
+ *
  * Returns 0 if reset finished successfully, negative on timeout or interrupt.
  */
 int iavf_wait_for_reset(struct iavf_adapter *adapter)
 {
-	int ret = wait_event_interruptible_timeout(adapter->reset_waitqueue,
-					!iavf_is_reset_in_progress(adapter),
-					msecs_to_jiffies(5000));
+	struct net_device *netdev = adapter->netdev;
+	int ret;
+
+	netdev_unlock(netdev);
+	ret = wait_event_interruptible_timeout(adapter->reset_waitqueue,
+					       !iavf_is_reset_in_progress(adapter),
+					       msecs_to_jiffies(5000));
+	netdev_lock(netdev);
 
 	/* If ret < 0 then it means wait was interrupted.
 	 * If ret == 0 then it means we got a timeout while waiting
Signature · 1 line
2.52.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 123 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Petr Oros
Sent: Monday, February 2, 2026 9:48 AM
To: [email protected]
Cc: Vecera, Ivan <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Eric Dumazet <[email protected]>; [email protected]; Andrew Lunn <[email protected]>; Stanislav Fomichev <[email protected]>; Nguyen, Anthony L <[email protected]>; [email protected]; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; David S. Miller <[email protected]>
Subject: [Intel-wired-lan] [PATCH net] iavf: fix deadlock in reset handling

Three driver callbacks schedule a reset and wait for its completion:
ndo_change_mtu(), ethtool set_ringparam(), and ethtool set_channels().

Waiting for reset in ndo_change_mtu() and set_ringparam() was added by commit c2ed2403f12c74 ("iavf: Wait for reset in callbacks which trigger
it") to fix a race condition where adding an interface to bonding immediately after MTU or ring parameter change failed because the interface was still in __RESETTING state. The same commit also added waiting in iavf_set_priv_flags(), which was later removed by commit 53844673d55529 ("iavf: kill "legacy-rx" for good").

Waiting in set_channels() was introduced earlier by commit 4e5e6b5d9d13
("iavf: Fix return of set the new channel count") to ensure the PF has enough time to complete the VF reset when changing channel count, and to return correct error codes to userspace.

Commit ef490bbb226702 ("iavf: Add net_shaper_ops support") added net_shaper_ops to iavf, which required reset_task to use _locked NAPI variants (napi_enable_locked, napi_disable_locked) that need the netdev instance lock.

Later, commit 7e4d784f5810 ("net: hold netdev instance lock during rtnetlink operations") and commit 2bcf4772e45adb ("net: ethtool: try to protect all callback with netdev instance lock") started holding the netdev instance lock during ndo and ethtool callbacks for drivers with net_shaper_ops.

The combination of waiting for reset and the new locking requirements creates a deadlock: the callback holds the lock and waits for reset_task, but reset_task is blocked waiting for the same lock:

Thread 1 (callback) Thread 2 (reset_task)
------------------- ---------------------
netdev_lock()
ndo_change_mtu() or ethtool op
iavf_schedule_reset()
iavf_wait_for_reset() iavf_reset_task()
waiting... netdev_lock() <- DEADLOCK

Reproducer:

  # echo 16 > /sys/class/net/$PF/device/sriov_numvfs
  # ip link set $VF up
  # ip link set $VF mtu 5000
  RTNETLINK answers: Device or resource busy
  # dmesg | tail -1
  iavf: MTU change interrupted waiting for reset

Fix this by temporarily releasing the lock while waiting for reset to complete. This follows the pattern used elsewhere in the kernel (e.g.,
do_set_master() releases rtnl_lock before calling ndo_add_slave()).

Fixes 7e4d784f5810 ("net: hold netdev instance lock during

rtnetlink operations")

---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +1 -0
index 8aa6e92c16431f..d7738fb8fa60bc 100644
@@ -189,13 +189,22 @@ static bool iavf_is_reset_in_progress(struct
 iavf_adapter *adapter)
  * iavf_wait_for_reset - Wait for reset to finish.
  * @adapter: board private structure
  *
+ * The iavf driver selects NET_SHAPER, so callbacks that trigger

reset
+ are
+ * always called with netdev instance lock held, while reset_task also
+ needs
+ * this lock. Release the lock while waiting to avoid deadlock.
+ *
* Returns 0 if reset finished successfully, negative on timeout or
interrupt.
*/
int iavf_wait_for_reset(struct iavf_adapter *adapter) {

drivers/net/ethernet/intel/iavf/iavf_main.c +0 -1
-	int ret = wait_event_interruptible_timeout(adapter-
Quoted 1 line

reset_waitqueue,

-
!iavf_is_reset_in_progress(adapter),

drivers/net/ethernet/intel/iavf/iavf_main.c +5 -1
-					msecs_to_jiffies(5000));
+	struct net_device *netdev = adapter->netdev;
+	int ret;
+
+	netdev_unlock(netdev);
+	ret = wait_event_interruptible_timeout(adapter-
Quoted 1 line

reset_waitqueue,

+
!iavf_is_reset_in_progress(adapter),

drivers/net/ethernet/intel/iavf/iavf_main.c +2 -1
+					       msecs_to_jiffies(5000));
+	netdev_lock(netdev);
 
 	/* If ret < 0 then it means wait was interrupted.
 	 * If ret == 0 then it means we got a timeout while waiting
--
Quoted 1 line

2.52.0

Reviewed-by on v1 1/1
#2 lore raw
In reply to Petr Oros
Quoted 49 lines · Petr Oros

Three driver callbacks schedule a reset and wait for its completion:
ndo_change_mtu(), ethtool set_ringparam(), and ethtool set_channels().

Waiting for reset in ndo_change_mtu() and set_ringparam() was added by commit c2ed2403f12c74 ("iavf: Wait for reset in callbacks which trigger it") to fix a race condition where adding an interface to bonding immediately after MTU or ring parameter change failed because the interface was still in __RESETTING state. The same commit also added waiting in iavf_set_priv_flags(), which was later removed by commit 53844673d55529 ("iavf: kill "legacy-rx" for good").

Waiting in set_channels() was introduced earlier by commit 4e5e6b5d9d13 ("iavf: Fix return of set the new channel count") to ensure the PF has enough time to complete the VF reset when changing channel count, and to return correct error codes to userspace.

Commit ef490bbb226702 ("iavf: Add net_shaper_ops support") added net_shaper_ops to iavf, which required reset_task to use _locked NAPI variants (napi_enable_locked, napi_disable_locked) that need the netdev instance lock.

Later, commit 7e4d784f5810 ("net: hold netdev instance lock during rtnetlink operations") and commit 2bcf4772e45adb ("net: ethtool: try to protect all callback with netdev instance lock") started holding the netdev instance lock during ndo and ethtool callbacks for drivers with net_shaper_ops.

The combination of waiting for reset and the new locking requirements creates a deadlock: the callback holds the lock and waits for reset_task, but reset_task is blocked waiting for the same lock:

Thread 1 (callback) Thread 2 (reset_task)
------------------- ---------------------
netdev_lock()
ndo_change_mtu() or ethtool op
iavf_schedule_reset()
iavf_wait_for_reset() iavf_reset_task()
waiting... netdev_lock() <- DEADLOCK

Reproducer:

   # echo 16 > /sys/class/net/$PF/device/sriov_numvfs
   # ip link set $VF up
   # ip link set $VF mtu 5000
   RTNETLINK answers: Device or resource busy
   # dmesg | tail -1
   iavf: MTU change interrupted waiting for reset
Quoted 6 lines

Fix this by temporarily releasing the lock while waiting for reset to complete. This follows the pattern used elsewhere in the kernel (e.g., do_set_master() releases rtnl_lock before calling ndo_add_slave()).

Fixes 7e4d784f5810 ("net: hold netdev instance lock during rtnetlink operations")
Quoted 34 lines
---
  drivers/net/ethernet/intel/iavf/iavf_main.c | 15 ++++++++++++---
  1 file changed, 12 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +12 -3
index 8aa6e92c16431f..d7738fb8fa60bc 100644
@@ -189,13 +189,22 @@ static bool iavf_is_reset_in_progress(struct iavf_adapter *adapter)
   * iavf_wait_for_reset - Wait for reset to finish.
   * @adapter: board private structure
   *
+ * The iavf driver selects NET_SHAPER, so callbacks that trigger reset are
+ * always called with netdev instance lock held, while reset_task also needs
+ * this lock. Release the lock while waiting to avoid deadlock.
+ *
   * Returns 0 if reset finished successfully, negative on timeout or interrupt.
   */
  int iavf_wait_for_reset(struct iavf_adapter *adapter)
  {
-	int ret = wait_event_interruptible_timeout(adapter->reset_waitqueue,
-					!iavf_is_reset_in_progress(adapter),
-					msecs_to_jiffies(5000));
+	struct net_device *netdev = adapter->netdev;
+	int ret;
+
+	netdev_unlock(netdev);
+	ret = wait_event_interruptible_timeout(adapter->reset_waitqueue,
+					       !iavf_is_reset_in_progress(adapter),
+					       msecs_to_jiffies(5000));
+	netdev_lock(netdev);
 
  	/* If ret < 0 then it means wait was interrupted.
  	 * If ret == 0 then it means we got a timeout while waiting
Reviewed-by on v1 1/1
#3 lore raw
In reply to Petr Oros
Quoted 79 lines · Petr Oros

Three driver callbacks schedule a reset and wait for its completion:
ndo_change_mtu(), ethtool set_ringparam(), and ethtool set_channels().

Waiting for reset in ndo_change_mtu() and set_ringparam() was added by commit c2ed2403f12c74 ("iavf: Wait for reset in callbacks which trigger it") to fix a race condition where adding an interface to bonding immediately after MTU or ring parameter change failed because the interface was still in __RESETTING state. The same commit also added waiting in iavf_set_priv_flags(), which was later removed by commit 53844673d55529 ("iavf: kill "legacy-rx" for good").

Waiting in set_channels() was introduced earlier by commit 4e5e6b5d9d13 ("iavf: Fix return of set the new channel count") to ensure the PF has enough time to complete the VF reset when changing channel count, and to return correct error codes to userspace.

Commit ef490bbb226702 ("iavf: Add net_shaper_ops support") added net_shaper_ops to iavf, which required reset_task to use _locked NAPI variants (napi_enable_locked, napi_disable_locked) that need the netdev instance lock.

Later, commit 7e4d784f5810 ("net: hold netdev instance lock during rtnetlink operations") and commit 2bcf4772e45adb ("net: ethtool: try to protect all callback with netdev instance lock") started holding the netdev instance lock during ndo and ethtool callbacks for drivers with net_shaper_ops.

The combination of waiting for reset and the new locking requirements creates a deadlock: the callback holds the lock and waits for reset_task, but reset_task is blocked waiting for the same lock:

Thread 1 (callback) Thread 2 (reset_task)
------------------- ---------------------
netdev_lock()
ndo_change_mtu() or ethtool op
iavf_schedule_reset()
iavf_wait_for_reset() iavf_reset_task()
waiting... netdev_lock() <- DEADLOCK

Reproducer:

   # echo 16 > /sys/class/net/$PF/device/sriov_numvfs
   # ip link set $VF up
   # ip link set $VF mtu 5000
   RTNETLINK answers: Device or resource busy
   # dmesg | tail -1
   iavf: MTU change interrupted waiting for reset

Fix this by temporarily releasing the lock while waiting for reset to complete. This follows the pattern used elsewhere in the kernel (e.g., do_set_master() releases rtnl_lock before calling ndo_add_slave()).

Fixes 7e4d784f5810 ("net: hold netdev instance lock during rtnetlink operations")
---
  drivers/net/ethernet/intel/iavf/iavf_main.c | 15 ++++++++++++---
  1 file changed, 12 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +5 -3
index 8aa6e92c16431f..d7738fb8fa60bc 100644
@@ -189,13 +189,22 @@ static bool iavf_is_reset_in_progress(struct iavf_adapter *adapter)
   * iavf_wait_for_reset - Wait for reset to finish.
   * @adapter: board private structure
   *
+ * The iavf driver selects NET_SHAPER, so callbacks that trigger reset are
+ * always called with netdev instance lock held, while reset_task also needs
+ * this lock. Release the lock while waiting to avoid deadlock.
+ *
   * Returns 0 if reset finished successfully, negative on timeout or interrupt.
   */
  int iavf_wait_for_reset(struct iavf_adapter *adapter)
  {
-	int ret = wait_event_interruptible_timeout(adapter->reset_waitqueue,
-					!iavf_is_reset_in_progress(adapter),
-					msecs_to_jiffies(5000));
+	struct net_device *netdev = adapter->netdev;

drivers/net/ethernet/intel/iavf/iavf_main.c static bool iavf_is_reset_in_progress(struct iavf_adapter *adapter) · line 210

Quoted 10 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +7 -0
+	int ret;
+
+	netdev_unlock(netdev);
+	ret = wait_event_interruptible_timeout(adapter->reset_waitqueue,
+					       !iavf_is_reset_in_progress(adapter),
+					       msecs_to_jiffies(5000));
+	netdev_lock(netdev);
 
  	/* If ret < 0 then it means wait was interrupted.
  	 * If ret == 0 then it means we got a timeout while waiting
maintainer
#4 lore raw
In reply to Petr Oros

drivers/net/ethernet/intel/iavf/iavf_main.c static bool iavf_is_reset_in_progress(struct iavf_adapter *adapter) · line 207

Quoted 5 lines · On Mon, 2 Feb 2026 09:48:20 +0100 Petr Oros wrote:
drivers/net/ethernet/intel/iavf/iavf_main.c +5 -0
+	netdev_unlock(netdev);
+	ret = wait_event_interruptible_timeout(adapter->reset_waitqueue,
+					       !iavf_is_reset_in_progress(adapter),
+					       msecs_to_jiffies(5000));
+	netdev_lock(netdev);

Dropping locks taken by the core around the driver callback is obviously unacceptable. SMH.

#5 lore raw
Quoted 9 lines · Jakub Kicinski

drivers/net/ethernet/intel/iavf/iavf_main.c static bool iavf_is_reset_in_progress(struct iavf_adapter *adapter) · line 207

Quoted 5 lines · On Mon, 2 Feb 2026 09:48:20 +0100 Petr Oros wrote:
drivers/net/ethernet/intel/iavf/iavf_main.c +5 -0
+	netdev_unlock(netdev);
+	ret = wait_event_interruptible_timeout(adapter->reset_waitqueue,
+					       !iavf_is_reset_in_progress(adapter),
+					       msecs_to_jiffies(5000));
+	netdev_lock(netdev);

Dropping locks taken by the core around the driver callback is obviously unacceptable. SMH.

Right. It seems like the correct fix is to either a) have reset take and hold the netdev lock (now that its distinct from the global RTNL lock) or b) refactor reset so that it can defer any of the netdev related stuff somehow.

author
#6 lore raw
Quoted 10 lines · Jacob Keller
Quoted 7 lines · Jakub Kicinski
Quoted 5 lines · On Mon,  2 Feb 2026 09:48:20 +0100 Petr Oros wrote:

+    netdev_unlock(netdev);
+    ret = wait_event_interruptible_timeout(adapter->reset_waitqueue,
+ !iavf_is_reset_in_progress(adapter),
+                           msecs_to_jiffies(5000));
+    netdev_lock(netdev);

Quoted 5 lines
Quoted 2 lines

Dropping locks taken by the core around the driver callback is obviously unacceptable. SMH.

Right. It seems like the correct fix is to either a) have reset take and hold the netdev lock (now that its distinct from the global RTNL lock) or b) refactor reset so that it can defer any of the netdev related stuff somehow.

I modeled this after the existing pattern in iavf_close() (ndo_stop), which also temporarily releases the netdev instance lock taken by the core to wait for an async operation to complete:

static int iavf_close(struct net_device *netdev) {
        netdev_assert_locked(netdev);
        ...
        iavf_down(adapter); iavf_change_state(adapter, __IAVF_DOWN_PENDING); iavf_free_traffic_irqs(adapter);

        netdev_unlock(netdev);

        status = wait_event_timeout(adapter->down_waitqueue, adapter->state == __IAVF_DOWN, msecs_to_jiffies(500));
        if (!status)
                netdev_warn(netdev, "Device resources not yet released\n"); netdev_lock(netdev);
        ...
}

This was introduced by commit 120f28a6f314fe ("iavf: get rid of the crit lock"), and ndo_stop is called with netdev instance lock held by the core just like ndo_change_mtu is. Could you clarify why the unlock-wait-lock pattern is acceptable in ndo_stop but not here?

maintainer
#7 lore raw
Quoted 12 lines · Petr Oros
Quoted 10 lines · Jacob Keller
Quoted 7 lines · Jakub Kicinski
Quoted 5 lines · On Mon,  2 Feb 2026 09:48:20 +0100 Petr Oros wrote:

+    netdev_unlock(netdev);
+    ret = wait_event_interruptible_timeout(adapter->reset_waitqueue,
+ !iavf_is_reset_in_progress(adapter),
+                           msecs_to_jiffies(5000));
+    netdev_lock(netdev);

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

Dropping locks taken by the core around the driver callback is obviously unacceptable. SMH.

Right. It seems like the correct fix is to either a) have reset take and hold the netdev lock (now that its distinct from the global RTNL lock) or b) refactor reset so that it can defer any of the netdev related stuff somehow.

I modeled this after the existing pattern in iavf_close() (ndo_stop), which also temporarily releases the netdev instance lock taken by the core to wait for an async operation to complete:

First of all, thank you for working on that, I was hit by the very same problem (no series yet), but my local fix is the same as of now.

I don't see an easy fix (w/o substantial driver refactor).

Quoted 21 lines

static int iavf_close(struct net_device *netdev) {
        netdev_assert_locked(netdev);
        ...
        iavf_down(adapter); iavf_change_state(adapter, __IAVF_DOWN_PENDING); iavf_free_traffic_irqs(adapter);

        netdev_unlock(netdev);

        status = wait_event_timeout(adapter->down_waitqueue, adapter->state == __IAVF_DOWN, msecs_to_jiffies(500)); if (!status)
                netdev_warn(netdev, "Device resources not yet
released\n");
        netdev_lock(netdev);
        ...
}

Quoted 1 line

This was introduced by commit 120f28a6f314fe ("iavf: get rid of the crit lock"), and ndo_stop is called with netdev instance lock held by the core just like ndo_change_mtu is.

technically it was introduced by commmit afc664987ab3 ("eth: iavf:
extend the netdev_lock usage")

Quoted 2 lines

Could you clarify why the unlock-wait- lock pattern is acceptable in ndo_stop but not here?

perhaps just closing netdev is a special kind of operation

Other thing is that the lock was added to allow further NAPI development, and one silly driver should not stop that effort. Sadly, we have not managed to re-design the driver yet. I would like to do so personally, but have much work accumulated/pending to free my time

author
#8 lore raw
Quoted 53 lines · Przemek Kitszel
Quoted 12 lines · Petr Oros
Quoted 10 lines · Jacob Keller
Quoted 7 lines · Jakub Kicinski
Quoted 5 lines · On Mon,  2 Feb 2026 09:48:20 +0100 Petr Oros wrote:

+    netdev_unlock(netdev);
+    ret = wait_event_interruptible_timeout(adapter->reset_waitqueue,
+ !iavf_is_reset_in_progress(adapter),
+                           msecs_to_jiffies(5000));
+    netdev_lock(netdev);

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

Dropping locks taken by the core around the driver callback is obviously unacceptable. SMH.

Right. It seems like the correct fix is to either a) have reset take and hold the netdev lock (now that its distinct from the global RTNL lock) or b) refactor reset so that it can defer any of the netdev related stuff somehow.

I modeled this after the existing pattern in iavf_close() (ndo_stop), which also temporarily releases the netdev instance lock taken by the core to wait for an async operation to complete:

First of all, thank you for working on that, I was hit by the very same problem (no series yet), but my local fix is the same as of now.

I don't see an easy fix (w/o substantial driver refactor).

Quoted 20 lines

static int iavf_close(struct net_device *netdev) {
         netdev_assert_locked(netdev);
         ...
         iavf_down(adapter); iavf_change_state(adapter, __IAVF_DOWN_PENDING); iavf_free_traffic_irqs(adapter);

         netdev_unlock(netdev);

         status = wait_event_timeout(adapter->down_waitqueue, adapter->state == __IAVF_DOWN, msecs_to_jiffies(500));
         if (!status)
                 netdev_warn(netdev, "Device resources not yet released\n"); netdev_lock(netdev);
         ...
}

Quoted 1 line

This was introduced by commit 120f28a6f314fe ("iavf: get rid of the crit lock"), and ndo_stop is called with netdev instance lock held by the core just like ndo_change_mtu is.

technically it was introduced by commmit afc664987ab3 ("eth: iavf:
extend the netdev_lock usage")

Quoted 2 lines

Could you clarify why the unlock-wait- lock pattern is acceptable in ndo_stop but not here?

Quoted 7 lines

perhaps just closing netdev is a special kind of operation

Other thing is that the lock was added to allow further NAPI development, and one silly driver should not stop that effort. Sadly, we have not managed to re-design the driver yet. I would like to do so personally, but have much work accumulated/pending to free my time

I agree, the unlock-wait-lock pattern is fundamentally flawed (I now understand why it is unacceptable) and should be avoided.

What can we do now?

* Eliminating the wait is not an option: As noted in the description of commit c2ed2403f12c, this wait was originally added to fix a race condition where adding an interface to bonding failed because the device remained in __RESETTING state after the callback returned.
* Passing the lock into reset is impractical: The reset path is triggered from numerous contexts, many of which are not under the netdev_lock, making this even more complex than a full refactor.

If dropping the lock is a no-go, the only viable path forward is to split the reset_task so that the waiting portion is decoupled from the netdev_lock critical section.

The fact remains that MTU configuration and ring parameter changes are currently broken in iavf. Changing the MTU on a Virtual Function is a fundamental configuration not an obscure edge case that can remain non-functional.

I would appreciate any further guidance on how you would prefer...

#9 lore raw
Quoted 47 lines · Petr Oros
Quoted 45 lines · Przemek Kitszel
Quoted 12 lines · Petr Oros
Quoted 10 lines · Jacob Keller
Quoted 7 lines · Jakub Kicinski
Quoted 5 lines · On Mon,  2 Feb 2026 09:48:20 +0100 Petr Oros wrote:

+    netdev_unlock(netdev);
+    ret = wait_event_interruptible_timeout(adapter->reset_waitqueue,
+ !iavf_is_reset_in_progress(adapter),
+                           msecs_to_jiffies(5000));
+    netdev_lock(netdev);

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

Dropping locks taken by the core around the driver callback is obviously unacceptable. SMH.

Right. It seems like the correct fix is to either a) have reset take and hold the netdev lock (now that its distinct from the global RTNL lock) or b) refactor reset so that it can defer any of the netdev related stuff somehow.

I modeled this after the existing pattern in iavf_close() (ndo_stop), which also temporarily releases the netdev instance lock taken by the core to wait for an async operation to complete:

First of all, thank you for working on that, I was hit by the very same problem (no series yet), but my local fix is the same as of now.

I don't see an easy fix (w/o substantial driver refactor).

Quoted 20 lines

static int iavf_close(struct net_device *netdev) {
         netdev_assert_locked(netdev);
         ...
         iavf_down(adapter); iavf_change_state(adapter, __IAVF_DOWN_PENDING); iavf_free_traffic_irqs(adapter);

         netdev_unlock(netdev);

         status = wait_event_timeout(adapter->down_waitqueue, adapter->state == __IAVF_DOWN, msecs_to_jiffies(500));
         if (!status)
                 netdev_warn(netdev, "Device resources not yet released\n"); netdev_lock(netdev);
         ...
}

Quoted 7 lines
Quoted 7 lines
Quoted 1 line

This was introduced by commit 120f28a6f314fe ("iavf: get rid of the crit lock"), and ndo_stop is called with netdev instance lock held by the core just like ndo_change_mtu is.

technically it was introduced by commmit afc664987ab3 ("eth: iavf:
extend the netdev_lock usage")

Quoted 2 lines

Could you clarify why the unlock-wait- lock pattern is acceptable in ndo_stop but not here?

It may simply be that no one spotted it in ndo_stop.

Quoted 12 lines
Quoted 8 lines

perhaps just closing netdev is a special kind of operation

Other thing is that the lock was added to allow further NAPI development, and one silly driver should not stop that effort. Sadly, we have not managed to re-design the driver yet. I would like to do so personally, but have much work accumulated/pending to free my time

I agree, the unlock-wait-lock pattern is fundamentally flawed (I now understand why it is unacceptable) and should be avoided.

Quoted 1 line

What can we do now?

Quoted 7 lines

* Eliminating the wait is not an option: As noted in the description of commit c2ed2403f12c, this wait was originally added to fix a race condition where adding an interface to bonding failed because the device remained in __RESETTING state after the callback returned.
* Passing the lock into reset is impractical: The reset path is triggered from numerous contexts, many of which are not under the netdev_lock, making this even more complex than a full refactor.

Hm. I was thinking we could just hold the netdev lock for the reset, but... we already take the netdev lock there as of commit ef490bbb2267 ("iavf: Add net_shaper_ops support").

That's actually what causes the deadlock: prior to that change reset didn't hold the netdev lock for the duration. This is what gets us stuck. We are waiting for reset to finish while holding the lock that blocks the reset.

But I am not really sure how to fix this: We want change MTU to only return once reset is complete.. but reset is dependent on the very lock that we're holding. And there's no way to communicate this fact to the reset handler...

Quoted 5 lines

If dropping the lock is a no-go, the only viable path forward is to split the reset_task so that the waiting portion is decoupled from the netdev_lock critical section.

We used to do this back before the netdev shaper ops. We didn't acquire either netdev lock or RTNL during reset.

I thought we had some code in the past that would handle netdev stuff outside of reset.. but I don't really know and git blame is not making it easy to find this information.

Perhaps we don't actually need to hold the netdev lock over the reset task.. except Przemek's refactor to remove the critical lock now makes us fully dependent on the netdev lock in this case for reset :(

Quoted 4 lines

The fact remains that MTU configuration and ring parameter changes are currently broken in iavf. Changing the MTU on a Virtual Function is a fundamental configuration not an obscure edge case that can remain non- functional.

Agreed. This needs a resolution. It is just very tricky to figure out what the solution should be.

We need to hold the netdev lock during reset, and we need to have our handlers wait for reset to complete in order to be certain their task is done... but reset is a separate thread so we can't really communicate to it that we're holding the lock, and attempts to do that would be a huge problem.

We don't want to go back to the critical lock and all of its horrible problems either. The commit that removed it is here: 120f28a6f314 ("iavf: get rid of the crit lock")

Quoted 2 lines

I would appreciate any further guidance on how you would prefer...

I wish I had some better ideas..

Bad ideas I've thought about so far:

1) this patch with its drop lock and wait, which we discussed as problematic before. It creates a lot of issues since it means the operations are no longer atomic and we could potentially get stuck with some other operation in the event of another thread starting some core netdev task. No good.

2) not holding netdev_lock in reset, which is now a nogo since we removed the crit_lock, and apparently we held netdev_lock prior to that too anyways...

3) we could maybe do some sort of ref counting dance where we take some reference in threads that queue a reset, and the reset task would know if that reference was non-zero then another driver thread is holding netdev_lock so its safe to go into reset without locking... but this feels extremely ugly and error prone to me...

4) convert reset handling to a separate function that depends on the netdev_lock, and call that directly from within the threads that currently "wait for reset" while holding the netdev lock. Thus, we basically move this entire call chain into the thread already holding the lock, and call it from the context of the function like the MTU change, etc. This feels like its also a huge issue, and could potentially lead to some sort of issue where we need to still block the reset thread from going if we reset at the end of the netdev_lock thread..

I don't really like any of these solutions, even if (3) and (4) aren't fully ruled out as completely broken... they probably have all kinds of issues...

maintainer
#10 lore raw

[...]

Quoted 7 lines
Quoted 4 lines

If dropping the lock is a no-go, the only viable path forward is to split the reset_task so that the waiting portion is decoupled from the netdev_lock critical section.

We used to do this back before the netdev shaper ops. We didn't acquire either netdev lock or RTNL during reset.

I thought we had some code in the past that would handle netdev stuff outside of reset.. but I don't really know and git blame is not making it easy to find this information.

IIRC it was iavf_config_task that is used to complete stuff requested under RTNL but later

Quoted 21 lines

Perhaps we don't actually need to hold the netdev lock over the reset task.. except Przemek's refactor to remove the critical lock now makes us fully dependent on the netdev lock in this case for reset :(

Quoted 4 lines

The fact remains that MTU configuration and ring parameter changes are currently broken in iavf. Changing the MTU on a Virtual Function is a fundamental configuration not an obscure edge case that can remain non- functional.

Agreed. This needs a resolution. It is just very tricky to figure out what the solution should be.

We need to hold the netdev lock during reset, and we need to have our handlers wait for reset to complete in order to be certain their task is done... but reset is a separate thread so we can't really communicate to it that we're holding the lock, and attempts to do that would be a huge problem.

We don't want to go back to the critical lock and all of its horrible problems either. The commit that removed it is here: 120f28a6f314 ("iavf: get rid of the crit lock")

Quoted 2 lines

I would appreciate any further guidance on how you would prefer...

I wish I had some better ideas..

Bad ideas I've thought about so far:

Quoted 7 lines

1) this patch with its drop lock and wait, which we discussed as problematic before. It creates a lot of issues since it means the operations are no longer atomic and we could potentially get stuck with some other operation in the event of another thread starting some core netdev task. No good.

2) not holding netdev_lock in reset, which is now a nogo since we removed the crit_lock, and apparently we held netdev_lock prior to that too anyways...

3) we could maybe do some sort of ref counting dance where we take some reference in threads that queue a reset, and the reset task would know if that reference was non-zero then another driver thread is holding netdev_lock so its safe to go into reset without locking... but this feels extremely ugly and error prone to me...

4) convert reset handling to a separate function that depends on the netdev_lock, and call that directly from within the threads that currently "wait for reset" while holding the netdev lock. Thus, we basically move this entire call chain into the thread already holding the lock, and call it from the context of the function like the MTU change, etc.

reset_thread() {
	while (!stopped) {
		netdev_lock();
		reset_step();
		netdev_unlock();
	}
}

looks cool, IIRC I did something similar with the "after crit lock
removal refactor continuation", but I've put it on hold
https://github.com/pkitszel/linux/commits/undeadlock/
The linked code went even further and merged all of our admin-worker threads into one and the whole was protected by the netdev_lock :)

This feels like its also a huge issue, and could

Quoted 1 line

potentially lead to some sort of issue where we need to still block the reset thread from going if we reset at the end of the netdev_lock thread..

that should queue on the "do later stuff queue", which we don't have right now (and keep some of such stuff in the state machine), but would be useful for many other actions too (like virtchnl messages, for which we have queue-of-1 right now

Quoted 2 lines

I don't really like any of these solutions, even if (3) and (4) aren't fully ruled out as completely broken... they probably have all kinds of issues...

#11 lore raw
Quoted 51 lines · Przemek Kitszel

[...]

Quoted 7 lines
Quoted 4 lines

If dropping the lock is a no-go, the only viable path forward is to split the reset_task so that the waiting portion is decoupled from the netdev_lock critical section.

We used to do this back before the netdev shaper ops. We didn't acquire either netdev lock or RTNL during reset.

I thought we had some code in the past that would handle netdev stuff outside of reset.. but I don't really know and git blame is not making it easy to find this information.

IIRC it was iavf_config_task that is used to complete stuff requested under RTNL but later

Quoted 21 lines

Perhaps we don't actually need to hold the netdev lock over the reset task.. except Przemek's refactor to remove the critical lock now makes us fully dependent on the netdev lock in this case for reset :(

Quoted 4 lines

The fact remains that MTU configuration and ring parameter changes are currently broken in iavf. Changing the MTU on a Virtual Function is a fundamental configuration not an obscure edge case that can remain non- functional.

Agreed. This needs a resolution. It is just very tricky to figure out what the solution should be.

We need to hold the netdev lock during reset, and we need to have our handlers wait for reset to complete in order to be certain their task is done... but reset is a separate thread so we can't really communicate to it that we're holding the lock, and attempts to do that would be a huge problem.

We don't want to go back to the critical lock and all of its horrible problems either. The commit that removed it is here: 120f28a6f314 ("iavf: get rid of the crit lock")

Quoted 2 lines

I would appreciate any further guidance on how you would prefer...

I wish I had some better ideas..

Bad ideas I've thought about so far:

Quoted 7 lines

1) this patch with its drop lock and wait, which we discussed as problematic before. It creates a lot of issues since it means the operations are no longer atomic and we could potentially get stuck with some other operation in the event of another thread starting some core netdev task. No good.

2) not holding netdev_lock in reset, which is now a nogo since we removed the crit_lock, and apparently we held netdev_lock prior to that too anyways...

3) we could maybe do some sort of ref counting dance where we take some reference in threads that queue a reset, and the reset task would know if that reference was non-zero then another driver thread is holding netdev_lock so its safe to go into reset without locking... but this feels extremely ugly and error prone to me...

4) convert reset handling to a separate function that depends on the netdev_lock, and call that directly from within the threads that currently "wait for reset" while holding the netdev lock. Thus, we basically move this entire call chain into the thread already holding the lock, and call it from the context of the function like the MTU change, etc.

reset_thread() {
    while (!stopped) {
        netdev_lock();
        reset_step();
        netdev_unlock();
    }
}

Quoted 5 lines

looks cool, IIRC I did something similar with the "after crit lock
removal refactor continuation", but I've put it on hold
https://github.com/pkitszel/linux/commits/undeadlock/
The linked code went even further and merged all of our admin-worker threads into one and the whole was protected by the netdev_lock :)

That is a lot of patches and doesn't feel like a minimal fix.

Quoted 8 lines

This feels like its also a huge issue, and could

Quoted 1 line

potentially lead to some sort of issue where we need to still block the reset thread from going if we reset at the end of the netdev_lock thread..

that should queue on the "do later stuff queue", which we don't have right now (and keep some of such stuff in the state machine), but would be useful for many other actions too (like virtchnl messages, for which we have queue-of-1 right now

I think we need to lay out what we need and maybe that will help figure out a solution.

1) several NDO operations need to perform tasks that require AVF hardware to reset, and which need to be certain that happens before they return.

2) reset is handled by a separate workqueue task

3) reset also requires the netdev lock

We can't make the ndo operations avoid the netdev lock

We pretty much can't make reset not require the netdev lock, especially since we are now using it as effectively the main driver lock now.

I am not certain we can move all of the reset code to work from the ndo thread context, as we still also have to wait for hardware notification that reset happened, which seems like a pretty massive refactor to get right.

We can't drop the waiting in the ndo operation because we need to be sure that the operation applied properly, otherwise we get errors elsewhere.

So that leaves me without any solution so far, certainly not one that can be completed quickly... which means we're stuck with a guaranteed deadlock anytime the MTU is changed?

Quoted 2 lines
Quoted 2 lines

I don't really like any of these solutions, even if (3) and (4) aren't fully ruled out as completely broken... they probably have all kinds of issues...

author
#12 lore raw
Quoted 83 lines · Jacob Keller
Quoted 51 lines · Przemek Kitszel

[...]

Quoted 7 lines
Quoted 4 lines

If dropping the lock is a no-go, the only viable path forward is to split the reset_task so that the waiting portion is decoupled from the netdev_lock critical section.

We used to do this back before the netdev shaper ops. We didn't acquire either netdev lock or RTNL during reset.

I thought we had some code in the past that would handle netdev stuff outside of reset.. but I don't really know and git blame is not making it easy to find this information.

IIRC it was iavf_config_task that is used to complete stuff requested under RTNL but later

Quoted 21 lines

Perhaps we don't actually need to hold the netdev lock over the reset task.. except Przemek's refactor to remove the critical lock now makes us fully dependent on the netdev lock in this case for reset :(

Quoted 4 lines

The fact remains that MTU configuration and ring parameter changes are currently broken in iavf. Changing the MTU on a Virtual Function is a fundamental configuration not an obscure edge case that can remain non- functional.

Agreed. This needs a resolution. It is just very tricky to figure out what the solution should be.

We need to hold the netdev lock during reset, and we need to have our handlers wait for reset to complete in order to be certain their task is done... but reset is a separate thread so we can't really communicate to it that we're holding the lock, and attempts to do that would be a huge problem.

We don't want to go back to the critical lock and all of its horrible problems either. The commit that removed it is here: 120f28a6f314 ("iavf: get rid of the crit lock")

Quoted 2 lines

I would appreciate any further guidance on how you would prefer...

I wish I had some better ideas..

Bad ideas I've thought about so far:

Quoted 7 lines

1) this patch with its drop lock and wait, which we discussed as problematic before. It creates a lot of issues since it means the operations are no longer atomic and we could potentially get stuck with some other operation in the event of another thread starting some core netdev task. No good.

2) not holding netdev_lock in reset, which is now a nogo since we removed the crit_lock, and apparently we held netdev_lock prior to that too anyways...

3) we could maybe do some sort of ref counting dance where we take some reference in threads that queue a reset, and the reset task would know if that reference was non-zero then another driver thread is holding netdev_lock so its safe to go into reset without locking... but this feels extremely ugly and error prone to me...

4) convert reset handling to a separate function that depends on the netdev_lock, and call that directly from within the threads that currently "wait for reset" while holding the netdev lock. Thus, we basically move this entire call chain into the thread already holding the lock, and call it from the context of the function like the MTU change, etc.

reset_thread() {
     while (!stopped) {
         netdev_lock();
         reset_step();
         netdev_unlock();
     }
}

Quoted 5 lines

looks cool, IIRC I did something similar with the "after crit lock
removal refactor continuation", but I've put it on hold
https://github.com/pkitszel/linux/commits/undeadlock/
The linked code went even further and merged all of our admin-worker threads into one and the whole was protected by the netdev_lock :)

That is a lot of patches and doesn't feel like a minimal fix.

Quoted 8 lines

This feels like its also a huge issue, and could

Quoted 1 line

potentially lead to some sort of issue where we need to still block the reset thread from going if we reset at the end of the netdev_lock thread..

that should queue on the "do later stuff queue", which we don't have right now (and keep some of such stuff in the state machine), but would be useful for many other actions too (like virtchnl messages, for which we have queue-of-1 right now

I think we need to lay out what we need and maybe that will help figure out a solution.

1) several NDO operations need to perform tasks that require AVF hardware to reset, and which need to be certain that happens before they return.

2) reset is handled by a separate workqueue task

3) reset also requires the netdev lock

We can't make the ndo operations avoid the netdev lock

Quoted 7 lines

We pretty much can't make reset not require the netdev lock, especially since we are now using it as effectively the main driver lock now.

I am not certain we can move all of the reset code to work from the ndo thread context, as we still also have to wait for hardware notification that reset happened, which seems like a pretty massive refactor to get right.

We can't drop the waiting in the ndo operation because we need to be sure that the operation applied properly, otherwise we get errors elsewhere.

So that leaves me without any solution so far, certainly not one that can be completed quickly... which means we're stuck with a guaranteed deadlock anytime the MTU is changed?

I’ve been looking at the code on GitHub, and in my opinion, the fastest and most straightforward solution is to use a slightly modified approach based on patch 8c90ca2 ("iavf: split out body of reset task").

Since that patch refactors iavf_reset_task into iavf_reset_step and removes all netdev_lock acquisitions from its internal logic, we can resolve the deadlock by calling it directly.

In places where we currently wait (MTU, channels, ringparam), we should replace the asynchronous scheduling and waiting with a synchronous call. This avoids the deadlock by executing the reset in the thread that already holds the netdev_lock:

        if (netif_running(netdev)) {
-               iavf_schedule_reset(adapter, IAVF_FLAG_RESET_NEEDED);
-               ret = iavf_wait_for_reset(adapter);
-               if (ret < 0)
-                       netdev_warn(netdev, "MTU change interrupted waiting for reset"); -               else if (ret)
-                       netdev_warn(netdev, "MTU change timed out waiting for reset"); +               adapter->flags |= IAVF_FLAG_RESET_NEEDED;
+               iavf_reset_step(adapter);
        }
What do you think about this?

Quoted 4 lines
Quoted 3 lines
Quoted 3 lines

I don't really like any of these solutions, even if (3) and (4) aren't fully ruled out as completely broken... they probably have all kinds of issues...

#13 lore raw
Quoted 99 lines · Petr Oros
Quoted 83 lines · Jacob Keller
Quoted 51 lines · Przemek Kitszel

[...]

Quoted 7 lines
Quoted 4 lines

If dropping the lock is a no-go, the only viable path forward is to split the reset_task so that the waiting portion is decoupled from the netdev_lock critical section.

We used to do this back before the netdev shaper ops. We didn't acquire either netdev lock or RTNL during reset.

I thought we had some code in the past that would handle netdev stuff outside of reset.. but I don't really know and git blame is not making it easy to find this information.

IIRC it was iavf_config_task that is used to complete stuff requested under RTNL but later

Quoted 21 lines

Perhaps we don't actually need to hold the netdev lock over the reset task.. except Przemek's refactor to remove the critical lock now makes us fully dependent on the netdev lock in this case for reset :(

Quoted 4 lines

The fact remains that MTU configuration and ring parameter changes are currently broken in iavf. Changing the MTU on a Virtual Function is a fundamental configuration not an obscure edge case that can remain non- functional.

Agreed. This needs a resolution. It is just very tricky to figure out what the solution should be.

We need to hold the netdev lock during reset, and we need to have our handlers wait for reset to complete in order to be certain their task is done... but reset is a separate thread so we can't really communicate to it that we're holding the lock, and attempts to do that would be a huge problem.

We don't want to go back to the critical lock and all of its horrible problems either. The commit that removed it is here: 120f28a6f314 ("iavf: get rid of the crit lock")

Quoted 2 lines

I would appreciate any further guidance on how you would prefer...

I wish I had some better ideas..

Bad ideas I've thought about so far:

Quoted 7 lines

1) this patch with its drop lock and wait, which we discussed as problematic before. It creates a lot of issues since it means the operations are no longer atomic and we could potentially get stuck with some other operation in the event of another thread starting some core netdev task. No good.

2) not holding netdev_lock in reset, which is now a nogo since we removed the crit_lock, and apparently we held netdev_lock prior to that too anyways...

3) we could maybe do some sort of ref counting dance where we take some reference in threads that queue a reset, and the reset task would know if that reference was non-zero then another driver thread is holding netdev_lock so its safe to go into reset without locking... but this feels extremely ugly and error prone to me...

4) convert reset handling to a separate function that depends on the netdev_lock, and call that directly from within the threads that currently "wait for reset" while holding the netdev lock. Thus, we basically move this entire call chain into the thread already holding the lock, and call it from the context of the function like the MTU change, etc.

reset_thread() {
     while (!stopped) {
         netdev_lock();
         reset_step();
         netdev_unlock();
     }
}

Quoted 5 lines

looks cool, IIRC I did something similar with the "after crit lock
removal refactor continuation", but I've put it on hold
https://github.com/pkitszel/linux/commits/undeadlock/
The linked code went even further and merged all of our admin-worker threads into one and the whole was protected by the netdev_lock :)

That is a lot of patches and doesn't feel like a minimal fix.

Quoted 8 lines

This feels like its also a huge issue, and could

Quoted 1 line

potentially lead to some sort of issue where we need to still block the reset thread from going if we reset at the end of the netdev_lock thread..

that should queue on the "do later stuff queue", which we don't have right now (and keep some of such stuff in the state machine), but would be useful for many other actions too (like virtchnl messages, for which we have queue-of-1 right now

I think we need to lay out what we need and maybe that will help figure out a solution.

1) several NDO operations need to perform tasks that require AVF hardware to reset, and which need to be certain that happens before they return.

2) reset is handled by a separate workqueue task

3) reset also requires the netdev lock

We can't make the ndo operations avoid the netdev lock

Quoted 7 lines

We pretty much can't make reset not require the netdev lock, especially since we are now using it as effectively the main driver lock now.

I am not certain we can move all of the reset code to work from the ndo thread context, as we still also have to wait for hardware notification that reset happened, which seems like a pretty massive refactor to get right.

We can't drop the waiting in the ndo operation because we need to be sure that the operation applied properly, otherwise we get errors elsewhere.

So that leaves me without any solution so far, certainly not one that can be completed quickly... which means we're stuck with a guaranteed deadlock anytime the MTU is changed?

I’ve been looking at the code on GitHub, and in my opinion, the fastest and most straightforward solution is to use a slightly modified approach based on patch 8c90ca2 ("iavf: split out body of reset task").

Since that patch refactors iavf_reset_task into iavf_reset_step and removes all netdev_lock acquisitions from its internal logic, we can resolve the deadlock by calling it directly.

In places where we currently wait (MTU, channels, ringparam), we should replace the asynchronous scheduling and waiting with a synchronous call. This avoids the deadlock by executing the reset in the thread that already holds the netdev_lock:

Quoted 14 lines

        if (netif_running(netdev)) {
-               iavf_schedule_reset(adapter, IAVF_FLAG_RESET_NEEDED); -               ret = iavf_wait_for_reset(adapter);
-               if (ret < 0)
-                       netdev_warn(netdev, "MTU change interrupted waiting for reset");
-               else if (ret)
-                       netdev_warn(netdev, "MTU change timed out waiting for reset");
+               adapter->flags |= IAVF_FLAG_RESET_NEEDED; +               iavf_reset_step(adapter);
        }
What do you think about this?

I think this works. The netdev lock itself will provide synchronization between threads that need to reset, (since we take the netdev lock around reset and we hold it here).

This is more or less one of my ideas earlier, but I didn't look closely enough to see how easy it is to implement.

We will need to do some double checking to make sure that nothing else checks the reset flags without holding the netdev lock, but I think since Przemek's cleanups that is true.

Good idea! Hopefully its not too much work to pull out just that part of the refactor and get it cleaned up.

I'm currently working on setting my system up to reproduce the deadlock.

author
#14 lore raw

PATCH 1/1 iavf: fix deadlock in reset handling

description...

Fixes 120f28a6f314 ("iavf: get rid of the crit lock")
---
 drivers/net/ethernet/intel/iavf/iavf.h        |  2 +-
 .../net/ethernet/intel/iavf/iavf_ethtool.c    | 21 +++---
 drivers/net/ethernet/intel/iavf/iavf_main.c   | 72 +++++++------------
 3 files changed, 33 insertions(+), 62 deletions(-)
drivers/net/ethernet/intel/iavf/iavf.h +1 -1
index d552f912e8a947..0c3844b3ff1c86 100644
@@ -625,5 +625,5 @@ void iavf_add_adv_rss_cfg(struct iavf_adapter *adapter);
 void iavf_del_adv_rss_cfg(struct iavf_adapter *adapter);
 struct iavf_mac_filter *iavf_add_filter(struct iavf_adapter *adapter,
 					const u8 *macaddr);
-int iavf_wait_for_reset(struct iavf_adapter *adapter);
+void iavf_reset_step(struct iavf_adapter *adapter);
 #endif /* _IAVF_H_ */
drivers/net/ethernet/intel/iavf/iavf_ethtool.c +8 -13
index 2cc21289a70779..9b0f47f9340942 100644
@@ -492,7 +492,6 @@ static int iavf_set_ringparam(struct net_device *netdev,
 {
 	struct iavf_adapter *adapter = netdev_priv(netdev);
 	u32 new_rx_count, new_tx_count;
-	int ret = 0;
 
 	if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
 		return -EINVAL;
@@ -537,13 +536,11 @@ static int iavf_set_ringparam(struct net_device *netdev,
 	}
 
 	if (netif_running(netdev)) {
-		iavf_schedule_reset(adapter, IAVF_FLAG_RESET_NEEDED);
-		ret = iavf_wait_for_reset(adapter);
-		if (ret)
-			netdev_warn(netdev, "Changing ring parameters timeout or interrupted waiting for reset");
+		adapter->flags |= IAVF_FLAG_RESET_NEEDED;
+		iavf_reset_step(adapter);
 	}
 
-	return ret;
+	return 0;
 }
 
 /**
@@ -1723,7 +1720,6 @@ static int iavf_set_channels(struct net_device *netdev,
 {
 	struct iavf_adapter *adapter = netdev_priv(netdev);
 	u32 num_req = ch->combined_count;
-	int ret = 0;
 
 	if ((adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_ADQ) &&
 	    adapter->num_tc) {
@@ -1745,13 +1741,12 @@ static int iavf_set_channels(struct net_device *netdev,
 
 	adapter->num_req_queues = num_req;
 	adapter->flags |= IAVF_FLAG_REINIT_ITR_NEEDED;
-	iavf_schedule_reset(adapter, IAVF_FLAG_RESET_NEEDED);
-
-	ret = iavf_wait_for_reset(adapter);
-	if (ret)
-		netdev_warn(netdev, "Changing channel count timeout or interrupted waiting for reset");
+	if (netif_running(netdev)) {
+		adapter->flags |= IAVF_FLAG_RESET_NEEDED;
+		iavf_reset_step(adapter);
+	}
 
-	return ret;
+	return 0;
 }
 
 /**
drivers/net/ethernet/intel/iavf/iavf_main.c +24 -48

133 lines not on this page · raw message

Signature · 1 line
2.52.0
Tested-by Reviewed-by on v1 1/1
#15 lore raw
Quoted 5 lines · Petr Oros

description...

Fixes 120f28a6f314 ("iavf: get rid of the crit lock")

---

Code changes look correct to me. Description obviously needs to get written, but...

I loaded both the net as of ee9241524b46 ("amd-xgbe: do not select NET_SELFTESTS when INET is disabled") and tested it with and without this fix applied.

Before the fix, changing MTU till timeout after a few seconds with the complaint, after which the reset will happen and MTU will be applied late (the timeout in the wait event prevents a permanent deadlock). With the fix the command completes quickly with no errors and the MTU change applies immediately.

Additionally, for a version with a proper commit message, please feel free to add:

Thanks for working on this, Petr!

Regards,
Jake

maintainer
#16 lore raw
In reply to Petr Oros
Quoted 1 line · On Fri, 6 Feb 2026 11:04:26 +0100 Petr Oros wrote:
Fixes 120f28a6f314 ("iavf: get rid of the crit lock")

This is so much better 👍️