From: Alexander Lopintsev <cldlss@gmail.com>
To: anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com
Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com
Subject: [PATCH net] iavf: restore queues after failed VF reset
Date: Thu, 3 Dec 2026 11:39:36 +0300 [thread overview]
Message-ID: <20261203083936.79920-1-cldlss@gmail.com> (raw)
If Admin Queue initialization fails during a VF reset, iavf_disable_vf()
frees the queues and lets the watchdog retry initialization. The registered
netdev can retain IFF_UP while the adapter reaches __IAVF_DOWN. The
finish-config worker updates the queue counts but does not allocate and
enable the data queues, leaving the interface without traffic until a
manual down/up.
This was observed as a connectivity loss on a running SR-IOV guest.
Reproduce the recovery failure by returning IAVF_ERR_ADMIN_QUEUE_ERROR
once from the post-reset iavf_init_adminq() call through a lab-only hook.
Request the VF reset by changing the RX descriptor count.
Share the queue-start sequence with ndo_open and run it from
iavf_finish_config() for an already registered, administratively up VF.
Keep RTNL before the netdev lock, skip removal and pending resets, and
leave carrier updates to the existing virtchnl completion path. Clear
address synchronization state when the VF filters are discarded so that
reinitialization can replay them. Reschedule finish-config when a
follow-on reset finishes before queue restart.
Remove the unreachable RUNNING check while extracting the open sequence.
The preceding DOWN check already returns -EBUSY for RUNNING adapters.
The 2023 revert removed dev_close() from reset failures while retaining
the removal of direct IFF_UP updates. Reopening the preserved interface
after successful reinitialization restores the missing recovery step.
Two hardware A/B runs on an Intel X722 VF with an i40e PF and Ubuntu
7.0.0-38-generic reproduced carrier 0 for 30 seconds with the baseline.
With this change, the same injected failure recovered carrier and three
consecutive IPv6 replies while preserving IFF_UP. Control resets also
recovered. Testing required the one-shot source hook described
above.
The full x86 allmodconfig and allyesconfig all targets build before and
after this fix with W=1 and GCC 13.4.0. CONFIG_WERROR and
CONFIG_DRM_WERROR are disabled for existing baseline warnings, while
iavf_main.c is built with -Werror. allyesconfig uses KASAN_OUTLINE to fit
the build host; KASAN remains enabled. The fixed builds reuse completed
baseline objects and add no warnings. Kernel networking selftests and
runtime testing on the current net base have not been run.
Developed with AI assistance (Codex); reviewed with Kimi and Mistral.
Fixes: d916d273041b ("Revert "iavf: Do not restart Tx queues after reset task failure"")
Signed-off-by: Alexander Lopintsev <cldlss@gmail.com>
---
Notes for reviewers:
Przemek's XLVF v7 01/15 [1] addresses RSS and resource handling during
reinitialization after iavf_disable_vf(). This patch restores the data
queues when that reinitialization leaves a registered, administratively
up netdev in __IAVF_DOWN. The relevant posted XLVF diffs do not add this
queue restart.
Yuho's queue-disable failure patch [2] keeps rings allocated when the PF
fails VIRTCHNL_OP_DISABLE_QUEUES. Here, the injected failure is in
post-reset Admin Queue initialization. The comparison is based on the
posted diffs; combined runtime testing with either proposal has not been
performed.
The trigger of the original PF reset has not been established. The
one-shot hook reproduces the recovery failure after that reset. Hardware
A/B used the Ubuntu kernel described above; runtime testing on the net
base remains pending. The Fixes attribution follows source history,
without a hardware bisect of historical kernels.
A local C control-flow regression and an alternative hardware regression
harness are public at [3]. The public hardware harness uses fail_function
with a debug kernel. The A/B results above used the one-shot module
parameter hook; the public fail_function harness has not been
hardware-validated.
[1] https://lists.openwall.net/netdev/2026/11/21/273
[2] https://lists.openwall.net/netdev/2026/11/02/63
[3] https://github.com/alopintsev/iavf-recovery/tree/bddcb3ba700b42f25487e9027f8018047bbf06ff
drivers/net/ethernet/intel/iavf/iavf_main.c | 107 ++++++++++++--------
1 file changed, 66 insertions(+), 41 deletions(-)
diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
index 4de3ea852..c235c408f 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -14,6 +14,7 @@
#define CREATE_TRACE_POINTS
#include "iavf_trace.h"
+static int iavf_start_queues(struct iavf_adapter *adapter);
static int iavf_setup_all_tx_resources(struct iavf_adapter *adapter);
static int iavf_setup_all_rx_resources(struct iavf_adapter *adapter);
static int iavf_close(struct net_device *netdev);
@@ -2003,21 +2004,23 @@ static int iavf_reinit_interrupt_scheme(struct iavf_adapter *adapter, bool runni
static void iavf_finish_config(struct work_struct *work)
{
struct iavf_adapter *adapter;
+ struct net_device *netdev;
bool netdev_released = false;
int pairs, err;
adapter = container_of(work, struct iavf_adapter, finish_config);
+ netdev = adapter->netdev;
/* Always take RTNL first to prevent circular lock dependency;
* the dev->lock (== netdev lock) is needed to update the queue number.
*/
rtnl_lock();
- netdev_lock(adapter->netdev);
+ netdev_lock(netdev);
if ((adapter->flags & IAVF_FLAG_SETUP_NETDEV_FEATURES) &&
- adapter->netdev->reg_state == NETREG_REGISTERED &&
+ netdev->reg_state == NETREG_REGISTERED &&
!test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section)) {
- netdev_update_features(adapter->netdev);
+ netdev_update_features(netdev);
adapter->flags &= ~IAVF_FLAG_SETUP_NETDEV_FEATURES;
}
@@ -2027,33 +2030,44 @@ static void iavf_finish_config(struct work_struct *work)
* state == __IAVF_DOWN
*/
pairs = adapter->num_active_queues;
- netif_set_real_num_rx_queues(adapter->netdev, pairs);
- netif_set_real_num_tx_queues(adapter->netdev, pairs);
+ netif_set_real_num_rx_queues(netdev, pairs);
+ netif_set_real_num_tx_queues(netdev, pairs);
- if (adapter->netdev->reg_state != NETREG_REGISTERED) {
- netdev_unlock(adapter->netdev);
+ if (netdev->reg_state != NETREG_REGISTERED) {
+ netdev_unlock(netdev);
netdev_released = true;
- err = register_netdevice(adapter->netdev);
+ err = register_netdevice(netdev);
if (err) {
dev_err(&adapter->pdev->dev, "Unable to register netdev (%d)\n",
err);
/* go back and try again.*/
- netdev_lock(adapter->netdev);
+ netdev_lock(netdev);
iavf_free_rss(adapter);
iavf_free_misc_irq(adapter);
iavf_reset_interrupt_capability(adapter);
iavf_change_state(adapter,
__IAVF_INIT_CONFIG_ADAPTER);
- netdev_unlock(adapter->netdev);
+ netdev_unlock(netdev);
goto out;
}
+ } else if ((netdev->flags & IFF_UP) && netif_device_present(netdev) &&
+ !(adapter->flags & (IAVF_FLAG_PF_COMMS_FAILED |
+ IAVF_FLAG_RESET_PENDING |
+ IAVF_FLAG_RESET_NEEDED)) &&
+ !test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section)) {
+ /* The netdev kept IFF_UP while the VF was down. */
+ adapter->flags |= IAVF_FLAG_QUEUES_DISABLED;
+ err = iavf_start_queues(adapter);
+ if (err)
+ netdev_err(netdev, "Failed to restart queues after VF reinitialization: %d\n",
+ err);
}
break;
case __IAVF_RUNNING:
pairs = adapter->num_active_queues;
- netif_set_real_num_rx_queues(adapter->netdev, pairs);
- netif_set_real_num_tx_queues(adapter->netdev, pairs);
+ netif_set_real_num_rx_queues(netdev, pairs);
+ netif_set_real_num_tx_queues(netdev, pairs);
break;
default:
@@ -2062,7 +2076,7 @@ static void iavf_finish_config(struct work_struct *work)
out:
if (!netdev_released)
- netdev_unlock(adapter->netdev);
+ netdev_unlock(netdev);
rtnl_unlock();
}
@@ -3068,7 +3082,11 @@ static void iavf_disable_vf(struct iavf_adapter *adapter)
iavf_free_all_rx_resources(adapter);
}
+ /* Startup must be able to replay addresses whose VF filters are lost. */
+ netif_addr_lock_bh(adapter->netdev);
spin_lock_bh(&adapter->mac_vlan_list_lock);
+ __dev_uc_unsync(adapter->netdev, NULL);
+ __dev_mc_unsync(adapter->netdev, NULL);
/* Delete all of the filters */
list_for_each_entry_safe(f, ftmp, &adapter->mac_filter_list, list) {
@@ -3083,6 +3101,7 @@ static void iavf_disable_vf(struct iavf_adapter *adapter)
adapter->num_vlan_filters = 0;
spin_unlock_bh(&adapter->mac_vlan_list_lock);
+ netif_addr_unlock_bh(adapter->netdev);
spin_lock_bh(&adapter->cloud_filter_list_lock);
list_for_each_entry_safe(cf, cftmp, &adapter->cloud_filter_list, list) {
@@ -3341,6 +3360,9 @@ void iavf_reset_step(struct iavf_adapter *adapter)
} else {
iavf_change_state(adapter, __IAVF_DOWN);
wake_up(&adapter->down_waitqueue);
+ /* A follow-on reset can finish before the queues were restarted. */
+ if (netif_running(netdev))
+ iavf_schedule_finish_config(adapter);
}
adapter->flags &= ~IAVF_FLAG_REINIT_ITR_NEEDED;
@@ -4472,39 +4494,13 @@ static void iavf_restore_fdir_filters(struct iavf_adapter *adapter)
spin_unlock_bh(&adapter->fdir_fltr_lock);
}
-/**
- * iavf_open - Called when a network interface is made active
- * @netdev: network interface device structure
- *
- * Returns 0 on success, negative value on failure
- *
- * The open entry point is called when a network interface is made
- * active by the system (IFF_UP). At this point all resources needed
- * for transmit and receive operations are allocated, the interrupt
- * handler is registered with the OS, the watchdog is started,
- * and the stack is notified that the interface is ready.
- **/
-static int iavf_open(struct net_device *netdev)
+static int iavf_start_queues(struct iavf_adapter *adapter)
{
- struct iavf_adapter *adapter = netdev_priv(netdev);
+ struct net_device *netdev = adapter->netdev;
int err;
netdev_assert_locked(netdev);
- if (adapter->flags & IAVF_FLAG_PF_COMMS_FAILED) {
- dev_err(&adapter->pdev->dev, "Unable to open device due to PF driver failure.\n");
- return -EIO;
- }
-
- if (adapter->state != __IAVF_DOWN)
- return -EBUSY;
-
- if (adapter->state == __IAVF_RUNNING &&
- !test_bit(__IAVF_VSI_DOWN, adapter->vsi.state)) {
- dev_dbg(&adapter->pdev->dev, "VF is already open.\n");
- return 0;
- }
-
/* allocate transmit descriptors */
err = iavf_setup_all_tx_resources(adapter);
if (err)
@@ -4545,6 +4541,35 @@ static int iavf_open(struct net_device *netdev)
return err;
}
+/**
+ * iavf_open - Called when a network interface is made active
+ * @netdev: network interface device structure
+ *
+ * Returns 0 on success, negative value on failure
+ *
+ * The open entry point is called when a network interface is made
+ * active by the system (IFF_UP). At this point all resources needed
+ * for transmit and receive operations are allocated, the interrupt
+ * handler is registered with the OS, the watchdog is started,
+ * and the stack is notified that the interface is ready.
+ **/
+static int iavf_open(struct net_device *netdev)
+{
+ struct iavf_adapter *adapter = netdev_priv(netdev);
+
+ netdev_assert_locked(netdev);
+
+ if (adapter->flags & IAVF_FLAG_PF_COMMS_FAILED) {
+ dev_err(&adapter->pdev->dev, "Unable to open device due to PF driver failure.\n");
+ return -EIO;
+ }
+
+ if (adapter->state != __IAVF_DOWN)
+ return -EBUSY;
+
+ return iavf_start_queues(adapter);
+}
+
/**
* iavf_close - Disables a network interface
* @netdev: network interface device structure
base-commit: 0d39bf81267861742b80d5f1c52e8a63e9ca0ca1
--
2.50.1 (Apple Git-155)
reply other threads:[~2026-12-03 8:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261203083936.79920-1-cldlss@gmail.com \
--to=cldlss@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox