🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #5014

Re: [PATCH net-next v1 1/5] net: lan743x: reset DMA channels that fail to stop

#5014
From: netdev-bot+sashiko
Date: Mon, 19 Oct 2026 16:34
145 lines
13735 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 (1) · 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 patch does not fully close the bug it targets.

Pre-existing issues:
- [Medium] lan743x_tx_open() and lan743x_rx_open() now use the new
  lan743x_dmac_{tx,rx}_reset() helpers, but on -ETIMEDOUT they only call…

--

net: lan743x: reset DMA channels that fail to stop

This patch makes lan743x_tx_close() and lan743x_rx_close() check the
result of waiting for the DMA channel to stop. If the channel is still
stop-pending or still started, they now issue a channel soft reset. The
reset sequence is moved into lan743x_dmac_tx_reset() and
lan743x_dmac_rx_reset(), and the open paths use these helpers and log a
message if the reset times out.

> diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
> index 82d3ec20ba259..9e1276cf313c8 100644
> --- a/drivers/net/ethernet/microchip/lan743x_main.c
> +++ b/drivers/net/ethernet/microchip/lan743x_main.c

[ ... ]

> @@ -2221,11 +2239,22 @@ static int lan743x_tx_ring_init(struct lan743x_tx *tx)
>  static void lan743x_tx_close(struct lan743x_tx *tx)
>  {
>  	struct lan743x_adapter *adapter = tx->adapter;
> +	int ret;
>  
>  	lan743x_csr_write(adapter,
>  			  DMAC_CMD,
>  			  DMAC_CMD_STOP_T_(tx->channel_number));
> -	lan743x_dmac_tx_wait_till_stopped(adapter, tx->channel_number);
> +	ret = lan743x_dmac_tx_wait_till_stopped(adapter, tx->channel_number);
> +	if (ret < 0 || ret == DMAC_CHANNEL_STATE_STARTED) {
> +		netdev_warn(adapter->netdev,
> +			    "TX channel %d failed to stop, resetting it\n",
> +			    tx->channel_number);
> +		ret = lan743x_dmac_tx_reset(adapter, tx->channel_number);
> +		if (ret)
> +			netdev_err(adapter->netdev,
> +				   "TX channel %d reset timed out\n",
> +				   tx->channel_number);
> +	}

[Severity: High]
What happens if this channel reset also times out?

The commit message says the soft reset is issued "and wait for it before
anything is freed". However, if lan743x_dmac_tx_reset() returns -ETIMEDOUT,
the code only logs it, and lan743x_tx_close() goes on with the normal
teardown:

lan743x_tx_close()
    ...
    lan743x_tx_release_all_descriptors(tx);  /* unmap and free skbs */
    ...
    lan743x_tx_ring_cleanup(tx);  /* dma_free_coherent() ring and head */

The commit message describes a wedged channel that may not honour the stop
request. Could that channel ignore the soft reset as well? It would then
keep fetching descriptors from, or writing the head index into, memory that
has already been freed and reused.

lan743x_rx_close() has the same pattern. After a timed-out RX reset,
lan743x_rx_ring_cleanup() unmaps and frees every RX skb, even though their
descriptors still have OWN set. It then frees the descriptor ring and the
head write-back buffer. On RX, the device could write packet data into
freed pages.

Later in the series, "net: lan743x: reset the device on TX timeout" does not
change this. It runs the global DMAC reset (DMAC_CMD_SWR_) from
lan743x_reset_work() only after lan743x_netdev_close() has already freed the
rings. A plain ifdown never reaches that reset at all.

Could the close paths act on the reset failure before freeing anything?
One option is to escalate to the global DMAC_CMD_SWR_ reset or clear PCI
bus mastering. Another is to leak the ring, the head buffer and the mapped
buffers when the channel can't be shown to be quiesced.

[ ... ]

> @@ -2271,11 +2300,11 @@ static int lan743x_tx_open(struct lan743x_tx *tx)
>  			  FCT_TX_CTL_EN_(tx->channel_number));
>  
>  	/* reset tx channel */
> -	lan743x_csr_write(adapter, DMAC_CMD,
> -			  DMAC_CMD_TX_SWR_(tx->channel_number));
> -	lan743x_csr_wait_for_bit(adapter, DMAC_CMD,
> -				 DMAC_CMD_TX_SWR_(tx->channel_number),
> -				 0, 1000, 20000, 100);
> +	ret = lan743x_dmac_tx_reset(adapter, tx->channel_number);
> +	if (ret)
> +		netdev_err(adapter->netdev,
> +			   "TX channel %d reset timed out\n",
> +			   tx->channel_number);

