From patchwork Tue May 15 18:20:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 135924 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1375008lji; Tue, 15 May 2018 11:24:37 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrKidA+NGTBHi+6gYxiHZHhJq9jWHpsZTQxK/4/Flbv+qyRFfq9CYiXBN5RcthOHKSwJ3cn X-Received: by 2002:a17:902:903:: with SMTP id 3-v6mr595914plm.377.1526408676966; Tue, 15 May 2018 11:24:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526408676; cv=none; d=google.com; s=arc-20160816; b=QWgnfN49WN421DoiVXWq4Nw9QEHkiHRPf2FQOrbWb0DTblXHLYf3Z6DTfkzFrosKDa xlK4ls1KXFPTbfgd9l7SBZqYJvYD7zRZRasJeRvqNyaDjLNIaBcCGr/TW4dBmD8+2sqU auc3n7mnsRPiK3MgjG1j/1SCtIUsMiv0ga3uwKRJ2dR1fGSRgyBLubvfMHWW7cTLnb5Z Mo1/eX+Nt5eoXzYkJV5Fb7TfcL1ba+h4/exKq8XbBhA5ZEgkuoaX21wAneGWwZXo5xG/ NSOxAJ1TtxmDiIJ0Z21CCtTQAoJAFA/kNyqg188QnMaLNyMKu8KweBFl9wHkebYFMUdC PNZA== 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=ParrnGO5yUoosUpKhJb7iGNVQ8QcxrxS0vgsZOkjUwo=; b=Kgs564Cd4rezh7k7MmCjAN/g1ybWJoVCEM7UI/XYPPkWWeEINk/GqgQysr4NM1uBIh n4LLEgQc+BB/4rbBdT6r7RPqSEX9moZT/+jj1IxUrcA6BOUow2md2ez0vWtTu1dVY2Ps IaIOtgVzw1UhdDYZ9JVTIv8Rkvpgj1NobMf6Ob5dxiPJp91UGSAky5HSeOSHmZLNFXkK Wfcn4db0bvY3lbI9/gqjCbAfCa7WaR5sIzrs9opW8xH8bnCVZpUHXO4zK8L7ZxHWUY2K VFQ2kTZOe0OMhcR47yVxwiZYuw6B0zcQU1lay9OHrvnol++pF1S/8NeyZCabj865aNM7 nTTw== 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 f18-v6si493975pgt.63.2018.05.15.11.24.36; Tue, 15 May 2018 11:24:36 -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 S1753179AbeEOSVP (ORCPT + 29 others); Tue, 15 May 2018 14:21:15 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:59834 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752978AbeEOSVL (ORCPT ); Tue, 15 May 2018 14:21:11 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id E8CE6F9A7C66B; Wed, 16 May 2018 02:21:06 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.227.234) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.382.0; Wed, 16 May 2018 02:20:58 +0800 From: Salil Mehta To: CC: , , , , , , , Fuyun Liang Subject: [PATCH net-next 01/10] net: hns3: Fix for deadlock problem occurring when unregistering ae_algo Date: Tue, 15 May 2018 19:20:05 +0100 Message-ID: <20180515182014.42196-2-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180515182014.42196-1-salil.mehta@huawei.com> References: <20180515182014.42196-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.234] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fuyun Liang When hnae3_unregister_ae_algo is called by PF, pci_disable_sriov is called. And then, hns3_remove is called by VF. We get deadlocked in this case. Since VF pci device is dependent on PF pci device, When PF pci device is removed, VF pci device must be removed. Also, To solve the deadlock problem, VF pci device should be removed before PF pci device is removed. This patch moves pci_enable/disable_sriov from hclge to hns3 to solve the deadlock problem. Also, we do not need to return EPROBE_DEFER in hnae3_register_ae_dev, because SRIOV is no longer enabled in the context calling hnae3_register_ae_dev. Mutex_trylock can be replaced with mutex_lock. Fixes: 424eb834a9be ("net: hns3: Unified HNS3 {VF|PF} Ethernet Driver for hip08 SoC") Signed-off-by: Fuyun Liang Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hnae3.c | 12 +--- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 74 +++++++++++++++++++++- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 42 ++---------- 3 files changed, 79 insertions(+), 49 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.c b/drivers/net/ethernet/hisilicon/hns3/hnae3.c index 02145f2..1686ceb 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.c +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.c @@ -196,17 +196,9 @@ int hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev) const struct pci_device_id *id; struct hnae3_ae_algo *ae_algo; struct hnae3_client *client; - int ret = 0, lock_acquired; + int ret = 0; - /* we can get deadlocked if SRIOV is being enabled in context to probe - * and probe gets called again in same context. This can happen when - * pci_enable_sriov() is called to create VFs from PF probes context. - * Therefore, for simplicity uniformly defering further probing in all - * cases where we detect contention. - */ - lock_acquired = mutex_trylock(&hnae3_common_lock); - if (!lock_acquired) - return -EPROBE_DEFER; + mutex_lock(&hnae3_common_lock); list_add_tail(&ae_dev->node, &hnae3_ae_dev_list); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 4031174..af9e90f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -1487,6 +1487,68 @@ static const struct net_device_ops hns3_nic_netdev_ops = { .ndo_set_vf_vlan = hns3_ndo_set_vf_vlan, }; +static bool hns3_is_phys_func(struct pci_dev *pdev) +{ + u32 dev_id = pdev->device; + + switch (dev_id) { + case HNAE3_DEV_ID_GE: + case HNAE3_DEV_ID_25GE: + case HNAE3_DEV_ID_25GE_RDMA: + case HNAE3_DEV_ID_25GE_RDMA_MACSEC: + case HNAE3_DEV_ID_50GE_RDMA: + case HNAE3_DEV_ID_50GE_RDMA_MACSEC: + case HNAE3_DEV_ID_100G_RDMA_MACSEC: + return true; + case HNAE3_DEV_ID_100G_VF: + case HNAE3_DEV_ID_100G_RDMA_DCB_PFC_VF: + return false; + default: + dev_warn(&pdev->dev, "un-recognized pci device-id %d", + dev_id); + } + + return false; +} + +static int get_num_req_vfs(struct pci_dev *pdev) +{ + /* a variable vf num will be supported later */ + return pci_sriov_get_totalvfs(pdev); +} + +static void hns3_enable_sriov(struct pci_dev *pdev) +{ + int num_req_vfs = get_num_req_vfs(pdev); + int ret; + + /* Enable SRIOV */ + if (!num_req_vfs) + return; + + dev_info(&pdev->dev, "active VFs(%d) found, enabling SRIOV\n", + num_req_vfs); + + ret = pci_enable_sriov(pdev, num_req_vfs); + if (ret) + dev_err(&pdev->dev, "SRIOV enable failed %d\n", ret); +} + +static void hns3_disable_sriov(struct pci_dev *pdev) +{ + /* If our VFs are assigned we cannot shut down SR-IOV + * without causing issues, so just leave the hardware + * available but disabled + */ + if (pci_vfs_assigned(pdev)) { + dev_warn(&pdev->dev, + "disabling driver while VFs are assigned\n"); + return; + } + + pci_disable_sriov(pdev); +} + /* hns3_probe - Device initialization routine * @pdev: PCI device information struct * @ent: entry in hns3_pci_tbl @@ -1514,7 +1576,14 @@ static int hns3_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ae_dev->dev_type = HNAE3_DEV_KNIC; pci_set_drvdata(pdev, ae_dev); - return hnae3_register_ae_dev(ae_dev); + ret = hnae3_register_ae_dev(ae_dev); + if (ret) + return ret; + + if (hns3_is_phys_func(pdev) && IS_ENABLED(CONFIG_PCI_IOV)) + hns3_enable_sriov(pdev); + + return 0; } /* hns3_remove - Device removal routine @@ -1524,6 +1593,9 @@ static void hns3_remove(struct pci_dev *pdev) { struct hnae3_ae_dev *ae_dev = pci_get_drvdata(pdev); + if (hns3_is_phys_func(pdev) && IS_ENABLED(CONFIG_PCI_IOV)) + hns3_disable_sriov(pdev); + hnae3_unregister_ae_dev(ae_dev); } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 316ec842..343197a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -1473,21 +1473,8 @@ static int hclge_alloc_vport(struct hclge_dev *hdev) hdev->vport = vport; hdev->num_alloc_vport = num_vport; -#ifdef CONFIG_PCI_IOV - /* Enable SRIOV */ - if (hdev->num_req_vfs) { - dev_info(&pdev->dev, "active VFs(%d) found, enabling SRIOV\n", - hdev->num_req_vfs); - ret = pci_enable_sriov(hdev->pdev, hdev->num_req_vfs); - if (ret) { - hdev->num_alloc_vfs = 0; - dev_err(&pdev->dev, "SRIOV enable failed %d\n", - ret); - return ret; - } - } - hdev->num_alloc_vfs = hdev->num_req_vfs; -#endif + if (IS_ENABLED(CONFIG_PCI_IOV)) + hdev->num_alloc_vfs = hdev->num_req_vfs; for (i = 0; i < num_vport; i++) { vport->back = hdev; @@ -2946,21 +2933,6 @@ static void hclge_service_task(struct work_struct *work) hclge_service_complete(hdev); } -static void hclge_disable_sriov(struct hclge_dev *hdev) -{ - /* If our VFs are assigned we cannot shut down SR-IOV - * without causing issues, so just leave the hardware - * available but disabled - */ - if (pci_vfs_assigned(hdev->pdev)) { - dev_warn(&hdev->pdev->dev, - "disabling driver while VFs are assigned\n"); - return; - } - - pci_disable_sriov(hdev->pdev); -} - struct hclge_vport *hclge_get_vport(struct hnae3_handle *handle) { /* VF handle has no client */ @@ -5540,7 +5512,7 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) ret = hclge_map_tqp(hdev); if (ret) { dev_err(&pdev->dev, "Map tqp error, ret = %d.\n", ret); - goto err_sriov_disable; + goto err_msi_irq_uninit; } if (hdev->hw.mac.media_type == HNAE3_MEDIA_TYPE_COPPER) { @@ -5548,7 +5520,7 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) if (ret) { dev_err(&hdev->pdev->dev, "mdio config fail ret=%d\n", ret); - goto err_sriov_disable; + goto err_msi_irq_uninit; } } @@ -5612,9 +5584,6 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) err_mdiobus_unreg: if (hdev->hw.mac.phydev) mdiobus_unregister(hdev->hw.mac.mdio_bus); -err_sriov_disable: - if (IS_ENABLED(CONFIG_PCI_IOV)) - hclge_disable_sriov(hdev); err_msi_irq_uninit: hclge_misc_irq_uninit(hdev); err_msi_uninit: @@ -5717,9 +5686,6 @@ static void hclge_uninit_ae_dev(struct hnae3_ae_dev *ae_dev) set_bit(HCLGE_STATE_DOWN, &hdev->state); - if (IS_ENABLED(CONFIG_PCI_IOV)) - hclge_disable_sriov(hdev); - if (hdev->service_timer.function) del_timer_sync(&hdev->service_timer); if (hdev->service_task.func) From patchwork Tue May 15 18:20:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 135916 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1371476lji; Tue, 15 May 2018 11:21:23 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpCM37N95fKgsHCuinpsmbvf2z3ojM0Zayoq+B0WpFh3bCT7FxZT1+5Af0QW9PsbU2uc3J3 X-Received: by 2002:a17:902:125:: with SMTP id 34-v6mr15865337plb.42.1526408483275; Tue, 15 May 2018 11:21:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526408483; cv=none; d=google.com; s=arc-20160816; b=wRVku3w6zfpAoQ7IQ3ESgjMybdOe15D+f4pp+WrR1H8Z+/W1lrErRl7zrro9lUWS1s CEtczz+QLTWK/+15zQ9+fqy6WlhqlJCVBx/AMdGDe14VrG6L6icKHlf1fgKYDsDjb5GF Owq/OfQDYY75nShMiKwI+zO+7Ou9Zq97r0vjuAK4KCNjZIgO0lLwMQu2a3pVMOyVfLWL k/Co76J/cBsbht1W1ghJwHZZpJzYG4HiRn1HW1kRvrmZ7rSmYihowhEnUAAdX93htx32 P9OtvTAFW/jMnxImspP3LH13UShuDPSBHREDf5RYVsajgjnGf0ZG+vdTK3F9KN3sWyd7 amRA== 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=TtIbiIn5zLPX2zmL0mPP7A+mhAdEjew6tOCXeF9Ec+c=; b=RNPI1U/V1e21oXTQ+6ht8laCAyfZwS2slkiTjvxA9KHRwUsfYkFwczjSM8HGBAfU1q /uD3+PDBXvtEPor3nqUm9DaaCqRTbPBAzdKUSFa7iUCMGHMOsztVx24evmY+htaI0ZFK oGJHMTBR7xSWygFPvJSm6LInXq7bfQy2tGVBkPCnICyEN4ighm5mDW/bQB7ppKjNsR12 lgc216EtC9iUklpk2lBPMMvn0AKpJwGlIhKuUgS5zOGrZt2BJDNZhpbomqfFUyHTUG2P BLdf3fuoPsnnG1piHMYtfW2eCWPoUgKY42+kwYHazkkVg9k+rVe3fmBy9pNexknsfb8Q 2HXw== 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 s12-v6si455531pgq.616.2018.05.15.11.21.23; Tue, 15 May 2018 11:21:23 -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 S1753364AbeEOSVS (ORCPT + 29 others); Tue, 15 May 2018 14:21:18 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:59461 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753113AbeEOSVQ (ORCPT ); Tue, 15 May 2018 14:21:16 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 9E8BF1FC0D57D; Wed, 16 May 2018 02:21:11 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.227.234) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.382.0; Wed, 16 May 2018 02:21:04 +0800 From: Salil Mehta To: CC: , , , , , , , Fuyun Liang Subject: [PATCH net-next 03/10] net: hns3: Add a check for client instance init state Date: Tue, 15 May 2018 19:20:07 +0100 Message-ID: <20180515182014.42196-4-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180515182014.42196-1-salil.mehta@huawei.com> References: <20180515182014.42196-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.234] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fuyun Liang If the client instance is initializd failed, we do not need to uninit it. This patch adds a state check to check init state of client instance. Fixes: 38caee9d3ee8 ("net: hns3: Add support of the HNAE3 framework") Signed-off-by: Fuyun Liang Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hnae3.c | 15 ++++++++++++--- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.c b/drivers/net/ethernet/hisilicon/hns3/hnae3.c index ab2e72c..21cb0c5 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.c +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.c @@ -50,13 +50,22 @@ static int hnae3_match_n_instantiate(struct hnae3_client *client, /* now, (un-)instantiate client by calling lower layer */ if (is_reg) { ret = ae_dev->ops->init_client_instance(client, ae_dev); - if (ret) + if (ret) { dev_err(&ae_dev->pdev->dev, "fail to instantiate client\n"); - return ret; + return ret; + } + + hnae_set_bit(ae_dev->flag, HNAE3_CLIENT_INITED_B, 1); + return 0; + } + + if (hnae_get_bit(ae_dev->flag, HNAE3_CLIENT_INITED_B)) { + ae_dev->ops->uninit_client_instance(client, ae_dev); + + hnae_set_bit(ae_dev->flag, HNAE3_CLIENT_INITED_B, 0); } - ae_dev->ops->uninit_client_instance(client, ae_dev); return 0; } diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index 804ea83..ffec231 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -52,6 +52,7 @@ #define HNAE3_DEV_INITED_B 0x0 #define HNAE3_DEV_SUPPORT_ROCE_B 0x1 #define HNAE3_DEV_SUPPORT_DCB_B 0x2 +#define HNAE3_CLIENT_INITED_B 0x3 #define HNAE3_DEV_SUPPORT_ROCE_DCB_BITS (BIT(HNAE3_DEV_SUPPORT_DCB_B) |\ BIT(HNAE3_DEV_SUPPORT_ROCE_B)) From patchwork Tue May 15 18:20:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 135923 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1374560lji; Tue, 15 May 2018 11:24:11 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpuPZRra0q+TeXJ0NKJ50WJuAbLWoDu/FVsiTp8uzyzrt98ypPMLwXNEawnIpOMRzsnHIvY X-Received: by 2002:a65:4dc7:: with SMTP id q7-v6mr13384013pgt.48.1526408650798; Tue, 15 May 2018 11:24:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526408650; cv=none; d=google.com; s=arc-20160816; b=09vnEW7BKzlVksRw0atnOrlV9TcOY82WYADrulAZfLUJHjIiE6suEuzypM7Jl+Au20 lu4swPyYqivjRfUrWUlSjGA895CYrBT7EnyF9mi3Fp4c4oUuOhKlxhGLvo3idGDz4KyE ntZEjJEfNKHfwI4djsk7FGaBFLMs9+LENqkWjtkFPPOrjlQ5JPf/ZVcrgdq8CpFbC87b rc9qH04ZCiAE45EuGL5JlhT8xccNfHXVbcTTl9I2cBEc353gdYLtIUrkOnWFaY1KOHwR qC4oznzzdMcLUspTt2DPz3dwtbINkzJFQbnht229nGxpdDsIbKZCZhAMzwgFIopTxcKY DZ7A== 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=l2zNqHEe4cMXGDkIqDZQSJvHW+I9vdywi+t2181dG1k=; b=ti5ZYGZ5DfBuHONaGzxzw0VlN48I6v7JM5/WwH96sxmT9N/VB8bMBsD0URAVKqyABc fGjByx8MBfxT9MXBQ2QebCN/T81D++N51/r97qeVWOaZFbuj1Rjm7+hLOHNMq3SjEVBs eo6hTP7bjVwy47dJcIBBpeCZWeLHmWjeiPSvhBY7G40fzMZrpRM83AT7J832T/6iyh9z 8w2I5MAwSt3QVhfB5+5VSLLVbU4x1tkP1Vw8Uy8N49bjBm7R7Js8oyoQ9OdeMYObInzm 7HHCXO0hRgT6b7FAgCOST67nSa6nZdRXzdtZx1llJRjGX8a4hXqOv7vDhOFkTqPG9scv 4n/g== 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 t125-v6si479847pgc.118.2018.05.15.11.24.10; Tue, 15 May 2018 11:24:10 -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 S1753772AbeEOSYI (ORCPT + 29 others); Tue, 15 May 2018 14:24:08 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:59458 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753118AbeEOSVQ (ORCPT ); Tue, 15 May 2018 14:21:16 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id ACDF9F2EFD3C1; Wed, 16 May 2018 02:21:11 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.227.234) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.382.0; Wed, 16 May 2018 02:21:07 +0800 From: Salil Mehta To: CC: , , , , , , , Fuyun Liang Subject: [PATCH net-next 04/10] net: hns3: Change return type of hnae3_register_ae_dev Date: Tue, 15 May 2018 19:20:08 +0100 Message-ID: <20180515182014.42196-5-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180515182014.42196-1-salil.mehta@huawei.com> References: <20180515182014.42196-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.234] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fuyun Liang If hclge.ko has not been inserted, the value of ret always is zero in hnae3_register_ae_dev. If hclge.ko has been inserted, the value of ret is zero or non zero. Different execution ways have different results. It is confusing. The ae_dev which is initialized failed can be reinitialized when we remove hclge.ko and insert it again. For the case initializing client instance, it is just like the case initializing ae_dev. The main function of hnae3_register_ae_dev is adding the ae_dev to ad_dev list. Because adding ae_dev is always ok, we does not need to return any in this function. This patch changes the return type of hnae3_register_ae_dev from int to void. Signed-off-by: Fuyun Liang Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hnae3.c | 5 +---- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 4 +--- 3 files changed, 3 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.c b/drivers/net/ethernet/hisilicon/hns3/hnae3.c index 21cb0c5..cb93295 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.c +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.c @@ -203,7 +203,7 @@ EXPORT_SYMBOL(hnae3_unregister_ae_algo); * @ae_dev: the AE device * NOTE: the duplicated name will not be checked */ -int hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev) +void hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev) { const struct pci_device_id *id; struct hnae3_ae_algo *ae_algo; @@ -224,7 +224,6 @@ int hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev) if (!ae_dev->ops) { dev_err(&ae_dev->pdev->dev, "ae_dev ops are null\n"); - ret = -EOPNOTSUPP; goto out_err; } @@ -251,8 +250,6 @@ int hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev) out_err: mutex_unlock(&hnae3_common_lock); - - return ret; } EXPORT_SYMBOL(hnae3_register_ae_dev); diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index ffec231..ea6e6ea 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -515,7 +515,7 @@ struct hnae3_handle { #define hnae_get_bit(origin, shift) \ hnae_get_field((origin), (0x1 << (shift)), (shift)) -int hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev); +void hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev); void hnae3_unregister_ae_dev(struct hnae3_ae_dev *ae_dev); void hnae3_unregister_ae_algo(struct hnae3_ae_algo *ae_algo); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index af9e90f..ac75b5d 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -1576,9 +1576,7 @@ static int hns3_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ae_dev->dev_type = HNAE3_DEV_KNIC; pci_set_drvdata(pdev, ae_dev); - ret = hnae3_register_ae_dev(ae_dev); - if (ret) - return ret; + hnae3_register_ae_dev(ae_dev); if (hns3_is_phys_func(pdev) && IS_ENABLED(CONFIG_PCI_IOV)) hns3_enable_sriov(pdev); From patchwork Tue May 15 18:20:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 135922 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1373903lji; Tue, 15 May 2018 11:23:35 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrO241R1cl01trYkFglXr4s2O1N4BzJKWa5WBqXeYDwemsUjYex57rMk4/29P9vX88pm6wd X-Received: by 2002:a63:7c01:: with SMTP id x1-v6mr13003749pgc.286.1526408615250; Tue, 15 May 2018 11:23:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526408615; cv=none; d=google.com; s=arc-20160816; b=h5nzqoKdsC6aIn8ovwJDbglZBQrmgslU57r3SaKNFymSfrtJTgzoRGIOpEpGZx9ZSn 3gVo6QEGK9SgNH0DIMAX3dcroH340/NwI68FErTo6koSC2/Ubk5vkpwQt4OcWSNgtMZQ haPF/U2B7MkR66aIUmJUDytdLtQvisNu39b7pTDMnZeVoGeBpnA/Eb1v6c0ckRwesI2m bMQg6nnsdy8VgnO84xD/DXh7yamNhcuEEZRb+cM2iFppEIGx0z9vMoUPK0OaK5frzrn2 ARTPT6ZqsU0ZfNDSLuemGa1J68ot92B9XUgIIvIT90uwnfXDbuBB09wY4kndEs8cQTwE RKcw== 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=fjj/AJfwJ0i2r6vDc4sGHAEmtW6dcFNw5bzw15WG5m4=; b=RVsD2dVpUfd/Ez8ym1We1laynlHpZtisYlHCAsSPCgSYLUcVoEpovJxCTK5/Jswq1F gzSeyJtZRWJpTp+LUOoCekxG9tjKxIoxaPQUgjj75nTpoZW0f0LNt1Aa8HB7yJJd9uQy gAYRu0YwD2Sn39ZnJlOkmHOfj5/RXx5SXIdIvGPrRUPvlaaqU3xdLti8Hb73zRD9O4na QMRBvYIUZcotv1NyjsjxNKW7E9DXfa9Q/Dfv8sBPuLfBwvgk3siCjX7E4VC60yJOZ2EX e1IM9ZdBij5z3LU16wvRf2ndlpATm6lck7u11BoaVz0aB6eacUhm2HTUkmQDE7mCLiFj 7D3w== 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 m6-v6si459488pgq.611.2018.05.15.11.23.34; Tue, 15 May 2018 11:23:35 -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 S1753406AbeEOSVY (ORCPT + 29 others); Tue, 15 May 2018 14:21:24 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:59900 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752836AbeEOSVV (ORCPT ); Tue, 15 May 2018 14:21:21 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 20A21184560DA; Wed, 16 May 2018 02:21:17 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.227.234) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.382.0; Wed, 16 May 2018 02:21:10 +0800 From: Salil Mehta To: CC: , , , , , , , Fuyun Liang Subject: [PATCH net-next 05/10] net: hns3: Change return type of hnae3_register_ae_algo Date: Tue, 15 May 2018 19:20:09 +0100 Message-ID: <20180515182014.42196-6-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180515182014.42196-1-salil.mehta@huawei.com> References: <20180515182014.42196-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.234] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fuyun Liang The ae_algo is used by many ae_devs. It is not only belong to just a ae_dev. Initializing ae_dev failed does not represent registering ae_algo failed. Because the action of registering ae_algo just is adding ae_algo to the ae_algo list and it is always is true, it make no sense to define return type as int. This patch changes the return type of hnae3_register_ae_algo from int to void. Signed-off-by: Fuyun Liang Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hnae3.c | 4 +--- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 4 +++- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 4 +++- 4 files changed, 8 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.c b/drivers/net/ethernet/hisilicon/hns3/hnae3.c index cb93295..3b1c396 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.c +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.c @@ -121,7 +121,7 @@ EXPORT_SYMBOL(hnae3_unregister_client); * @ae_algo: AE algorithm * NOTE: the duplicated name will not be checked */ -int hnae3_register_ae_algo(struct hnae3_ae_algo *ae_algo) +void hnae3_register_ae_algo(struct hnae3_ae_algo *ae_algo) { const struct pci_device_id *id; struct hnae3_ae_dev *ae_dev; @@ -160,8 +160,6 @@ int hnae3_register_ae_algo(struct hnae3_ae_algo *ae_algo) } mutex_unlock(&hnae3_common_lock); - - return ret; } EXPORT_SYMBOL(hnae3_register_ae_algo); diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index ea6e6ea..2f266ef 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -519,7 +519,7 @@ void hnae3_register_ae_dev(struct hnae3_ae_dev *ae_dev); void hnae3_unregister_ae_dev(struct hnae3_ae_dev *ae_dev); void hnae3_unregister_ae_algo(struct hnae3_ae_algo *ae_algo); -int hnae3_register_ae_algo(struct hnae3_ae_algo *ae_algo); +void hnae3_register_ae_algo(struct hnae3_ae_algo *ae_algo); void hnae3_unregister_client(struct hnae3_client *client); int hnae3_register_client(struct hnae3_client *client); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index c2501b1..d060903 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -6250,7 +6250,9 @@ static int hclge_init(void) { pr_info("%s is initializing\n", HCLGE_NAME); - return hnae3_register_ae_algo(&ae_algo); + hnae3_register_ae_algo(&ae_algo); + + return 0; } static void hclge_exit(void) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index b7578c6..f1f4a17 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -1852,7 +1852,9 @@ static int hclgevf_init(void) { pr_info("%s is initializing\n", HCLGEVF_NAME); - return hnae3_register_ae_algo(&ae_algovf); + hnae3_register_ae_algo(&ae_algovf); + + return 0; } static void hclgevf_exit(void) From patchwork Tue May 15 18:20:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 135917 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1371594lji; Tue, 15 May 2018 11:21:29 -0700 (PDT) X-Google-Smtp-Source: AB8JxZptslyD8vxsbLNekKyfMPpIWHI37TVcmvV2SA19YjDx6JsCRzdqoZJgRidthByyIjrs86YO X-Received: by 2002:a63:4207:: with SMTP id p7-v6mr4474326pga.163.1526408489178; Tue, 15 May 2018 11:21:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526408489; cv=none; d=google.com; s=arc-20160816; b=ANK9qk+MBKNQTGNlqcpm1yo7diS2lTF/TjUTRbHp2+FAuzzLflAZcwucadx2PQ0Eh0 IwRT8bc4W+bZcMCpHzkWJqipCsrCuboIr3oiYHRHz+UFwpzCADME0FWtwAqqeR0iTYan DWQg5NUiuhZ2L1inU3n/FDyqZiqek4Du5gTl9LXv4xbRbTICECb0JEM7Gkc6/mnRA4RD X9rcaQTeElGtvLDjVf6CNZYTJK4E7OaLBbApFI1M+0YEXnxpSVTkXC5af4izzpxNVzd3 IwfhlqiQaBuq7C8cPpLdTRmarcBPTaZdE0UYYMZ5ZHlBhjkrPXvAZJeEqKiKDdxd+7Jw nQHA== 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=Se4cTjiZyYDQx20AszUxuAZxQnm9gwyofM35OV/MjPw=; b=ZYlDwKZV9jsT+ZafQTSR5q1uFyZQ9L2SUEhclyzBfWOoSSL4A5j/0YcMwqPkj2N1MY MhbXyuX3BU8pcaqVWM6rnb+jCBisl2fwapEObBG2w6h7DDdN7zVltqRtMqE5gJXy8VZ5 JvyKAzy3VyCfQ63fcKPhU8as7ZULRclwvlgTba6nJ8f9CmX/V4GZtB9b4XUNB9xwvEmy H5H67ebrT16SuvN9UvcwUH3lHKkwJ5jlsNPhSAz5UacYZOra1b3Z3ysKepwgUvVVdr9j DLjwTvCXRJP3AKVnMfM5sGb7+3zMAW8Gi+atlwQKXkNFn3Fmkz9nKv9NtGtFCBgI2pWN 0ydw== 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 x4-v6si446329pgc.411.2018.05.15.11.21.28; Tue, 15 May 2018 11:21:29 -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 S1753490AbeEOSVZ (ORCPT + 29 others); Tue, 15 May 2018 14:21:25 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:59893 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751859AbeEOSVV (ORCPT ); Tue, 15 May 2018 14:21:21 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 12D1134A6D796; Wed, 16 May 2018 02:21:17 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.227.234) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.382.0; Wed, 16 May 2018 02:21:13 +0800 From: Salil Mehta To: CC: , , , , , , , Fuyun Liang Subject: [PATCH net-next 06/10] net: hns3: Change return value in hnae3_register_client Date: Tue, 15 May 2018 19:20:10 +0100 Message-ID: <20180515182014.42196-7-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180515182014.42196-1-salil.mehta@huawei.com> References: <20180515182014.42196-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.234] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fuyun Liang A client includes many client instance. Just like ae_algo, Initializing client instance failed does not represent registering client failed. The action of registering client just is adding client to the client list and the result always is true. This patch changes the return value of hnae3_register_client form a variable value to a fixed value, makes the function always return ok. Signed-off-by: Fuyun Liang Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hnae3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.c b/drivers/net/ethernet/hisilicon/hns3/hnae3.c index 3b1c396..bd3c232 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.c +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.c @@ -98,7 +98,7 @@ int hnae3_register_client(struct hnae3_client *client) exit: mutex_unlock(&hnae3_common_lock); - return ret; + return 0; } EXPORT_SYMBOL(hnae3_register_client); From patchwork Tue May 15 18:20:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 135919 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1371841lji; Tue, 15 May 2018 11:21:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrqaRZY9+h5dfQxqWckg58L+JY5IlZKZ6Vo3N93vdb7+NgFBf/ngn0lGKhLSORSZ2exxOVl X-Received: by 2002:a63:6c04:: with SMTP id h4-v6mr13281784pgc.220.1526408502880; Tue, 15 May 2018 11:21:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526408502; cv=none; d=google.com; s=arc-20160816; b=UJwfQ/EokOoNK00VIG7loqoowvNxexRcybUxCG5eEj1TpPR3BnJBZoTfpLpnY7IzsK k3hcuOb4HlsZJ8tEUmFpzh/ScYZnVmgh74+ldWURPTWv6bIM6Q2taJ2K1HOFWbp1Qn+p VFsC20nwceXqTVza4GJDiKwgGvZH7h8qHSxQ6MzXEVG0lXgmkcv/7vtyalh+e0lpL+u6 CQEwzWB1ULKMuJNm4asbKQCldq/QHzRI9oVHdOTjO13HLdMV55VGF/7S3ctr7fQmXBE2 ypuFEk54DqN+8QIDFcwWS52MOxSye6s3OrYSBvtZv8MuqFclapzp3tYZ293w6wSgXBdL ZwKg== 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=IVLRaEsn86mPby4246hyrwxJT8ox6EQB7FSAwoyiDPY=; b=o04nvy2KjpkiQ/KGm6VuARweziWdVTLfa1C1ukjnXXnwdEpSh41k9fxyNuM7TjKmN+ JXTQUdZdfRLVqwVof3NsBSnGSSJ81SDEyOb5A0hNB+zYbmlQd8wCmqCHbGmJK2nq1Tw6 gNU2Ff79GOD/D5B27ip8cdARwC7nEvEInF2cPZcXV4TYxu8uc/i9OiI6sIscjfj6t6Yq fQ6gk8+JKN/IeNR6iCHRSpgwbqRT1OujTY73nhDpvLWRc+PhX/7L2VmbBqhDadzCi6XT evZB/gGVq0Dsbrlb1kN/NoAMZ+skSXpD6l4UBwhQdfv6btmn47I4MawLkCcTe+F2tPgA elVQ== 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 v5-v6si591477plo.166.2018.05.15.11.21.42; Tue, 15 May 2018 11:21:42 -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 S1753742AbeEOSVj (ORCPT + 29 others); Tue, 15 May 2018 14:21:39 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:7690 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751859AbeEOSVg (ORCPT ); Tue, 15 May 2018 14:21:36 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 09F6430A24B4D; Wed, 16 May 2018 02:21:22 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.227.234) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.382.0; Wed, 16 May 2018 02:21:15 +0800 From: Salil Mehta To: CC: , , , , , , , Yunsheng Lin Subject: [PATCH net-next 07/10] net: hns3: Fixes the back pressure setting When sriov is enabled Date: Tue, 15 May 2018 19:20:11 +0100 Message-ID: <20180515182014.42196-8-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180515182014.42196-1-salil.mehta@huawei.com> References: <20180515182014.42196-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.234] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yunsheng Lin When sriov is enabled, the Qset and tc mapping is not longer one to one relation. This patch fixes it by mapping all pf and vf's Qset to tc. Fixes: 848440544b41 ("net: hns3: Add support of TX Scheduler & Shaper to HNS3 driver") Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c | 45 +++++++++++++++++++--- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h | 5 +++ 2 files changed, 45 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c index c69ecab..262c125 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c @@ -500,7 +500,8 @@ static int hclge_tm_qs_schd_mode_cfg(struct hclge_dev *hdev, u16 qs_id, u8 mode) return hclge_cmd_send(&hdev->hw, &desc, 1); } -static int hclge_tm_qs_bp_cfg(struct hclge_dev *hdev, u8 tc) +static int hclge_tm_qs_bp_cfg(struct hclge_dev *hdev, u8 tc, u8 grp_id, + u32 bit_map) { struct hclge_bp_to_qs_map_cmd *bp_to_qs_map_cmd; struct hclge_desc desc; @@ -511,9 +512,8 @@ static int hclge_tm_qs_bp_cfg(struct hclge_dev *hdev, u8 tc) bp_to_qs_map_cmd = (struct hclge_bp_to_qs_map_cmd *)desc.data; bp_to_qs_map_cmd->tc_id = tc; - - /* Qset and tc is one by one mapping */ - bp_to_qs_map_cmd->qs_bit_map = cpu_to_le32(1 << tc); + bp_to_qs_map_cmd->qs_group_id = grp_id; + bp_to_qs_map_cmd->qs_bit_map = cpu_to_le32(bit_map); return hclge_cmd_send(&hdev->hw, &desc, 1); } @@ -1167,6 +1167,41 @@ static int hclge_pfc_setup_hw(struct hclge_dev *hdev) hdev->tm_info.hw_pfc_map); } +/* Each Tc has a 1024 queue sets to backpress, it divides to + * 32 group, each group contains 32 queue sets, which can be + * represented by u32 bitmap. + */ +static int hclge_bp_setup_hw(struct hclge_dev *hdev, u8 tc) +{ + struct hclge_vport *vport = hdev->vport; + u32 i, k, qs_bitmap; + int ret; + + for (i = 0; i < HCLGE_BP_GRP_NUM; i++) { + qs_bitmap = 0; + + for (k = 0; k < hdev->num_alloc_vport; k++) { + u16 qs_id = vport->qs_offset + tc; + u8 grp, sub_grp; + + grp = hnae_get_field(qs_id, HCLGE_BP_GRP_ID_M, + HCLGE_BP_GRP_ID_S); + sub_grp = hnae_get_field(qs_id, HCLGE_BP_SUB_GRP_ID_M, + HCLGE_BP_SUB_GRP_ID_S); + if (i == grp) + qs_bitmap |= (1 << sub_grp); + + vport++; + } + + ret = hclge_tm_qs_bp_cfg(hdev, tc, i, qs_bitmap); + if (ret) + return ret; + } + + return 0; +} + static int hclge_mac_pause_setup_hw(struct hclge_dev *hdev) { bool tx_en, rx_en; @@ -1218,7 +1253,7 @@ int hclge_pause_setup_hw(struct hclge_dev *hdev) dev_warn(&hdev->pdev->dev, "set pfc pause failed:%d\n", ret); for (i = 0; i < hdev->tm_info.num_tc; i++) { - ret = hclge_tm_qs_bp_cfg(hdev, i); + ret = hclge_bp_setup_hw(hdev, i); if (ret) return ret; } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h index 2dbe177..c2b6e8a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h @@ -89,6 +89,11 @@ struct hclge_pg_shapping_cmd { __le32 pg_shapping_para; }; +#define HCLGE_BP_GRP_NUM 32 +#define HCLGE_BP_SUB_GRP_ID_S 0 +#define HCLGE_BP_SUB_GRP_ID_M GENMASK(4, 0) +#define HCLGE_BP_GRP_ID_S 5 +#define HCLGE_BP_GRP_ID_M GENMASK(9, 5) struct hclge_bp_to_qs_map_cmd { u8 tc_id; u8 rsvd[2]; From patchwork Tue May 15 18:20:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 135921 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1373228lji; Tue, 15 May 2018 11:22:58 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqbj/v+PT31aWsQpb1E1zsHwRToU3Dn5IsRNGxU++E0MArghKXsC4WD7ZmfUcMBsHQx2oT2 X-Received: by 2002:a62:8605:: with SMTP id x5-v6mr16244399pfd.103.1526408578245; Tue, 15 May 2018 11:22:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526408578; cv=none; d=google.com; s=arc-20160816; b=F+K6kVrHuz/nEywk7re38m7KsIbs9FZoCvB9lDqZcCGvEKo2gnXuQ1XrhAH9Txrxv8 Hebc62G+aBrI0/uo8pa1TeMkEdyY6FZnqF7QKJaLXpTMQjJHlAHdZt6p9srjE8e9P2+2 seaDHbW5NK5c8/7WQUoAdCUbdSYcPHU7Szh/vm2uNziTu/AVgRiZnQWm2d//VC+WyM3c j0FxWEjJwsq3Wu4FALQsCFilmjz7cW/OzFnXyFqLnduuaCau7UaRoTFg8zp7BQj0FPjQ ivtN05qYjKKs/jSSmXBln0GJ+gdb+g44FAiA6f2rQnMPUZH4hRMg+qg8IMTxHWJFOtu7 X/dQ== 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=vYxp/2MJWYKRZhjs6uMi7MhS3IKyKznaDGakv4I0b7M=; b=qJlNe4PJhh6Xch8Nzv5xmc1RHUI5bqBYVswQ/tnUZm5FbAV4acyM4OgqxHqNeYT+MC NDJFNEQvaUnxuMIZt/sReiTbkd+eetDjGFoQjMBRFJgGt/EM00LjssGnuqy0dFG7xuqX 92f015b9NHFKV3JZE3Fqs4Paarzkr0xzdA4mtA/9qgGTIdKeyUT/FKFvEcR2g7GzEXmP ulDtckPm7ynWTsVqYDj4SPicWgY0Kik2Zw2qrbX7nSVkB1WIRzHv/wejJnoS8ct04e8q Hfs5OLkhOM2w6ROYAzBTsOm1sZCtuAwgngD5/WTBuSti5APIYU7dBxcjpMz7wK1DBLZ9 Twmw== 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 j28-v6si591161pfe.337.2018.05.15.11.22.57; Tue, 15 May 2018 11:22:58 -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 S1753577AbeEOSVd (ORCPT + 29 others); Tue, 15 May 2018 14:21:33 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:59571 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752861AbeEOSVb (ORCPT ); Tue, 15 May 2018 14:21:31 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id D7546C55B3F7C; Wed, 16 May 2018 02:21:26 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.227.234) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.382.0; Wed, 16 May 2018 02:21:18 +0800 From: Salil Mehta To: CC: , , , , , , , Yunsheng Lin Subject: [PATCH net-next 08/10] net: hns3: Fix for fiber link up problem Date: Tue, 15 May 2018 19:20:12 +0100 Message-ID: <20180515182014.42196-9-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180515182014.42196-1-salil.mehta@huawei.com> References: <20180515182014.42196-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.234] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yunsheng Lin When hclge_ae_start is called, hdev->hw.mac.link may be set to one after up/down multi-times, which does not correspond to the link state of netdev when the netdev is up. This fixes it by setting hdev->hw.mac.link to zero when hclge_ae_start is called. Fixes: 46a3df9f9718 ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support") Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 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 d060903..75d9b8c 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -3756,6 +3756,7 @@ static int hclge_ae_start(struct hnae3_handle *handle) hclge_cfg_mac_mode(hdev, true); clear_bit(HCLGE_STATE_DOWN, &hdev->state); mod_timer(&hdev->service_timer, jiffies + HZ); + hdev->hw.mac.link = 0; /* reset tqp stats */ hclge_reset_tqp_stats(handle); @@ -3792,7 +3793,6 @@ static void hclge_ae_stop(struct hnae3_handle *handle) /* reset tqp stats */ hclge_reset_tqp_stats(handle); - hclge_update_link_status(hdev); } static int hclge_get_mac_vlan_cmd_status(struct hclge_vport *vport, From patchwork Tue May 15 18:20:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 135918 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1371708lji; Tue, 15 May 2018 11:21:36 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr6cK8oU8JHuyMtQN/+BZQeS5Hv+7EW5DDMIA/+RnF4bMkofwJFCO7PNw//YgIBiJlbpc+q X-Received: by 2002:a17:902:bb83:: with SMTP id m3-v6mr15549011pls.236.1526408496300; Tue, 15 May 2018 11:21:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526408496; cv=none; d=google.com; s=arc-20160816; b=LRqLNXeCdLqZ6Ldz7q6P8OWib5xoWafMoZqHj+UHFPBqdoSwDD80WALI0rHjfA4Q7F rNr8T9jxiKzUU1lA5GAd3zWvt2pQ3nqaW7Z6TShg9bqdihsFwXsuti5BLIlmrQMN0Hna +oq5GpOTXLKX8x8RTmoyQSt4SAlwA/Ry4f5gEuuxW+D2fHHnihQy49t/iKBX2F9xWC3X Y18din4hY4D2TgbKDAzdUHRVyHhlkqvE0WzsKbzWp2tox/YmGTWUlkBL1Pih5YT9kAUo FKIuQldJWsBkwM1fahVjJik4vSvjbR+sA7VCRaz8aY3J9mzD/aTKUdCMLQ3XFQRTkVU1 Nt2Q== 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=t+JZbugqxwT3h4Q18jAZg+ymLtM+E4GWP2trQVyQyu8=; b=VY3m0VdlVJZDMLi6cEw4dPCx1kmPu4RalQ07l1F8zxo9gMxiP76No3kMTkEa3atOo+ AWwEpk26gtPayWoTTAQncgeEEvkv/YjSv6RFlf4PD+of7fA0mKdDJDmfIkRut4PUufis bcAW5P2Rdu0Mz9BNUT+SMQfok/Wjkb+Vu+xdqnUjQpoI65PomKOPYV6rBWdk0VXu3mcg A3qQDVAz35IKSHo8tNgkLk8QdGx0Tk7kqVt5ZG1rTFLN1+HlXjrmfQrJW+MPksdh/Pnl tR1qekxoHMQ3pKy1PehQjH24+yELR4FWYEzuPlD+eAAgDMUq19bZxdbeCir57j9B+g0E oW4g== 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 x4-v6si446329pgc.411.2018.05.15.11.21.36; Tue, 15 May 2018 11:21:36 -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 S1753677AbeEOSVe (ORCPT + 29 others); Tue, 15 May 2018 14:21:34 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:59564 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751859AbeEOSVb (ORCPT ); Tue, 15 May 2018 14:21:31 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id C8A69EA251E04; Wed, 16 May 2018 02:21:26 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.227.234) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.382.0; Wed, 16 May 2018 02:21:21 +0800 From: Salil Mehta To: CC: , , , , , , Subject: [PATCH net-next 09/10] net: hns3: Add support of .sriov_configure in HNS3 driver Date: Tue, 15 May 2018 19:20:13 +0100 Message-ID: <20180515182014.42196-10-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180515182014.42196-1-salil.mehta@huawei.com> References: <20180515182014.42196-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.234] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peng Li As HNS3 driver will enable SRIOV default and enable all VFs the HW support, if PF and VF driver compiled to kernel, VF driver will work on host default, it is not right. This patch adds support for hns3_driver.sriov_configure to support user configs the VF_num, and do not enable sriov default. Signed-off-by: Peng Li Suggested-by: Zhou Wang Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 58 ++++++++++++++----------- 1 file changed, 32 insertions(+), 26 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index ac75b5d..e85ff38 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -1511,29 +1511,6 @@ static bool hns3_is_phys_func(struct pci_dev *pdev) return false; } -static int get_num_req_vfs(struct pci_dev *pdev) -{ - /* a variable vf num will be supported later */ - return pci_sriov_get_totalvfs(pdev); -} - -static void hns3_enable_sriov(struct pci_dev *pdev) -{ - int num_req_vfs = get_num_req_vfs(pdev); - int ret; - - /* Enable SRIOV */ - if (!num_req_vfs) - return; - - dev_info(&pdev->dev, "active VFs(%d) found, enabling SRIOV\n", - num_req_vfs); - - ret = pci_enable_sriov(pdev, num_req_vfs); - if (ret) - dev_err(&pdev->dev, "SRIOV enable failed %d\n", ret); -} - static void hns3_disable_sriov(struct pci_dev *pdev) { /* If our VFs are assigned we cannot shut down SR-IOV @@ -1578,9 +1555,6 @@ static int hns3_probe(struct pci_dev *pdev, const struct pci_device_id *ent) hnae3_register_ae_dev(ae_dev); - if (hns3_is_phys_func(pdev) && IS_ENABLED(CONFIG_PCI_IOV)) - hns3_enable_sriov(pdev); - return 0; } @@ -1597,11 +1571,43 @@ static void hns3_remove(struct pci_dev *pdev) hnae3_unregister_ae_dev(ae_dev); } +/** + * hns3_pci_sriov_configure + * @pdev: pointer to a pci_dev structure + * @num_vfs: number of VFs to allocate + * + * Enable or change the number of VFs. Called when the user updates the number + * of VFs in sysfs. + **/ +int hns3_pci_sriov_configure(struct pci_dev *pdev, int num_vfs) +{ + int ret; + + if (!(hns3_is_phys_func(pdev) && IS_ENABLED(CONFIG_PCI_IOV))) { + dev_warn(&pdev->dev, "Can not config SRIOV\n"); + return -EINVAL; + } + + if (num_vfs) { + ret = pci_enable_sriov(pdev, num_vfs); + if (ret) + dev_err(&pdev->dev, "SRIOV enable failed %d\n", ret); + } else if (!pci_vfs_assigned(pdev)) { + pci_disable_sriov(pdev); + } else { + dev_warn(&pdev->dev, + "Unable to free VFs because some are assigned to VMs.\n"); + } + + return 0; +} + static struct pci_driver hns3_driver = { .name = hns3_driver_name, .id_table = hns3_pci_tbl, .probe = hns3_probe, .remove = hns3_remove, + .sriov_configure = hns3_pci_sriov_configure, }; /* set default feature to hns3 */ From patchwork Tue May 15 18:20:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 135920 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1371995lji; Tue, 15 May 2018 11:21:50 -0700 (PDT) X-Google-Smtp-Source: AB8JxZocpnKGFf66Y+SF4n28LfQwQBN5OPd103QcpyCPdu2PPIEL7++2jlMswAjHLNfEIUANA/Pu X-Received: by 2002:a63:3756:: with SMTP id g22-v6mr13460994pgn.257.1526408510082; Tue, 15 May 2018 11:21:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526408510; cv=none; d=google.com; s=arc-20160816; b=CM33ACaWfzSh634WDWm4ni4CU+hFcpf+06BZQZJptNDgpg4Q8FddjoE5vA79K8jT0+ 7ciPKRQr2kLKhHfeZ4LdI+2xT8i2GX20ual1PWfP0tOOrA5TC69RL7BzJwnmmgtw0JXB d9hqR+YYi3gKWYq+2DreWXj2rGRa6bUMuJRMYnsJoUx5GZNCQ7X4ONa9EWBCGRFDWf76 xMknCxg86uR66VnZcdstcsBMnNMaXgXYFlsIy4jk274EaK5NAJhUrPwdcpLYI34AlpV6 l7TMJmVg7L4VoWs3B11XzDaoWCarVuOu3yiKtYhBcz77gP6uPMYJF1pjWyVsmZbaIEOm S1GQ== 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=TYlDJQwdft9RiuZQggMa5jjyI/r9E+JuLXyXewhSxPE=; b=kFsc0RrINKJ+5RDC8zz02bN9H6XFzp1gVaIy5Yy6fnFfBf51uwiJq3rNb5+rwXUrEa vfXDbhjzU8I+j5xJXxlOXe7OEqH6l1TBHOaIqBtaJ1EY3sFI4OmpabQ0xBLKp4+IYEP+ wPkNYo883Ylk+blmgNzI5DdAyhJ5ZiXV7LK60wd2TXKJ6oedlPElQI9mA1hogbK3brDk ax2VMmlcHUBsMutL6M+GQfhHvyp7Ge4IebvahLCFPsE/4cxdTkSdlralVk+pElMyMXje IG8XgLqYaNDnS/tbbsiI09wVadFXPD1IwTip3mlUPy+2e4l2DRHnsnQERZWBiNqX+rVS w76g== 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 t13-v6si630373pfc.333.2018.05.15.11.21.49; Tue, 15 May 2018 11:21:50 -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 S1753872AbeEOSVs (ORCPT + 29 others); Tue, 15 May 2018 14:21:48 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:7691 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752485AbeEOSVq (ORCPT ); Tue, 15 May 2018 14:21:46 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 29047E25116EB; Wed, 16 May 2018 02:21:32 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.227.234) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.382.0; Wed, 16 May 2018 02:21:24 +0800 From: Salil Mehta To: CC: , , , , , , , Fuyun Liang Subject: [PATCH net-next 10/10] net: hns3: Fixes the missing PCI iounmap for various legs Date: Tue, 15 May 2018 19:20:14 +0100 Message-ID: <20180515182014.42196-11-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180515182014.42196-1-salil.mehta@huawei.com> References: <20180515182014.42196-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.234] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fuyun Liang We call pcim_iomap in hclge_pci_init, pcim_iounmap should be called in error handle of hclge_init_ae_dev. We call pcim_iomap in hclge_pci_init, but do not call pcim_iounmap in hclge_pci_uninit. When we remove the hclge.ko and insert it again, a problem that pci can not map will happen. pcim_iounmap need to be called in hclge_pci_uninit. 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 --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 2 ++ 1 file changed, 2 insertions(+) -- 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 75d9b8c..46435c8 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -5425,6 +5425,7 @@ static void hclge_pci_uninit(struct hclge_dev *hdev) { struct pci_dev *pdev = hdev->pdev; + pcim_iounmap(pdev, hdev->hw.io_base); pci_free_irq_vectors(pdev); pci_clear_master(pdev); pci_release_mem_regions(pdev); @@ -5589,6 +5590,7 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) err_cmd_uninit: hclge_destroy_cmd_queue(&hdev->hw); err_pci_uninit: + pcim_iounmap(pdev, hdev->hw.io_base); pci_clear_master(pdev); pci_release_regions(pdev); pci_disable_device(pdev);