mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] net: mdio: fix duplicate registrations for phy with c45 in __of_mdiobus_register()
@ 2023-06-10 16:13 Jianhui Zhao
  2023-06-10 17:10 ` Andrew Lunn
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Jianhui Zhao @ 2023-06-10 16:13 UTC (permalink / raw)
  To: andrew, hkallweit1, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-kernel, Jianhui Zhao

Maybe mdiobus_scan_bus_c45() is called in __mdiobus_register().
Thus it should skip already registered PHYs later.

Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
---
 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] net: mdio: fix duplicate registrations for phy with c45 in __of_mdiobus_register()
  2023-06-10 16:13 [PATCH] net: mdio: fix duplicate registrations for phy with c45 in __of_mdiobus_register() Jianhui Zhao
@ 2023-06-10 17:10 ` Andrew Lunn
  2023-06-11  8:58 ` Jianhui Zhao
  2023-06-11 14:57 ` Jianhui Zhao
  2 siblings, 0 replies; 5+ messages in thread
From: Andrew Lunn @ 2023-06-10 17:10 UTC (permalink / raw)
  To: Jianhui Zhao
  Cc: hkallweit1, davem, edumazet, kuba, pabeni, netdev, linux-kernel

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] net: mdio: fix duplicate registrations for phy with c45 in __of_mdiobus_register()
  2023-06-10 16:13 [PATCH] net: mdio: fix duplicate registrations for phy with c45 in __of_mdiobus_register() Jianhui Zhao
  2023-06-10 17:10 ` Andrew Lunn
@ 2023-06-11  8:58 ` Jianhui Zhao
  2023-06-11 14:57 ` Jianhui Zhao
  2 siblings, 0 replies; 5+ messages in thread
From: Jianhui Zhao @ 2023-06-11  8:58 UTC (permalink / raw)
  To: zhaojh329
  Cc: andrew, davem, edumazet, hkallweit1, kuba, linux-kernel, netdev, pabeni

__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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] net: mdio: fix duplicate registrations for phy with c45 in __of_mdiobus_register()
  2023-06-10 16:13 [PATCH] net: mdio: fix duplicate registrations for phy with c45 in __of_mdiobus_register() Jianhui Zhao
  2023-06-10 17:10 ` Andrew Lunn
  2023-06-11  8:58 ` Jianhui Zhao
@ 2023-06-11 14:57 ` Jianhui Zhao
  2023-06-11 15:11   ` Andrew Lunn
  2 siblings, 1 reply; 5+ messages in thread
From: Jianhui Zhao @ 2023-06-11 14:57 UTC (permalink / raw)
  To: zhaojh329
  Cc: andrew, davem, edumazet, hkallweit1, kuba, linux-kernel, netdev, pabeni

Sorry, I misread the code.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] net: mdio: fix duplicate registrations for phy with c45 in __of_mdiobus_register()
  2023-06-11 14:57 ` Jianhui Zhao
@ 2023-06-11 15:11   ` Andrew Lunn
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Lunn @ 2023-06-11 15:11 UTC (permalink / raw)
  To: Jianhui Zhao
  Cc: davem, edumazet, hkallweit1, kuba, linux-kernel, netdev, pabeni

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-06-11 15:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-10 16:13 [PATCH] net: mdio: fix duplicate registrations for phy with c45 in __of_mdiobus_register() Jianhui Zhao
2023-06-10 17:10 ` Andrew Lunn
2023-06-11  8:58 ` Jianhui Zhao
2023-06-11 14:57 ` Jianhui Zhao
2023-06-11 15:11   ` Andrew Lunn

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®