From: Maxime Chevallier <maxime.chevallier@bootlin.com>
To: Savvas Etairidis <setairidis@gmail.com>, netdev@vger.kernel.org
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org, saet@hms.se,
Andre Pribil <andpr@hms.se>, Bela Scholtes <besc@hms.se>,
Michail Georgios Etairidis <miet@hms.se>
Subject: Re: [PATCH net] net: stmmac: hold the MDIO bus lock during the MAC soft reset
Date: Wed, 2 Dec 2026 19:43:33 +0100 [thread overview]
Message-ID: <0418f4e8-47d1-4d18-b9dc-627e098818b3@bootlin.com> (raw)
In-Reply-To: <20261202170439.2911343-1-setairidis@gmail.com>
Hi,
On 12/2/26 18:04, Savvas Etairidis wrote:
> From: Savvas Etairidis <saet@hms.se>
>
> The MAC soft reset in stmmac_init_dma_engine() stops the MDIO master.
> If an MDIO transaction is in flight at that moment, it is cut off in
> the middle of a frame. On a Realtek switch managed over MDIO (SMI),
> this was seen to store a value in the wrong register (0x00bb written to
> 0x08a2) or leave the switch not answering.
>
> Take the MDIO bus lock around the reset with stmmac_mdio_lock(), as
> dwmac-dwc-qos-eth already does for its pad calibration, so that no
> transaction can be running while the reset happens. Every MDIO
> transaction holds this lock for the whole frame.
>
> On two boards, forced MAC resets triggered the corruption within 250
> resets without the lock. With the lock, 36000 forced resets caused
> none.
>
> stmmac_init_dma_engine() is only called from __stmmac_open() and
> stmmac_resume(), neither of which holds the bus lock.
>
> This patch was developed with the help of an AI coding assistant
> (Claude Code). It wrote the change and the changelog. I reviewed
> both and tested the fix on 6.6.162 hardware (36000 forced MAC resets
> with the lock, none failing).
>
> Fixes: 47dd7a540b8a ("net: add support for STMicroelectronics Ethernet controllers.")
> Signed-off-by: Savvas Etairidis <saet@hms.se>
I've browsed the docs, this seems to be indeed required.
I think this makes sense,
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
(out of curiosity, how did you hit that ? it seems fairly rare no ?)
Maxime
> ---
> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index a685ce4638f6..1011e08f20c8 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -3331,7 +3331,10 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv)
> if (ret)
> return ret;
>
> + /* The soft reset stops the MDIO master, so keep the bus idle. */
> + stmmac_mdio_lock(priv);
> ret = stmmac_reset(priv);
> + stmmac_mdio_unlock(priv);
> if (ret) {
> netdev_err(priv->dev, "Failed to reset the dma\n");
> return ret;
prev parent reply other threads:[~2026-12-02 18:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 17:04 [PATCH net] net: stmmac: hold the MDIO bus lock during the MAC soft reset Savvas Etairidis
2026-12-02 17:08 ` netdev-bot+sinfo
2026-12-02 18:43 ` Maxime Chevallier [this message]
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=0418f4e8-47d1-4d18-b9dc-627e098818b3@bootlin.com \
--to=maxime.chevallier@bootlin.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andpr@hms.se \
--cc=andrew+netdev@lunn.ch \
--cc=besc@hms.se \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=miet@hms.se \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saet@hms.se \
--cc=setairidis@gmail.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