Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3320025pxf; Mon, 15 Mar 2021 07:05:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3eUyOqY5wp/lkFTsqaCHNEbDwfNO0OWrBcML1bQZfdHuSEmrATqF0wlxU/gPuKRTby5ax X-Received: by 2002:a17:906:3088:: with SMTP id 8mr23668959ejv.499.1615817102404; Mon, 15 Mar 2021 07:05:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615817102; cv=none; d=google.com; s=arc-20160816; b=ZUBE3K0s7o2wS1yM9EdS9vM2ZTvQeNYP4z+lmCKDQ4I1QOVqtOOQltNgzzQktX1oYu aMqMmifV8OXUfY1cIAnNMeEFRLZ9aDB11IQwiioTlzquXAlbtGRJUo4J1+bm0W0q5043 Rb9ug1WdZo2cNlaaFTvPC/lwqxuvyQ8we76BmsOdJ2jL4PvjRCqNPKmbR0A8oWpeotft IQOzjKHpBDwdPQqle6wJtbJt2WNAW7ixZOkxfeUkkRN0pMX0/dMUOiiL0kYDS8J9W9pJ XqAdhxSD2Nj+CGBoyQEGnXZah3RnZFt8gHYzGK+EUPu54tOa9v3kStb7pQ790ahKcb6C R1Ag== 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=u9JTYVZ8oc54hxHf5NJ6x5xFwSTL3WjK/0EZznXynuc=; b=dJHe2q5a1/AM7AD0l4JWJ5PneKvhKMTOMwWfMv3D/jSJwXsiBZ27980Z7iLi7SSnH8 bMZjNdF3xPllejOad4OTPSEb06uRcGlJCFgw87mvgZugzovd2aKI4zJyvZvH7nNf0W+w b2Pd6W4K2tGk7DZlvd+lqVudwx4j0ofyGVHO16F/j9rw5JOZFzLTCTs2mOZ5OYdHw9iH IGv1mAXZQKEayzGnygmbJGdAT9Y1X1eYWBXT+op1/PsMUBM1Xjt8/0ubtzlvFcrJH1ZF pKdD6mNCVPUemKM3dZxxLddZxMuPxVhT2NEC4d46VYWK0n5DqfhPA43xus6jRfdQaOFp Jgng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ru0sFllj; 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 r9si3243465edd.8.2021.03.15.07.04.38; Mon, 15 Mar 2021 07:05:02 -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=Ru0sFllj; 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 S234381AbhCOODR (ORCPT + 99 others); Mon, 15 Mar 2021 10:03:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:34198 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231302AbhCON5J (ORCPT ); Mon, 15 Mar 2021 09:57:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D85CD64F0D; Mon, 15 Mar 2021 13:57:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816628; bh=k8Ics59ORAUE2T+ODVhCOe9G1Dw8Qj8IZDa8uSA9du4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ru0sFlljcqapZLglJ47EaVHUUwMdzuoWn0RWUGVQTlnJemY5OKHwABrhUmDRRPlP2 6BMIGby7Z2wNnF2SLRD/aiznu9UW2tA0YIQ7if3H9wMRPZypmDY1UgR4EMW7kfFDVG 5KAqvZmkQJp3J+ZDrD+Zg/8hWNqZteuteNzFqSgk= 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" Subject: [PATCH 5.10 021/290] net: phy: fix save wrong speed and duplex problem if autoneg is on Date: Mon, 15 Mar 2021 14:51:54 +0100 Message-Id: <20210315135542.646613529@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@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 commit d9032dba5a2b2bbf0fdce67c8795300ec9923b43 upstream. 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: Greg Kroah-Hartman --- drivers/net/phy/phy.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -293,14 +293,16 @@ int phy_ethtool_ksettings_set(struct phy 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;