Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1689159pxb; Fri, 26 Feb 2021 19:09:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJyfBJ/SxMlU6g+UdhUs/4g7t0LW0D7FiIeKxeswWCqwUMJYQi3xKRvsC5Lr5G2LKdvOY7SX X-Received: by 2002:a17:907:9702:: with SMTP id jg2mr6530248ejc.48.1614395376507; Fri, 26 Feb 2021 19:09:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614395376; cv=none; d=google.com; s=arc-20160816; b=hALFOKmH/7rUW0lBwCnriwzcJo4riIYKkQO3SYk8cK9eXyOgap0TuPuy90bjJby5Yo 68z4w8B92+xFxYRlWKCXB7VQiyjnkzhxm/mVYUvafh4ftfFJZhETpJ2plkV+f8hMHq4l lAFQmTGmqftoAvtR0jfycsSC/NGw4+i0ImXvMRXZSekaXPfoLtrXh8XYxNtipJAlp4Bj RwCg6OAcfLCulmwkG6K8M4zvfaOsPKhDe/AeOGSjlZDF9063EilFcpDrU72OU1+0mU6Z Xr3h05ToKJqrp3kMcDY4usK/Zo1PRID5Rum0/982n1wnE3X1kz48wgLlujzM5wzr9F0t S+cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=FI+OJBFfNPUPR2WHrAdfi91tL/9DE9OsA9NAb7h189Y=; b=OO7A72tV2+QMeHm/xHQMqIXylyDxQexmbFxzX9H+NOjgh5uT1gGL7p+8cDrOdehAHc ZgzgnVZ86tai4gy658HvpkjFodKcUWn1hx3GIQnglDCIk1fDr/UMWx3ZFlKT4kOaxQF7 q0k+i33A124Am3I4y8bKMcAXpPPS+PNKOZQk41HU486Fr1Mb50/XB5vEI2JG6DEXXlaR 5v+kSU+PL9A73mdJQ5GnQJ1xqGYf0cg2fFMSxHI241DH1/1GDI+sVd2UAHYkKGAsjQFH Knrl9YN7UklSeNredW/nD/CjzQrFCS1KeXO7heoQnrjfwRb8oY2/VITTNbHNuQmpQL4r GBTw== 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 j18si7018230edw.197.2021.02.26.19.09.13; Fri, 26 Feb 2021 19:09:36 -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 S229949AbhB0DGK (ORCPT + 99 others); Fri, 26 Feb 2021 22:06:10 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:12212 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229745AbhB0DGJ (ORCPT ); Fri, 26 Feb 2021 22:06:09 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4DnWYk5zjBzlQKg; Sat, 27 Feb 2021 11:03:22 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.498.0; Sat, 27 Feb 2021 11:05:17 +0800 From: Huazhong Tan To: , , , , CC: , , , Guangbin Huang , Huazhong Tan Subject: [PATCH V2 net] net: phy: fix save wrong speed and duplex problem if autoneg is on Date: Sat, 27 Feb 2021 11:05:58 +0800 Message-ID: <1614395158-5294-1-git-send-email-tanhuazhong@huawei.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Fixes: 51e2a3846eab ("PHY: Avoid unnecessary aneg restarts") Signed-off-by: Guangbin Huang Signed-off-by: Huazhong Tan --- V1->V2: add a Fixes tag --- drivers/net/phy/phy.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 1be07e4..fc2e7cb 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -276,14 +276,16 @@ int phy_ethtool_ksettings_set(struct phy_device *phydev, phydev->autoneg = autoneg; - phydev->speed = speed; + if (autoneg == AUTONEG_DISABLE) { + phydev->speed = speed; + phydev->duplex = duplex; + } linkmode_copy(phydev->advertising, advertising); linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, phydev->advertising, autoneg == AUTONEG_ENABLE); - phydev->duplex = duplex; phydev->master_slave_set = cmd->base.master_slave_cfg; phydev->mdix_ctrl = cmd->base.eth_tp_mdix_ctrl; -- 2.7.4