From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796488096; b=oTsEz9CGwECACZ74ME09GknzZIfDjSuHCH8REcE8Aoo5/uiNN+7bEXTu4K+v0xQA7Am+ +ECuq/b3Huywrb0nCDNqCbKoXAiw/FpoKOf0foxjXpEmtB2K5vzF1rUSQ42mushKS47/3 ShyDn0rPfI94ctu5FBbUR5ho8UVwI1XiKQ+w29GqEYLvegX0HD6AyhFQXgQaiQ9uKQDyK jd3xH4riC/waobPD4/Mc2UUb1ggPHccHxCAyuWBW9g4pUBS4SsFdXbJuDiOOFh+rAJtMB PUxV7NVMbC7xmL6yqKNwN6xoEsyDNNiL1nfLpa8phqC7ewUdvLW5kfgpRogAY/UyIzg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796488096; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=xiL0lSLFTHLA8zHQO/ZdePMWSND6Iz85j5Ox4B/OI/A=; b=gx3ajYJiNO4wxUQEu+RqIr/ymiPsCvUG5/oCH4/nmBnBkO0j0AvrgGoYB0XYQsz2dbOC /Qb1md9R8EbFQQ6ADaATxGsv9kBu9/C8/QjJRLTxeWcj24PilBPIh9JXg3KtfBsgcSQdS D8zWnObChkeLDCkyZlyW42UyUNfwrtOX643ySJTTbMLD1xuj0qwFP6MR6CxxwU5ba9ewZ GJ6eTPipxueQkNVzeEKoGTQ4qIRgdYK4C6TLY5VjxMmbFTOVIPl40mR+bbzFnPUyU/3N0 R71sP8nZ3lyZowCZs5YWRoZ5yoVH1BGkdHVHAfbyUkB6/TJYyGqrbi6yb6lreOyED+Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="QScti5/b"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E67F2606A31F; Sat, 5 Dec 2026 16:28:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=QScti5/b Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE21D1F0092B; Sat, 5 Dec 2026 16:28:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796488095; bh=xiL0lSLFTHLA8zHQO/ZdePMWSND6Iz85j5Ox4B/OI/A=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=QScti5/b1bNFw+4jbgyux7KTHVu4wy9E48IeS+fRV/x6qZHmXum6S98KMumfWuLOw 75E1pqmpxko+iKZeyejCsTbsmlbYQ42VCwD81cLjXPy4bh2fDC2t/GxH8MYjxW+tI1 ihvlqATyc5wt2szr16PoqSe73Cv4cM19diuTQsGlENhvQwLeTzxJZB6d2YF5s20eJ0 uTp2pBdDSssGwZ0iJKfC/UQzoNxtdgfR2J53ENo1asSxAzjKhTjj2CDDHSOVMfQszF 9YK2h4USLfNTI0LwivE5p9ZzZTeg+Mj5NzoAotrhOt+wijS5jd7zhjb1uHquPpbpEb o1CHFm+Vzr+bA== Subject: Re: [PATCH net-next v6 3/7] enic: recover V2 VF mailbox after request failure From: netdev-bot+sashiko@kernel.org To: satishkh@cisco.com Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, willemb@google.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, sebaddel@cisco.com, aradhana@cisco.com, rfaucett@cisco.com, sdf@fomichev.me Date: Sat, 05 Dec 2026 16:28:14 +0000 Message-ID: <179648809418.3146.9244959051160965661@kernel.org> In-Reply-To: <20261204-b4-enic-sriov-v2-vf-receive-control-v6-3-ca38950bbe07@cisco.com> References: <20261204-b4-enic-sriov-v2-vf-receive-control-v6-3-ca38950bbe07@cisco.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 3 · Low: 2 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] The subject and framing describe V2 VF mailbox recovery, but the patch also changes reset and stop behaviour for every enic… - [Medium] A mailbox fault that arrives while enic_reset() or enic_hang_reset() is reopening a V2 VF, after the re-registration in… - [Medium] __enic_stop() clears datapath_open on entry and then jumps to stop_failed at the first failing vnic_wq_disable() or… - [Low] vnic_dev_hang_reset() no longer sends CMD_INIT after its SOFT_RESET fallback. - [Low] enic: duplicated recovery logic and dead reopen checks in reset handlers -- enic: recover V2 VF mailbox after request failure This commit adds recovery for the V2 VF mailbox after a lost or inconsistent reply, or after a send-completion timeout. Recovery runs on a dedicated work item that shares the hang-reset sequence with the Tx watchdog. The commit also reworks the reset paths to check stop, reset, INIT and reopen results, and adds a datapath_open latch and an RX quarantine gate. > diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c > index dde9098357d16..587c340854cb2 100644 > --- a/drivers/net/ethernet/cisco/enic/enic_main.c > +++ b/drivers/net/ethernet/cisco/enic/enic_main.c [ ... ] > @@ -1841,12 +1929,17 @@ static int enic_open(struct net_device *netdev) > } > > /* rtnl lock is held, process context */ > -static int enic_stop(struct net_device *netdev) > +static int __enic_stop(struct net_device *netdev) > { > struct enic *enic = netdev_priv(netdev); > unsigned int i; > int err; > > + /* IFF_UP can outlive a failed internal recovery. Stop software once. */ > + if (!READ_ONCE(enic->datapath_open)) > + return 0; > + WRITE_ONCE(enic->datapath_open, false); > + [ ... ] > @@ -1871,23 +1964,25 @@ static int enic_stop(struct net_device *netdev) > napi_disable(&enic->napi[enic_cq_wq(enic, i)]); > netif_tx_disable(netdev); > > + /* Detach IRQ callbacks even if a later queue disable fails. */ > + enic_unset_affinity_hint(enic); > + enic_free_intr(enic); > + > if (!enic_is_dynamic(enic) && !enic_is_sriov_vf(enic)) > enic_dev_del_station_addr(enic); > > for (i = 0; i < enic->wq_count; i++) { > err = vnic_wq_disable(&enic->wq[i].vwq); > if (err) > - return err; > + goto stop_failed; > } > for (i = 0; i < enic->rq_count; i++) { > err = vnic_rq_disable(&enic->rq[i].vrq); > if (err) > - return err; > + goto stop_failed; > } > > enic_dev_notify_unset(enic); [ ... ] > @@ -1902,6 +1997,18 @@ static int enic_stop(struct net_device *netdev) > vnic_intr_clean(&enic->intr[i]); > > return 0; > + > +stop_failed: > + /* Prevent another open from treating this partial stop as a clean one. > + * Generic queue DMA lifetime after a stop failure is separate work. > + */ > + enic_detach_after_recovery_failure(enic); > + return err; > +} [Severity: Medium] Does this path leave the remaining queues enabled, and leak the RQ page pools and in-flight TX skbs? datapath_open is cleared on entry. The first failing vnic_wq_disable() or vnic_rq_disable() then jumps to stop_failed and skips: - the remaining WQ and RQ disables - enic_dev_notify_unset() - vnic_wq_clean() for the TX skbs and their DMA mappings - vnic_rq_clean() and page_pool_destroy() - the CQ and intr cleans The unwind in enic_open() keeps disabling every queue after a failure, so the two paths now behave differently. Because datapath_open is already false, a later remove does not retry the stop: enic_remove() unregister_netdev() enic_stop() __enic_stop() <- returns 0, !datapath_open enic_dev_deinit() enic_free_vnic_resources() <- frees rings of queues never disabled enic_dev_close() Also, enic_reset() no longer soft resets the device after a stop failure. It abandons recovery instead. The queues after the first failing one are not stuck. Could they still be disabled? Could the rings be freed only after CMD_CLOSE when the stop failed? [ ... ] > @@ -2271,135 +2497,343 @@ static void enic_admin_chan_reopen(struct enic *enic) [ ... ] > +static bool enic_vf_mbox_recovery_finish(struct enic *enic, bool succeeded) > +{ > + bool restart; > + > + spin_lock_bh(&enic->mbox_state_lock); > + /* Restart only for a fault still outstanding after recovery. Fresh > + * registration may already have consumed a fault from the old channel. > + * A failed handshake remains quarantined for an external recovery event. > + */ > + restart = succeeded && > + (READ_ONCE(enic->vf_mbox_reconnect_required) || > + READ_ONCE(enic->mbox_tx_poisoned)); > + enic->vf_mbox_recovery_active = false; > + spin_unlock_bh(&enic->mbox_state_lock); > + > + return restart; > } [Severity: Medium] Can a mailbox fault in the reopen window leave a V2 VF down with no follow-up recovery? The window opens after enic_admin_chan_reopen() has re-registered and closes at the final check in enic_open(): enic_hang_reset() or enic_reset() enic_vf_mbox_recovery_begin() <- sets vf_mbox_recovery_active enic_admin_chan_reopen() <- registration succeeds fault: admin_rx_lost, vf_ack_work send timeout, ... enic_mbox_vf_kick_recovery() <- no schedule, recovery active enic_open() final mailbox state check <- returns -EIO enic_admin_channel_close() enic_vf_mbox_recovery_finish(enic, false) <- restart is false The VF is left in this state: - IFF_UP set - datapath_open false - carrier off - RX quarantined - admin channel down With no admin channel, no new fault can be raised. The Tx watchdog needs carrier. Nothing queues vf_mbox_recovery_work again. If the same fault arrives just after the final check passes, it does get a restart. Later in the series, enic_open() also sends station-address and packet-filter requests, which widens this window. The final version still uses "restart = succeeded && ...". Should a transient fault after a successful handshake be handled differently from a PF that cannot complete registration at all? [ ... ] > + err = enic_dev_soft_reset(enic); > + if (err) { > + enic_detach_after_recovery_failure(enic); > + goto reset_out; > + } > + /* Firmware completes SOFT_RESET in OPEN state. Non-dynamic vNICs need > + * CMD_INIT to recreate and enable their LIF before resource restore. > + */ > + if (!enic_is_dynamic(enic)) { > + err = enic_vnic_dev_init(enic); > + if (err) { > + netdev_err(enic->netdev, > + "vNIC init after soft reset failed: %d\n", > + err); > + enic_detach_after_recovery_failure(enic); > + goto reset_out; > + } > + } > > - enic_dev_soft_reset(enic); > enic_reset_addr_lists(enic); [Severity: Medium] The subject and most of the commit message describe V2 VF mailbox recovery. Several changes in this patch apply to every enic function, though, including PFs, standalone vNICs and dynamic vNICs: - enic_reset() now sends CMD_INIT through enic_vnic_dev_init() after SOFT_RESET for every non-dynamic function. The old code never did this. - On any function, a failed soft reset, hang reset or INIT, or a queue-disable failure in __enic_stop(), now calls netif_device_detach(). Before, the error was ignored and the datapath was reopened. - The legacy vnic_dev_hang_reset() fallback no longer sends INIT itself. - enic_reset_addr_lists() now takes netif_addr_lock_bh(). - Soft reset start and status now run under devcmd_lock. The new comment says the old code could collide with CMD_STATS_DUMP and report a false failure. For example, one transient devcmd timeout during queue-error recovery on a standalone NIC now leaves the interface detached until the driver is rebound. Before this patch, the interface was reopened. The V2 PF SR-IOV enable path is still dormant, since enic_sriov_configure() is __maybe_unused. For PF and non-SR-IOV users, these generic changes are the only part of the patch that takes effect. The locking changes look like fixes for older bugs, and the INIT change is either a fix or a new firmware command on every PF reset. Could these be split into their own patches with Fixes: tags? Could the commit message also describe the new behaviour for non-VF functions? [ ... ] > diff --git a/drivers/net/ethernet/cisco/enic/vnic_dev.c b/drivers/net/ethernet/cisco/enic/vnic_dev.c > index 92eec1455ceb8..a78bd58f950f5 100644 > --- a/drivers/net/ethernet/cisco/enic/vnic_dev.c > +++ b/drivers/net/ethernet/cisco/enic/vnic_dev.c > @@ -721,17 +721,23 @@ int vnic_dev_hang_reset(struct vnic_dev *vdev, int arg) > { > u64 a0 = (u32)arg, a1 = 0; > int wait = 1000; > - int err; > > + vdev->hang_reset_uses_soft_reset = false; > if (vnic_dev_capable(vdev, CMD_HANG_RESET)) { > return vnic_dev_cmd(vdev, CMD_HANG_RESET, > &a0, &a1, wait); > - } else { > - err = vnic_dev_soft_reset(vdev, arg); > - if (err) > - return err; > - return vnic_dev_init(vdev, 0); > } > + > + /* enic_dev_wait() polls SOFT_RESET_STATUS. INIT follows reset completion > + * in the driver, after the ordinary close has succeeded. > + */ > + vdev->hang_reset_uses_soft_reset = true; > + return vnic_dev_soft_reset(vdev, arg); > } [Severity: Low] Is this comment accurate? Its only caller, enic_hang_reset(), sends INIT only when: if (needs_init && !enic_is_dynamic(enic)) { enic_dev_hang_reset() also forces needs_init to false for V2 VFs. So on firmware without CMD_HANG_RESET, a dynamic vNIC now gets a bare SOFT_RESET and no INIT. The old helper always called vnic_dev_init(). The commit message says dynamic vNICs follow their probe-time initialization contract, and enic_probe() matches that. Could this comment say which functions receive INIT afterwards, so the helper and its caller agree on who owns INIT? [ ... ] > @@ -2271,135 +2497,343 @@ static void enic_admin_chan_reopen(struct enic *enic) > */ > schedule_work(&enic->link_notify_work); > } > + > + return 0; > +} > + > +static bool enic_vf_mbox_recovery_begin(struct enic *enic, > + bool mailbox_recovery) > +{ > + bool claimed = false; > + > + /* Reset workers claim ownership only after taking RTNL. This state > + * lock still makes the handoff atomic with mailbox fault producers. > + */ > + spin_lock_bh(&enic->mbox_state_lock); > + /* Open may have consumed a queued mailbox fault while holding RTNL. */ > + if (!enic->vf_mbox_recovery_active && > + (!mailbox_recovery || > + READ_ONCE(enic->vf_mbox_reconnect_required) || > + READ_ONCE(enic->mbox_tx_poisoned))) { > + enic->vf_mbox_recovery_active = true; > + WRITE_ONCE(enic->vf_rx_quarantined, true); > + claimed = true; > + } > + spin_unlock_bh(&enic->mbox_state_lock); > + > + return claimed; > +} > + > +static bool enic_vf_mbox_recovery_finish(struct enic *enic, bool succeeded) > +{ > + bool restart; > + > + spin_lock_bh(&enic->mbox_state_lock); > + /* Restart only for a fault still outstanding after recovery. Fresh > + * registration may already have consumed a fault from the old channel. > + * A failed handshake remains quarantined for an external recovery event. > + */ > + restart = succeeded && > + (READ_ONCE(enic->vf_mbox_reconnect_required) || > + READ_ONCE(enic->mbox_tx_poisoned)); > + enic->vf_mbox_recovery_active = false; > + spin_unlock_bh(&enic->mbox_state_lock); > + > + return restart; > } > > static void enic_reset(struct work_struct *work) > { > struct enic *enic = container_of(work, struct enic, reset); > + bool recovery_owned = false; > + bool restart = false; > + bool reopen; > + int stop_err = 0; > + int err = 0; > > if (!netif_running(enic->netdev)) > return; > - > rtnl_lock(); > - > - if (!netif_running(enic->netdev)) > + reopen = netif_running(enic->netdev); > + if (!reopen || !netif_device_present(enic->netdev)) > goto unlock; > > - /* Stop any activity from infiniband */ > + /* Serialize a live V2 VF protocol recovery and preserve its one bounded > + * late-fault follow-up. > + */ > + if (reopen && enic_is_sriov_vf_v2(enic)) { > + recovery_owned = enic_vf_mbox_recovery_begin(enic, false); > + if (!recovery_owned) > + goto unlock; > + } > + > + /* Stop any activity from infiniband. */ > enic_set_api_busy(enic, true); > > - /* Close the V2 admin/MBOX channel before the soft reset. Release its > - * DMA resources only after both queues report stopped; otherwise > - * quarantine the channel and abandon the reset. > + /* Close the admin channel before reset without sending DEL_MAC; reset and > + * fresh registration discard the old VF-requested state. Release its DMA > + * resources only after both queues report stopped. Otherwise quarantine > + * the channel and abandon the reset. > */ > if (enic_has_admin_chan(enic)) { > - enic_admin_channel_close(enic); > + int close_err = enic_admin_channel_close(enic); > + > + if (close_err && enic_admin_channel_is_quarantined(enic)) > + netdev_err(enic->netdev, > + "Admin queue did not stop: %d\n", close_err); > + else if (close_err) > + netdev_warn(enic->netdev, > + "Admin QP disable returned: %d\n", > + close_err); > /* Channel close has drained registration replies. */ > if (enic_is_sriov_vf_v2(enic)) > WRITE_ONCE(enic->vf_registered, false); > } > - if (enic_admin_channel_is_quarantined(enic)) { > - /* Core close excludes netpoll and clears __LINK_STATE_START first. */ > - dev_close(enic->netdev); > - goto reset_out; > - } > + if (READ_ONCE(enic->datapath_open)) > + stop_err = __enic_stop(enic->netdev); > > - enic_stop(enic->netdev); > if (enic_is_sriov_vf_v2(enic)) > enic_mbox_vf_link_state_reset(enic); > + if (stop_err || enic_control_dma_unresolved(enic)) { > + err = stop_err ?: -EBUSY; > + netdev_err(enic->netdev, > + "Recovery blocked after close (datapath stop %d)\n", > + stop_err); > + goto reset_out; > + } > + > + err = enic_dev_soft_reset(enic); > + if (err) { > + enic_detach_after_recovery_failure(enic); > + goto reset_out; > + } > + /* Firmware completes SOFT_RESET in OPEN state. Non-dynamic vNICs need > + * CMD_INIT to recreate and enable their LIF before resource restore. > + */ > + if (!enic_is_dynamic(enic)) { > + err = enic_vnic_dev_init(enic); > + if (err) { > + netdev_err(enic->netdev, > + "vNIC init after soft reset failed: %d\n", > + err); > + enic_detach_after_recovery_failure(enic); > + goto reset_out; > + } > + } > > - enic_dev_soft_reset(enic); > enic_reset_addr_lists(enic); > enic_init_vnic_resources(enic); > enic_set_rss_nic_cfg(enic); > enic_dev_set_ig_vlan_rewrite_mode(enic); > enic_ext_cq(enic); > > - if (enic_open(enic->netdev)) > + /* A V2 VF registers with the PF before reopening its datapath. > + * A V2 PF rebuilds its admin channel after datapath open. > + */ > + if (enic_is_sriov_vf_v2(enic)) { > + err = enic_admin_chan_reopen(enic); > + if (err) > + goto reset_out; > + } > + > + if (reopen) > + err = enic_open(enic->netdev); > + if (reopen && err) { > + if (enic_is_sriov_vf_v2(enic) && enic_has_admin_chan(enic)) { > + int close_err = enic_admin_channel_close(enic); > + > + WRITE_ONCE(enic->vf_registered, false); > + if (close_err) > + netdev_warn(enic->netdev, > + "Admin close after datapath reopen failure returned: %d\n", > + close_err); > + } > + netdev_err(enic->netdev, > + "Failed to reopen datapath after reset: %d\n", err); > goto reset_out; > + } > > - /* Re-establish the admin/MBOX channel after the data path is back up. > - * It was fully torn down by enic_admin_channel_close() above; > - * enic_admin_chan_reopen() reopens it and, for a PF re-pushes link > - * state, or for a VF re-runs the probe-time PF handshake. > + /* A PF reopens its admin channel after the datapath and re-pushes link > + * state. The VF handshake, which open depends on, completed above. > */ > - if (enic_has_admin_chan(enic)) > - enic_admin_chan_reopen(enic); > - if (enic_is_sriov_vf_v2(enic) && > - enic_admin_channel_is_quarantined(enic)) > - dev_close(enic->netdev); > + if (enic_has_admin_chan(enic) && !enic_is_sriov_vf_v2(enic)) { > + int admin_err = enic_admin_chan_reopen(enic); > + > + if (admin_err) > + netdev_err(enic->netdev, > + "Failed to reopen PF admin channel after reset: %d\n", > + admin_err); > + if (!err) > + err = admin_err; > + } > > reset_out: > /* Allow infiniband to fiddle with the device again */ > enic_set_api_busy(enic, false); > > - call_netdevice_notifiers(NETDEV_REBOOT, enic->netdev); > + if (reopen) > + call_netdevice_notifiers(NETDEV_REBOOT, enic->netdev); > > unlock: > + if (recovery_owned) > + restart = enic_vf_mbox_recovery_finish(enic, > + !err && > + !enic_control_dma_unresolved(enic)); > rtnl_unlock(); > + if (restart) > + schedule_work(&enic->vf_mbox_recovery_work); > } > > -static void enic_tx_hang_reset(struct work_struct *work) > +static void enic_hang_reset(struct enic *enic, bool mailbox_recovery) > { > - struct enic *enic = container_of(work, struct enic, tx_hang_reset); > + bool recovery_owned = false; > + bool restart = false; > + bool needs_init; > + bool reopen; > + int stop_err = 0; > + int err = 0; > > rtnl_lock(); > - > - if (!netif_running(enic->netdev)) > + reopen = netif_running(enic->netdev); > + if (!reopen || !netif_device_present(enic->netdev)) > goto unlock; > + if (reopen && enic_is_sriov_vf_v2(enic)) { > + recovery_owned = enic_vf_mbox_recovery_begin(enic, > + mailbox_recovery); > + if (!recovery_owned) > + goto unlock; > + } > > - /* Stop any activity from infiniband */ > + /* Stop any activity from infiniband. */ > enic_set_api_busy(enic, true); > > - /* Close the V2 admin/MBOX channel before the hang reset. Release its > - * DMA resources only after both queues report stopped; otherwise > - * quarantine the channel and abandon the reset. > + /* Report an actual Tx hang before stopping and cleaning its queue. Mailbox > + * recovery reuses the VF-allowed hang-reset pair but must not report a > + * spurious Tx hang. As in the soft-reset path, skip DEL_MAC because reset > + * and fresh registration are the cleanup boundary. Release admin DMA only > + * after both queues report stopped; otherwise quarantine the channel and > + * abandon the reset. > */ > + if (!mailbox_recovery) > + enic_dev_hang_notify(enic); > if (enic_has_admin_chan(enic)) { > - enic_admin_channel_close(enic); > + int close_err = enic_admin_channel_close(enic); > + > + if (close_err && enic_admin_channel_is_quarantined(enic)) > + netdev_err(enic->netdev, > + "Admin queue did not stop: %d\n", close_err); > + else if (close_err) > + netdev_warn(enic->netdev, > + "Admin QP disable returned: %d\n", > + close_err); > /* Channel close has drained registration replies. */ > if (enic_is_sriov_vf_v2(enic)) > WRITE_ONCE(enic->vf_registered, false); > } > - if (enic_admin_channel_is_quarantined(enic)) { > - dev_close(enic->netdev); > - goto reset_out; > - } > - > - enic_dev_hang_notify(enic); > - enic_stop(enic->netdev); > + if (READ_ONCE(enic->datapath_open)) > + stop_err = __enic_stop(enic->netdev); > if (enic_is_sriov_vf_v2(enic)) > enic_mbox_vf_link_state_reset(enic); > + if (stop_err || enic_control_dma_unresolved(enic)) { > + err = stop_err ?: -EBUSY; > + netdev_err(enic->netdev, > + "Recovery blocked after close (datapath stop %d)\n", > + stop_err); > + goto hang_reset_out; > + } > > - enic_dev_hang_reset(enic); > + err = enic_dev_hang_reset(enic, &needs_init); > + if (err) { > + enic_detach_after_recovery_failure(enic); > + goto hang_reset_out; > + } > + /* Native HANG_RESET preserves firmware's desired admin state and the > + * firmware reinitializes it. Only the legacy SOFT_RESET fallback sets > + * needs_init and requires the deferred CMD_INIT below. > + */ > + if (needs_init && !enic_is_dynamic(enic)) { > + err = enic_vnic_dev_init(enic); > + if (err) { > + netdev_err(enic->netdev, > + "vNIC init after hang reset failed: %d\n", > + err); > + enic_detach_after_recovery_failure(enic); > + goto hang_reset_out; > + } > + } > enic_reset_addr_lists(enic); > enic_init_vnic_resources(enic); > enic_set_rss_nic_cfg(enic); > enic_dev_set_ig_vlan_rewrite_mode(enic); > enic_ext_cq(enic); > > - if (enic_open(enic->netdev)) > - goto reset_out; > + if (enic_is_sriov_vf_v2(enic)) { > + err = enic_admin_chan_reopen(enic); > + if (err) > + goto hang_reset_out; > + } > + > + if (reopen) > + err = enic_open(enic->netdev); > + if (reopen && err) { > + if (enic_is_sriov_vf_v2(enic) && enic_has_admin_chan(enic)) { > + int close_err = enic_admin_channel_close(enic); > > - /* Re-establish the admin/MBOX channel after the data path is back up. > - * It was fully torn down by enic_admin_channel_close() above; > - * enic_admin_chan_reopen() reopens it and, for a PF re-pushes link > - * state, or for a VF re-runs the probe-time PF handshake. > + WRITE_ONCE(enic->vf_registered, false); > + if (close_err) > + netdev_warn(enic->netdev, > + "Admin close after datapath reopen failure returned: %d\n", > + close_err); > + } > + netdev_err(enic->netdev, > + "Failed to reopen datapath after hang reset: %d\n", err); > + goto hang_reset_out; > + } > + > + /* A PF reopens its admin channel after the datapath and re-pushes link > + * state. The VF handshake, which open depends on, completed above. > */ > - if (enic_has_admin_chan(enic)) > - enic_admin_chan_reopen(enic); > - if (enic_is_sriov_vf_v2(enic) && > - enic_admin_channel_is_quarantined(enic)) > - dev_close(enic->netdev); > + if (enic_has_admin_chan(enic) && !enic_is_sriov_vf_v2(enic)) { > + int admin_err = enic_admin_chan_reopen(enic); > > -reset_out: > + if (admin_err) > + netdev_err(enic->netdev, > + "Failed to reopen PF admin channel after hang reset: %d\n", > + admin_err); > + if (!err) > + err = admin_err; > + } > + > +hang_reset_out: > /* Allow infiniband to fiddle with the device again */ > enic_set_api_busy(enic, false); > > - call_netdevice_notifiers(NETDEV_REBOOT, enic->netdev); > + if (reopen) > + call_netdevice_notifiers(NETDEV_REBOOT, enic->netdev); > > unlock: > + if (recovery_owned) > + restart = enic_vf_mbox_recovery_finish(enic, > + !err && > + !enic_control_dma_unresolved(enic)); > rtnl_unlock(); > + if (restart) > + schedule_work(&enic->vf_mbox_recovery_work); > +} > + > +static void enic_tx_hang_reset(struct work_struct *work) > +{ > + struct enic *enic = container_of(work, struct enic, tx_hang_reset); > + > + enic_hang_reset(enic, false); > +} > + > +static void enic_vf_mbox_recovery_work(struct work_struct *work) > +{ > + struct enic *enic = container_of(work, struct enic, > + vf_mbox_recovery_work); > + > + enic_hang_reset(enic, true); > } > > static int enic_set_intr_mode(struct enic *enic) [Severity: Low] enic_reset() and enic_hang_reset() are now almost line-for-line copies of each other. Both do the following: - take RTNL and check netif_running() and netif_device_present() - claim recovery with enic_vf_mbox_recovery_begin() - close the admin channel, with the same logging - call __enic_stop() and enic_mbox_vf_link_state_reset() - run the same blocked-recovery check - re-init the vNIC resources - reopen the VF admin channel - call enic_open(), with the same admin-close rollback on failure - reopen the PF admin channel and send NETDEV_REBOOT - call enic_vf_mbox_recovery_finish() and queue the vf_mbox_recovery_work follow-up The only real differences are: - enic_dev_hang_notify() for a genuine Tx hang - SOFT_RESET followed by INIT on every non-dynamic function, versus HANG_RESET with INIT only when needs_init is set - the mailbox_recovery argument passed to enic_vf_mbox_recovery_begin() This sequence has subtle ordering between the admin channel, the datapath and mbox_state_lock. With two copies, the paths can easily drift apart. Later in the series, the receive-mode replay after reopen already had to be added to both functions. There is also dead code. Both functions set reopen from netif_running() and jump to unlock when it is false. Nothing changes reopen after that, so every later test of it is always true. That covers four checks in each function: - the check before the recovery claim - the check before enic_open() - the check on the open error path - the check before the NETDEV_REBOOT notifier These checks suggest a case where recovery runs without reopening, but no such case exists. Could the shared sequence move into one helper that takes the reset type, with the two work functions only choosing it? If reopen is meant to cover a device that is not running, which path is that? -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204-b4-enic-sriov-v2-vf-receive-control-v6-0-ca38950bbe07%40cisco.com