[lkml]   [2019]   [Jul]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[RFC] net: phy: read link status twice when phy_check_link_status()
According to the datasheet of Marvell phy and Realtek phy, the
copper link status should read twice, or it may get a fake link
up status, and cause up->down->up at the first time when link up.
This happens more oftem at Realtek phy.

I add a fake status read, and can solve this problem.

I also see that in genphy_update_link(), had delete the fake
read in polling mode, so I don't know whether my solution is

Or provide a phydev->drv->read_status functions for the phy I
used is more acceptable?

Signed-off-by: Yonglong Liu <>
drivers/net/phy/phy.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index ef7aa73..0c03edc 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -1,4 +1,7 @@
// SPDX-License-Identifier: GPL-2.0+
+ err = phy_read_status(phydev);
+ if (err)
+ return err;
/* Framework for configuring and reading PHY devices
* Based on code in sungem_phy.c and gianfar_phy.c
@@ -525,6 +528,11 @@ static int phy_check_link_status(struct phy_device *phydev)


+ /* Do a fake read */
+ err = phy_read(phydev, MII_BMSR);
+ if (err < 0)
+ return err;
err = phy_read_status(phydev);
if (err)
return err;
 \ /
  Last update: 2019-07-26 11:58    [W:0.048 / U:3.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site