Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3514237pxf; Mon, 15 Mar 2021 11:13:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvDkS1u+0KIJA9FjR9iLoCXvOe9uxQfu4/3eKRonruoY5HCEAB3B79Cb/t2SGGd31OE2DW X-Received: by 2002:a05:6402:6cb:: with SMTP id n11mr31932405edy.198.1615832022543; Mon, 15 Mar 2021 11:13:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832022; cv=none; d=google.com; s=arc-20160816; b=qatvakWUvIhCr74ulnql0sUF8moyqF7M0a8ujH1aVtKtu9/e8jevJUj6QtITntz+Cy Prnwwlr07qcZvoEwuCm13adA5F6ZnorbYtPoG6iYKj3nDOyejDhUOw7MpNtIYrgyFkLe Gi4Wdb2Qf+pZ+goBvbpxEhYPNP76yTZ0kuLZyTja0SLtX0ojYY5sRvbgRD22SW6C933a Ei8L+RMO54rqeWV+746DxyRwWqquKvfRCE6/NTyFtz0/HQPquKm8zhUHGQpKu63kSAoy XaP3eRhhZUnskWhTZe0Baf8RwiwZxAsU/t8kDEa793vfke2kQjcxqie37pnqV16t1D+u 2GQQ== 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=84z4MFwv+4O6XofrOeQSFnX1PSXG8GT2CeBWyGTqJaE=; b=GObSsHHVfjVwJeAnP+b1BS8s9itaXhEtJ6KtyXuRloLixP70h39i/vy/e7WJIC+eBc NoaLj2Abfgc/iTIMQUpDeWVq76ZnwTlZDXJsjtU3RoRaRCJLLz+sqvp7Js+B2UGAajEt dhZGaYqlv6mtvKYxROMp6yBbijGlVM+SxMuwZeGW5vE3c0wLZjFdagwg+eQzjg9TU9zn 0LrYL9tbEzDN2TcQoNI1yI/hufsVvS+ufAZjNw3zZ6K+EONNCU2JN1q7AWTWDCssvuGB U+pNJvTDPko7Ngs6FSCPvYfIsv9VlQSsDiehlwtRw2PUr8c18TgNNH/LWGVHo4oq2ZbE 2zFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="WqXx+/lx"; 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 a3si11380679ejd.167.2021.03.15.11.13.20; Mon, 15 Mar 2021 11:13:42 -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="WqXx+/lx"; 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 S236280AbhCOOMl (ORCPT + 99 others); Mon, 15 Mar 2021 10:12:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:36622 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232414AbhCON6y (ORCPT ); Mon, 15 Mar 2021 09:58:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 35DCA64F2F; Mon, 15 Mar 2021 13:58:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816711; bh=VupWNzS1C9FEPcZk+mVDKvKN4MycCpmLi/K35zgcKvU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WqXx+/lxwrbGeskdeKoapC+wZUyYEipA0S2B0FHGfo1OF0vxSFX3OJoJj4PzyLW0G zqYqYbjK+3JXG4inAnOdmBjUIPQXRlhp/QBPU3Cj/cNMKlLjFJoTRni4AevwWtIb5E tO1hJyxzAGYbIidhKsyNmfHriatxF96JK4zNbIyU= 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 5.4 061/168] net: phy: fix save wrong speed and duplex problem if autoneg is on Date: Mon, 15 Mar 2021 14:54:53 +0100 Message-Id: <20210315135552.371764008@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135550.333963635@linuxfoundation.org> References: <20210315135550.333963635@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 b718b11607fc..b0b8a3ce82b6 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -345,15 +345,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->mdix_ctrl = cmd->base.eth_tp_mdix_ctrl; /* Restart the PHY */ -- 2.30.1