๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #21086

Re: [PATCH net v8 4/4] net: stmmac: restore the XSK TX pool on resume

#21086
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 14:39
135 lines
13477 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 ยท High: 1 (1) ยท Medium: 0 ยท 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).

- [High] The fix is incomplete because it is applied to one caller
  instead of the shared helper.

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the same
  resume path leaves corrupted TX next-descriptor pointers in chain mode.

--

net: stmmac: restore the XSK TX pool on resume

When dma_free_tx_skbufs() completes outstanding XSK TX frames, it also
clears tx_q->xsk_pool. This commit restores that pointer in
stmmac_resume_descriptors() after the call. Without the restore,
stmmac_tx_clean() skips zero-copy transmission after resume, even though
the AF_XDP socket is still bound.

> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 1508cf08f03b0..550a0bd647e13 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -2277,6 +2277,9 @@ static int stmmac_resume_descriptors(struct stmmac_priv *priv)
>  	for (queue = 0; queue < priv->plat->tx_queues_to_use; queue++) {
>  		stmmac_reset_tx_queue(priv, queue);
>  		dma_free_tx_skbufs(priv, dma_conf, queue);
> +		/* Buffer cleanup may clear the pool; the socket remains bound. */
> +		dma_conf->tx_queue[queue].xsk_pool =
> +			stmmac_get_xsk_pool(priv, queue);

[Severity: High]

Does stmmac_tx_err() run into the same problem? It is not a teardown
path, but it also calls dma_free_tx_skbufs() and then restarts the queue:

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:stmmac_tx_err() {
    ...
	stmmac_stop_tx_dma(priv, chan);
	dma_free_tx_skbufs(priv, &priv->dma_conf, chan);
	stmmac_clear_tx_descriptors(priv, &priv->dma_conf, chan);
	stmmac_reset_tx_queue(priv, chan);
	stmmac_init_tx_chan(priv, priv->ioaddr, priv->plat->dma_cfg,
			    tx_q->dma_tx_phy, chan);
	stmmac_start_tx_dma(priv, chan);
    ...
}

stmmac_dma_interrupt() and stmmac_msi_intr_tx() call it on a TX hard
error. If xsk_frames_done is non-zero, dma_free_tx_skbufs() does:

	if (tx_q->xsk_pool && tx_q->xsk_frames_done) {
		xsk_tx_completed(tx_q->xsk_pool, tx_q->xsk_frames_done);
		tx_q->xsk_frames_done = 0;
		tx_q->xsk_pool = NULL;
	}

Nothing in stmmac_tx_err() sets the pointer again, even though
af_xdp_zc_qps still has the bit set for this queue.

After that, stmmac_tx_clean() skips its if (tx_q->xsk_pool) block, so
stmmac_xdp_xmit_zc() never runs. stmmac_napi_check() also starts sending
TX interrupts to ch->tx_napi:

	tx_napi = tx_q->xsk_pool ? &ch->rxtx_napi : &ch->tx_napi;

For ZC queues, stmmac_enable_all_queues() enabled rxtx_napi, not tx_napi.

Wouldn't this stall zero-copy TX in the same way as the resume case?

The commit message says:

    Keep the buffer cleanup helper's behavior for teardown unchanged.

This suggests the other callers of dma_free_tx_skbufs() are all teardown
paths, but stmmac_tx_err() is not one of them.

Would it be better to fix this in the shared helper instead? For example,
xsk_pool could be cleared only in __free_dma_tx_desc_resources(), or
dma_free_tx_skbufs() could stop clearing it altogether. Either would
cover both paths and remove the need for a restore in each caller.

>  		stmmac_clear_tx_descriptors(priv, dma_conf, queue);
>  	}

[Severity: High]

This isn't a bug introduced by this patch, but does the TX loop here
need the same chain-pointer rebuild as the RX loop?

In chain mode with non-extended descriptors and hwts_tx_en set, the MAC
writes the timestamp seconds into des3 of the last-segment descriptor.
In chain mode, des3 also holds the address of the next descriptor.
clean_desc3() in chain_mode.c repairs this:

	if (tx_q->tx_skbuff_dma[entry].last_segment && !priv->extend_desc &&
	    priv->hwts_tx_en)
		/* NOTE: Device will overwrite des3 with timestamp value if
		 * 1588-2002 time stamping is enabled, hence reinitialize it
		 * to keep explicit chaining in the descriptor.
		 */

