mirror of https://lore.kernel.org/lkml/
 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 3/7] net: lan743x: start phylink last and stop it first
Date: Wed, 25 Nov 2026 14:37:03 +0000	[thread overview]
Message-ID: <179561742372.3135.13284250569382417809@kernel.org> (raw)
In-Reply-To: <df1845de5cbdd4c556a39a48faa23848e02d4944.1795027003.git.cbabroski@nvidia.com>

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] In lan743x_netdev_close()
  (drivers/net/ethernet/microchip/lan743x_main.c:3378), the patch now…
- [Medium] lan743x_netdev_open() now calls lan743x_phylink_connect()
  (drivers/net/ethernet/microchip/lan743x_main.c:3430) after all RX and…

--

net: lan743x: start phylink last and stop it first

This patch moves lan743x_phylink_connect() to the end of
lan743x_netdev_open() and lan743x_phylink_disconnect() to the start of
lan743x_netdev_close(). The goal is that mac_link_up() can no longer wake
the TX queues while the rings are missing. The phylink disconnect is also
dropped from the open error path, because phylink is now connected only
after everything else has succeeded.

> diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
> index 57d52930f89be..8eb0645493e63 100644
> --- a/drivers/net/ethernet/microchip/lan743x_main.c
> +++ b/drivers/net/ethernet/microchip/lan743x_main.c
> @@ -3375,6 +3375,8 @@ static int lan743x_netdev_close(struct net_device *netdev)
>  	struct lan743x_adapter *adapter = netdev_priv(netdev);
>  	int index;
>  
> +	lan743x_phylink_disconnect(adapter);
> +
>  	synchronize_net();
>  	netif_tx_disable(netdev);
>  

[Severity: Medium]
Does the whole of lan743x_phylink_disconnect() need to move ahead of the
ring teardown, or only phylink_stop()?

lan743x_phylink_disconnect() does both:

    phylink_stop(adapter->phylink);
    phylink_disconnect_phy(adapter->phylink);

phylink_disconnect_phy() ends up in phy_detach_internal(), which calls
phy_suspend(phydev) and later phy_device_reset(phydev, 1).

As a result, the PHY is now powered down before lan743x_tx_close() and
lan743x_rx_close() run their DMAC_CMD_STOP_T_ / DMAC_CMD_STOP_R_ and
FCT_TX_CTL / FCT_RX_CTL disable handshakes. If a reset GPIO exists, the PHY
is also held in reset at that point. This happens on ndo_stop, on the
suspend path through lan743x_pcidev_shutdown(), and on the TX timeout reset
later in the series.

Suppose the FCT or DMA teardown depends on a PHY-sourced clock, such as
RGMII RXC, MII TX_CLK/RX_CLK, or a PHY-supplied RMII REF_CLK. Could the RX
FIFO then still be half-disabled when the ring is freed? The result of
this poll in lan743x_rx_close() is ignored:

    lan743x_csr_write(adapter, FCT_RX_CTL,
                      FCT_RX_CTL_DIS_(rx->channel_number));
    lan743x_csr_wait_for_bit(adapter, FCT_RX_CTL,
                             FCT_RX_CTL_EN_(rx->channel_number),
                             0, 1000, 20000, 100);

lan743x_tx_close() could also take the "failed to stop, resetting it"
path, and lan743x_tx_fifo_disable() could time out.

I couldn't confirm from the driver code or a datasheet that the FCT and
DMA teardown needs the PHY clock. Also, lan743x_mac_close() already ran
after the PHY detach before this patch.

Keeping mac_link_up() from waking the queues seems to need only
phylink_stop() first. Could phylink_disconnect_phy() stay after the ring
and FIFO teardown? __stmmac_release() uses that order: it calls
phylink_stop(), stops DMA and frees the descriptors, and only then calls
phylink_disconnect_phy().

The ordering here is still the same at the end of the series.

[ ... ]

> @@ -3409,10 +3409,6 @@ static int lan743x_netdev_open(struct net_device *netdev)
>  	if (ret)
>  		goto close_intr;
>  
> -	ret = lan743x_phylink_connect(adapter);
> -	if (ret)
> -		goto close_mac;
> -
>  	ret = lan743x_ptp_open(adapter);
>  	if (ret)
>  		goto close_mac;
> @@ -3431,6 +3427,10 @@ static int lan743x_netdev_open(struct net_device *netdev)
>  			goto close_tx;
>  	}
>  
> +	ret = lan743x_phylink_connect(adapter);
> +	if (ret)
> +		goto close_tx;
> +

[Severity: Medium]
On a reopen, the PHY is still suspended from phy_detach_internal() in the
previous close. It is only resumed through phy_attach_direct() and
phy_resume() inside lan743x_phylink_connect(). Before this patch, the PHY
was attached and resumed right after lan743x_mac_open(), before any FIFO
or DMA reset.

With connect moved here, the FCT resets and the DMA channel resets
(lan743x_dmac_tx_reset() and lan743x_dmac_rx_reset()) in
lan743x_rx_open() and lan743x_tx_open() now run while the PHY is powered
down.

If the FCT resets need the PHY-sourced MAC clock, can this make the open
fail? lan743x_tx_fifo_enable() returns an error on timeout:

    lan743x_csr_write(adapter, FCT_TX_CTL,
                      FCT_TX_CTL_RESET_(tx->channel_number));
    ret = lan743x_csr_wait_for_bit(adapter, FCT_TX_CTL,
                                   FCT_TX_CTL_RESET_(tx->channel_number),
                                   0, 1000, 20000, 100);
    if (ret) {
        netdev_err(adapter->netdev,
                   "TX channel %d FIFO reset timed out\n",
                   tx->channel_number);
        return ret;
    }

If that times out, the interface would not come back up after its first
ifdown or suspend. The FCT_RX_CTL_RESET_ wait in lan743x_rx_open() ignores
its result. In that case FCT_FLOW would be programmed and the RX FIFO
enabled even though the reset never finished.

A second effect is that phylink_start() now calls mac_config() after the
FIFOs and DMA are already running. For SGMII, 1000BASE-X and 2500BASE-X,
lan743x_phylink_mac_config() calls lan743x_serdes_clock_and_aneg_update(),
which switches the SerDes MPLL, and then lan743x_pcs_power_reset(). Is it
safe to do that on every open while DMA is active? phylink_resolve() can
already call mac_config() at runtime when the PHY changes interface, so
this part is less certain.

As on the close side, I couldn't confirm the clock dependency from the
driver code. The DMAC global reset in lan743x_dmac_init() also already
runs on resume with the PHY detached.

Would splitting the helper avoid this? The PHY could be attached early as
before, with only phylink_start() called last. mac_link_up() would still
not run before the rings exist.

This ordering is also unchanged at the end of the series.

-- 
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
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 [this message]
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=179561742372.3135.13284250569382417809@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

all inboxes | Powered by JetHome®