From patchwork Tue May 1 18:56:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 134795 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp5280348lji; Tue, 1 May 2018 11:58:51 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpvtP4xGRwnTwSTvp2QPS31vXTlIzDaBv2TspH2FeXyGQADXCRIYDqUn1zpOJVDVwCUoMLN X-Received: by 2002:a65:4c4f:: with SMTP id l15-v6mr13959153pgr.61.1525201131763; Tue, 01 May 2018 11:58:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525201131; cv=none; d=google.com; s=arc-20160816; b=Z96RBRSVjQBjkIUSg46Z+hgBdakCSJFKIfN17eJ665POMTakWio6He26LX8jn5k7aF hK5Cn6qd3F4lQcYoiezvOWAIJZigRJRPEcng1SR4DJP49Q89h1pLkzPiT0NNpLo1u/BL QSMNmIvkIsAtCDJaZMu6rkKPHvm8wcUpDYJD+W4tS6uamihIGsKSA9BbgGz6YW99800s ZuNxSd13nJtCeUt+Onm5ey7/ng0E+cfBsiRJPVIxeJe9P70ktH6AlJHvelHFobHV0SEQ XfgMSPU31nl5BP+EIWGIZhrPlad0ilYvTPB821TelN/n1X1xj7oh7bSFDUrv7d4+XLzT LLBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=Vy4vZhQliJ7OrSOgHoxRk1D+bZ/Uwqc7E1+E+HNpzGs=; b=DVPrSAEhMWhj7nhZ5w1IayGiKan+H0MdzeKzbwIkNcB0Z3eQlyEm95PHN6//bcPFcN aWE2xkvPc/37ognqat8f+Wb81lph7vTBgTMcX+CcH1z7BJkq9XbBn1sKcMnzIM/++oBX CN4GXMmcJeWzZv8nrJ9wjPOwP3Ie4e2j+aMotnzN+upRahZJEIsrm4CvFUhtE6/DSzC3 N2g10Gk6eLVJnPaj+wEm9hg8KtgzP/nrqALCNAtzSTm7/foknZPyS1mjwZMu/trQ71wL vIUwub4GQ7gIhAdgRFI3MtEDtw6FlolRVrjwLxfTujVGA8aDoDbEJ+a+7uqm8bDIyMvd 2G+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s1-v6si8220928pgq.282.2018.05.01.11.58.51; Tue, 01 May 2018 11:58:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756742AbeEAS6t (ORCPT + 9 others); Tue, 1 May 2018 14:58:49 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7643 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756652AbeEAS6K (ORCPT ); Tue, 1 May 2018 14:58:10 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 68E0BC510B6EA; Wed, 2 May 2018 02:57:57 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.226.46) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.361.1; Wed, 2 May 2018 02:57:47 +0800 From: Salil Mehta To: CC: , , , , , , , Huazhong Tan Subject: [PATCH net-next 5/9] net: hns3: fix for phy_addr error in hclge_mac_mdio_config Date: Tue, 1 May 2018 19:56:01 +0100 Message-ID: <20180501185605.9584-6-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180501185605.9584-1-salil.mehta@huawei.com> References: <20180501185605.9584-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.226.46] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Huazhong Tan When phy exists, phy_addr must less than PHY_MAX_ADDR. If not, hclge_mac_mdio_config should return error. And for fiber(phy_addr=0xff), it does not need hclge_mac_mdio_config. Signed-off-by: Huazhong Tan Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 12 +++++++----- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c | 7 +++++-- 2 files changed, 12 insertions(+), 7 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index b5e0c58..cc09713 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -5503,11 +5503,13 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) goto err_sriov_disable; } - ret = hclge_mac_mdio_config(hdev); - if (ret) { - dev_warn(&hdev->pdev->dev, - "mdio config fail ret=%d\n", ret); - goto err_sriov_disable; + if (hdev->hw.mac.media_type == HNAE3_MEDIA_TYPE_COPPER) { + ret = hclge_mac_mdio_config(hdev); + if (ret) { + dev_err(&hdev->pdev->dev, + "mdio config fail ret=%d\n", ret); + goto err_sriov_disable; + } } ret = hclge_mac_init(hdev); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c index 682c2d6..9f7932e42 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c @@ -140,8 +140,11 @@ int hclge_mac_mdio_config(struct hclge_dev *hdev) struct mii_bus *mdio_bus; int ret; - if (hdev->hw.mac.phy_addr >= PHY_MAX_ADDR) - return 0; + if (hdev->hw.mac.phy_addr >= PHY_MAX_ADDR) { + dev_err(&hdev->pdev->dev, "phy_addr(%d) is too large.\n", + hdev->hw.mac.phy_addr); + return -EINVAL; + } mdio_bus = devm_mdiobus_alloc(&hdev->pdev->dev); if (!mdio_bus)