linux/drivers/net/ethernet/intel/iavf
Jose Ignacio Tornos Martinez 436729a56d iavf: send MAC change request synchronously
After commit ad7c7b2172 ("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 fdadbf6e84 ("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.

Fixes: ad7c7b2172 ("net: hold netdev instance lock during sysfs operations")
cc: stable@vger.kernel.org
Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Tested-by: Rafal Romanowski <rafal.romanowski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
2026-09-28 09:09:06 -07:00
..
iavf_adminq_cmd.h iavf: use libie adminq descriptors 2025-07-24 09:28:26 -07:00
iavf_adminq.c iavf: use libie adminq descriptors 2025-07-24 09:28:26 -07:00
iavf_adminq.h net/intel: Replace manual array size calculation with ARRAY_SIZE 2026-06-13 16:43:47 -07:00
iavf_adv_rss.c iavf: add RSS support for GTP protocol via ethtool 2025-11-06 14:19:43 -08:00
iavf_adv_rss.h iavf: add RSS support for GTP protocol via ethtool 2025-11-06 14:19:43 -08:00
iavf_alloc.h iavf: remove some unused functions and pointless wrappers 2023-06-22 09:26:55 -07:00
iavf_common.c virtchnl: move virtchnl and virtchnl2 headers to 'include/linux/net/intel' 2026-08-12 13:56:50 -07:00
iavf_devids.h
iavf_ethtool.c net: ethtool: keep rtnl_lock for ops using ethtool_op_get_link() 2026-06-25 10:18:34 -07:00
iavf_fdir.c iavf: add support for offloading tc U32 cls filters 2024-08-13 14:51:29 -07:00
iavf_fdir.h iavf: add support for offloading tc U32 cls filters 2024-08-13 14:51:29 -07:00
iavf_main.c iavf: send MAC change request synchronously 2026-09-28 09:09:06 -07:00
iavf_osdep.h iavf: remove some unused functions and pointless wrappers 2023-06-22 09:26:55 -07:00
iavf_prototype.h virtchnl: move virtchnl and virtchnl2 headers to 'include/linux/net/intel' 2026-08-12 13:56:50 -07:00
iavf_ptp.c Convert 'alloc_flex' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
iavf_ptp.h iavf: add support for Rx timestamps to hotpath 2025-02-14 10:58:08 -08:00
iavf_register.h iavf: remove mask from iavf_irq_enable_queues() 2023-06-10 00:09:54 -07:00
iavf_status.h virtchnl: i40e/iavf: rename iwarp to rdma 2023-01-25 08:55:19 -08:00
iavf_trace.h iavf: define Rx descriptors as qwords 2025-02-14 10:58:08 -08:00
iavf_txrx.c net: Use helpers to get/set UDP len tree-wide 2026-07-22 13:47:02 +02:00
iavf_txrx.h net: intel: move RSS packet classifier types to libie 2025-06-09 09:56:18 -07:00
iavf_type.h iavf: fix wrong VLAN mask for legacy Rx descriptors L2TAG2 2026-04-18 12:01:35 -07:00
iavf_types.h virtchnl: move virtchnl and virtchnl2 headers to 'include/linux/net/intel' 2026-08-12 13:56:50 -07:00
iavf_virtchnl.c iavf: send MAC change request synchronously 2026-09-28 09:09:06 -07:00
iavf.h iavf: send MAC change request synchronously 2026-09-28 09:09:06 -07:00
Makefile iavf: add initial framework for registering PTP clock 2025-02-14 10:58:07 -08:00