Received: by 10.192.165.148 with SMTP id m20csp5270248imm; Tue, 1 May 2018 12:00:09 -0700 (PDT) X-Google-Smtp-Source: AB8JxZopqsInkvIXJ+TmXZxwxaqTp3wEUdQoosSjbxBVX8mRhn31zBSXDK2EklM/Bbt76l3emLGr X-Received: by 2002:a63:6441:: with SMTP id y62-v6mr14095152pgb.362.1525201209332; Tue, 01 May 2018 12:00:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525201209; cv=none; d=google.com; s=arc-20160816; b=L6zCHJVt3Td+5p+r4L7dOLjmhgOAOcRcF4NX7YDfwrxMNMcYEXom+8Tem2YoBxZPBz 4lKufvC6LjFPdXVZgRFzk99/b3XMr7eNwKV/RRf5eISmBCF0BXyMErO5n5wvHKaIrmCo b/+DP40D+kQShOIoPBrNVz4of+JRZmX/pEPoTtsJ6k79K1/NdA31xtf00Mcisd54q9Rz tIfQmmVww7g/gQHp2OPVmRhRbu5PIdLH9IasGs1NK1tWN+bYu1x83zGYCqYchmeR5ulx 9IeJsiBlEoeJqKNwyxxdh9jM/NAmBd6VFECypIcj4B7bQ0d101ssJIqDncgPJO8Z9j9W Z/Aw== 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=djA9ExH5PjtBa7X4x5lKbrfbiqye947Ye4UGuhlzCCMWWNygB7E+S2EsPO8tkpqeTk CiWTGThBCL8j2wvqlO/80fxCWgc+nXmKk2DCcAbsHtMwV4GLfn5+aKfz0AVACa/N16e6 n+k0tkg9WGqO1Y4X54xG//X1GpdoB+rnu8Vgp/3I/6kxM5Cyr4Ml9Kh9pmt12ma2DgRf 5SRULv6xOFzp8o9aaVIjtS50JQd6t5WogvNUqJvkIR1A1/Czmh9b1Pwv/+iMM8oP+25d wHfjm9Z7SzthMekcTA/eW2oVlMCmHCi4UugQvKTFB/UMCF8bCrKT91u9/JfZxU3g+1CN 1rEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 m10-v6si8108812pgd.194.2018.05.01.11.59.55; Tue, 01 May 2018 12:00:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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 linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756751AbeEAS6v (ORCPT + 99 others); Tue, 1 May 2018 14:58:51 -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 Content-Type: text/plain X-Originating-IP: [10.202.226.46] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) 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) -- 2.7.4