🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #23435

Re: [PATCH net v5] net: mana: Avoid waiting on dead HWC after device reset

#23435
From: netdev-bot+sashiko
Date: Fri, 27 Nov 2026 09:32
184 lines
15069 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 · Low: 0

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] mana_dealloc_queues()
  (drivers/net/ethernet/microsoft/mana/mana_en.c) used to wait up to 120…
- [Medium] mana_dealloc_queues() sets hwc_dead only when
  mana_gd_dev_reset() returns 0.

--

net: mana: Avoid waiting on dead HWC after device reset

This patch drops the 120s sleep-based TX drain in mana_dealloc_queues().
It now polls each queue's CQ synchronously for about 300 ms and resets
the device if sends are still outstanding. A successful reset sets a new
hwc_dead flag, which makes mana_hwc_send_request() fail fast and skips
mana_fence_rqs() and the SHM teardown handshake.

> diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
> index 95bf153c3e1a8..cf0409704b08b 100644
> --- a/drivers/net/ethernet/microsoft/mana/mana_en.c
> +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c

[ ... ]

> @@ -3802,31 +3813,83 @@ static int mana_dealloc_queues(struct net_device *ndev)
>  	 * to false, but it doesn't matter since mana_start_xmit() drops any
>  	 * new packets due to apc->port_is_up being false.
>  	 *
> -	 * Drain all the in-flight TX packets.
> -	 * A timeout of 120 seconds for all the queues is used.
> -	 * This will break the while loop when h/w is not responding.
> -	 * This value of 120 has been decided here considering max
> -	 * number of queues.
> +	 * Drain the in-flight TX completions for each queue. TX is already
> +	 * stopped, so pending_sends can no longer grow. For each queue,
> +	 * disable NAPI so it cannot run at the same time as this drain,
> +	 * then poll its CQ for up to 300 ms. If sends are still missing,
> +	 * the hardware is not responding: reset the device.

[ ... ]

> +				tx_cq->budget = 0;
> +				for (retry = 0; retry <= MANA_TX_DRAIN_RETRIES;
> +				     retry++) {
> +					do {
> +						tx_cq->work_done = 0;
> +						mana_poll_tx_cq(tx_cq);
> +					} while (tx_cq->work_done);
> +
> +					if (!atomic_read(&txq->pending_sends) ||
> +					    trigger_flr ||
> +					    READ_ONCE(hwc->hwc_dead))
> +						break;
> +					if (retry < MANA_TX_DRAIN_RETRIES)
> +						msleep(100);
>  				}

[Severity: Medium]
Is 300 ms long enough to decide that the hardware is unresponsive?

mana_dealloc_queues() runs on every mana_detach() path, not only on
unload or after a hang:

  - ndo_close
  - mana_change_mtu()
  - XDP install in mana_bpf.c
  - the ethtool channel, ring and priv-flag paths
  - mana_per_port_queue_reset_work_handler()

The driver itself expects TX to stall for seconds on working hardware:

mana_init_net_dev() {
    ...
	/* Recommended timeout based on HW FPGA re-config scenario. */
	ndev->watchdog_timeo = 15 * HZ;
    ...
}

Say a slow but working device still has completions outstanding 300 ms
after TX is stopped. An MTU change or ethtool -L would then go:

mana_detach()
  mana_dealloc_queues()
    mana_gd_dev_reset()   /* pcie_flr() on PCI, cdx_dev_reset() on CDX */
    WRITE_ONCE(hwc->hwc_dead, true)
mana_attach()
  -> fails with -ETIMEDOUT from mana_hwc_send_request()

The reset covers the whole function. Would the other vPorts and mana_ib
on the same gdma_context lose their HWC as well?

On PCI, recovery seems to depend on mana_gf_stats_work_handler() seeing
-ETIMEDOUT and calling mana_schedule_serv_work(gc,
GDMA_EQE_HWC_RESET_REQUEST). That runs a full suspend, 10 s sleep and
resume cycle, which also tears down RDMA.

mana_cdx_bus_ops has .dev_reset but no .schedule_serv_work, so
mana_schedule_serv_work() returns -EOPNOTSUPP there. Does that leave the
CDX netdev unusable until the device is unbound and rebound?

Nothing is logged in mana_dealloc_queues() when the reset succeeds. Also,
mana_need_log() now suppresses -ETIMEDOUT logging while hwc_dead is set.
Could these resets be hard to diagnose?

The commit message says the 300 ms "is not based on a hardware limit".
The commit being fixed, a7dfeda6fdec, picked 120 seconds as "more than
long enough for functional hardware to complete any sends".

This patch is tagged for stable. Could the commit message say that a
routine reconfiguration of one port can now reset the whole function?

[ ... ]

> +		if (trigger_flr && !READ_ONCE(hwc->hwc_dead)) {
> +			/* Completions never arrived: the device is
> +			 * unresponsive, so reset it. Mark the HWC dead only
> +			 * if the reset succeeds, so that later HWC commands
> +			 * fail fast. If it fails, the device may still access
> +			 * memory, so the teardown commands are still posted
> +			 * and the first one waits the full hwc_timeout.
> +			 */
> +			err = mana_gd_dev_reset(gd->gdma_context);
> +			if (err) {
> +				netdev_err(ndev, "device reset failed %d with %d pkts pending in txq %u\n",
> +					   err, flr_pending, flr_txq_id);
> +			} else {
> +				WRITE_ONCE(hwc->hwc_dead, true);
>  			}
>  		}

[Severity: Medium]
Is it right to treat every non-zero return from mana_gd_dev_reset() as
meaning the device may not have been reset?

pcie_flr() can fail after the FLR has already been issued:

drivers/pci/pci.c:pcie_flr() {
    ...
	pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR);
    ...
	msleep(100);

	ret = pci_dev_wait(dev, "FLR", PCIE_RESET_READY_POLL_MS);
done:
	pci_dev_reset_iommu_done(dev);
	return ret;
}

Only two failures happen before the reset starts: the -ENOTTY return
when pci_dev_config_accessible() is false, and a failing
pci_dev_reset_iommu_prepare().

If pci_dev_wait() times out, the function's state, including the HWC
queues, has already been reset, or the function is stuck in reset. In
that case hwc_dead stays false.

The driver will already have spent up to PCIE_RESET_READY_POLL_MS in
pci_dev_wait(). Would it then also:

  - post MANA_CONFIG_VPORT_RX and wait the full hwc_timeout
  - run mana_fence_rqs(), which sleeps 100 ms per RX queue on error
  - run mana_smc_teardown_hwc() from mana_hwc_destroy_channel()
    against a function that cannot answer

RTNL could then be held for well over 120 s. That is the hung-task
symptom this patch sets out to remove.

The commit message says "If the reset fails, the device may not have
been reset and may still access memory". Could the case where the FLR
was issued but the wait failed be told apart, or the device's reset
state be checked, so that this path also fails fast?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126093032.816436-1-sahilchandna%40linux.microsoft.com
Technical Details
Message-ID: <179577195250.3135.5489299451914207495@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372583-linux-kernel-netdev=dewy.ru
References: <20261126093032.816436-1-sahilchandna@linux.microsoft.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372583-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v5] net: mana: Avoid waiting on dead HWC after device reset
Date: Fri, 27 Nov 2026 09:32:32 +0000
Organization: Usenet Network
Message-ID: <179577195250.3135.5489299451914207495@kernel.org>
References: <20261126093032.816436-1-sahilchandna@linux.microsoft.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="695515"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:ZyNmsEE7h9DBPDBKNod+/dyr9bQ= sha256:b9/e5Jnr6LIbUbtcE6+l+8pym+AlN856kqbt2+gAHTY=
	sha1:i6iWPjLfthlIIt0VE9UgGaRTJvA= sha256:agnEs92zNqv2NHKGyZzZLrGJa4ilvmz80L3bNLIgo8g=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 3B6DA125F39; Fri, 27 Nov 2026 12:32:50 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.501
X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 2R7oDNkDFVSq;
	Fri, 27 Nov 2026 12:32:45 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-372583-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id C171B125F36; Fri, 27 Nov 2026 12:32:37 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 040F660796A; Fri, 27 Nov 2026 09:32:37 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795771955;
	b=wl58CpoAc4occONUbwmvTleR9VcMi9icfxdff+/cj+MeykYVDJ5gqc1PgCMOnp+ChOYx
	 EH7Xj/lr8IrmctcwjLGwUuGcxmdsMjWOsIifm+O1RCJkXahvUkgtT9/asaeJ1sbX2tPWw
	 5Tesb2SJfKxLRcZG98LmlpFbTmact7TH0zLbAHzN5gK2r6BhiQu1O38PFyapNyzd6FPXS
	 AFvBga8KqsC1iQRh1jnPYCZziaPQ/L6RC3go2wZND+GcYnEd+KNxLeQyF39NBDxFWK22g
	 wtscbJHB2WjP8TCmyeOXD2n1e6rp1apFuNyl+O1n0S3jSC/5/Goi4tyHhZ4oP6awMcw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795771955;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=I+yexljqZ8dH7oYYYT3kCGp9Kqah9eMG4Yd5LvFz2ME=;
	b=yCvJg6kssrNGNgHGjlStKtQE8m3RnRXK/fPO9gBqZtcFTHKkh9c8YwoXIad26Vh7MpT3
	 N1U/7u44iU1P6AYU5SCGUnzM1Gb6HaXbw+sUXMvXecsAUhJoXB8N2DEtj/ozqE0QNkCD7
	 kCT/0MT622l/0hoKZObUd46iftwYgdJgwophA0q0+H6X8vEHDSIr1VXMuA6PL+jsudfj/
	 GWXwaVQU9sQqXscOPtyL+fLM+hmO9ZdxTFJdb6z2sfEk788H+q5anISOBB1ZEv4uOr5B2
	 72lnO+UIhNWnURa7+BlnhbZbtQIwg6dmzfDTjUFwCz5xU8Ykmbmm8SwhGriykZHaFXw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ORCVgFvy;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 733FD606A32C;
	Fri, 27 Nov 2026 09:32:35 +0000 (UTC)