[Severity: Medium]
This is a pre-existing issue and was not introduced by this patch. The old
code also discarded the return value of lan743x_csr_wait_for_bit(), and
this change only adds a log message.

After a failed reset, lan743x_tx_open() still programs TX_BASE_ADDR,
TX_HEAD_WRITEBACK_ADDR, TX_CFG_A/B/C and TX_TAIL. It then writes
DMAC_CMD_START_T_ and returns 0.

Can the interface come up on a channel whose soft reset never finished?
If the reset completes late, the register writes made while it was pending
may be lost or wiped.

lan743x_rx_open() handles the reset the same way. There, if RX_HEAD is
non-zero after a failed RX reset, the code takes this path:

	rx->last_head = lan743x_csr_read(adapter, RX_HEAD(rx->channel_number));
	if (rx->last_head) {
		ret = -EIO;
		goto napi_delete;
	}

That reaches lan743x_rx_ring_cleanup() without the stop and reset handling
that this patch adds to lan743x_rx_close().

Should the open paths return an error when the channel reset times out?

>  
>  	/* Write TX_BASE_ADDR */
>  	lan743x_csr_write(adapter,

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1792008404.git.cbabroski%40nvidia.com
Technical Details
Message-ID: <179242764415.3135.15367182924729818631@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-348707-linux-kernel-netdev=dewy.ru
References: <bf487e5d01fe6352069d4314087f680fea717cc5.1792008404.git.cbabroski@nvidia.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-348707-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v1 1/5] net: lan743x: reset DMA channels that
 fail to stop
