Fix i40e/ice/iavf VF bonding after netdev lock changes
Subsystems (4)
v5 cover Fix i40e/ice/iavf VF bonding after netdev lock changes
This series fixes VF bonding failures introduced by commit ad7c7b2172c3 ("net: hold netdev instance lock during sysfs operations").
When adding VFs to a bond immediately after setting trust mode, MAC address changes fail with -EAGAIN, preventing bonding setup. This affects both i40e (700-series) and ice (800-series) Intel NICs.
The core issue is lock contention: iavf_set_mac() is now called with the netdev lock held and waits for MAC change completion while holding it. However, both the watchdog task that sends the request and the adminq_task that processes PF responses also need this lock, creating a deadlock where neither can run, causing timeouts.
Additionally, setting VF trust triggers an unnecessary ~10 second VF reset in i40e driver that delays bonding setup, even though filter synchronization happens naturally during normal VF operation. For ice driver, the delay is not so big, but in the same way the operation is not necessary.
This series:
1. Adds safety guard to prevent MAC changes during reset or early initialization (before VF is ready)
2. Eliminates unnecessary VF reset when setting trust in i40e (reset only if revoking trust and VF has advanced features configured).
3. Fixes lock contention by polling admin queue synchronously
4. Eliminates unnecessary VF reset when setting trust in ice, (reset only if revoking trust and VF has advanced features configured).
The key fix (patch 3/4) implements a synchronous MAC change operation similar to the approach used for ndo_change_mtu deadlock fix:
https://lore.kernel.org/intel-wired-lan/[email protected]/
Instead of scheduling work and waiting, it:
- Sends the virtchnl message directly (not via watchdog)
- Polls the admin queue hardware directly for responses
- Processes all messages inline (including non-MAC messages)
- Returns when complete or times out
This allows the operation to complete synchronously while holding netdev_lock, without relying on watchdog or adminq_task.
The function can sleep for up to 2.5 seconds polling hardware, but this is acceptable since netdev_lock is per-device and only serializes operations on the same interface.
Testing shows VF bonding now works reliably in ~5 seconds vs 15+ seconds before (i40e), without timeouts or errors (i40e and ice).
Tested on Intel 700-series (i40e) and 800-series (ice) dual-port NICs with iavf driver.
Thanks to Jan Tluka <[email protected]> and Yuying Ma <[email protected]> for reporting the issues.
Jose Ignacio Tornos Martinez (4):
iavf: return EBUSY if reset in progress or not ready during MAC change
i40e: skip unnecessary VF reset when setting trust
iavf: send MAC change request synchronously
ice: skip unnecessary VF reset when setting trust
---
v5:
- No changes to patch 1 from v4
- For the new functions or with changes in the prototypes, kdoc should end
with '*/' not '**/', patch 2, 3 and 4
- For patch 2 and patch 4, after the comments from AI review (sashiko.dev) from Simon Horman, adopt a conservative approach checking multiple conditions before skipping the reset
- Complete patch 3 with the comments from Przemek Kitszel and AI review from Simon Horman.
v4: https://lore.kernel.org/all/[email protected]/
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 38 ++++++++++++++++++++++++++++---------- drivers/net/ethernet/intel/iavf/iavf.h | 10 ++++++++-- drivers/net/ethernet/intel/iavf/iavf_main.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------ drivers/net/ethernet/intel/iavf/iavf_virtchnl.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------- drivers/net/ethernet/intel/ice/ice_sriov.c | 33 +++++++++++++++++++++++++++++---- 5 files changed, 211 insertions(+), 44 deletions(-)
--
2.43.0
PATCH v5 1/4 iavf: return EBUSY if reset in progress or not ready during MAC change
When a MAC address change is requested while the VF is resetting or still initializing, return -EBUSY immediately instead of attempting the operation.
Additionally, during early initialization states (before __IAVF_DOWN), the PF may be slow to respond to MAC change requests, causing long delays. Only allow MAC changes once the VF reaches __IAVF_DOWN state or later, when the watchdog is running and the VF is ready for operations.
After commit ad7c7b2172c3 ("net: hold netdev instance lock during sysfs operations"), MAC changes are called with the netdev lock held, so we should not wait with the lock held during reset or initialization. This allows the caller to retry or handle the busy state appropriately without blocking other operations.
---
drivers/net/ethernet/intel/iavf/iavf_main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/intel/iavf/iavf_main.c +3 -0
@@ -1060,6 +1060,9 @@ static int iavf_set_mac(struct net_device *netdev, void *p)struct sockaddr *addr = p;int ret; +if (iavf_is_reset_in_progress (adapter) || adapter->state < __IAVF_DOWN) +return -EBUSY ; +if (!is_valid_ether_addr (addr->sa_data))return -EADDRNOTAVAIL ;
Signature · 1 line
2.53.0
RE: [Intel-wired-lan] [PATCH net v5 1/4] iavf: return EBUSY if reset in progress or not ready during MAC change
Quoted 53 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jose Ignacio Tornos Martinez
Sent: Wednesday, April 29, 2026 12:24 PM
To: [email protected]
Cc: [email protected]; Kitszel, Przemyslaw <[email protected]>; Loktionov, Aleksandr <[email protected]>; Keller, Jacob E <[email protected]>; [email protected]; [email protected]; Nguyen, Anthony L <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Jose Ignacio Tornos Martinez <[email protected]>
Subject: [Intel-wired-lan] [PATCH net v5 1/4] iavf: return EBUSY if reset in progress or not ready during MAC changeWhen a MAC address change is requested while the VF is resetting or still initializing, return
-EBUSYimmediately instead of attempting the operation.Additionally, during early initialization states (before
__IAVF_DOWN), the PF may be slow to respond to MAC change requests, causing long delays. Only allow MAC changes once the VF reaches__IAVF_DOWNstate or later, when the watchdog is running and the VF is ready for operations.After commit
ad7c7b2172c3("net: hold netdev instance lock during sysfs operations"), MAC changes are called with the netdev lock held, so we should not wait with the lock held during reset or initialization. This allows the caller to retry or handle the busy state appropriately without blocking other operations.Signed-off-by Jose Ignacio Tornos Martinez <[email protected]>Reviewed-by Przemek Kitszel <[email protected]>Reviewed-by Aleksandr Loktionov <[email protected]>---
drivers/net/ethernet/intel/iavf/iavf_main.c | 3 +++ 1 file changed, 3 insertions(+)drivers/net/ethernet/intel/iavf/iavf_main.c +3
-0@@ -1060,6 +1060,9 @@ static int iavf_set_mac(struct net_device *netdev, void *p)struct sockaddr *addr = p;int ret; +if (iavf_is_reset_in_progress (adapter) || adapter->state < __IAVF_DOWN) +return -EBUSY ; +if (!is_valid_ether_addr (addr->sa_data))return
-EADDRNOTAVAIL;
Quoted 2 lines
--
2.53.0
PATCH v5 2/4 i40e: skip unnecessary VF reset when setting trust
In reply to Jose Ignacio Tornos MartinezThe current implementation triggers a VF reset when changing the trust setting, causing a ~10 second delay during bonding setup.
In all the cases, the reset causes a ~10 second delay during which:
- VF must reinitialize completely
- Any in-progress operations (like bonding enslave) fail with timeouts
- VF is unavailable
When granting trust, no reset is needed - we can just set the capability flag to allow privileged operations.
When revoking trust, we only need to reset (conservative approach) if the VF has actually configured advanced features that require cleanup (ADQ/cloud filters, promiscuous mode). For VFs in a clean state, we can safely change the trust setting without the disruptive reset.
When we don't reset, we manually handle capability flag via helper function, eliminating the delay.
---
v5: kdoc should end with '*/' not '**/' (new function)
Address AI review (sashiko.dev) from Simon Horman:
- Adopt a conservative approach checking multiple conditions before skipping reset: ADQ, cloud filters, promiscuous mode
- Simplify helper function to only handle capability flag
v4: https://lore.kernel.org/all/[email protected]/
.../ethernet/intel/i40e/i40e_virtchnl_pf.c | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +28 -10
@@ -4943,6 +4943,23 @@ int i40e_ndo_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool enable)return ret; } +/** +* i40e_setup_vf_trust - Enable/disable VF trust mode without reset +* @vf: VF to configure +* @setting: trust setting +* +* Update VF flags when changing trust without performing a VF reset. +* This is only called when it's safe to skip the reset (VF has no advanced +* features configured that need cleanup). +*/ +static void i40e_setup_vf_trust (struct i40e_vf *vf,bool setting) +{ +if (setting) +set_bit (I40E_VIRTCHNL_VF_CAP_PRIVILEGE , &vf->vf_caps); +else +clear_bit (I40E_VIRTCHNL_VF_CAP_PRIVILEGE , &vf->vf_caps); +} +/** * i40e_ndo_set_vf_trust * @netdev: network interface device structure of the pf
@@ -4987,19 +5004,20 @@ int i40e_ndo_set_vf_trust(struct net_device *netdev, int vf_id, bool setting)set_bit (__I40E_MACVLAN_SYNC_PENDING, pf->state); pf->vsi[vf->lan_vsi_idx]->flags |=I40E_VSI_FLAG_FILTER_CHANGED ; -i40e_vc_reset_vf (vf, true); +/* Reset only if revoking trust and VF has advanced features configured */ +if (!setting && + (vf->adq_enabled || vf->num_cloud_filters >0 || +test_bit (I40E_VF_STATE_UC_PROMISC , &vf->vf_states) || +test_bit (I40E_VF_STATE_MC_PROMISC , &vf->vf_states))) { +i40e_vc_reset_vf (vf, true); +i40e_del_all_cloud_filters (vf); + }else { +i40e_setup_vf_trust (vf, setting); + } +dev_info (&pf->pdev->dev,"VF %u is now %strusted\n" , vf_id, setting ?"" :"un" ); -if (vf->adq_enabled) { -if (!vf->trusted) { -dev_info (&pf->pdev->dev, -"VF %u no longer Trusted, deleting all cloud filters\n" , - vf_id); -i40e_del_all_cloud_filters (vf); - } - } - out:clear_bit (__I40E_VIRTCHNL_OP_PENDING, pf->state);return ret;
Signature · 1 line
2.53.0
RE: [Intel-wired-lan] [PATCH net v5 2/4] i40e: skip unnecessary VF reset when setting trust
Quoted 110 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jose Ignacio Tornos Martinez
Sent: Wednesday, April 29, 2026 12:24 PM
To: [email protected]
Cc: [email protected]; Kitszel, Przemyslaw <[email protected]>; Loktionov, Aleksandr <[email protected]>; Keller, Jacob E <[email protected]>; [email protected]; [email protected]; Nguyen, Anthony L <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Jose Ignacio Tornos Martinez <[email protected]>
Subject: [Intel-wired-lan] [PATCH net v5 2/4] i40e: skip unnecessary VF reset when setting trustThe current implementation triggers a VF reset when changing the trust setting, causing a ~10 second delay during bonding setup.
In all the cases, the reset causes a ~10 second delay during which:
- VF must reinitialize completely
- Any in-progress operations (like bonding enslave) fail with timeouts
- VF is unavailableWhen granting trust, no reset is needed - we can just set the capability flag to allow privileged operations.
When revoking trust, we only need to reset (conservative approach) if the VF has actually configured advanced features that require cleanup (ADQ/cloud filters, promiscuous mode). For VFs in a clean state, we can safely change the trust setting without the disruptive reset.
When we don't reset, we manually handle capability flag via helper function, eliminating the delay.
Signed-off-by Jose Ignacio Tornos Martinez <[email protected]>---
v5: kdoc should end with '*/' not '**/' (new function)
Address AI review (sashiko.dev) from Simon Horman:
- Adopt a conservative approach checking multiple conditions before skipping reset: ADQ, cloud filters, promiscuous mode
- Simplify helper function to only handle capability flag
v4: https://lore.kernel.org/all/20260423130405.139568-3-
[email protected]/.../ethernet/intel/i40e/i40e_virtchnl_pf.c | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-)drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +16
-0@@ -4943,6 +4943,23 @@ int i40e_ndo_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool enable)return ret; } +/** +* i40e_setup_vf_trust - Enable/disable VF trust mode without reset +* @vf: VF to configure +* @setting: trust setting +* +* Update VF flags when changing trust without performing a VF reset. +* This is only called when it's safe to skip the reset (VF has no +advanced +* features configured that need cleanup). +*/ +static void i40e_setup_vf_trust (struct i40e_vf *vf,bool setting) { +if (setting) +set_bit (I40E_VIRTCHNL_VF_CAP_PRIVILEGE , &vf->vf_caps); +else +clear_bit (I40E_VIRTCHNL_VF_CAP_PRIVILEGE , &vf->vf_caps); } +/** * i40e_ndo_set_vf_trust * @netdev: network interface device structure of the pf @@ -4987,19 +5004,20 @@ int
i40e_ndo_set_vf_trust(struct net_device *netdev, int vf_id, bool setting)drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +1
-1set_bit (__I40E_MACVLAN_SYNC_PENDING, pf->state); pf->vsi[vf->lan_vsi_idx]->flags |=I40E_VSI_FLAG_FILTER_CHANGED ; -i40e_vc_reset_vf (vf, true); +/* Reset only if revoking trust and VF has advanced features configured */
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +10
-4+if (!setting && + (vf->adq_enabled || vf->num_cloud_filters >0 || +test_bit (I40E_VF_STATE_UC_PROMISC , &vf->vf_states) || +test_bit (I40E_VF_STATE_MC_PROMISC , &vf->vf_states))) { +i40e_vc_reset_vf (vf, true); +i40e_del_all_cloud_filters (vf); + }else { +i40e_setup_vf_trust (vf, setting); + } +dev_info (&pf->pdev->dev,"VF %u is now %strusted\n" , vf_id, setting ?"" :"un" ); -if (vf->adq_enabled) { -if (!vf->trusted) { - dev_info(&pf->pdev->dev, - "VF %u no longer Trusted, deleting all cloudfilters\n",
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +0
-6- vf_id); -i40e_del_all_cloud_filters (vf); - } - } - out:clear_bit (__I40E_VIRTCHNL_OP_PENDING, pf->state);return ret; --
Quoted 1 line
2.53.0
PATCH v5 3/4 iavf: send MAC change request synchronously
In reply to Jose Ignacio Tornos MartinezAfter commit ad7c7b2172c3 ("net: hold netdev instance lock during sysfs operations"), iavf_set_mac() is called with the netdev instance lock already held.
The function queues a MAC address change request via iavf_replace_primary_mac() and then waits for completion. However, in the current flow, the actual virtchnl message is sent by the watchdog task, which also needs to acquire the netdev lock to run. Additionally, the adminq_task which processes virtchnl responses also needs the netdev lock.
This creates a deadlock scenario:
1. iavf_set_mac() holds netdev lock and waits for MAC change
2. Watchdog needs netdev lock to send the request -> blocked
3. Even if request is sent, adminq_task needs netdev lock to process PF response -> blocked
4. MAC change times out after 2.5 seconds
5. iavf_set_mac() returns -EAGAIN
This particularly affects VFs during bonding setup when multiple VFs are enslaved in quick succession.
Fix by implementing a synchronous MAC change operation similar to the approach used in commit fdadbf6e84c4 ("iavf: fix incorrect reset handling in callbacks").
The solution:
1. Send the virtchnl ADD_ETH_ADDR message directly (not via watchdog)
2. Poll the admin queue hardware directly for responses
3. Process all received messages (including non-MAC messages)
4. Return when MAC change completes or times out
A new generic function iavf_poll_virtchnl_response() is introduced that can be reused for any future synchronous virtchnl operations. It takes a callback to check completion, allowing flexible condition checking.
This allows the operation to complete synchronously while holding netdev_lock, without relying on watchdog or adminq_task. The function can sleep for up to 2.5 seconds polling hardware, but this is acceptable since netdev_lock is per-device and only serializes operations on the same interface.
To support this, change iavf_add_ether_addrs() to return an error code instead of void, allowing callers to detect failures. Additionally, export iavf_mac_add_reject() to enable proper rollback on local failures (timeouts, send errors) - PF rejections are already handled automatically by iavf_virtchnl_completion().
Remove vc_waitqueue entirely because iavf_set_mac was the only waiter on this waitqueue and after the changes it is not needed.
---
v5: Address the comments from Przemek Kitszel:
- Add note in commit message about vc_waitqueue removal.
- Change kdoc to use "Return:" instead of "Returns"
- kdoc should end with '*/' not '**/' (new functions or with changes in the prototypes)
- Sort lines from longest to shortest (iavf_poll_virtchnl_response)
- Avoid "sleep then check time" (iavf_poll_virtchnl_response) Address AI review (sashiko.dev) from Simon Horman:
- Restore adapter->hw.mac.addr on local failure (complete rollback in iavf_set_mac)
- Remove timeout current_op clearing to prevent overlapping command race, the status can be controlled from outside and better to not corrupt it (iavf_poll_virtchnl_response) (as in v3).
v4: https://lore.kernel.org/all/[email protected]/
drivers/net/ethernet/intel/iavf/iavf.h | 10 +- drivers/net/ethernet/intel/iavf/iavf_main.c | 71 +++++++++---- .../net/ethernet/intel/iavf/iavf_virtchnl.c | 100 ++++++++++++++++-- 3 files changed, 151 insertions(+), 30 deletions(-)
drivers/net/ethernet/intel/iavf/iavf.h +8 -2
@@ -260,7 +260,6 @@ struct iavf_adapter {struct work_struct adminq_task;struct work_struct finish_config;wait_queue_head_t down_waitqueue; -wait_queue_head_t vc_waitqueue;struct iavf_q_vector *q_vectors;struct list_head vlan_filter_list;int num_vlan_filters;
@@ -589,8 +588,9 @@ void iavf_configure_queues(struct iavf_adapter *adapter);void iavf_enable_queues (struct iavf_adapter *adapter);void iavf_disable_queues (struct iavf_adapter *adapter);void iavf_map_queues (struct iavf_adapter *adapter); -void iavf_add_ether_addrs (struct iavf_adapter *adapter); +int iavf_add_ether_addrs (struct iavf_adapter *adapter);void iavf_del_ether_addrs (struct iavf_adapter *adapter); +void iavf_mac_add_reject (struct iavf_adapter *adapter);void iavf_add_vlans (struct iavf_adapter *adapter);void iavf_del_vlans (struct iavf_adapter *adapter);void iavf_set_promiscuous (struct iavf_adapter *adapter);
@@ -607,6 +607,12 @@ void iavf_disable_vlan_stripping(struct iavf_adapter *adapter);void iavf_virtchnl_completion (struct iavf_adapter *adapter,enum virtchnl_ops v_opcode,enum iavf_status v_retval,u8 *msg,u16 msglen); +int iavf_poll_virtchnl_response (struct iavf_adapter *adapter, +bool (*condition)(struct iavf_adapter *adapter, +const void *data, +enum virtchnl_ops v_op), +const void *cond_data, +unsigned int timeout_ms);int iavf_config_rss (struct iavf_adapter *adapter);void iavf_cfg_queues_bw (struct iavf_adapter *adapter);void iavf_cfg_queues_quanta_size (struct iavf_adapter *adapter);
drivers/net/ethernet/intel/iavf/iavf_main.c +53 -18
93 lines not on this page · raw message
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +90 -10
164 lines not on this page · raw message
Signature · 1 line
2.53.0
RE: [PATCH net v5 3/4] iavf: send MAC change request synchronously
Quoted 118 lines
-----Original Message-----
From: Jose Ignacio Tornos Martinez <[email protected]>
Sent: Wednesday, April 29, 2026 12:24 PM
To: [email protected]
Cc: [email protected]; Kitszel, Przemyslaw <[email protected]>; Loktionov, Aleksandr <[email protected]>; Keller, Jacob E <[email protected]>; [email protected]; [email protected]; Nguyen, Anthony L <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Jose Ignacio Tornos Martinez <[email protected]>; [email protected]
Subject: [PATCH net v5 3/4] iavf: send MAC change request synchronouslyAfter commit
ad7c7b2172c3("net: hold netdev instance lock during sysfs operations"),iavf_set_mac()is called with the netdev instance lock already held.The function queues a MAC address change request via
iavf_replace_primary_mac()and then waits for completion. However, in the current flow, the actual virtchnl message is sent by the watchdog task, which also needs to acquire the netdev lock to run. Additionally, theadminq_taskwhich processes virtchnl responses also needs the netdev lock.This creates a deadlock scenario:
1.iavf_set_mac()holds netdev lock and waits for MAC change 2. Watchdog needs netdev lock to send the request -> blocked 3. Even if request is sent,adminq_taskneeds netdev lock to process PF response -> blocked
4. MAC change times out after 2.5 seconds 5.iavf_set_mac()returns - EAGAINThis particularly affects VFs during bonding setup when multiple VFs are enslaved in quick succession.
Fix by implementing a synchronous MAC change operation similar to the approach used in commit
fdadbf6e84c4("iavf: fix incorrect reset handling in callbacks").The solution:
1. Send the virtchnlADD_ETH_ADDRmessage directly (not via watchdog)
2. Poll the admin queue hardware directly for responses 3. Process all received messages (including non-MAC messages) 4. Return when MAC change completes or times outA new generic function
iavf_poll_virtchnl_response()is introduced that can be reused for any future synchronous virtchnl operations. It takes a callback to check completion, allowing flexible condition checking.This allows the operation to complete synchronously while holding
netdev_lock, without relying on watchdog oradminq_task. The function can sleep for up to 2.5 seconds polling hardware, but this is acceptable sincenetdev_lockis per-device and only serializes operations on the same interface.To support this, change
iavf_add_ether_addrs()to return an error code instead of void, allowing callers to detect failures. Additionally, exportiavf_mac_add_reject()to enable proper rollback on local failures (timeouts, send errors) - PF rejections are already handled automatically byiavf_virtchnl_completion().Remove
vc_waitqueueentirely becauseiavf_set_macwas the only waiter on this waitqueue and after the changes it is not needed.Fixes ad7c7b2172c3 ("net: hold netdev instance lock during sysfsoperations")
Signed-off-by Jose Ignacio Tornos Martinez <[email protected]>---
v5: Address the comments from Przemek Kitszel:
- Add note in commit message aboutvc_waitqueueremoval.
- Change kdoc to use "Return:" instead of "Returns"
- kdoc should end with '*/' not '**/' (new functions or with
changes in the
prototypes)
- Sort lines from longest to shortest
(iavf_poll_virtchnl_response)
- Avoid "sleep then check time" (iavf_poll_virtchnl_response) Address AI review (sashiko.dev) from Simon Horman:
- Restoreadapter->hw.mac.addron local failure (complete rollback iniavf_set_mac)
- Remove timeoutcurrent_opclearing to prevent overlapping
command
race, the status can be controlled from outside and better to
not
corrupt it (iavf_poll_virtchnl_response) (as in v3).
v4: https://lore.kernel.org/all/20260423130405.139568-4-
[email protected]/drivers/net/ethernet/intel/iavf/iavf.h | 10 +- drivers/net/ethernet/intel/iavf/iavf_main.c | 71 +++++++++---- .../net/ethernet/intel/iavf/iavf_virtchnl.c | 100 ++++++++++++++++-(quoted diff) +0
-1- 3 files changed, 151 insertions(+), 30 deletions(-)drivers/net/ethernet/intel/iavf/iavf.h +0
-1@@ -260,7 +260,6 @@ struct iavf_adapter {struct work_struct adminq_task;struct work_struct finish_config;wait_queue_head_t down_waitqueue; -wait_queue_head_t vc_waitqueue;struct iavf_q_vector *q_vectors;struct list_head vlan_filter_list;int num_vlan_filters;@@ -589,8 +588,9 @@ void iavf_configure_queues(struct iavf_adapter *adapter); void iavf_enable_queues(struct iavf_adapter *adapter);void
iavf_disable_queues(struct iavf_adapter *adapter); voidiavf_map_queues(struct iavf_adapter *adapter); -voidiavf_add_ether_addrs(struct iavf_adapter *adapter);
...
Quoted 69 lines
+/**
+ *iavf_poll_virtchnl_response- Poll admin queue for virtchnl response
+ * @adapter: adapter structure
+ * @condition: callback to check if desired response received
+ * @cond_data: context data passed to condition callback
+ * @timeout_ms: maximum time to wait in milliseconds
+ *
+ * Polls the admin queue and processes all incoming virtchnl messages.
+ * After processing each valid message, calls the condition callback todrivers/net/ethernet/intel/iavf/iavf.h +12
-0+check +* if the expected response has been received. The callback receives +the opcode +* of the processed message to identify which response was received. +Continues +* polling until the callback returns true or timeout expires. +* Caller must hold netdev_lock. This can sleep for up to timeout_ms +while +* polling hardware. +* +* Return: 0 on success (condition met), -EAGAIN on timeout, or error +code */ int iavf_poll_virtchnl_response(struct iavf_adapter*adapter,
drivers/net/ethernet/intel/iavf/iavf.h +1
-0+ bool (*condition)(struct iavf_adapter*adapter,
drivers/net/ethernet/intel/iavf/iavf.h +26
-0+const void *data, + enum virtchnl_ops v_op), + const void *cond_data, + unsigned int timeout_ms) +{ + struct iavf_hw *hw = &adapter->hw; +struct iavf_arq_event_info event; +enum virtchnl_ops received_op; +unsigned long timeout; +int ret = -EAGAIN ; +u16 pending =0 ; +u32 v_retval; + +netdev_assert_locked (adapter->netdev); + + event.buf_len =IAVF_MAX_AQ_BUF_SIZE ; + event.msg_buf =kzalloc (event.buf_len,GFP_KERNEL ); +if (!event.msg_buf) +return -ENOMEM ; + + timeout = jiffies +msecs_to_jiffies (timeout_ms); + do { + if (!pending) + usleep_range(50, 75); + + if (iavf_clean_arq_element(hw, &event, &pending) ==
IAVF_SUCCESS) {drivers/net/ethernet/intel/iavf/iavf.h +1
-0+ received_op = (enumvirtchnl_ops)le32_to_cpu(event.desc.cookie_high);
drivers/net/ethernet/intel/iavf/iavf.h +2
-0+if (received_op !=VIRTCHNL_OP_UNKNOWN ) { + v_retval =
le32_to_cpu(event.desc.cookie_low);drivers/net/ethernet/intel/iavf/iavf.h +2
-0+ + iavf_virtchnl_completion(adapter,
received_op,drivers/net/ethernet/intel/iavf/iavf.h +1
-0+ (enumiavf_status)v_retval,
drivers/net/ethernet/intel/iavf/iavf.h +1
-0+ event.msg_buf,event.msg_len);
drivers/net/ethernet/intel/iavf/iavf.h +2
-0+ + if (condition(adapter, cond_data,
received_op)) {
drivers/net/ethernet/intel/iavf/iavf.h
Quoted 9 lines
drivers/net/ethernet/intel/iavf/iavf.h +9
-0+ ret =0 ; +break ; + } + } + +memset (event.msg_buf,0 ,IAVF_MAX_AQ_BUF_SIZE ); + +if (pending) +continue ;
I think continue at the end of the cycle is redundant.
Quoted 8 lines
drivers/net/ethernet/intel/iavf/iavf.h +6
-1+ } + }while (time_before (jiffies, timeout)); + +kfree (event.msg_buf); +return ret; +} --2.53.0
Re: [PATCH net v5 3/4] iavf: send MAC change request synchronously
Hello Aleksandr,
Quoted 1 line
I think continue at the end of the cycle is redundant.
That continue is intentional; without it, if timeout expires but there are still messages in the queue, we give up without processing them. The message we're waiting for might be in the queue and not a lot of messages stored are expected.
That continue reduces possible false timeouts (because the expected message could be stored in the queue) while keeping the delay minimal. The timeout is really just an estimate, and I don't think it needs to be very precise.
Thanks
Best regards
Jose Ignacio
Przemek Kitszel
maintainerRe: [PATCH net v5 3/4] iavf: send MAC change request synchronously
Quoted 5 lines · Jose Ignacio Tornos Martinez
Hello Aleksandr,
Quoted 1 line
I think continue at the end of the cycle is redundant.
That continue is intentional; without it, if timeout expires but there are still messages in the queue, we give up without processing them. The
Alex is right,
"continue" causes to check the condition clause of while loop, also for do-while
Quoted 6 lines
message we're waiting for might be in the queue and not a lot of messages stored are expected.
That continue reduces possible false timeouts (because the expected message could be stored in the queue) while keeping the delay minimal. The timeout is really just an estimate, and I don't think it needs to be very precise.
with that said, current code is correct
removing the redundant "if" could be done while applying (if that will be the only nitpick left)
after more thinking:
in theory, not checking the time but processing next message if there were any pending on the previous message could cause infinite loop (to fix that we should stop refreshing "pending" value after the timeout, but only decrementing it - but I think that this would be needless complication)
My Reviewed-by still holds
Quoted 6 lines
Thanks
Best regards
Jose Ignacio
Romanowski, Rafal
Tested-byRE: [Intel-wired-lan] [PATCH net v5 3/4] iavf: send MAC change request synchronously
Quoted 37 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Przemek Kitszel
Sent: Wednesday, April 29, 2026 3:04 PM
To: Jose Ignacio Tornos Martinez <[email protected]>; Loktionov, Aleksandr <[email protected]>
Cc: Nguyen, Anthony L <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Keller, Jacob E <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [Intel-wired-lan] [PATCH net v5 3/4] iavf: send MAC change request synchronouslyQuoted 6 lines · Jose Ignacio Tornos Martinez
Hello Aleksandr,
Quoted 1 line
I think continue at the end of the cycle is redundant.
That continue is intentional; without it, if timeout expires but there are still messages in the queue, we give up without processing them. The
Alex is right,
"continue" causes to check the condition clause of while loop, also for do-whileQuoted 6 lines
message we're waiting for might be in the queue and not a lot of messages stored are expected.
That continue reduces possible false timeouts (because the expected message could be stored in the queue) while keeping the delay minimal. The timeout is really just an estimate, and I don't think it needs to be very precise.with that said, current code is correct
removing the redundant "if" could be done while applying (if that will be the only nitpick left)
Quoted 14 lines
after more thinking:
in theory, not checking the time but processing next message if there were any pending on the previous message could cause infinite loop (to fix that we should stop refreshing "pending" value after the timeout, but only decrementing it - but I think that this would be needless complication)My Reviewed-by still holds
Quoted 6 lines
Thanks
Best regards
Jose Ignacio
Re: [PATCH net v5 3/4] iavf: send MAC change request synchronously
In reply to Jose Ignacio Tornos MartinezQuoted 48 lines · Jose Ignacio Tornos Martinez
After commit
ad7c7b2172c3("net: hold netdev instance lock during sysfs operations"),iavf_set_mac()is called with the netdev instance lock already held.The function queues a MAC address change request via
iavf_replace_primary_mac()and then waits for completion. However, in the current flow, the actual virtchnl message is sent by the watchdog task, which also needs to acquire the netdev lock to run. Additionally, theadminq_taskwhich processes virtchnl responses also needs the netdev lock.This creates a deadlock scenario:
1.iavf_set_mac()holds netdev lock and waits for MAC change
2. Watchdog needs netdev lock to send the request -> blocked
3. Even if request is sent,adminq_taskneeds netdev lock to processPF response -> blocked4. MAC change times out after 2.5 seconds
5.iavf_set_mac()returns-EAGAINThis particularly affects VFs during bonding setup when multiple VFs are enslaved in quick succession.
Fix by implementing a synchronous MAC change operation similar to the approach used in commit
fdadbf6e84c4("iavf: fix incorrect reset handling in callbacks").The solution:
1. Send the virtchnlADD_ETH_ADDRmessage directly (not via watchdog)
2. Poll the admin queue hardware directly for responses
3. Process all received messages (including non-MAC messages)
4. Return when MAC change completes or times outA new generic function
iavf_poll_virtchnl_response()is introduced that can be reused for any future synchronous virtchnl operations. It takes a callback to check completion, allowing flexible condition checking.This allows the operation to complete synchronously while holding
netdev_lock, without relying on watchdog oradminq_task. The function can sleep for up to 2.5 seconds polling hardware, but this is acceptable sincenetdev_lockis per-device and only serializes operations on the same interface.To support this, change
iavf_add_ether_addrs()to return an error code instead of void, allowing callers to detect failures. Additionally, exportiavf_mac_add_reject()to enable proper rollback on local failures (timeouts, send errors) - PF rejections are already handled automatically byiavf_virtchnl_completion().
Quoted 6 lines
Remove
vc_waitqueueentirely becauseiavf_set_macwas the only waiter on this waitqueue and after the changes it is not needed.Fixes ad7c7b2172c3 ("net: hold netdev instance lock during sysfs operations")Signed-off-by Jose Ignacio Tornos Martinez <[email protected]>
thank you very much!
PATCH v5 4/4 ice: skip unnecessary VF reset when setting trust
In reply to Jose Ignacio Tornos MartinezSimilar to the i40e fix, ice_set_vf_trust() unconditionally calls ice_reset_vf() when the trust setting changes. While the delay is smaller than i40e this reset is still unnecessary in most cases.
Additionally, the original code has a race condition: it deletes MAC LLDP filters BEFORE resetting the VF. During this deletion, the VF is still ACTIVE and can add new MAC LLDP filters concurrently, potentially corrupting the filter list.
When granting trust, no reset is needed - we can just set the capability flag to allow privileged operations.
When revoking trust, we only need to reset (conservative approach) if the VF has actually configured advanced features that require cleanup (MAC LLDP filters, promiscuous mode). For VFs in a clean state, we can safely change the trust setting without the disruptive reset.
When we do reset (MAC LLDP case), we fix the race condition by resetting first to clear VF state (which blocks new MAC LLDP filter additions), then delete existing filters safely. During cleanup, vf->trusted remains true so ice_vf_is_lldp_ena() works properly. Only after cleanup do we set vf->trusted = false.
When we don't reset, we manually handle capability flag via helper function, eliminating the delay.
---
v5 Address the comments from Aleksandr Loktionov:
- Error handling when ice_setup_vf_trust is called is not necessary because ice_vf_clear_all_promisc_modes is not used due to the conservative approach to solve AI tool review concerns
- kdoc should end with '*/' not '**/' (new function)
Address AI review (sashiko.dev) from Simon Horman:
- Adopt a conservative approach checking multiple conditions before skipping reset: MAC LLDP filters, promiscuous mode
- Simplify helper function to only handle capability flag
- No need to export ice_vf_clear_all_promisc_modes
v4: https://lore.kernel.org/all/[email protected]/
drivers/net/ethernet/intel/ice/ice_sriov.c | 33 +++++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/ice/ice_sriov.c +29 -4
@@ -1364,6 +1364,23 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)return __ice_set_vf_mac (ice_netdev_to_pf (netdev), vf_id, mac); } +/** +* ice_setup_vf_trust - Enable/disable VF trust mode without reset +* @vf: VF to configure +* @setting: trust setting +* +* Update VF flags when changing trust without performing a VF reset. +* This is only called when it's safe to skip the reset (VF has no advanced +* features configured that need cleanup). +*/ +static void ice_setup_vf_trust (struct ice_vf *vf,bool setting) +{ +if (setting) +set_bit (ICE_VIRTCHNL_VF_CAP_PRIVILEGE , &vf->vf_caps); +else +clear_bit (ICE_VIRTCHNL_VF_CAP_PRIVILEGE , &vf->vf_caps); +} +/** * ice_set_vf_trust * @netdev: network interface device structure
@@ -1399,11 +1416,19 @@ int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted)mutex_lock (&vf->cfg_lock); -while (!trusted && vf->num_mac_lldp) -ice_vf_update_mac_lldp_num (vf,ice_get_vf_vsi (vf), false); - +/* Reset only if revoking trust and VF has advanced features configured */ +if (!trusted && + (vf->num_mac_lldp >0 || +test_bit (ICE_VF_STATE_UC_PROMISC , vf->vf_states) || +test_bit (ICE_VF_STATE_MC_PROMISC , vf->vf_states))) { +ice_reset_vf (vf,ICE_VF_RESET_NOTIFY ); +while (vf->num_mac_lldp) +ice_vf_update_mac_lldp_num (vf,ice_get_vf_vsi (vf), false); + }else { +ice_setup_vf_trust (vf, trusted); + } vf->trusted = trusted; -ice_reset_vf (vf,ICE_VF_RESET_NOTIFY ); +dev_info (ice_pf_to_dev (pf),"VF %u is now %strusted\n" , vf_id, trusted ?"" :"un" );
Signature · 1 line
2.53.0
RE: [Intel-wired-lan] [PATCH net v5 4/4] ice: skip unnecessary VF reset when setting trust
Quoted 114 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jose Ignacio Tornos Martinez
Sent: Wednesday, April 29, 2026 12:24 PM
To: [email protected]
Cc: [email protected]; Kitszel, Przemyslaw <[email protected]>; Loktionov, Aleksandr <[email protected]>; Keller, Jacob E <[email protected]>; [email protected]; [email protected]; Nguyen, Anthony L <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Jose Ignacio Tornos Martinez <[email protected]>
Subject: [Intel-wired-lan] [PATCH net v5 4/4] ice: skip unnecessary VF reset when setting trustSimilar to the i40e fix,
ice_set_vf_trust()unconditionally callsice_reset_vf()when the trust setting changes. While the delay is smaller than i40e this reset is still unnecessary in most cases.Additionally, the original code has a race condition: it deletes MAC LLDP filters BEFORE resetting the VF. During this deletion, the VF is still ACTIVE and can add new MAC LLDP filters concurrently, potentially corrupting the filter list.
When granting trust, no reset is needed - we can just set the capability flag to allow privileged operations.
When revoking trust, we only need to reset (conservative approach) if the VF has actually configured advanced features that require cleanup (MAC LLDP filters, promiscuous mode). For VFs in a clean state, we can safely change the trust setting without the disruptive reset.
When we do reset (MAC LLDP case), we fix the race condition by resetting first to clear VF state (which blocks new MAC LLDP filter additions), then delete existing filters safely. During cleanup,
vf->trustedremains true soice_vf_is_lldp_ena()works properly. Only after cleanup do we setvf->trusted= false.When we don't reset, we manually handle capability flag via helper function, eliminating the delay.
Fixes 2296345416b0 ("ice: receive LLDP on trusted VFs")Signed-off-by Jose Ignacio Tornos Martinez <[email protected]>---
v5 Address the comments from Aleksandr Loktionov:
- Error handling whenice_setup_vf_trustis called is not necessary becauseice_vf_clear_all_promisc_modesis not used due to the conservative approach to solve AI tool review concerns
- kdoc should end with '*/' not '**/' (new function) Address AI review (sashiko.dev) from Simon Horman:
- Adopt a conservative approach checking multiple conditions before skipping reset: MAC LLDP filters, promiscuous mode
- Simplify helper function to only handle capability flag
- No need to exportice_vf_clear_all_promisc_modes
v4: https://lore.kernel.org/all/20260423130405.139568-5-
[email protected]/drivers/net/ethernet/intel/ice/ice_sriov.c | 33 +++++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-)drivers/net/ethernet/intel/ice/ice_sriov.c +16
-0@@ -1364,6 +1364,23 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)return __ice_set_vf_mac (ice_netdev_to_pf (netdev), vf_id, mac); } +/** +* ice_setup_vf_trust - Enable/disable VF trust mode without reset +* @vf: VF to configure +* @setting: trust setting +* +* Update VF flags when changing trust without performing a VF reset. +* This is only called when it's safe to skip the reset (VF has no +advanced +* features configured that need cleanup). +*/ +static void ice_setup_vf_trust (struct ice_vf *vf,bool setting) { +if (setting) +set_bit (ICE_VIRTCHNL_VF_CAP_PRIVILEGE , &vf->vf_caps); +else +clear_bit (ICE_VIRTCHNL_VF_CAP_PRIVILEGE , &vf->vf_caps); } +/** * ice_set_vf_trust * @netdev: network interface device structure @@ -1399,11 +1416,19 @@ int
ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted)drivers/net/ethernet/intel/ice/ice_sriov.c +1
-3mutex_lock (&vf->cfg_lock); -while (!trusted && vf->num_mac_lldp) -ice_vf_update_mac_lldp_num (vf,ice_get_vf_vsi (vf), false); - +/* Reset only if revoking trust and VF has advanced features configured */
drivers/net/ethernet/intel/ice/ice_sriov.c +7
-0+if (!trusted && + (vf->num_mac_lldp >0 || +test_bit (ICE_VF_STATE_UC_PROMISC , vf->vf_states) || +test_bit (ICE_VF_STATE_MC_PROMISC , vf->vf_states))) { +ice_reset_vf (vf,ICE_VF_RESET_NOTIFY ); +while (vf->num_mac_lldp) + ice_vf_update_mac_lldp_num(vf, ice_get_vf_vsi(vf),false);
drivers/net/ethernet/intel/ice/ice_sriov.c +4
-2+ }else { +ice_setup_vf_trust (vf, trusted); + } vf->trusted = trusted; -ice_reset_vf (vf,ICE_VF_RESET_NOTIFY ); +dev_info (ice_pf_to_dev (pf),"VF %u is now %strusted\n" , vf_id, trusted ?"" :"un" ); --
Quoted 1 line
2.53.0