Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: cbabroski@nvidia.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	bryan.whitehead@microchip.com, UNGLinuxDriver@microchip.com,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com,
	linux@armlinux.org.uk, Raju.Lakkaraju@microchip.com,
	maxime.chevallier@bootlin.com, yuiko.oshino@microchip.com,
	nb@tipi-net.de, woojung.huh@microchip.com
Subject: Re: [PATCH net-next v2 1/7] net: lan743x: check DMA channel stop and reset results
Date: Wed, 25 Nov 2026 14:37:01 +0000	[thread overview]
Message-ID: <179561742163.3135.1760016027745827288@kernel.org> (raw)
In-Reply-To: <b1dc6a8037ab596053cc60c065a9b447982118df.1795027003.git.cbabroski@nvidia.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 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).

- [High] The fix does not finish its own error path.
- [Low] In lan743x_tx_close(), the return value of the new
  lan743x_tx_fifo_disable() is discarded, and `if (stop_failed)…

--

net: lan743x: check DMA channel stop and reset results

This patch checks the DMA channel stop result in lan743x_tx_close() and
lan743x_rx_close(). If the channel is still stop-pending or started, it
issues a channel soft reset before the rings are freed. It also moves the
channel and TX FIFO reset sequences into helpers, and lan743x_tx_open()
and lan743x_rx_open() now fail when those resets time out.

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

[ ... ]

> @@ -2218,14 +2248,63 @@ 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;
> +	bool stop_failed = false;
> +	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) {
> +		stop_failed = true;
> +		netdev_warn(adapter->netdev,
> +			    "TX channel %d failed to stop, resetting it\n",
> +			    tx->channel_number);
> +	}
>  
>  	lan743x_csr_write(adapter,
>  			  DMAC_INT_EN_CLR,
> @@ -2235,11 +2314,9 @@ static void lan743x_tx_close(struct lan743x_tx *tx)
>  	napi_disable(&tx->napi);
>  	netif_napi_del(&tx->napi);
>  
> -	lan743x_csr_write(adapter, FCT_TX_CTL,
> -			  FCT_TX_CTL_DIS_(tx->channel_number));
> -	lan743x_csr_wait_for_bit(adapter, FCT_TX_CTL,
> -				 FCT_TX_CTL_EN_(tx->channel_number),
> -				 0, 1000, 20000, 100);
> +	lan743x_tx_fifo_disable(tx);
> +	if (stop_failed)
> +		lan743x_dmac_tx_reset(adapter, tx->channel_number);

[Severity: Low]
The return value of lan743x_tx_fifo_disable() is dropped here. The channel
SWR is issued based on stop_failed alone, even if FCT_TX_CTL_EN_ never
cleared.

The commit message says:

    the TX channel should only be reset once its FIFO is stopped.

This patch targets a wedged channel. On that path, the FIFO is probably
the part most likely to also miss the 100 ms disable poll. Should the FIFO
disable result be checked before DMAC_CMD_TX_SWR_ is written? Another
option is a FIFO reset with FCT_TX_CTL_RESET_ at that point.

>  
>  	lan743x_tx_release_all_descriptors(tx);
>  

[Severity: High]
What happens here if lan743x_dmac_tx_reset() also times out?

The helper returns -ETIMEDOUT and logs "TX channel %d reset timed out".
That return value is dropped, and lan743x_tx_close() continues into two
calls:

- lan743x_tx_release_all_descriptors(), which unmaps and frees the TX
  skbs.
- lan743x_tx_ring_cleanup(), which calls dma_free_coherent() on the
  descriptor ring and the head write-back buffer.

The commit message says the reset is issued "before anything is freed",
so that memory the channel "may still be fetching from or writing to" is
not released. If a wedged channel can ignore STOP_T, can it also ignore
SWR? The open path in this patch already treats an SWR timeout as a real
failure.

lan743x_rx_close() follows the same pattern:

	ret = lan743x_dmac_rx_wait_till_stopped(adapter, rx->channel_number);
	if (ret < 0 || ret == DMAC_CHANNEL_STATE_STARTED) {
		...
		lan743x_dmac_rx_reset(adapter, rx->channel_number);
	}
	...
	lan743x_rx_ring_cleanup(rx);

On the RX side, an engine that is still running could write incoming
frame data, descriptor status and the head index into memory that has
already gone back to the allocator.

Older code makes this worse on the next open. The call chain
lan743x_rx_ring_init()->lan743x_rx_init_ring_element()->
lan743x_rx_update_tail() writes RX_TAIL before lan743x_rx_open() resets
the channel. At that point RX_BASE_ADDR still points at the ring that was
freed.

This also looks unchanged after the later patch in the series, "net:
lan743x: reset the device on TX timeout". That patch runs
lan743x_dmac_init() only after lan743x_netdev_close() has already freed
the rings.

Could the close paths check the reset result and, if it failed, leak the
DMA memory instead of freeing it? Escalating to a full DMAC or PCI reset
would be another option.

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1795027003.git.cbabroski%40nvidia.com

  reply	other threads:[~2026-11-25 14:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 14:33 [PATCH net-next v2 0/7] net: lan743x: automatically recover from TX hang Chris Babroski
2026-11-24 14:33 ` [PATCH net-next v2 1/7] net: lan743x: check DMA channel stop and reset results Chris Babroski
2026-11-25 14:37   ` netdev-bot+sashiko [this message]
2026-11-24 14:33 ` [PATCH net-next v2 2/7] net: lan743x: quiesce TX before freeing the rings Chris Babroski
2026-11-24 14:33 ` [PATCH net-next v2 3/7] net: lan743x: start phylink last and stop it first Chris Babroski
2026-11-25 14:37   ` netdev-bot+sashiko
2026-11-24 14:33 ` [PATCH net-next v2 4/7] net: lan743x: keep the fixed link across reopen Chris Babroski
2026-11-25  0:32   ` Andrew Lunn
2026-11-24 14:33 ` [PATCH net-next v2 5/7] net: lan743x: handle a failed reopen on resume Chris Babroski
2026-11-25 14:37   ` netdev-bot+sashiko
2026-11-24 14:33 ` [PATCH net-next v2 6/7] net: lan743x: reset the device on TX timeout Chris Babroski
2026-11-25 14:37   ` netdev-bot+sashiko
2026-11-24 14:33 ` [PATCH net-next v2 7/7] net: lan743x: add byte queue limits support Chris Babroski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179561742163.3135.1760016027745827288@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=Raju.Lakkaraju@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=bryan.whitehead@microchip.com \
    --cc=cbabroski@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=maxime.chevallier@bootlin.com \
    --cc=nb@tipi-net.de \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=woojung.huh@microchip.com \
    --cc=yuiko.oshino@microchip.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox