Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3319986pxf; Mon, 15 Mar 2021 07:04:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5ZS3B9X7o9Nfq9nXojrjNrs+NjHs3pOX054l9kQHDMQMLT4MMDRGhKnoP7Q+p8CslVnN0 X-Received: by 2002:a17:906:14d0:: with SMTP id y16mr24243631ejc.242.1615817099748; Mon, 15 Mar 2021 07:04:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615817099; cv=none; d=google.com; s=arc-20160816; b=qPX2+TCpCF8kFG78RP3m6z/COayERWlSjLN7Kr0xKzR1TDCLp92eYg9Gjct/JwQoc/ 8Xw86xPAzOoDCCLzULKJ2QjlKGos9owUP0Oet3JyccMXt+wTPmpa7EuBnGdY75w5GE/j Wk87+sgX14/4FwXIxXl5UsVU8cF8/KavMJ3sLo5nnzc3xsaFuIWXEBx3bY8wPAsh0mLQ 9jtB4hJMghCDcewJNbVwZNKeB5es8xJoqMHWJHXnNBycYsSpjkpmZTVAPbZxPyGAzV+G QXhgsXKkEMnweeCdI4ZR1wbtNS890+rILqGHfMstR/kuWfovhzmEjIjFLKTKv7sWnsnS m9IQ== 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=oG5yfGdlNZoprH5nbgzjw9CaPw0UWpm3kxBY+B0n5y4=; b=s50oi0zuHn61iUxKLWVSZ5goZj2Z3PuGz1sbTYtz23eUyfrP5ggZFJRjnnS0csi0G8 RFH/iuI8t/SVUoOsUyJrvBgsxkStGPhuY9OznrXAyz2RiacX+ytgbfY/rh8sdRbc9N// Fjbgy/T1Q/PBzrlf2vT7XIwE0X9D9s9vTEQ2kYcyKx7uo0MsCvF3ETPyrLvYiRIk7auB T8OcifGfbjVqEYhvKNnYh+Tos/C6BqJS91MXR9TidGmM7BxPzDY625o8a1nwXt0ZPkfI QBb5tFEz2/mgQrOlEJP4LKMPGA7d4/I1frnJfDpwQJkBi6hNwiAWENCEGujbROgzMW61 2AiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WNjbfgob; 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 u1si10778805ejt.544.2021.03.15.07.04.36; Mon, 15 Mar 2021 07:04:59 -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=WNjbfgob; 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 S234312AbhCOODL (ORCPT + 99 others); Mon, 15 Mar 2021 10:03:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:34280 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231299AbhCON5J (ORCPT ); Mon, 15 Mar 2021 09:57:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8B84364F0C; Mon, 15 Mar 2021 13:57:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816626; bh=QBRAwhpye3waUYbqT08YlDboSZ3WWwEkgwyh6D7dgjs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WNjbfgobUwf7/VvMxVtq+9zVhhMCLD+XzI+JzGih7MNW9DGH3pTwCgmQxDcNFKilT XvZJSMTMi5Sj/yVTX4hVvQ2iRV64fwHAJ3zjM+OeBSOwpLEs0f3fnmUvgHKPEi1Xnj /BAz3oxsSgPHDKqZxITQzAyvxvwOhezi0/qt+tV4= 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.11 028/306] net: phy: fix save wrong speed and duplex problem if autoneg is on Date: Mon, 15 Mar 2021 14:51:31 +0100 Message-Id: <20210315135508.570816874@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@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 @@ -276,14 +276,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;