Skip to contentSkip to conversation

net: mdio: handle broken-turn-around for non-PHY MDIO devices

PATCH Superseded Bastian Germann 2 participants 4 messages Nov 21

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: mdio: handle broken-turn-around for non-PHY MDIO devices

The "broken-turn-around" property is documented in mdio.yaml for any MDIO device, but the MDIO core currently parses it only for PHY devices in fwnode_mdiobus_phy_device_register(). Non-PHY devices, such as DSA switches, are registered through of_mdiobus_register_device(), where the property is ignored, so MDIO bus drivers that rely on phy_ignore_ta_mask still treat the turn-around/read failure as an error.

Parse the property in of_mdiobus_register_phy() and of_mdiobus_register_device() instead, so it is handled in one place for both PHYs and other MDIO devices, and drop it from fwnode_mdiobus_phy_device_register().

---
 drivers/net/mdio/fwnode_mdio.c | 3 ---
 drivers/net/mdio/of_mdio.c     | 6 ++++++
 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/net/mdio/fwnode_mdio.c +0 -3
index ba7091518265..129481e8a910 100644
@@ -89,9 +89,6 @@ int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio,
 		phy->irq = mdio->irq[addr];
 	}
 
-	if (fwnode_property_read_bool(child, "broken-turn-around"))
-		mdio->phy_ignore_ta_mask |= 1 << addr;
-
 	/* Associate the fwnode with the device structure so it
 	 * can be looked up later
 	 */
drivers/net/mdio/of_mdio.c +6 -0
index b8d298c04d3f..c03fcf34b3a6 100644
@@ -46,6 +46,9 @@ EXPORT_SYMBOL(of_mdiobus_phy_device_register);
 static int of_mdiobus_register_phy(struct mii_bus *mdio,
 				    struct device_node *child, u32 addr)
 {
+	if (of_property_read_bool(child, "broken-turn-around"))
+		mdio->phy_ignore_ta_mask |= BIT(addr);
+
 	return fwnode_mdiobus_register_phy(mdio, of_fwnode_handle(child), addr);
 }
 
@@ -56,6 +59,9 @@ static int of_mdiobus_register_device(struct mii_bus *mdio,
 	struct mdio_device *mdiodev;
 	int rc;
 
+	if (fwnode_property_read_bool(fwnode, "broken-turn-around"))
+		mdio->phy_ignore_ta_mask |= BIT(addr);
+
 	mdiodev = mdio_device_create(mdio, addr);
 	if (IS_ERR(mdiodev))
 		return PTR_ERR(mdiodev);
maintainer
#1 lore raw
Quoted 4 lines

Parse the property in of_mdiobus_register_phy() and of_mdiobus_register_device() instead, so it is handled in one place for both PHYs and other MDIO devices, and drop it from fwnode_mdiobus_phy_device_register().

This seems odd. "handled in one place", yet you do it in two?

Is there a reason not to do it in __of_mdiobus_parse_phys() ?

Andrew

#2 lore raw

Hi Andrew,

Quoted 7 lines · Andrew Lunn
Quoted 4 lines

Parse the property in of_mdiobus_register_phy() and of_mdiobus_register_device() instead, so it is handled in one place for both PHYs and other MDIO devices, and drop it from fwnode_mdiobus_phy_device_register().

This seems odd. "handled in one place", yet you do it in two?

Is there a reason not to do it in __of_mdiobus_parse_phys() ?

Yes. My v2 draft was exactly that (which is the reason for the commit message oddity) but I noticed that children with empty reg that are handled in the auto-scan loop would then not get the bit mask set, which is an unnecessary behavior change for PHYs. I will send a v3 with your proposal. I am happy with either of them.

Thanks,
Bastian

maintainer
#3 lore raw
Quoted 7 lines · Bastian Germann

Hi Andrew,

Quoted 4 lines · Andrew Lunn
Quoted 4 lines

Parse the property in of_mdiobus_register_phy() and of_mdiobus_register_device() instead, so it is handled in one place for both PHYs and other MDIO devices, and drop it from fwnode_mdiobus_phy_device_register().

Quoted 8 lines
Quoted 3 lines

This seems odd. "handled in one place", yet you do it in two?

Is there a reason not to do it in __of_mdiobus_parse_phys() ?

Yes. My v2 draft was exactly that (which is the reason for the commit message oddity) but I noticed that children with empty reg that are handled in the auto-scan loop would then not get the bit mask set, which is an unnecessary behavior change for PHYs.

Ah, O.K. I never liked that scan code filling in missing devices. It has a warning not to do that. So i don't know if it is actually used.

Also, i could not find any in kernel dt blobs using broken-turn-around. So we are not going to break anything.

Andrew

---
pw-bot: cr