Re: [PATCH net] net: phy: rtl8211f: do a double read to get real time link status

From: Yonglong Liu
Date: Fri Aug 09 2019 - 00:57:55 EST




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