Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1635702pxb; Fri, 26 Feb 2021 16:58:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJy2WWhrUAG3x/T2zw/94Y0rXVd/sUyy0TeUBK6E6XC3ga2p7mgVdk7cJRQG3xec26ddMz+b X-Received: by 2002:a17:906:95c3:: with SMTP id n3mr5929935ejy.269.1614387483619; Fri, 26 Feb 2021 16:58:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614387483; cv=none; d=google.com; s=arc-20160816; b=PBcGN6HdGMQb6BMPw0TwNelZoPe6gsvp3Di+fBNwlYqkKnc0WOEDtP5QVIe6nKm04X Qh4QhQ7LMblB0Gzwi278tGh3eLRaICzNCu46x4rPuoYx8v6s419c92D3SAqQD8i3Eghb SwuHoLD/z2naAGeJxYVtIEnvrSslhz+jQrMfT6plriDI0H8o9De6+5LFby76sJqHgv7Y 9qZ79KCBBH4xpY85D1zVWqi6pxUI195DrQf3gjeiVMM0+2040m5RR3JQXONPzScDsolH jgBUjiHRbe5Fm2n1gYpfwbj3MmrrIizK0LO5JV2HAQtO9EcV9zhikWA3h5aLvOBREQYo r5tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=73BmWNi/I20+uA3+mG1+g0mHIMBkSJTqNecXne9mglY=; b=RJk+FcxV9LADgIV0M2SoUL7yQZVr3pxmP4I6/22fyGuWiDoKpdpKZKLNpuVD2R+Lhs 8d0j9j1Gb2X8fSdqKy4E0Xv8g+vcucQjwKfx84X1wpETIAKP3m1OaCoYSs60H5DQck8S JXH38VXE9TRNc5vTPacjtF4RZ6HmQ6y/nFMvKuxSncts0qn8CjBhGj6UGRB5rw0T3AgT wZqhSV/KuhNH0fPVAIM31Qz8h7zopjj6SOJbycku7QwpbCvB8onkNAoTEtuuDTdjmppu jF9Ypmji5IJOp9UbW07WMT4HLTAwgc9wR06Lb0mMc6trMdeTo2U1nC+hK5fBFm2dR4Fg snag== 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 bk20si6794716ejb.203.2021.02.26.16.57.11; Fri, 26 Feb 2021 16:58:03 -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 S229949AbhB0Ayn (ORCPT + 99 others); Fri, 26 Feb 2021 19:54:43 -0500 Received: from vps0.lunn.ch ([185.16.172.187]:32858 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229622AbhB0Aym (ORCPT ); Fri, 26 Feb 2021 19:54:42 -0500 Received: from andrew by vps0.lunn.ch with local (Exim 4.94) (envelope-from ) id 1lFnrl-008gSc-0W; Sat, 27 Feb 2021 01:53:53 +0100 Date: Sat, 27 Feb 2021 01:53:53 +0100 From: Andrew Lunn To: Huazhong Tan Cc: f.fainelli@gmail.com, hkallweit1@gmail.com, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Guangbin Huang Subject: Re: [PATCH net] net: phy: fix save wrong speed and duplex problem if autoneg is on Message-ID: References: <1614325482-25208-1-git-send-email-tanhuazhong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1614325482-25208-1-git-send-email-tanhuazhong@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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