From: Yonglong Liu <liuyonglong@huawei.com>
To: <andrew@lunn.ch>, <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linuxarm@huawei.com>, <salil.mehta@huawei.com>,
<yisen.zhuang@huawei.com>, <shiju.jose@huawei.com>
Subject: [RFC] net: phy: read link status twice when phy_check_link_status()
Date: Fri, 26 Jul 2019 17:53:51 +0800 [thread overview]
Message-ID: <1564134831-24962-1-git-send-email-liuyonglong@huawei.com> (raw)
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
correct.
Or provide a phydev->drv->read_status functions for the phy I
used is more acceptable?
Signed-off-by: Yonglong Liu <liuyonglong@huawei.com>
---
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)
WARN_ON(!mutex_is_locked(&phydev->lock));
+ /* Do a fake read */
+ err = phy_read(phydev, MII_BMSR);
+ if (err < 0)
+ return err;
+
err = phy_read_status(phydev);
if (err)
return err;
--
2.8.1
next reply other threads:[~2019-07-26 9:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-26 9:53 Yonglong Liu [this message]
2019-07-26 18:14 ` [RFC] net: phy: read link status twice when phy_check_link_status() Heiner Kallweit
2019-07-29 3:59 ` liuyonglong
2019-07-29 20:57 ` Heiner Kallweit
2019-07-30 4:03 ` liuyonglong
2019-07-30 6:08 ` Heiner Kallweit
2019-07-30 6:35 ` liuyonglong
2019-07-30 6:39 ` liuyonglong
2019-07-30 19:04 ` Heiner Kallweit
2019-07-31 3:33 ` liuyonglong
2019-07-31 5:44 ` Heiner Kallweit
2019-07-31 5:58 ` liuyonglong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1564134831-24962-1-git-send-email-liuyonglong@huawei.com \
--to=liuyonglong@huawei.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=salil.mehta@huawei.com \
--cc=shiju.jose@huawei.com \
--cc=yisen.zhuang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox