From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25CA0C43215 for ; Tue, 19 Nov 2019 05:36:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F19E120862 for ; Tue, 19 Nov 2019 05:36:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574141787; bh=ooDI27F35NIkgvcvKJNcQQRxPTs8GoiGuAb3F5wcRGw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=yOhr/SYao7cM1+Vu7q7t3W5whBmEFMsHmrHuCmiGEW5HTSqJr4G9lFM8EpPPotSJe L9evSl45Pclj7Ivqa47MQmEKsfVXilsroBMqivuLwTcesTY1z1GmIBU+TVEO70jHTo fWpfSUDjm8FP8ab+El2wpau3FgMadnXTV2GAhn58= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729964AbfKSFg0 (ORCPT ); Tue, 19 Nov 2019 00:36:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:57662 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729952AbfKSFgX (ORCPT ); Tue, 19 Nov 2019 00:36:23 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A61B020862; Tue, 19 Nov 2019 05:36:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574141783; bh=ooDI27F35NIkgvcvKJNcQQRxPTs8GoiGuAb3F5wcRGw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QSvhFTLvnjjqECJgTkEvFvccBYt6kSMdD7+1zrNcSx0xNEFtVxl5rYs1nXXfpFTM6 PPLxp/rPsoSGDVkzvcjWl6TPp1VJwQtO9h9DrPenNp/sTUvLxuMcKcw+9qoBufAg1V yW4CACaexEPyZgTGwxtc6dq/ZA7+CNGtrZlXN7cw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fuyun Liang , Peng Li , Salil Mehta , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 280/422] net: hns3: Fix for setting speed for phy failed problem Date: Tue, 19 Nov 2019 06:17:57 +0100 Message-Id: <20191119051417.129968165@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191119051400.261610025@linuxfoundation.org> References: <20191119051400.261610025@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fuyun Liang [ Upstream commit fd8133148eb6a733f9cfdaecd4d99f378e21d582 ] The function of genphy_read_status is that reading phy information from HW and using these information to update SW variable. If user is using ethtool to setting the speed of phy and service task is calling by hclge_get_mac_phy_link, the result of speed setting is uncertain. Because ethtool cmd will modified phydev and hclge_get_mac_phy_link also will modified phydev. Because phy state machine will update phy link periodically, we can just use phydev->link to check the link status. This patch removes function call of genphy_read_status. To ensure accuracy, this patch adds a phy state check. If phy state is not PHY_RUNNING, we consider link is down. Because in some scenarios, phydev->link may be link up, but phy state is not PHY_RUNNING. This is just an intermediate state. In fact, the link is not ready yet. Fixes: 46a3df9f9718 ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support") Signed-off-by: Fuyun Liang Signed-off-by: Peng Li Signed-off-by: Salil Mehta Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 0cf33fa351df3..6889e83a55707 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -2367,7 +2367,7 @@ static int hclge_get_mac_phy_link(struct hclge_dev *hdev) mac_state = hclge_get_mac_link_status(hdev); if (hdev->hw.mac.phydev) { - if (!genphy_read_status(hdev->hw.mac.phydev)) + if (hdev->hw.mac.phydev->state == PHY_RUNNING) link_stat = mac_state & hdev->hw.mac.phydev->link; else -- 2.20.1