Date: Mon, 19 Oct 2026 16:34:04 +0000
Organization: Usenet Network
Message-ID: <179242764415.3135.15367182924729818631@kernel.org>
References: <bf487e5d01fe6352069d4314087f680fea717cc5.1792008404.git.cbabroski@nvidia.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3664469"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:0nE1HyJrjcM9O/onMOHUx1/aPcc= sha256:9859/V/7rjRixpJATsIxtTiwgDD9QBYSOJvvej4pa8k=
	sha1:V0BMQfyB+ACK3NgJKK1JvoLB+uE= sha256:Ub2J5+p6pxUNWhxtW6umKSTlsBLi8NjYtqrBghzhrDI=
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 244C6110A72; Mon, 19 Oct 2026 20:22:14 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.729
X-Spam-Status: No, score=-3.729 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.329, 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 L3UizRLkNuYs;
	Mon, 19 Oct 2026 20:22:10 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-348707-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 02922110A6E; Mon, 19 Oct 2026 20:21:59 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (aws-us-west-2-korg-listserv-alma10-1.taild15c8.ts.net [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id BBD893ED85; Mon, 19 Oct 2026 16:34:20 +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=1792427651;
	b=Yg+OenPG6QbVUMJh7kLy32zhD7V7y9Sd5u4HYK3diOIdVa5j4GEvmdO4FhAShgroFtwX
	 92ZewH7PgI96UZKGRogHUHlV1hZEF+PFVeQyHx1I05EdPzSit3+SarYGE2APSNRmbutBb
	 BVjm4TbdMNs8G8zdHDFMRRYKW7cAujuT5/JK0nZUlXGvWWLKVXWqeeqbnYRegLDCgMyJJ
	 Ql93f6ij2eMoaJy+H3lm9h+lMEdQk21Yz4GNW9NiPt8E0O56+Uqo+x4QFpu+W5tW7z9Ra
	 CdK8a2SXhCnRy0gcZNdK6S3Dl9WscLXR0SWkeqw5xTnmXBg3AfuQkuimAhzaPhgRffQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792427651;
	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=PS6ZQS8kXTgxRqgfxQ1kJS2QfBiBG2NGPCiekUyrwzs=;
	b=gPgD5WhDWj/MKS/tmysFtmUzk5y2t7XEFY1wCfZVDX8/syKmppInqX5kzGE7LjPUs7VH
	 wFNbM4x/7iiSvxc2Zzcq/xhAjEmQpUyjrIuIJ50aZXTAnEF61XNdLsIYCENdlT+uUpbnh
	 u9Xj41kuYw5s+Lxu13PZfz1F4u1Y+rz9KSqNQ3egv2IyqVRVb0zFUzRp+cW0zo0O7n7T0
	 HH2aFfC+6uAAnNkqiNp0RSD8k7jSO1WlYbEGH3S21nw3ahxUf8CpPxcnyE/bh/Rd5KnI8
	 KUFMKrNee3luXvAArtRQ3LCTd5aTSK140DgEPL3MmhMTT7k9m2tGfukZgIVQ/aQMN9A==
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=bqRCxpsL;
	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 D310C606A33F;
	Mon, 19 Oct 2026 16:34:11 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bqRCxpsL
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=1792427646;
	b=pouNwORuUDtTbSjyVGeNz/o60/zZ33qXqKoPFFSsW/H/2Pxi1Mi1ctAI8+d/ZjvHIy7s
	 oaDjCZaXmopqw0HBcCrdVPQJQTRZOtkVsQkI4XneYUbpw5VXzC7HYdRinhGe9B9ucNppt
	 be4GZc5k3IkyNTso4IJx696MIZqjhyjb5vWMyyueNI2m/hzyoTJa7f3W1Sh3jQq40dHw5
	 GkhPyxSoVEtD6s7SLi2vLNVopzn36thOr8J2i5mTYZn9z7aiiHa4QQHBLLAH403K75HLD
	 xU24IydaRexTAJI314aMdpXLbhos/Dlpp8A+cajg/524MAaRleL7pTyEyh1joz/9jYA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792427646;
	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=PS6ZQS8kXTgxRqgfxQ1kJS2QfBiBG2NGPCiekUyrwzs=;
	b=RMqtPOxMgsanPcz9hoQR/h7ZHY8h5hl12P9gn9CTM0K4xdLIKfB45W1jRpYiIYnwioSb
	 UzyfZ7Stiq/XYxRcp59QMq1zHfX8OrnFaws7Al4cPlhP1e/IKj7SmtjKBG3a2A9XampRq
	 1eu8jB5tS/MWDW2bjqt9mOM4sH5wgoVaY59pLizl8DbaT0Nsyx7R2esHxM7wjs7QePn8s
	 U3ZtdDhYxS5UIwAPwdMvDySFXWP+SriRSj54uEEqc5hNQ9msywx/QoZ1v3+LGNHcapjOK
	 IIfuF6sRSksEnQASpd54GROjUNIBOI3GM0hcw7N5g2YMisCOoerJ8rnMr9s0vO1YJyA==
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=bqRCxpsL;
	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 B23B0606A31C;
	Mon, 19 Oct 2026 16:34:05 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB26C1F000C4;
	Mon, 19 Oct 2026 16:34:04 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1792427645;
	bh=PS6ZQS8kXTgxRqgfxQ1kJS2QfBiBG2NGPCiekUyrwzs=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=bqRCxpsLrEiIqKqTY7s/oTtiPNI0ZYzHKXQ4FQVT5c/H1IH0hCexrBCDqWGyoiAeZ
	 NnkVgdReceQ9GSt+xDWmN6RJFBphOgDgqGDv6HZnBM0L2EiMcjUfO+bcJHfRQ2nZ3J
	 od/3za1SuJM886ZQooxrx+wJE09fs/iMLGc4HPExEOe3/iS1csPFhAhbPjA6LOqTmm
	 NQVtj1mPN6CoCQqUeACwsAvRzSYMVEwaYXrtz9L15aKlX2Sg0vwxMyJpFCIqvYoEmL
	 2yxGc/Gp74xB4/dG2ihc9bhxPpYtpx8MHgZ6xuCttRM6DvzrwIwVXHzNeIXxbJ9DAf
	 K2hjsAYypAZxw==
X-Cc: bryan.whitehead@microchip.com, UNGLinuxDriver@microchip.com,
 andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
 kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org,
 linux-kernel@vger.kernel.org, richardcochran@gmail.com, linux@armlinux.org.uk,
 maxime.chevallier@bootlin.com, Raju.Lakkaraju@microchip.com,
 davthompson@nvidia.com
X-In-Reply-To: <bf487e5d01fe6352069d4314087f680fea717cc5.1792008404.git.cbabroski@nvidia.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