From: Heiner Kallweit <hkallweit1@gmail.com>
To: Yonglong Liu <liuyonglong@huawei.com>, Andrew Lunn <andrew@lunn.ch>
Cc: davem@davemloft.net, 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: Re: [PATCH net] net: phy: rtl8211f: do a double read to get real time link status
Date: Fri, 9 Aug 2019 22:05:38 +0200 [thread overview]
Message-ID: <7f18113e-268b-6a4a-af83-236cfa337fcd@gmail.com> (raw)
In-Reply-To: <414c6809-86a3-506c-b7b0-a32b7cd72fd6@huawei.com>
On 09.08.2019 06:57, Yonglong Liu wrote:
>
>
> On 2019/8/9 4:34, Andrew Lunn wrote:
>> On Thu, Aug 08, 2019 at 10:01:39PM +0200, Heiner Kallweit wrote:
>>> On 08.08.2019 21:40, Andrew Lunn wrote:
>>>>> @@ -568,6 +568,11 @@ int phy_start_aneg(struct phy_device *phydev)
>>>>> if (err < 0)
>>>>> goto out_unlock;
>>>>>
>>>>> + /* The PHY may not yet have cleared aneg-completed and link-up bit
>>>>> + * w/o this delay when the following read is done.
>>>>> + */
>>>>> + usleep_range(1000, 2000);
>>>>> +
>>>>
>>>> Hi Heiner
>>>>
>>>> Does 802.3 C22 say anything about this?
>>>>
>>> C22 says:
>>> "The Auto-Negotiation process shall be restarted by setting bit 0.9 to a logic one. This bit is self-
>>> clearing, and a PHY shall return a value of one in bit 0.9 until the Auto-Negotiation process has been
>>> initiated."
>>>
>>> Maybe we should read bit 0.9 in genphy_update_link() after having read BMSR and report
>>> aneg-complete and link-up as false (no matter of their current value) if 0.9 is set.
>>
>> Yes. That sounds sensible.
>>
>> Andrew
>>
>> .
>>
>
> Hi Heiner:
> I have test more than 50 times, it works. Previously less
> than 20 times must be recurrence. so I think this patch solved the
> problem.
> And I checked about 40 times of the time gap between read
> and autoneg started, all of them is more than 2ms, as below:
>
> kworker/u257:1-670 [015] .... 27.182632: mdio_access: mii-0000:bd:00.3 write phy:0x07 reg:0x00 val:0x1240
> kworker/u257:1-670 [015] .... 27.184670: mdio_access: mii-0000:bd:00.3 read phy:0x07 reg:0x01 val:0x7989
>
>
Instead of using this fixed delay, the following experimental patch
considers that fact that between triggering aneg start and actual
start of aneg (incl. clearing aneg-complete bit) Clause 22 requires
a PHY to keep bit 0.9 (aneg restart) set.
Could you please test this instead of the fixed-delay patch?
Thanks, Heiner
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index b039632de..163295dbc 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1741,7 +1741,17 @@ EXPORT_SYMBOL(genphy_aneg_done);
*/
int genphy_update_link(struct phy_device *phydev)
{
- int status;
+ int status = 0, bmcr;
+
+ bmcr = phy_read(phydev, MII_BMCR);
+ if (bmcr < 0)
+ return bmcr;
+
+ /* Autoneg is being started, therefore disregard BMSR value and
+ * report link as down.
+ */
+ if (bmcr & BMCR_ANRESTART)
+ goto done;
/* The link state is latched low so that momentary link
* drops can be detected. Do not double-read the status
--
2.22.0
next prev parent reply other threads:[~2019-08-09 20:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-07 13:16 [PATCH net] net: phy: rtl8211f: do a double read to get real time link status Yonglong Liu
2019-08-07 16:47 ` Heiner Kallweit
2019-08-08 1:15 ` Yonglong Liu
2019-08-08 6:11 ` Heiner Kallweit
2019-08-08 6:21 ` Yonglong Liu
2019-08-08 19:26 ` Heiner Kallweit
2019-08-08 19:40 ` Andrew Lunn
2019-08-08 20:01 ` Heiner Kallweit
2019-08-08 20:34 ` Andrew Lunn
2019-08-09 4:57 ` Yonglong Liu
2019-08-09 20:05 ` Heiner Kallweit [this message]
2019-08-12 4:49 ` Yonglong Liu
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=7f18113e-268b-6a4a-af83-236cfa337fcd@gmail.com \
--to=hkallweit1@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=liuyonglong@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;
as well as URLs for NNTP newsgroup(s).