However, clean_desc3() only runs from stmmac_tx_clean(). stmmac_suspend()
disables NAPI before it stops DMA. A frame that completes in between is
never cleaned, so its des3 still holds the timestamp.

On resume, stmmac_clear_tx_descriptors()->ndesc_init_tx_desc() only
clears TDES0_OWN and sets the chain bit. It does not touch des3, and
nothing on this path calls stmmac_mode_init() for TX again.

The RX side of this function already handles the same hazard in
stmmac_reinit_rx_descriptors():

	/* Hardware timestamp writeback may have overwritten chain pointers. */
	if (priv->descriptor_mode == STMMAC_CHAIN_MODE) {
		...
		stmmac_mode_init(priv, des, rx_q->dma_rx_phy,
				 dma_conf->dma_rx_size, priv->extend_desc);
	}

Could TX DMA then fetch its next descriptor from an address equal to the
PTP seconds value? stmmac_tx_err() seems to have the same gap.

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1795096430.git.dinghui%40lixiang.com
Technical Details
Message-ID: <179544477829.3135.13778479191723150995@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-369487-linux-kernel-netdev=dewy.ru
References: <5874b73b815d2385bbbf5f6988d50b3772fa0ce0.1795096430.git.dinghui@lixiang.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-369487-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v8 4/4] net: stmmac: restore the XSK TX pool on resume
Date: Mon, 23 Nov 2026 14:39:38 +0000
Organization: Usenet Network
Message-ID: <179544477829.3135.13778479191723150995@kernel.org>
References: <5874b73b815d2385bbbf5f6988d50b3772fa0ce0.1795096430.git.dinghui@lixiang.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3903740"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:XRVlDIS5y/n2Br90uZQnf72+Cl8= sha256:NztpdP/JAWOI9BNEijAnU+DXDX3u97H7vc5qoJujLbY=
	sha1:ghJKmhC0P9FZBwwe/HeqGRjjceQ= sha256:is1D9cDp7N2TkPX5Ge1UpWGTMCaIciFm8qj1dgf0MSA=
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 8747A125DBB; Mon, 23 Nov 2026 17:40:03 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, 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 jntKAgWcmTEK;
	Mon, 23 Nov 2026 17:39:57 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-369487-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id BCBAF125DBC; Mon, 23 Nov 2026 17:39:47 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 590C131C7C; Mon, 23 Nov 2026 14:39:41 +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=1795444781;
	b=p9g4k7/drD8RfP5C7dQTTCbsiElUr+WpxQz/xDWB+cPpfp7Qu+E8pJKTrqn3BtfXvSjc
	 HejR7pAbu1Q8ElYwzOHHAnb1KF0HhobNgsBf9w0JgE8DSx5cRmfbDc2BML/pvjyBxD0Q4
	 MeHeVtdeka1lhapEwUEZG1fhru2Hmk551IsKlbCqdPR/CLYy0rmfI0MyPoyqfrOi5OMNG
	 yteBcb7o5aeskHP6RvQzHbnKRPwiJ5o4PoFttgK9eGYP4JMMOOiy9T6VZ3X2pKYWR8hkT
	 tlwjk5XV01l4av/6DV7IskT6vzYjGjoy5rytL/cKJf2pEdxWFnumbava1YdQK5wCl3Q==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795444781;
	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=9UfLcSiWn0FiNKGKel4Ik3gxc0PzMKz6UDRi4JIVcvI=;
	b=l7SPmGNSG0hwAom/G7eXS+QJWvjVEX2DIINeRh+tdPNbwF2tQz3tdCBBi9iPhZk1uCTo
	 aLU37rt5akhtdR1IkY1bmtan6kXlv8ymhxBpp1DbDS6tr7l5VmBtTyoIrP8EcKMD/RZxa
	 TiRBtfsz/hehj9PymqFPFuLV43prdG1UNrieHywBt38ISwOxrzdrsq5MZeDu69m9nK8Qb
	 7rI3vgASFnYAir2A3cpFXUfCRUpylkSrnmMuhb5F7LclbwRI43SwzaYfXVUFkZpkczQ6C
	 URc+gcpqMxUKkD41vdqw3v7vL0UcfCzW1i4YJOfERn3eZgtvswsMcIZ4Vn3z5Mq0YhA==
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=YtJ2IneO;
	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 1B6D2606A336;
	Mon, 23 Nov 2026 14:39:41 +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=YtJ2IneO
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=1795444780;
	b=QD2DJOSp8z7pgRdG04zhZnL+prgmiUC/oqRlqQpHIA9+HPlIhTc+RJAfBp1YETtTBTGy
	 iOazYWdNtIyzpmUdpfwQBvvfJHmxO+naSM+TUFHr82OgX27nD3KYIFxbTB5uS/PFtMABy
	 ilnKnkEByHGcMjkpsDziXhRhC+hxQYRSya28QFYnZnA83sk/xQPjDFH5eHFYwZduj6I+2
	 MwPyhxs/xSXUxmNmQ8jcPfMm6aTkC2sFsCKVjZuBWcMYxeToy8HexBOmbTLz1nrsoLDuE
	 P+Wj6+mGIf6MnSyz7WIi3k0ntC2wAoQObM69PJKOw3GoeThIFQoPGqa006ALTBihjFg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795444780;
	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=9UfLcSiWn0FiNKGKel4Ik3gxc0PzMKz6UDRi4JIVcvI=;
	b=TgL+zkWT3HH/yfapLm0ZjQuxfc/o8wgbQ+U1a+JGt1aqSz9GPqv1t87oU+7S6D/VzOye
	 /3/3yc21icGX24nDiL7IxC/TwO2UxiO8+E9rC2yH3FSaNEhHA6CUd1wUq143JQ2Mas2Pv
	 hS9X5i8xZ7fj4WSngbZ4ZTlKfMsnrYAl/k0nUL5pqAJQgajYhfyf+SzdrMkXmnYx2xbDH
	 jQRyp3qA9AiBZ8Iy0DKjiiXVEcnRIoa1VwsrUs3YnAdIOLBFnuEzEht2w3ajPDDZ5ECjk
	 TuMGsMlBz2iszMqHdBFiRuWI8yyq1iJm46Jd78lilupNcVpS5eniZsRpYOEH1GcdSWg==
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=YtJ2IneO;
	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 3AF0F606A32A;
	Mon, 23 Nov 2026 14:39:39 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF2BC1F000C6;
	Mon, 23 Nov 2026 14:39:38 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795444779;
	bh=9UfLcSiWn0FiNKGKel4Ik3gxc0PzMKz6UDRi4JIVcvI=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=YtJ2IneO//CyRXjolhcD6mF1NS3/RUd09qy8o19j8zpBftrUoiUhqOzUD2fwVLp0C
	 1icm5AaSh5SZyMDzO1LmM/2cf+mRbwPrfpISWD7PFuGsvaPcFM9ORouJDJJ36nxGSA
	 7+eZLM+46c7X/hYvQ1C0vC6rh5Hn8s2YmNPAvWe0sBraK49u3SRhc02IDttaZbwH/3
	 DGkjIF6+EdrL9ekElAePKO6sPIPcv/8/NxWVucDvz/ZhOlXZCCtgj+d48PxmjjI9JO
	 7FbvbWqhyHjEKC1rTy5gvHDc3lEEVX1HJqp7hUxPf39rk6PWBGCkwPsHbfkoSATJMc
	 udw2/KSs/5lXQ==
X-Cc: maxime.chevallier@bootlin.com, andrew+netdev@lunn.ch, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com,
 netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com,
 linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org,
 dinghui@lixiang.com, xiasanbo@lixiang.com, yangchen11@lixiang.com,
 liuxuanjun@lixiang.com, fujiahui@lixiang.com, zhoujing3@lixiang.com
X-In-Reply-To: <5874b73b815d2385bbbf5f6988d50b3772fa0ce0.1795096430.git.dinghui@lixiang.com>
X-sashiko-severity: High
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