Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3521976pxf; Mon, 15 Mar 2021 11:25:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyY0LInJBeW7HNJTvz4b6HkLblU4L/enSSNRKyaet7ZMIS5gSzkj3xxpyfLqXW0hJBQO+T3 X-Received: by 2002:aa7:d5c9:: with SMTP id d9mr32574780eds.102.1615832720142; Mon, 15 Mar 2021 11:25:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832720; cv=none; d=google.com; s=arc-20160816; b=YKSJj2EjDz53uGFN3eWK1xp50SYO4rOJ/Hkjar1xRxPWrXxAPHw7HrWDvNHNNm7+P6 o1pshE26bWPztMptXzvGVdsHOqMJuTJEGsZHUvENoACRTkwRzDgn1Lga3UfzUU3SlgjY V5CGBxpL7BS46VB1ZE0UcGLfYgHQK0CCj50Yf1A7sEkfcGijHuh/XrJm6VohQGpfg5DB GHtoeSM2RexjtCHexpIdnRk7DmcJh3XJwihkpDbclxA7j3tebF6YSZmdgcnT87S8yddg 0bO1osyxPcyjAVwZnVUQMUXJMgEjNmy9qW1Q85qylk113QUOWrKJILuCUq/MoEiWGHDs NZ7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uDv5n9zPcqJ/iZjxokWJ0Z/BaGo1Bi/c8o3J+BXaIh0=; b=YB+2D0m0m7IjIUYa3KqZde5WKkTc9s/HNfXa/ehYu/uft5XcvcCsvQuvL6cnrXpe3m VXpBrnxKOnkt8YPOv75oxe63sm3JULKbobOhN6yB8kVXfDagHHzdAeYdzZqYzs2BQ7L9 3hpAhch3cbnohHuOFnfoCadCsBDOve44hWlkswD3HGrLieTqA1h86u7/xVca/ejCxAQE EPvG1RsLsvastf28Z9nZlGQAeUESi6Eb7/bRd4N8gG41mY/qjeg0JP39oajjaVAn3CeU 7YHABjVMTdEILmYMswldYCUnjr8rItqfBhMK5BvJGrK5gZ03DAj8zXsc27Wjap0F53OS ObAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1s4cOzla; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q27si12831122edi.328.2021.03.15.11.24.57; Mon, 15 Mar 2021 11:25:20 -0700 (PDT) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1s4cOzla; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234277AbhCOOZV (ORCPT + 99 others); Mon, 15 Mar 2021 10:25:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:37632 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231492AbhCON72 (ORCPT ); Mon, 15 Mar 2021 09:59:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 88CDD64EF2; Mon, 15 Mar 2021 13:59:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816744; bh=uWjmqd3vi/Hw0HY6wpiy2PHmEkJHmyNnY7TxG/om+FU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1s4cOzlawCl0AeMAC2nqRBqXVayaFs+NMoarhI92rx0wA02R+uLzMF6oGOb9JSl8l seCH995pVrWvnQiR2RQpLxOGZrBsrjd62SGhY88hyEsRoVlOlKKJLJZeQOvZLMhw6w R1Mm3AdJSV6PVcwt769OsXUCqJ0rLrl3pAET7k8s= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guangbin Huang , Huazhong Tan , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 041/120] net: phy: fix save wrong speed and duplex problem if autoneg is on Date: Mon, 15 Mar 2021 14:56:32 +0100 Message-Id: <20210315135721.337831191@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135720.002213995@linuxfoundation.org> References: <20210315135720.002213995@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Guangbin Huang [ Upstream commit d9032dba5a2b2bbf0fdce67c8795300ec9923b43 ] 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 Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/phy/phy.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index cc454b8c032c..dd4bf4265a5e 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -335,7 +335,10 @@ 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; + } phydev->advertising = advertising; @@ -344,8 +347,6 @@ int phy_ethtool_ksettings_set(struct phy_device *phydev, else phydev->advertising &= ~ADVERTISED_Autoneg; - phydev->duplex = duplex; - phydev->mdix_ctrl = cmd->base.eth_tp_mdix_ctrl; /* Restart the PHY */ -- 2.30.1