Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp7711596ybh; Thu, 8 Aug 2019 21:59:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXxSNHmZtNrKdjwE+oDaaC/9ZlCZDmU+6WxgM2CRyDRkMDyI9w67wEvS2LEiKBjLcfxkur X-Received: by 2002:a62:107:: with SMTP id 7mr19605057pfb.4.1565326765037; Thu, 08 Aug 2019 21:59:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565326765; cv=none; d=google.com; s=arc-20160816; b=Pbitxe1NfW+hkCMMJiWWXmjmv0r9LpNpRSC+zImp/PmOWyooEMVmcQYYkVampW2M/h I6QOUbkiFxjyzNC9qpP7KKF3qT9OzzwaZs8uWQD6NUEDJguFdTQKGVoWShHdNqhMczFp fxoQU1BNTEacqb5BqEI9sgWsFg58rpo4nnMdICC7BcwmeJ6XsQKVQIDKxx4+EZ03ZBlD bUYESH3t0s8jNshtt3YrO6e5rl16pzff87Ze2i0EvuFyj5IwiSDFzdn32LgU5s7LCGgm XHkBmo2GkBqF0A7oC6o8lQj02qONapq/Q8xmY2LNsOf4MPcvOEBV/iJOvCabpp456WpQ ryAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=DaO/fxmsAd5v4Q5BAZQvC8iBWu/Aym5S8tdXaD9TrEA=; b=LtYaIi++UEQ6HExxYozS2LRlIdbkFWqbYFF2z6n4n23nWIdVGMOG/zVLrcr49ycix5 JkonutRj+TgEqN7VMfA5t/lXysbXjl+RKaOxkSxY1fXLtMSv50RMpmzjNQxhA5X7SaTx BKS8oKwQXRvS+swuRXpaf/Mx7sBbIyxAAsgTYliX+eMpW34kTuQC++cXkTLrp148YFbP Q1hYClEWx+l5gvqrUVFgzSnqvZ4VhaslSfTUcdNAvqO1XCwGOrRDN8JCwqDFgvn4rnOU WaoUH/ruxow1W4GeQqF0JqDqngWGrU/Ezhr5/ROJl04PLxgxjvx08NHN4gLmEuS933NB SwrQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b6si51119146pge.44.2019.08.08.21.59.08; Thu, 08 Aug 2019 21:59:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405241AbfHIE5y (ORCPT + 99 others); Fri, 9 Aug 2019 00:57:54 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:3085 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725811AbfHIE5w (ORCPT ); Fri, 9 Aug 2019 00:57:52 -0400 Received: from DGGEMM401-HUB.china.huawei.com (unknown [172.30.72.53]) by Forcepoint Email with ESMTP id 01A2419AF3CE2F54FA67; Fri, 9 Aug 2019 12:57:50 +0800 (CST) Received: from dggeme760-chm.china.huawei.com (10.3.19.106) by DGGEMM401-HUB.china.huawei.com (10.3.20.209) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 9 Aug 2019 12:57:49 +0800 Received: from [127.0.0.1] (10.57.37.248) by dggeme760-chm.china.huawei.com (10.3.19.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Fri, 9 Aug 2019 12:57:49 +0800 Subject: Re: [PATCH net] net: phy: rtl8211f: do a double read to get real time link status To: Andrew Lunn , Heiner Kallweit CC: , , , , , , References: <1565183772-44268-1-git-send-email-liuyonglong@huawei.com> <080b68c7-abe6-d142-da4b-26e8a7d4dc19@gmail.com> <20190808194049.GM27917@lunn.ch> <26e2c5c9-915c-858b-d091-e5bfa7ab6a5b@gmail.com> <20190808203415.GO27917@lunn.ch> From: Yonglong Liu Message-ID: <414c6809-86a3-506c-b7b0-a32b7cd72fd6@huawei.com> Date: Fri, 9 Aug 2019 12:57:48 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20190808203415.GO27917@lunn.ch> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.57.37.248] X-ClientProxiedBy: dggeme719-chm.china.huawei.com (10.1.199.115) To dggeme760-chm.china.huawei.com (10.3.19.106) X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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