Maybe mdiobus_scan_bus_c45() is called in __mdiobus_register().
Thus it should skip already registered PHYs later.
Signed-off-by: Jianhui Zhao <[email protected]>
---
drivers/net/mdio/of_mdio.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
index 7eb32ebb846d..441973fce79e 100644
--- a/drivers/net/mdio/of_mdio.c
+++ b/drivers/net/mdio/of_mdio.c
@@ -186,6 +186,10 @@ int __of_mdiobus_register(struct mii_bus *mdio, struct device_node *np,
continue;
}
+ /* skip already registered PHYs */
+ if (mdiobus_is_registered_device(mdio, addr))
+ continue;
+
if (of_mdiobus_child_is_phy(child))
rc = of_mdiobus_register_phy(mdio, child, addr);
else
--
2.34.1
On Sun, Jun 11, 2023 at 12:13:08AM +0800, Jianhui Zhao wrote:
> Maybe mdiobus_scan_bus_c45() is called in __mdiobus_register().
> Thus it should skip already registered PHYs later.
Please could you expand on your commit message. I don't see what is
going wrong here. What does your device tree look like? Do you have a
PHY which responds to both C22 and C45?
Thanks
Andrew
__of_mdiobus_register
__mdiobus_register
mdiobus_scan_bus_c45
of_mdiobus_child_is_phy
of_mdiobus_register_phy
fwnode_mdiobus_register_phy
is_c45 = fwnode_device_is_compatible(child, "ethernet-phy-ieee802.3-c45");
get_phy_device
phy_device_create
This is the function call chain. If a phy is already registered in
mdiobus_scan_bus_c45(), and it's compatible "ethernet-phy-ieee802.3-c45",
thus it will duplicated call get_phy_device later.
On Sun, Jun 11, 2023 at 10:57:28PM +0800, Jianhui Zhao wrote:
> Sorry, I misread the code.
So this is by code inspection, not an actual device tree booting on a
board?
What should happen is that __of_mdiobus_register() has:
/* Mask out all PHYs from auto probing. Instead the PHYs listed in
* the device tree are populated after the bus has been registered */
mdio->phy_mask = ~0;
So when
rc = __mdiobus_register(mdio, owner);
is called, no scanning happens. I _guess_ that is what you missed?
Andrew
--
pw-bot: reject
Sorry, I misread the code.