Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp4939112pxb; Mon, 28 Mar 2022 05:56:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUEgpf0tdwz+eXcTZgLVRqxqgbXw8I7U4YTeG+Wy2DVBeLuzv3CLyU24sDD+9KomAbHV28 X-Received: by 2002:a63:4f08:0:b0:34c:6090:603e with SMTP id d8-20020a634f08000000b0034c6090603emr10004172pgb.15.1648472209928; Mon, 28 Mar 2022 05:56:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648472209; cv=none; d=google.com; s=arc-20160816; b=gVB6FnhzJoXvcgw7hc2n80wWzeJZA7vhJe1yXJ5FKtKSTGXNAlKIPOa6j7Xs/Mf5a6 TTtUDFG52tyRPaOvOxRtmiErSh+Bbm/RqCXFb/8vfyPlhaFXvyBLACX4mOZ7MKfF0drz kYrkt3wpiPvqSa3IdderodVhM6Ul4LG0GW6JXTDnB32P3YWWaG4kgqlQngGAY5Ykujal HDsSy5XA1xkLfNCnMgRDdrLr095ZGUmEtQeGxTQ6HkLKSJOZ3/gGFMN0VxN6hmbIBBuZ GNiKg6nb0l4flz7BFwRn4VWILqYFnAyeqFBW8R6w9yxN7w3tgfC1A9Cvxeg0mAbE0q+o TzGQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=0RAKT3OkyG8DvrOmi8h145TWev/SMS9qXu32r80vtiE=; b=bJiXYy1WUxIszEllSuf8DlLhtf/mM9MpoxR5DoJdDrpGW0bZjD0Ow8UMMwYKIqEPSa 3Yzk89xZdrJBWmLTa9H3WqN9g0Rj4CeT52edfSvyAYLYR2qRBJunqv5ch9Xa/JGPJDFG W1jYL97AIqM8mCm4CB5Hc/eVseDqxwEkebAWENGNpHFW5ztK0HD0U6Uq1MfAfXA8cBdQ NxWE5EiSD3XYYVsNDRAsxbYEHM/pv0PVf3jSE7sgw6m6Ia1xbBsU0JeL6sGJH83xd4wR hemuVzZImPKe9FkLwYhp/uHoRBwpmi609Fgul5VH8eqPaQs2vXqnnEdYUNx8GhYXoh+P 4HxA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n7-20020a17090a928700b001bd14e01fc4si15626970pjo.178.2022.03.28.05.56.36; Mon, 28 Mar 2022 05:56:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232491AbiCZJ7E (ORCPT + 99 others); Sat, 26 Mar 2022 05:59:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232313AbiCZJ6P (ORCPT ); Sat, 26 Mar 2022 05:58:15 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5ED6D205F0; Sat, 26 Mar 2022 02:56:38 -0700 (PDT) Received: from kwepemi500005.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KQZ7n1l27zfZsP; Sat, 26 Mar 2022 17:55:01 +0800 (CST) Received: from kwepemm600016.china.huawei.com (7.193.23.20) by kwepemi500005.china.huawei.com (7.221.188.179) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Sat, 26 Mar 2022 17:56:36 +0800 Received: from localhost.localdomain (10.67.165.24) by kwepemm600016.china.huawei.com (7.193.23.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Sat, 26 Mar 2022 17:56:36 +0800 From: Guangbin Huang To: , CC: , , , , Subject: [PATCH net 6/6] net: hns3: fix phy can not link up when autoneg off and reset Date: Sat, 26 Mar 2022 17:51:05 +0800 Message-ID: <20220326095105.54075-7-huangguangbin2@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220326095105.54075-1-huangguangbin2@huawei.com> References: <20220326095105.54075-1-huangguangbin2@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.165.24] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600016.china.huawei.com (7.193.23.20) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, function hclge_mdio_read() will return 0 if during reset(the cmd state will be set to disable). If use general phy driver, the phy_state_machine() will update phy speed every second in function genphy_read_status_fixed() when PHY is set to autoneg off, no matter of link down or link up. If phy driver happens to read BMCR register during reset, phy speed will be updated to 10Mpbs as BMCR register value is 0. So it may call phy can not link up if previous speed is not 10Mpbs. To fix this problem, function hclge_mdio_read() should return -EBUSY if the cmd state is disable. So does function hclge_mdio_write(). Fixes: 1c1249380992 ("net: hns3: bugfix for hclge_mdio_write and hclge_mdio_read") Signed-off-by: Guangbin Huang --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c index 63d2be4349e3..03d63b6a9b2b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c @@ -48,7 +48,7 @@ static int hclge_mdio_write(struct mii_bus *bus, int phyid, int regnum, int ret; if (test_bit(HCLGE_COMM_STATE_CMD_DISABLE, &hdev->hw.hw.comm_state)) - return 0; + return -EBUSY; hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_MDIO_CONFIG, false); @@ -86,7 +86,7 @@ static int hclge_mdio_read(struct mii_bus *bus, int phyid, int regnum) int ret; if (test_bit(HCLGE_COMM_STATE_CMD_DISABLE, &hdev->hw.hw.comm_state)) - return 0; + return -EBUSY; hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_MDIO_CONFIG, true); -- 2.33.0