X-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=ORCVgFvy
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795771954;
	b=tUsqdjKIcYLmxK8ykmVjp6MlmqcvtSsTl9+KT0f46tMVA63vJYKBLJdkDSdKvnGKZo08
	 fSrNS6hq8U3VpqMCWosuHjVpTL0FbpUpY3JrAnU3DAtKAuA9wjy4qiXtLiEK7Vh5SI1rS
	 q7AtV+R95NZ26g4pkJ4kLhMPTkh8iFt5tSOAWn4wSaURB/csy3tfwa+tH7yD26A5em4uH
	 fD2etB9wKmlZUjWd4t4ZDBfkGC4V8ExCTId6ZmgB0+CVKJLBNOZiEvh5e6UORwr9zjcvS
	 nqKTzJgxPE6LmLNVhtTK05+l6yzcMISyknWXuRLFIcQT+3H09/d4V8UO5DHhGyJWG6w==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795771954;
	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=I+yexljqZ8dH7oYYYT3kCGp9Kqah9eMG4Yd5LvFz2ME=;
	b=GjS+w6+RkxK9eIJYsN8SEaQqct0SKuuSEun3rb75MHxJNxbmg9vVcj8HydmJ77BksUZb
	 zIz6gO4SvPhUu19ivpXiG+nldBXoMQVN6VzEchHuOg1qk3yiIW0z0UcSDljPeFueV2JKF
	 AFVERp8657PuWt8wA8v3qW/EZGlBx0lTkzo4vhuztmWGzPIYTGPtnX0lgfmKpzxP6st90
	 E7XlFkDjXYF5VVUqwUMrGSxoKD9RA/JxdkcjV4IM90Qh+qnMX20szPdqjP1ZpX84iFUAF
	 3Yw/46JnL24iYprLnmfi3zyuotZqnbPUNS2tQL/KguOxYmQkYoIQTR9+NnbcPh9XGvQ==
X-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=ORCVgFvy;
	arc=none smtp.remote-ip=100.103.45.18
X-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 93B98606A32E;
	Fri, 27 Nov 2026 09:32:34 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA6641F00899;
	Fri, 27 Nov 2026 09:32:32 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795771954;
	bh=I+yexljqZ8dH7oYYYT3kCGp9Kqah9eMG4Yd5LvFz2ME=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=ORCVgFvyxPS3SGECYpWmuQnGPSJL0E3pCF182JH+3BKzttCpfgBbADUiDiWQgqWbu
	 yWdVpQZY15U6TRaviH7GFNS5nYVhVgK7dpwmQG2vNFb4mkBIJ0TscMmQkEMOYbo/R4
	 wELCniGx/SRLWwiKAwDyvjvRpm67PDOc46Frl5Stic1+gEhEeGAceRGjdIpwjfBDPU
	 4W16JsUyM5f6lJyK8/fdRWJ5Ggc7TaMWknRV3KIIK1eU91mLFfG6AJogk8jJjdHghG
	 7nPyF8RX1+fqn+ueXC9z5YB+p02tyCvaro98txq5O7Wv1ITibNR8oWuRihLBDPrQSY
	 vIx3ZwVWphoWA==
X-Cc: haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com,
 andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
 kuba@kernel.org, pabeni@redhat.com, kotaranov@microsoft.com, horms@kernel.org,
 ernis@linux.microsoft.com, gargaditya@linux.microsoft.com,
 mawasthi@linux.microsoft.com, kees+treewide@kernel.org,
 schakrabarti@linux.microsoft.com, leitao@debian.org,
 linux-hyperv@vger.kernel.org, netdev@vger.kernel.org,
 linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org,
 stable@vger.kernel.org
X-In-Reply-To: <20261126093032.816436-1-sahilchandna@linux.microsoft.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list