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=1796133892; b=HLk75kMpGWq60vtaJNTX2fD8VtC5QWpLXp7hmYNtGdB0KXbDC9yz8hmp794UT1yaK99H 5OGsuNqWbY0VSJ6MfSuQx5UZriW5BLpY5msOoJJCTl9oNjMiyF4g0WunwLAIag748KmxK viDg1mGw/x7ZFP5n/2jYQQnSg0+hjJrv644khmjpL57qELTfMZD2qQowH3S7P9WumlWtg 9PDr/zB2fVjJ5J0Xy6hR7hdP2iHBvhwT3P4I19BFi8NBcskiUBjapviLNJb7o90bR0yKl 4wmB6Ji6XkeExA08rwukj2blKD6AFttPm7gMfFo1jI1/BVRLKX91U7SZnqQfkr+tq9w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796133892; 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=ZU3/4xX7WFS1CubuJG5Y2++FpMaRIw2KyP64Fpd8Dpk=; b=JoSZ2oX+OUcAg8+bVLx0LMmQE/3OVQYEGi2xI0TcLXAVFFrXuysOBcvar4nlzfa5+VCx bwfQaOzX78CmwcsakvpJHUs7a0oTcEoNVvXEfsCpClF1oUEanrA8rbvcnXKyDaQGy/lb1 zIk0UuQsTHKhN8Nc+l4rhJmPgcMiO0s4rSHbes7YjQGAzTzLz9YEsRBxnKBPwKwg3JJIA QLbZfpReyJYbraP0PolygxoYgrfw4LaXIcswwd/XjJ+dS5YbfUT0ISHUdHD2NwFp3FsQu ttHb2SfRGyFp39ppR5RQbFU1erExPjd1kSsCYHd3daMcLPBZZwV2Ne8f85zR9UAGarg== 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=DUgHMFJM; 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 8CF24606A325; Tue, 1 Dec 2026 14:04:52 +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=DUgHMFJM Received: by smtp.kernel.org (Postfix) with ESMTPSA id 160851F00893; Tue, 1 Dec 2026 14:04:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796133891; bh=ZU3/4xX7WFS1CubuJG5Y2++FpMaRIw2KyP64Fpd8Dpk=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=DUgHMFJMgU+E0GDpxLryMo4SfLDYN7bysbwO9IHuRNukFZC0bbF7FVBygPvFlRvSP OflanzKrwJgu/xwOGO40NvUn52rNZlnaq7UyN9BwFrG2ydgzssfKP5PjyE3pbVixxM 5Jv8UHV50Eic5emgEukrU7dkyF0AQzHIPLeMadrCajyx7V1HkPv1GYKcZ7tF88a5UZ twpR4J9GkbGeeXI0ZUrDl+FJt/FG4aYxcTtZNQBN7uiHJW1ANyZ43kGX1yYUTRNBn7 SLYWjCRY2iKD8+T7ELGo1tMTjitoJ7/uzcrDmcoWkpXI7LbU59x8JURsrshfNfa+3+ s0PZ6OR6IFP/A== Subject: Re: [PATCH net-next v4 3/6] 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 Date: Tue, 01 Dec 2026 14:04:50 +0000 Message-ID: <179613389066.3146.6241038227181892804@kernel.org> In-Reply-To: <20261130-b4-enic-sriov-v2-vf-receive-control-v4-3-5858d5a9ecb1@cisco.com> References: <20261130-b4-enic-sriov-v2-vf-receive-control-v4-3-5858d5a9ecb1@cisco.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-kernel@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 (1) 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 commit is titled and framed as V2 VF mailbox recovery, but it changes the shared reset, stop and open paths of every ENIC device. - [Medium] The RX quarantine is not armed for internal resets that are not caused by a mailbox fault. - [Medium] A mailbox fault that arrives while a recovery worker is running is dropped if it also makes that recovery fail. - [Low] At this commit, several new comments describe behaviour that only later patches add. - [Low] The schedule_reset_on_failure parameter of __enic_open() and the helper enic_schedule_datapath_reset() are dead code. Pre-existing issues: - [Low] When a generic WQ/RQ disable fails in __enic_stop(), the code jumps to stop_failed after datapath_open has already been cleared. -- enic: recover V2 VF mailbox after request failure This patch adds V2 VF mailbox recovery after a lost reply or a send-completion timeout. Recovery runs on a dedicated work item and shares the hang-reset sequence with the Tx watchdog. The patch also reworks the shared open, stop and reset paths: it tracks datapath_open, takes devcmd_lock around the reset polls, issues runtime CMD_INIT after soft reset, and detaches the netdev when recovery fails. > diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c > index dde9098357d16..9c4b94a949809 100644 > --- a/drivers/net/ethernet/cisco/enic/enic_main.c > +++ b/drivers/net/ethernet/cisco/enic/enic_main.c [ ... ] > @@ -1743,6 +1760,37 @@ static int enic_open(struct net_device *netdev) > enic_admin_channel_is_quarantined(enic)) > return -EBUSY; > [ ... ] > + if (enic_is_sriov_vf_v2(enic) && > + (READ_ONCE(enic->admin_chan_state) != ENIC_ADMIN_CHAN_LIVE || > + READ_ONCE(enic->mbox_tx_poisoned) || > + !READ_ONCE(enic->vf_registered) || > + READ_ONCE(enic->vf_mbox_reconnect_required))) { > + /* Re-registration makes the PF discard the old VF-requested > + * filters. Clear the netdev-core synchronization state so the > + * receive-mode callback replays the current address lists. > + */ > + enic_reset_addr_lists(enic); > + if (READ_ONCE(enic->admin_chan_state) != > + ENIC_ADMIN_CHAN_DOWN) { > + err = enic_admin_channel_close(enic); > + if (READ_ONCE(enic->admin_chan_state) != > + ENIC_ADMIN_CHAN_DOWN) { > + if (schedule_reset_on_failure && > + !enic_admin_channel_is_quarantined(enic)) > + enic_schedule_datapath_reset(enic); > + return err ?: -EBUSY; [Severity: Low] Can this branch ever call enic_schedule_datapath_reset()? The quarantined check just above returns -EBUSY before this block runs. So enic_admin_channel_close() is only reached here with the channel LIVE. >>From LIVE, enic_admin_channel_close() ends in one of two states. It is QUARANTINED if the WQ or RQ disable fails. Otherwise it is DOWN, through enic_admin_channel_release(). The state enum has only DOWN, LIVE and QUARANTINED. So "state != DOWN" implies quarantined here, and the inner condition looks unreachable. That would make enic_schedule_datapath_reset() dead code, and the schedule_reset_on_failure flag passed through enic_open(), enic_reset() and enic_hang_reset() would have no effect. Could both be dropped? This is unchanged at the end of the series. > + } > + } [ ... ] > @@ -1840,13 +1934,23 @@ static int enic_open(struct net_device *netdev) > return err; > } > > +static int enic_open(struct net_device *netdev) > +{ > + return __enic_open(netdev, true); > +} > + > /* 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); > + [Severity: Medium] The subject limits this to V2 VF mailbox recovery. Several changes here affect every ENIC device and fix older bugs. Should they be split out with their own Fixes: tags? Compared with the baseline, these look like standalone fixes: - The datapath_open guard. In the baseline, a failed enic_open() in enic_reset() could leave IFF_UP set. A later dev_close() then ran enic_stop() and called napi_disable() a second time. - Moving enic_free_intr() before the queue disables. Baseline enic_stop() returned before freeing the IRQs when vnic_wq_disable() or vnic_rq_disable() failed. - The devcmd_lock in enic_dev_soft_reset_start(), enic_dev_soft_reset_done() and enic_dev_hang_reset_start(). Baseline enic_dev_wait() called the reset helpers without the lock, so they could collide with CMD_STATS_DUMP. These change behaviour for PFs and other non-VF functions: - enic_reset() now issues CMD_INIT through enic_vnic_dev_init() after SOFT_RESET for every non-dynamic function. - A failed soft reset, hang reset, INIT or queue stop now calls enic_detach_after_recovery_failure() on any ENIC device. The driver has no netif_device_attach(), so only a rebind recovers. - The soft reset fallback in vnic_dev_hang_reset() no longer runs vnic_dev_init() inline. INIT is now deferred, and dynamic vNICs do not get it at all. Several smaller, unrelated changes are also included: - netif_addr_lock_bh() in enic_reset_addr_lists() - the VF ACK worker - CQ VLAN sender filtering in enic_admin_rq_cq_service() - the netif_device_present() checks in enic_set_ringparam() With everything in one commit, stable trees cannot take the hang, IRQ-leak or devcmd fixes on their own. A bisect of a PF reset regression would also land on a commit whose subject says it only touches V2 VFs. [ ... ] > @@ -1871,23 +1975,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); > - enic_unset_affinity_hint(enic); > - enic_free_intr(enic); > > for (i = 0; i < enic->wq_count; i++) > vnic_wq_clean(&enic->wq[i].vwq, enic_free_wq_buf); > @@ -1902,6 +2008,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: Low] This isn't a bug introduced by this patch, but the stop_failed path leaves the datapath resources allocated, and nothing frees them later. datapath_open was already cleared at the top of __enic_stop(). A later dev_close() or unregister_netdev()->enic_stop() therefore returns 0 at once. These calls never run: - enic_dev_notify_unset() - vnic_wq_clean() - vnic_rq_clean() with page_pool_destroy() - vnic_cq_clean() __enic_open() behaves the same way on its late unwind path when stop_err is set. The TX buffers and the pools of RQs that failed to disable are kept. Baseline enic_stop() also returned early on the same error, and the commit message calls this separate work. Keeping buffers for a queue that may still be running avoids DMA into freed memory, so this may be deliberate. Is a follow-up planned for these resources? [ ... ] > @@ -2215,12 +2422,13 @@ static bool enic_control_dma_unresolved(struct enic *enic) > * handshake (the reset wiped the VF's admin QP, so the VF must register > * again), or for a PF re-push the current link state to registered VFs. > */ > -static void enic_admin_chan_reopen(struct enic *enic) > +static int enic_admin_chan_reopen(struct enic *enic) > { [Severity: Low] The header comment of enic_admin_chan_reopen() still says it re-establishes the channel "after a reset has re-created the data path". For V2 VFs it now runs before the datapath reopen, from enic_reset(), enic_hang_reset() and __enic_open(). The comment also doesn't describe the new int return. Could it be updated? Some other new comments describe behaviour that only later patches in the series add: - The late check in __enic_open() says "while station and receive policy were being programmed". At this commit, VF station install is skipped and enic_set_rx_mode() uses devcmds. - enic_reset() and enic_hang_reset() say "A V2 VF needs PF registration before enic_open() can install its station address." - enic_mbox_wait_reply() says the reconnect decision is "an operation-specific decision made by the caller". No caller makes that decision yet. These become accurate after "enic: manage V2 VF station and administrative MAC" and "enic: configure V2 VF receive mode over mailbox". The enic_admin_chan_reopen() header comment is still stale at the end of the series. [ ... ] > @@ -2271,135 +2511,342 @@ 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] What happens to a mailbox fault that arrives while recovery is running and also makes that recovery fail? enic_vf_mbox_recovery_work() enic_hang_reset(enic, true) enic_vf_mbox_recovery_begin() /* vf_mbox_recovery_active = true */ enic_admin_chan_reopen() enic_admin_channel_open() /* channel is LIVE again */ enic_mbox_vf_capability_check() / enic_mbox_vf_register() Meanwhile, on the admin RX path: enic_admin_msg_enqueue() /* kmalloc failure or backlog full */ enic_admin_rx_lost() enic_mbox_vf_require_reconnect() vf_mbox_fault_generation++ enic_mbox_vf_kick_recovery() /* recovery_active, not scheduled */ A bad length, truncation, bad FCS or a send timeout in enic_mbox_send_msg_id() follows the same path. enic_admin_chan_reopen() then returns -EAGAIN from the generation check, or the late check in __enic_open() returns -EIO. Either way, enic_vf_mbox_recovery_finish(enic, false) returns restart == false, and nothing is scheduled. The VF is left in this state: - IFF_UP still set - datapath stopped and IRQs freed - admin channel DOWN - carrier off - netdev still attached None of the automatic recovery triggers can fire in this state. The Tx watchdog needs carrier, the error IRQ has been freed, and new mailbox faults need a LIVE channel. Only a manual down/up seems to recover it. Should a suppressed kick be remembered, or should finish() restart when vf_mbox_fault_generation changed during the recovery? The -EAGAIN return implies a retry that never happens. This is unchanged at the end of the series. [ ... ] > diff --git a/drivers/net/ethernet/cisco/enic/enic_mbox.c b/drivers/net/ethernet/cisco/enic/enic_mbox.c > index d1b6f13c8002f..3579d2980a246 100644 > --- a/drivers/net/ethernet/cisco/enic/enic_mbox.c > +++ b/drivers/net/ethernet/cisco/enic/enic_mbox.c [ ... ] > @@ -764,7 +921,12 @@ void enic_mbox_init(struct enic *enic) > mutex_init(&enic->vf_mbox_request_lock); > init_completion(&enic->mbox_comp); > spin_lock_init(&enic->mbox_state_lock); > + spin_lock_init(&enic->vf_ack_lock); > + INIT_LIST_HEAD(&enic->vf_ack_list); > + INIT_WORK(&enic->vf_ack_work, enic_mbox_vf_ack_work); > enic->mbox_msg_num = 0; > + if (enic_is_sriov_vf_v2(enic)) > + WRITE_ONCE(enic->vf_rx_quarantined, true); > enic->mbox_initialized = true; > } else { > reinit_completion(&enic->mbox_comp); [Severity: Medium] Is vf_rx_quarantined armed again for internal resets that weren't caused by a mailbox fault? It is set to true in only three places: - this first-init branch - the send-timeout branch of enic_mbox_send_msg_id() - enic_mbox_vf_mark_reconnect_locked() The reinit branch used by enic_admin_chan_reopen() leaves it at the false value from the last successful open. Take a queue-error reset (enic->reset) or a Tx-timeout reset (tx_hang_reset) on a V2 VF: enic_reset() enic_admin_channel_close() /* vf_registered = false */ __enic_stop() enic_admin_chan_reopen() enic_mbox_init() /* reinit branch, quarantine untouched */ __enic_open() enables RQs and NAPI, issues CMD_ENABLE ... late vf_registered / mbox_send_disabled check Any NAPI poll between CMD_ENABLE and the late check, for example busy poll, passes this check in enic_rq_indicate_buf(): if (unlikely(READ_ONCE(enic->vf_rx_quarantined))) { and delivers frames to the stack. The enic.h comment says the flag "keeps the RX hot path fail-closed while VF registration is lost or receive state may not match the PF". The commit message says "Keep VF carrier off and receive delivery quarantined until the final open-time mailbox check succeeds". Should the reset paths, or enic_admin_chan_reopen(), set vf_rx_quarantined to true when they drop the registration? -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130-b4-enic-sriov-v2-vf-receive-control-v4-0-5858d5a9ecb1%40cisco.com