Thread (11 messages) flat view 11 messages, 6 authors, 2021-03-26

Re: [PATCH net V2 1/1] net: phy: fix invalid phy id when probe using C22

From: Heiner Kallweit <hkallweit1@gmail.com>
Date: 2021-03-18 13:26:38
Also in: lkml, netdev

On 18.03.2021 10:09, Wong Vee Khee wrote:
When using Clause-22 to probe for PHY devices such as the Marvell
88E2110, PHY ID with value 0 is read from the MII PHYID registers
which caused the PHY framework failed to attach the Marvell PHY
driver.

Fixed this by adding a check of PHY ID equals to all zeroes.
I was wondering whether we have, and may break, use cases where a PHY,
for whatever reason, reports PHY ID 0, but works with the genphy
driver. And indeed in swphy_read_reg() we return PHY ID 0, therefore
the patch may break the fixed phy.
Having said that I think your patch is ok, but we need a change of
the PHY ID reported by swphy_read_reg() first.
At a first glance changing the PHY ID to 0x00000001 in swphy_read_reg()
should be sufficient. This value shouldn't collide with any real world
PHY ID.
quoted hunk ↗ jump to hunk
Fixes: ee951005e95e ("net: phy: clean up get_phy_c22_id() invalid ID handling")
Cc: stable@vger.kernel.org
Reviewed-by: Voon Weifeng <redacted>
Signed-off-by: Wong Vee Khee <redacted>
---
v2 changelog:
 - added fixes tag
 - marked for net instead of net-next
---
 drivers/net/phy/phy_device.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index cc38e326405a..c12c30254c11 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -809,8 +809,8 @@ static int get_phy_c22_id(struct mii_bus *bus, int addr, u32 *phy_id)
 
 	*phy_id |= phy_reg;
 
-	/* If the phy_id is mostly Fs, there is no device there */
-	if ((*phy_id & 0x1fffffff) == 0x1fffffff)
+	/* If the phy_id is mostly Fs or all zeroes, there is no device there */
+	if (((*phy_id & 0x1fffffff) == 0x1fffffff) || (*phy_id == 0))
 		return -ENODEV;
 
 	return 0;
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help