From: Charles Perry <charles.perry@microchip.com>
To: <netdev@vger.kernel.org>
Cc: Charles Perry <charles.perry@microchip.com>,
Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH net-next v4 3/3] net: phy: add a PHY write barrier when disabling interrupts
Date: Thu, 2 Apr 2026 06:12:24 -0700 [thread overview]
Message-ID: <20260402131229.319599-4-charles.perry@microchip.com> (raw)
In-Reply-To: <20260402131229.319599-1-charles.perry@microchip.com>
MDIO bus controllers are not required to wait for write transactions to
complete before returning as synchronization is often achieved by polling
status bits.
This can cause issues when disabling interrupts since an interrupt could
fire before the interrupt handler is unregistered and there's no status
bit to poll.
Add a phy_write_barrier() function and use it in phy_disable_interrupts()
to fix this issue. The write barrier just reads an MII register and
discards the value, which is enough to guarantee that previous writes have
completed.
Signed-off-by: Charles Perry <charles.perry@microchip.com>
---
Notes:
Changes in v4:
- Add this patch (Russell, Andrew)
drivers/net/phy/phy.c | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 13dd1691886d..2be0b90e9947 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -1368,14 +1368,39 @@ void phy_error(struct phy_device *phydev)
}
EXPORT_SYMBOL(phy_error);
+/**
+ * phy_write_barrier - ensure the last write completed for this PHY device
+ * @phydev: target phy_device struct
+ *
+ * MDIO bus controllers are not required to wait for write transactions to
+ * complete before returning. Calling this function ensures that the previous
+ * write has completed.
+ */
+static int phy_write_barrier(struct phy_device *phydev)
+{
+ int err;
+
+ err = phy_read(phydev, MII_PHYSID1);
+ if (err < 0)
+ return err;
+
+ return 0;
+}
+
/**
* phy_disable_interrupts - Disable the PHY interrupts from the PHY side
* @phydev: target phy_device struct
*/
int phy_disable_interrupts(struct phy_device *phydev)
{
+ int err;
+
/* Disable PHY interrupts */
- return phy_config_interrupt(phydev, PHY_INTERRUPT_DISABLED);
+ err = phy_config_interrupt(phydev, PHY_INTERRUPT_DISABLED);
+ if (err)
+ return err;
+
+ return phy_write_barrier(phydev);
}
/**
--
2.47.3
next prev parent reply other threads:[~2026-04-02 13:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-02 13:12 [PATCH net-next v4 0/3] Add support for PIC64-HPSC/HX MDIO controller Charles Perry
2026-04-02 13:12 ` [PATCH net-next v4 1/3] dt-bindings: net: document Microchip " Charles Perry
2026-04-02 13:12 ` [PATCH net-next v4 2/3] net: mdio: add a driver for " Charles Perry
2026-04-02 13:12 ` Charles Perry [this message]
2026-04-02 13:31 ` [PATCH net-next v4 3/3] net: phy: add a PHY write barrier when disabling interrupts Andrew Lunn
2026-04-02 17:51 ` Charles Perry
2026-04-02 18:03 ` Russell King (Oracle)
2026-04-02 18:09 ` Andrew Lunn
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=20260402131229.319599-4-charles.perry@microchip.com \
--to=charles.perry@microchip.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--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