From: netdev-bot+sashiko@kernel.org
To: aiyengar1990@gmail.com
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, wens@kernel.org,
jernej.skrabec@gmail.com, samuel@sholland.org,
p.zabel@pengutronix.de, linux@armlinux.org.uk,
netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev,
linux-stm32@st-md-mailman.stormreply.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v4 4/5] net: stmmac: Add MDIO init and exit platform hooks
Date: Tue, 24 Nov 2026 11:16:21 +0000 [thread overview]
Message-ID: <179551898118.3135.17931835729016827308@kernel.org> (raw)
In-Reply-To: <20261120-sun8i-emac-mux-uaf-v4-4-57eba8915f25@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 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).
- [Medium] stmmac_dvr_remove()
(drivers/net/ethernet/stmicro/stmmac/stmmac_main.c) asserts the MAC…
--
net: stmmac: Add MDIO init and exit platform hooks
This commit adds two platform hooks, mdio_init() and mdio_exit(), to
plat_stmmacenet_data. mdio_init() runs once the stmmac MDIO bus is
registered and mdio_exit() runs before it is unregistered. Glue drivers
can use them to add devices such as an MDIO mux on top of the bus.
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> index 7396b68899c66..fb1f7b1a5323b 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
[ ... ]
> @@ -703,6 +711,9 @@ int stmmac_mdio_unregister(struct net_device *ndev)
> if (!priv->mii)
> return 0;
>
> + if (priv->plat->mdio_exit)
> + priv->plat->mdio_exit(priv);
> +
[Severity: Medium]
Is the MDIO bus still usable when mdio_exit() runs on the remove path?
stmmac_dvr_remove() asserts the MAC resets before it calls
stmmac_mdio_unregister():
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:stmmac_dvr_remove() {
...
phylink_destroy(priv->phylink);
if (priv->plat->stmmac_rst)
reset_control_assert(priv->plat->stmmac_rst);
reset_control_assert(priv->plat->stmmac_ahb_rst);
stmmac_pcs_clean(ndev);
stmmac_mdio_unregister(ndev);
...
}
As a result, mdio_exit() runs while the MAC, which is the MDIO master, is
held in reset.
Later in this series, dwmac-sun8i uses this hook to call mdio_mux_uninit().
That unregisters the mux child buses and removes the PHYs on them. PHY
removal can issue MDIO transactions through the mux:
stmmac_dvr_remove()
reset_control_assert(stmmac_rst)
stmmac_mdio_unregister()
mdio_exit() -> sun8i_dwmac_unregister_mdio_mux()
mdio_mux_uninit()
mdiobus_unregister(child)
phy_remove()
phy_leds_unregister()
led_classdev_unregister() -> phy_led_set_brightness()
phydev->drv->remove()
Each of these can reach mdio_mux_syscon_switch_fn(), which calls
sun8i_dwmac_reset() on the MAC registers, and then
stmmac_mdio_read_c22() or stmmac_mdio_write_c22(). The H3/H5 DT names
its EMAC reset "stmmaceth", so plat->stmmac_rst is asserted while this
happens.
With the register file in reset, the busy poll in stmmac_mdio_wait() can
read 0 and report the bus as idle:
if (readl_poll_timeout(reg, v, !(v & mask), 100, 10000))
return -EBUSY;
In that case, would MDIO writes be dropped without any error, and reads
return 0 as if they had succeeded? On interconnects that stall on
accesses to a block in reset, could the access hang instead?
Before this series, the sun8i mux teardown ran before
stmmac_pltfr_remove(), while the MAC was still out of reset. The commit
message says mdio_exit() is "called before it is unregistered", which
suggests the bus still works when the hook runs. The new member in
include/linux/stmmac.h does not mention any restriction either.
Should mdio_exit() be called before the resets are asserted in
stmmac_dvr_remove()? If not, should the hook document that the MDIO
master may be in reset when it runs?
> mdiobus_unregister(priv->mii);
> priv->mii->priv = NULL;
> mdiobus_free(priv->mii);
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120-sun8i-emac-mux-uaf-v4-0-57eba8915f25%40gmail.com
next prev parent reply other threads:[~2026-11-24 11:16 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 10:45 [PATCH net-next v4 0/5] net: stmmac: dwmac-sun8i: Fix the EPHY and MDIO mux ordering Arun Iyengar via B4 Relay
2026-11-20 10:45 ` [PATCH net-next v4 1/5] net: stmmac: dwmac-sun8i: Put the EPHY clock and reset after the MAC Arun Iyengar via B4 Relay
2026-11-22 16:47 ` Maxime Chevallier
2026-11-24 11:16 ` netdev-bot+sashiko
2026-11-20 10:45 ` [PATCH net-next v4 2/5] net: stmmac: dwmac-sun8i: Get the EPHY clock and reset before the MAC probe Arun Iyengar via B4 Relay
2026-11-22 16:51 ` Maxime Chevallier
2026-11-24 11:16 ` netdev-bot+sashiko
2026-11-20 10:45 ` [PATCH net-next v4 3/5] net: stmmac: Balance runtime PM when the probe fails Arun Iyengar via B4 Relay
2026-11-22 17:03 ` Maxime Chevallier
2026-11-24 11:16 ` netdev-bot+sashiko
2026-11-20 10:45 ` [PATCH net-next v4 4/5] net: stmmac: Add MDIO init and exit platform hooks Arun Iyengar via B4 Relay
2026-11-22 17:05 ` Maxime Chevallier
2026-11-22 17:35 ` Maxime Chevallier
2026-11-24 11:16 ` netdev-bot+sashiko [this message]
2026-11-20 10:45 ` [PATCH net-next v4 5/5] net: stmmac: dwmac-sun8i: Register the MDIO mux in the MDIO setup Arun Iyengar via B4 Relay
2026-11-22 17:35 ` Maxime Chevallier
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=179551898118.3135.17931835729016827308@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=aiyengar1990@gmail.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=jernej.skrabec@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux-sunxi@lists.linux.dev \
--cc=linux@armlinux.org.uk \
--cc=maxime.chevallier@bootlin.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=samuel@sholland.org \
--cc=wens@kernel.org \
/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