Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1652027pxb; Fri, 26 Feb 2021 17:32:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJyI6jjmlecRMkgvMp8C4dHSfA4qi2dch3MvY0iATenGrpc8M1ADpM29gSUhtkl2sY7oonbu X-Received: by 2002:a17:906:19c9:: with SMTP id h9mr6385780ejd.288.1614389557807; Fri, 26 Feb 2021 17:32:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614389557; cv=none; d=google.com; s=arc-20160816; b=USdn5nn9sf+UhmxI7OWbEGMLouoF2hVWTnE90sA+3zGxong+hn+EKJe8ZQTnG45mTg 7zrciyzIP7Gm2JEO7eRTamZaLvssf6ZT/TRvbJQcEDON1kEFSPwMP39Rl5uELC7FCBJD EYYDjemA1NSXb6HEt3PSQjunnFb1VLfuKMXSzC1kopkWDd3klvxOqYSYQLCO4l334Oai 6KfAk1jeomcbrkQwqrhKfPLUI2tiCU+yBWLw82WcDGhxAzpfVF+ESwulSXZRVYW3n64n DdmIHpKmKp0DRRoYkbZAw8/mvn8Wm+a5frNV8aU/A8KHyZIbAuKK4EPSuHlJ189/kVjJ 428A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=hVoy4XyDXWQYwzJAtb8pfEPo14jtNKRTnmX4FvTqbhU=; b=LZ6f8+tN78uzpmFrrsbDujrf9tUIiJIBdWwSM3MGuOmeunrio5HfoSPdrZWka3fBFT JEJpa7GvNXwVWr3X7bcpLEsNyzYOL/Z1agLMsVCP5eOFKv10qlwNQopTfzNL4dOVDbvE ZLZ+tNNqJQ2H3BEmAfIX6kgVXxQi9W7PQReMmlNqowPx9LIbRIN/qgCupRceQ/VlUyep 9jwkWcVeg5B4YhczNqSdOsdvjlWIf/K3G60lJD/5wKD+w5LINRKRGhXUDoXB/Kjit+6D D8BcCcDOUb1/KLJIGuLjxUakGrEm73S/KRVexzPRjK8db2G6irgJFSMEzsxrKG3eYQn4 mISw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dt22si8039067ejc.522.2021.02.26.17.32.07; Fri, 26 Feb 2021 17:32:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230087AbhB0B2p (ORCPT + 99 others); Fri, 26 Feb 2021 20:28:45 -0500 Received: from szxga03-in.huawei.com ([45.249.212.189]:2910 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230063AbhB0B2n (ORCPT ); Fri, 26 Feb 2021 20:28:43 -0500 Received: from dggeme753-chm.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4DnTPC178Gz5W4x; Sat, 27 Feb 2021 09:25:51 +0800 (CST) Received: from [127.0.0.1] (10.69.26.252) by dggeme753-chm.china.huawei.com (10.3.19.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2106.2; Sat, 27 Feb 2021 09:27:54 +0800 Subject: Re: [PATCH net] net: phy: fix save wrong speed and duplex problem if autoneg is on To: Andrew Lunn CC: , , , , , , Guangbin Huang References: <1614325482-25208-1-git-send-email-tanhuazhong@huawei.com> From: Huazhong Tan Message-ID: Date: Sat, 27 Feb 2021 09:27:54 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [10.69.26.252] X-ClientProxiedBy: dggeme704-chm.china.huawei.com (10.1.199.100) To dggeme753-chm.china.huawei.com (10.3.19.99) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/2/27 8:53, Andrew Lunn wrote: > On Fri, Feb 26, 2021 at 03:44:42PM +0800, Huazhong Tan wrote: >> From: Guangbin Huang >> >> If phy uses generic driver and autoneg is on, enter command >> "ethtool -s eth0 speed 50" will not change phy speed actually, but >> command "ethtool eth0" shows speed is 50Mb/s because phydev->speed >> has been set to 50 and no update later. >> >> And duplex setting has same problem too. >> >> However, if autoneg is on, phy only changes speed and duplex according to >> phydev->advertising, but not phydev->speed and phydev->duplex. So in this >> case, phydev->speed and phydev->duplex don't need to be set in function >> phy_ethtool_ksettings_set() if autoneg is on. >> >> Signed-off-by: Guangbin Huang >> Signed-off-by: Huazhong Tan > I'm not sure, but i think this happens after > > commit 51e2a3846eab18711f4eb59cd0a4c33054e2980a > Author: Trent Piepho > Date: Wed Sep 24 10:55:46 2008 +0000 > > PHY: Avoid unnecessary aneg restarts > > The PHY's aneg is configured and restarted whenever the link is brought up, > e.g. when DHCP is started after the kernel has booted. This can take the > link down for several seconds while auto-negotiation is redone. > > If the advertised features haven't changed, then it shouldn't be necessary > to bring down the link and start auto-negotiation over again. > > genphy_config_advert() is enhanced to return 0 when the advertised features > haven't been changed and >0 when they have been. > > genphy_config_aneg() then uses this information to not call > genphy_restart_aneg() if there has been no change. > > Before then, i think autoneg was unconditionally restarted, and so the > speed would get overwritten when autoneg completed. After this patch, > since autoneg is not being changed when only speed is set, autoneg is > not triggered. > > Andrew Thanks. > .