From: James Hilliard <james.hilliard1@gmail.com>
To: Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
Michael Chan <michael.chan@broadcom.com>,
Hauke Mehrtens <hauke@hauke-m.de>, Andrew Lunn <andrew@lunn.ch>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
James Hilliard <james.hilliard1@gmail.com>
Subject: [PATCH net 4/4] net: phylink: reinitialize the PHY after an MII reset
Date: Fri, 13 Nov 2026 01:48:43 -0700 [thread overview]
Message-ID: <20261113-submit-phy-mii-reset-v1-v1-4-02a55f352a91@gmail.com> (raw)
In-Reply-To: <20261113-submit-phy-mii-reset-v1-v1-0-02a55f352a91@gmail.com>
phylink handles SIOCSMIIREG with a raw MDIO write, bypassing the reset
handling in phy_mii_ioctl(). A BMCR reset of the attached Clause 22 PHY
therefore clears hardware state without running the driver initialization
callbacks. The PHY worker continues using the old software state.
Delegate BMCR reset writes for the attached Clause 22 PHY to
phy_mii_ioctl(), which quiesces the PHY worker across reset completion and
driver initialization. Select this path in the register-write helper after
the Clause 45 cases, retaining raw access for the other register writes.
Fixes: 9525ae83959b ("phylink: add phylink infrastructure")
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/net/phy/phylink.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index e885da1c2831..2f0e3a30615c 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -3570,10 +3570,13 @@ static int phylink_phy_read(struct phylink *pl, unsigned int phy_id,
return mdiobus_read(pl->phydev->mdio.bus, phy_id, reg);
}
-static int phylink_phy_write(struct phylink *pl, unsigned int phy_id,
- unsigned int reg, unsigned int val)
+static int phylink_phy_write(struct phylink *pl, struct ifreq *ifr)
{
+ struct mii_ioctl_data *mii = if_mii(ifr);
struct phy_device *phydev = pl->phydev;
+ u16 phy_id = mii->phy_id;
+ u16 reg = mii->reg_num;
+ u16 val = mii->val_in;
int prtad, devad;
if (mdio_phy_id_is_c45(phy_id)) {
@@ -3608,6 +3611,10 @@ static int phylink_phy_write(struct phylink *pl, unsigned int phy_id,
reg, val);
}
+ if (phy_id == phydev->mdio.addr && reg == MII_BMCR &&
+ (val & BMCR_RESET))
+ return phy_mii_ioctl(phydev, ifr, SIOCSMIIREG);
+
return mdiobus_write(phydev->mdio.bus, phy_id, reg, val);
}
@@ -3697,8 +3704,7 @@ int phylink_mii_ioctl(struct phylink *pl, struct ifreq *ifr, int cmd)
break;
case SIOCSMIIREG:
- ret = phylink_phy_write(pl, mii->phy_id, mii->reg_num,
- mii->val_in);
+ ret = phylink_phy_write(pl, ifr);
break;
default:
--
2.53.0
next prev parent reply other threads:[~2026-11-13 8:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 8:48 [PATCH net 0/4] net: phy: restore driver state after userspace MII resets James Hilliard
2026-11-13 8:48 ` [PATCH net 1/4] net: b44: keep phylib ioctls outside the spinlock James Hilliard
2026-11-13 8:48 ` [PATCH net 2/4] net: phy: propagate MII register write errors James Hilliard
2026-11-13 8:48 ` [PATCH net 3/4] net: phy: quiesce the state machine during MII resets James Hilliard
2026-11-13 8:48 ` James Hilliard [this message]
2026-11-13 8:53 ` [PATCH net 0/4] net: phy: restore driver state after userspace " netdev-bot+sinfo
2026-11-13 9:28 ` James Hilliard
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=20261113-submit-phy-mii-reset-v1-v1-4-02a55f352a91@gmail.com \
--to=james.hilliard1@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hauke@hauke-m.de \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=michael.chan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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®