Thread View: linux.kernel.netdev
2 messages
2 total messages
Started by Arun Iyengar via B4 Relay
Sat, 28 Nov 2026 17:36
[PATCH net-next v5 0/6] net: stmmac: dwmac-sun8i: Fix the EPHY and MDIO mux ordering
Author: Arun Iyengar via B4 Relay
Date: Sat, 28 Nov 2026 17:36
Date: Sat, 28 Nov 2026 17:36
84 lines
14996 bytes
14996 bytes
Chen-Yu Tsai pointed out that the probe error path and remove() put the
EPHY clock and reset before sun8i_dwmac_exit() uses them (patch 1).
Sashiko and Maxime Chevallier pointed out that the EPHY lookup and the
mux registration run after register_netdev(), and Maxime suggested
registering the mux in the MDIO setup (patches 2, 5 and 6). Patch 2
replaces "Defer probe when the EPHY clock is not ready" [1]. Patches 3
and 4 make the stmmac probe error path, which a mux failure now takes,
undo runtime PM and the resets as remove() does. Patch 4 also asserts
the resets only after the MDIO bus is gone, so mdio_exit() runs with
the MAC out of reset.
Tested on QEMU orangepi-pc (H3, internal PHY) with KASAN; I have no H3,
H5 or V3s board. On net-next, a test-only mdio_mux_init() failure gives
a KASAN use-after-free in clk_disable(), and unbinding with the link up
oopses in phy_stop(). With the series both are clean, an EPHY clock
without a provider defers before the netdev exists, and unbind/bind
cycles pass. With patch 3 the MAC runtime-suspends after a failed probe
and rebind (usage 0, was 1). A test-only emulation of a bus that enables
runtime PM before probe keeps it enabled after the failed probe; PCI
itself is untested.
On an H616 (Orange Pi Zero2, external PHY), a forced -EPROBE_DEFER from
the MDIO setup leaves runtime PM disabled with usage 0, and the MAC
suspends after rebind. With patch 4 the MAC is in reset after the failed
probe, and a test PHY ID read from mdio_exit() on unbind returns
0x001cc916 (0 without patch 4).
Developed with Claude (Anthropic); I reviewed it.
[1] https://lore.kernel.org/r/20261113-b4-sun8i-emac-ephy-defer-v1-1-12a8591702fe@gmail.com
---
Changes in v5:
- Patch 2: say why the lookup moves; the deferral fix only matters for out-of-tree DTs (Sashiko)
- Patch 3: disable runtime PM only if the probe enabled it (Sashiko, Maxime Chevallier)
- New patch 4: assert the resets after the MDIO bus is gone, also on probe failure (Sashiko)
- Patch 5: document when the hooks run
- Patch 6: name the hooks patch (Sashiko)
- No Fixes tags, as this is net-next; patch 6 reverses the ordering from 634db83b8265 and 529254216773 (Sashiko, Andrew Lunn)
- Not changed (pre-existing): get_ephy_nodes() needs an mdio-mux node; stmmac_dvr_remove() disables runtime PM unconditionally
- Rebased onto net-next
- Link to v4: https://patch.msgid.link/20261120-sun8i-emac-mux-uaf-v4-0-57eba8915f25@gmail.com
Changes in v4:
- Put the EPHY clock and reset after stmmac_pltfr_remove() (Chen-Yu Tsai)
- Get the EPHY clock and reset before the MAC probe, defer on the clock (Sashiko, Maxime Chevallier)
- Balance runtime PM when the stmmac probe fails (new patch 3)
- Register the mux through new stmmac mdio_init()/mdio_exit() hooks (Maxime Chevallier)
- Now a series, new cover subject
- Link to v3: https://patch.msgid.link/20261115-sun8i-emac-mux-uaf-v3-1-c69d4189539d@gmail.com
Changes in v3:
- Drop the Fixes tag (Andrew Lunn)
- Shorter commit message
- Link to v2: https://patch.msgid.link/20261113-sun8i-emac-mux-uaf-v2-1-6203666b2687@gmail.com
Changes in v2:
- Target net-next instead of net, drop Cc: stable (Andrew Lunn)
- Shorter commit message
- Rebased onto net-next
- Link to v1: https://patch.msgid.link/20261112-sun8i-emac-mux-uaf-v1-1-308ae7e6fcf2@gmail.com
---
Arun Iyengar (6):
net: stmmac: dwmac-sun8i: Put the EPHY clock and reset after the MAC
net: stmmac: dwmac-sun8i: Get the EPHY clock and reset before the MAC probe
net: stmmac: Balance runtime PM when the probe fails
net: stmmac: Assert the resets after unregistering the MDIO bus
net: stmmac: Add MDIO init and exit platform hooks
net: stmmac: dwmac-sun8i: Register the MDIO mux in the MDIO setup
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 82 +++++++++--------------
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 17 +++--
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 11 +++
include/linux/stmmac.h | 3 +
4 files changed, 60 insertions(+), 53 deletions(-)
---
base-commit: 8f0f7f39913e8b1571f2e6a8295a700356492f2a
change-id: 20261112-sun8i-emac-mux-uaf-1ba885219fee
Best regards,
--
Arun Iyengar <aiyengar1990@gmail.com>
[PATCH net-next v5 4/6] net: stmmac: Assert the resets after unregistering the MDIO bus
Author: Arun Iyengar via B4 Relay
Date: Sat, 28 Nov 2026 17:37
Date: Sat, 28 Nov 2026 17:37
48 lines
12088 bytes
12088 bytes
From: Arun Iyengar <aiyengar1990@gmail.com> stmmac_dvr_remove() asserts the MAC resets before it unregisters the MDIO bus, so the PHYs on the bus are removed with the MDIO master in reset. The probe error path does not assert them at all. Assert them after the PCS and the MDIO bus are gone in both. Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com> --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 1280496741e7..da03a8223bba 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -8406,6 +8406,9 @@ static int __stmmac_dvr_probe(struct device *device, pm_runtime_put_noidle(device); stmmac_napi_del(ndev); error_hw_init: + if (priv->plat->stmmac_rst) + reset_control_assert(priv->plat->stmmac_rst); + reset_control_assert(priv->plat->stmmac_ahb_rst); destroy_workqueue(priv->wq); error_wq_init: bitmap_free(priv->af_xdp_zc_qps); @@ -8465,13 +8468,13 @@ void stmmac_dvr_remove(struct device *dev) stmmac_unregister_devlink(priv); phylink_destroy(priv->phylink); + stmmac_pcs_clean(ndev); + stmmac_mdio_unregister(ndev); + 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); - destroy_workqueue(priv->wq); mutex_destroy(&priv->lock); mutex_destroy(&priv->est_lock); -- 2.55.0
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads