[PATCH net-next v14 03/13] net: mdio: realtek-rtl9300: deny C45 over C22 access

Markus Stockhausen <[email protected]>
Newsgroups org.kernel.vger.linux-devicetree,org.kernel.vger.netdev
Message-ID <[email protected]>
Hardware polling breaks C45 over C22 PHY access. Currently this
is accepted by the driver but it silently fails with undefined
results. Make the situation clear to the caller by adding checks,
returning an error and giving a one-time warning message.

Suggested-by: Andrew Lunn <[email protected]>
Signed-off-by: Markus Stockhausen <[email protected]>
---
 drivers/net/mdio/mdio-realtek-rtl9300.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/mdio/mdio-realtek-rtl9300.c b/drivers/net/mdio/mdio-realtek-rtl9300.c
index 73ac5fdcd267..87b91aef9b56 100644
--- a/drivers/net/mdio/mdio-realtek-rtl9300.c
+++ b/drivers/net/mdio/mdio-realtek-rtl9300.c
@@ -115,6 +115,7 @@
 #include <linux/bitfield.h>
 #include <linux/bitmap.h>
 #include <linux/bits.h>
+#include <linux/device.h>
 #include <linux/find.h>
 #include <linux/mdio.h>
 #include <linux/mfd/syscon.h>
@@ -453,6 +454,10 @@ static int otto_emdio_read_c22(struct mii_bus *bus, int phy_id, int regnum)
 	int ret, port;
 	u32 value;
 
+	if (dev_WARN_ONCE(&bus->dev, regnum == MII_MMD_CTRL || regnum == MII_MMD_DATA,
+			  "C45 over C22 read access broken due to polling\n"))
+		return -ENOTSUPP;
+
 	port = otto_emdio_phy_to_port(bus, phy_id);
 	if (port < 0)
 		return port;
@@ -468,6 +473,10 @@ static int otto_emdio_write_c22(struct mii_bus *bus, int phy_id, int regnum, u16
 	struct otto_emdio_priv *priv = otto_emdio_bus_to_priv(bus);
 	int ret, port;
 
+	if (dev_WARN_ONCE(&bus->dev, regnum == MII_MMD_CTRL || regnum == MII_MMD_DATA,
+			  "C45 over C22 write access broken due to polling\n"))
+		return -ENOTSUPP;
+
 	port = otto_emdio_phy_to_port(bus, phy_id);
 	if (port < 0)
 		return port;
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.