From patchwork Wed Sep 19 17:29:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 147033 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp986693ljw; Wed, 19 Sep 2018 10:31:11 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbS6s0sPtFrGv3YuXha5qx+elMpJs05uwMnqNoCfqMvj6up+bTllZEzDqYLdlPoSXAsKXqs X-Received: by 2002:a65:5c83:: with SMTP id a3-v6mr33850338pgt.164.1537378270983; Wed, 19 Sep 2018 10:31:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537378270; cv=none; d=google.com; s=arc-20160816; b=EWvVFIRFjUsyeYV44s36d9GRgEMw/fW/+p3RLLKqYLuN5bp+29DHAGriWV+sFzmljc k0wyfDfvfnb74d78ipFIrrPNKmzLpyxRO6Q+VOHDp0sjmD9jlz3LW35wApTBc2Fr9eho lONi1ppoD+tY9a0r1Hs2me8CiW2CvrIVObbh98c7Dok2qlQ9a5uwL/DOKsykdf9+3b9f d0pOwiATc5w99Tcs5qUo2TQXK7P5+8uieTrtZr2wDLKFQxc2y0bAYZEZg5zPQAQG0pP3 rif8WMnHz94xRnPQR0PmV6PqOht02F2gz7OIxeGM6R4ynArHkgLYDS9ckCslW5wj31zt 8KAA== 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; bh=Sne03c2Q6EgsbD/+oNnqsXXD81K0xzJyJSrQtBMK1is=; b=LdZ1SlWj0TUGFboikMDD5PDok3hmzx5wrqk1MJ7bak8TDezgsaTvtwlDfs/AJnFrxN 80Eb5Mbbff2rBL1boIylG+GA5PnC2c9E4civhJyAiIKt3IMhtIlszu0DWyuXENQBWMDn ooYlfCLk11goukqKn2+xSr/WNPYiFNUKxhM46Q0WWc9QJTHhTk3B/t7PmjqsTucwSVqp 4QVdSF2of2qGfQGFplMn1xVMQMcbaFGq/nuEY3Th6611cxmZNZrNv3ZezSk0hNo8neuF czP+PsuQgyorF+kCSAEOHiaH/PFM1oUnfU3vJoZTUdMq+yVGQptQAsctb2dgHpn4O7N6 Ffzw== 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 k3-v6si21143200pld.6.2018.09.19.10.31.10; Wed, 19 Sep 2018 10:31:10 -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 S1733142AbeISXKE (ORCPT + 10 others); Wed, 19 Sep 2018 19:10:04 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:12206 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1733104AbeISXKE (ORCPT ); Wed, 19 Sep 2018 19:10:04 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 0A155DE362B08; Thu, 20 Sep 2018 01:31:03 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.226.54) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.399.0; Thu, 20 Sep 2018 01:30:56 +0800 From: Salil Mehta To: CC: , , , , , , Subject: [PATCH net-next 01/12] net: hns3: Add default irq affinity Date: Wed, 19 Sep 2018 18:29:47 +0100 Message-ID: <20180919172958.12992-2-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180919172958.12992-1-salil.mehta@huawei.com> References: <20180919172958.12992-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.226.54] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Peng Li All irq will float to cpu0 if do not set irq affinity. This patch adds default irq affinity in hns3 driver, users can also change the irq affinity in OS. Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 49 +++++++++++++++++++++++++ drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 2 + 2 files changed, 51 insertions(+) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 75e8ee9..052b7fb 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -66,6 +66,23 @@ static irqreturn_t hns3_irq_handle(int irq, void *vector) return IRQ_HANDLED; } +/* This callback function is used to set affinity changes to the irq affinity + * masks when the irq_set_affinity_notifier function is used. + */ +static void hns3_nic_irq_affinity_notify(struct irq_affinity_notify *notify, + const cpumask_t *mask) +{ + struct hns3_enet_tqp_vector *tqp_vectors = + container_of(notify, struct hns3_enet_tqp_vector, + affinity_notify); + + tqp_vectors->affinity_mask = *mask; +} + +static void hns3_nic_irq_affinity_release(struct kref *ref) +{ +} + static void hns3_nic_uninit_irq(struct hns3_nic_priv *priv) { struct hns3_enet_tqp_vector *tqp_vectors; @@ -77,6 +94,10 @@ static void hns3_nic_uninit_irq(struct hns3_nic_priv *priv) if (tqp_vectors->irq_init_flag != HNS3_VECTOR_INITED) continue; + /* clear the affinity notifier and affinity mask */ + irq_set_affinity_notifier(tqp_vectors->vector_irq, NULL); + irq_set_affinity_hint(tqp_vectors->vector_irq, NULL); + /* release the irq resource */ free_irq(tqp_vectors->vector_irq, tqp_vectors); tqp_vectors->irq_init_flag = HNS3_VECTOR_NOT_INITED; @@ -127,6 +148,15 @@ static int hns3_nic_init_irq(struct hns3_nic_priv *priv) return ret; } + tqp_vectors->affinity_notify.notify = + hns3_nic_irq_affinity_notify; + tqp_vectors->affinity_notify.release = + hns3_nic_irq_affinity_release; + irq_set_affinity_notifier(tqp_vectors->vector_irq, + &tqp_vectors->affinity_notify); + irq_set_affinity_hint(tqp_vectors->vector_irq, + &tqp_vectors->affinity_mask); + tqp_vectors->irq_init_flag = HNS3_VECTOR_INITED; } @@ -2640,6 +2670,23 @@ static void hns3_add_ring_to_group(struct hns3_enet_ring_group *group, group->count++; } +static void hns3_nic_set_cpumask(struct hns3_nic_priv *priv) +{ + struct pci_dev *pdev = priv->ae_handle->pdev; + struct hns3_enet_tqp_vector *tqp_vector; + int num_vectors = priv->vector_num; + int numa_node; + int vector_i; + + numa_node = dev_to_node(&pdev->dev); + + for (vector_i = 0; vector_i < num_vectors; vector_i++) { + tqp_vector = &priv->tqp_vector[vector_i]; + cpumask_set_cpu(cpumask_local_spread(vector_i, numa_node), + &tqp_vector->affinity_mask); + } +} + static int hns3_nic_init_vector_data(struct hns3_nic_priv *priv) { struct hnae3_ring_chain_node vector_ring_chain; @@ -2648,6 +2695,8 @@ static int hns3_nic_init_vector_data(struct hns3_nic_priv *priv) int ret = 0; u16 i; + hns3_nic_set_cpumask(priv); + for (i = 0; i < priv->vector_num; i++) { tqp_vector = &priv->tqp_vector[i]; hns3_vector_gl_rl_init_hw(tqp_vector, priv); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index cb450d7..31fa21f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -491,7 +491,9 @@ struct hns3_enet_tqp_vector { struct hns3_enet_ring_group rx_group; struct hns3_enet_ring_group tx_group; + cpumask_t affinity_mask; u16 num_tqps; /* total number of tqps in TQP vector */ + struct irq_affinity_notify affinity_notify; char name[HNAE3_INT_NAME_LEN]; From patchwork Wed Sep 19 17:29:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 147042 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp987207ljw; Wed, 19 Sep 2018 10:31:39 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYRPi423zRSqIjr2rPNbCbYTOjNRtqes9wlEPKq6jHWGY2506eEBoHIpN0LoZc3VgVvZ9FI X-Received: by 2002:a63:d54e:: with SMTP id v14-v6mr33950633pgi.264.1537378298992; Wed, 19 Sep 2018 10:31:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537378298; cv=none; d=google.com; s=arc-20160816; b=UCPDn+454S5lXMgNPeCWqim/8UkykiOcHYznOJbWayexzWRanx2P8W8Rwb3hCc82wf mk2KBaJUELfD/OivVhOlvWPSQ71CgHvjgKlV40r56nXMS7evdrKfJhyCs7IauEZprwAN RTUE4ag9b1L0pvhbz8x17mie9dB1UnFv9OZTF54/LCKzTlrNAfCv5jsgMfuANenDJrbL cuP9FlUxCDBN03jbC48cQOHlyDvbrrUBKHVnOdxJ1WA5kJ+FgHpQWHQYmC7tjMfnjpvE JJ9/lRZEHQtmAfu1xjlfkYGPyrVO3LuFeptShpJ1t1Ans+s9DCrnU5Y3GOtbahB61+GS Rz6Q== 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; bh=9EgZeXk7+t7niysXIrU3/oXmTvTySIZThr4al5Bh83U=; b=LhTIjGb5QbDz1qe16P3QJ9aWAKAZKHoIr7RwO0+KK/v7G6K3mD6pS5YvXrIO3u93G8 /MOTaXRjiCgC1rS8EMw8TIh2ZTRu5z9HGGLLpRPKKRST3BnonuO8MSdNJI8QuoYJ4YJy WsrS/MIXPpfpmy0ZDXMcJUS7L1TH6tTAW9cd76GX4JHnS1uvpCoTuh9NUfrumks5ohZD yXducTTr/miVRetrA1IAaeNI/FToGsWSa0lQ1/llYXSaJpNZY5zYUS+U8+Fd3rbYKhNk g8vLY4dc8FqBFESYeP22pPnyRwGOfrQcOsoJ6ycRu+kxxAoiiQBygODrdmGkDZhoR4Nr FNcg== 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 z1-v6si21622679pln.63.2018.09.19.10.31.38; Wed, 19 Sep 2018 10:31:38 -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 S1733312AbeISXKc (ORCPT + 10 others); Wed, 19 Sep 2018 19:10:32 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:12211 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732840AbeISXK3 (ORCPT ); Wed, 19 Sep 2018 19:10:29 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 6D38C40057760; Thu, 20 Sep 2018 01:31:28 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.226.54) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.399.0; Thu, 20 Sep 2018 01:31:20 +0800 From: Salil Mehta To: CC: , , , , , , , Jian Shen Subject: [PATCH net-next 10/12] net: hns3: Clear client pointer when initialize client failed or unintialize finished Date: Wed, 19 Sep 2018 18:29:56 +0100 Message-ID: <20180919172958.12992-11-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180919172958.12992-1-salil.mehta@huawei.com> References: <20180919172958.12992-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.226.54] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jian Shen If initialize client failed or finish uninitializing client, we should clear the client pointer. It may cause unexpected result when use uninitialized client. Meanwhile, we also should check whether client exist when uninitialize it. Fixes: 46a3df9f9718 ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support") Signed-off-by: Jian Shen Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 25 ++++++++++------ .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 33 ++++++++++++++++------ 2 files changed, 41 insertions(+), 17 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 8a50688..141da18 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -5162,13 +5162,13 @@ static int hclge_init_client_instance(struct hnae3_client *client, vport->nic.client = client; ret = client->ops->init_instance(&vport->nic); if (ret) - return ret; + goto clear_nic; ret = hclge_init_instance_hw(hdev); if (ret) { client->ops->uninit_instance(&vport->nic, 0); - return ret; + goto clear_nic; } if (hdev->roce_client && @@ -5177,11 +5177,11 @@ static int hclge_init_client_instance(struct hnae3_client *client, ret = hclge_init_roce_base_info(vport); if (ret) - return ret; + goto clear_roce; ret = rc->ops->init_instance(&vport->roce); if (ret) - return ret; + goto clear_roce; } break; @@ -5191,7 +5191,7 @@ static int hclge_init_client_instance(struct hnae3_client *client, ret = client->ops->init_instance(&vport->nic); if (ret) - return ret; + goto clear_nic; break; case HNAE3_CLIENT_ROCE: @@ -5203,16 +5203,25 @@ static int hclge_init_client_instance(struct hnae3_client *client, if (hdev->roce_client && hdev->nic_client) { ret = hclge_init_roce_base_info(vport); if (ret) - return ret; + goto clear_roce; ret = client->ops->init_instance(&vport->roce); if (ret) - return ret; + goto clear_roce; } } } return 0; + +clear_nic: + hdev->nic_client = NULL; + vport->nic.client = NULL; + return ret; +clear_roce: + hdev->roce_client = NULL; + vport->roce.client = NULL; + return ret; } static void hclge_uninit_client_instance(struct hnae3_client *client, @@ -5232,7 +5241,7 @@ static void hclge_uninit_client_instance(struct hnae3_client *client, } if (client->type == HNAE3_CLIENT_ROCE) return; - if (client->ops->uninit_instance) { + if (hdev->nic_client && client->ops->uninit_instance) { hclge_uninit_instance_hw(hdev); client->ops->uninit_instance(&vport->nic, 0); hdev->nic_client = NULL; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index 320043e..88cff5f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -1624,17 +1624,17 @@ static int hclgevf_init_client_instance(struct hnae3_client *client, ret = client->ops->init_instance(&hdev->nic); if (ret) - return ret; + goto clear_nic; if (hdev->roce_client && hnae3_dev_roce_supported(hdev)) { struct hnae3_client *rc = hdev->roce_client; ret = hclgevf_init_roce_base_info(hdev); if (ret) - return ret; + goto clear_roce; ret = rc->ops->init_instance(&hdev->roce); if (ret) - return ret; + goto clear_roce; } break; case HNAE3_CLIENT_UNIC: @@ -1643,7 +1643,7 @@ static int hclgevf_init_client_instance(struct hnae3_client *client, ret = client->ops->init_instance(&hdev->nic); if (ret) - return ret; + goto clear_nic; break; case HNAE3_CLIENT_ROCE: if (hnae3_dev_roce_supported(hdev)) { @@ -1654,15 +1654,24 @@ static int hclgevf_init_client_instance(struct hnae3_client *client, if (hdev->roce_client && hdev->nic_client) { ret = hclgevf_init_roce_base_info(hdev); if (ret) - return ret; + goto clear_roce; ret = client->ops->init_instance(&hdev->roce); if (ret) - return ret; + goto clear_roce; } } return 0; + +clear_nic: + hdev->nic_client = NULL; + hdev->nic.client = NULL; + return ret; +clear_roce: + hdev->roce_client = NULL; + hdev->roce.client = NULL; + return ret; } static void hclgevf_uninit_client_instance(struct hnae3_client *client, @@ -1671,13 +1680,19 @@ static void hclgevf_uninit_client_instance(struct hnae3_client *client, struct hclgevf_dev *hdev = ae_dev->priv; /* un-init roce, if it exists */ - if (hdev->roce_client) + if (hdev->roce_client) { hdev->roce_client->ops->uninit_instance(&hdev->roce, 0); + hdev->roce_client = NULL; + hdev->roce.client = NULL; + } /* un-init nic/unic, if this was not called by roce client */ - if ((client->ops->uninit_instance) && - (client->type != HNAE3_CLIENT_ROCE)) + if (client->ops->uninit_instance && hdev->nic_client && + client->type != HNAE3_CLIENT_ROCE) { client->ops->uninit_instance(&hdev->nic, 0); + hdev->nic_client = NULL; + hdev->nic.client = NULL; + } } static int hclgevf_pci_init(struct hclgevf_dev *hdev) From patchwork Wed Sep 19 17:29:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 147041 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp987158ljw; Wed, 19 Sep 2018 10:31:35 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYivWnxjyXgPF61bdsLBe3R+0bIG+M10whbjcjZFCpC8WQ+6VwgP3Fne6K6o+ih6QGw+S0l X-Received: by 2002:a62:bd4:: with SMTP id 81-v6mr37374437pfl.67.1537378295713; Wed, 19 Sep 2018 10:31:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537378295; cv=none; d=google.com; s=arc-20160816; b=R3SYYowSVLem+FGq0UugMgkS+YnrK81HTvl2U1a611FIC6TTKC/bYaONuZXMYByGfq 2232lRSd/hEDGGYecxcAynl2pF+bufqBksZadHvTpe+4d9xvROL6yd1A2qTvq5qb1KdB nPTV1xebucaNvbdmJ0wQ9+sdN2n3WAfHQYspzOuXCgYf92sM5EZR6yGAuV19bkl9bhfy q706UD66M23tFTr58XCr0eYschq7fciU/Zee0SfOobXKdq0HSZwS9ALBcmenbTeDCejt YCaYassqNBjUHZ1mjIXSsOkurf/FpHbFSTFjiTDxFhOMB9DgdDYTUyFfbycOzlVjPjU0 qf2g== 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; bh=MIFTWVTzQRspJjoIL1s0Ricyg67XadpzELWDhBNFoKs=; b=H9kvx0FyiqJtSOPYM5YXCQVAnjlFDNobZ2ZouyjIVhLBoIr1rlTHTk7Uc5UPI9Ndkt frYonTHsH1FXBIpmZ4hyQHUkidJcy6aft34U/rWN5H2VuCnGpyZidq0riBEz+9bpT1+n SbEdZtNRpyYUtBnHMifsaSsMaRwH2p4UXEWdZkS1olYSoOe2rF9dk0NONYbkH6Ww/Nqg VmVYgtjzD2obdRrqHmO/T1xfuhvbNwwWMvgjk9XFsrkTjVjGEyzmK0NUOaGq7MPkxCLY gW7UAWggJJdXDR4nE1izSR5rWzThZpZYmyWfU+4aWHNaiYbNSAyqZ0kTh+/F1lDtHU80 mKvw== 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 z1-v6si21622679pln.63.2018.09.19.10.31.35; Wed, 19 Sep 2018 10:31:35 -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 S1733295AbeISXK3 (ORCPT + 10 others); Wed, 19 Sep 2018 19:10:29 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:12212 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1733278AbeISXK3 (ORCPT ); Wed, 19 Sep 2018 19:10:29 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 7227C1B4826B6; Thu, 20 Sep 2018 01:31:28 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.226.54) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.399.0; Thu, 20 Sep 2018 01:31:23 +0800 From: Salil Mehta To: CC: , , , , , , , Jian Shen Subject: [PATCH net-next 11/12] net: hns3: Fix client initialize state issue when roce client initialize failed Date: Wed, 19 Sep 2018 18:29:57 +0100 Message-ID: <20180919172958.12992-12-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180919172958.12992-1-salil.mehta@huawei.com> References: <20180919172958.12992-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.226.54] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jian Shen When roce is loaded before nic, the roce client will not be initialized until nic client is initialized, but roce init flag is set before it. Furthermore, in this case of nic initialized success and roce failed, the nic init flag is not set, and roce init flag is not cleared. This patch fixes it by set init flag only after the client is initialized successfully. Fixes: e2cb1dec9779 ("net: hns3: Add HNS3 VF HCL(Hardware Compatibility Layer) Support") Fixes: 46a3df9f9718 ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support") Signed-off-by: Jian Shen Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hnae3.c | 12 +++++------- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 3 +++ drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 9 +++++++++ drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 9 +++++++++ 4 files changed, 26 insertions(+), 7 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.c b/drivers/net/ethernet/hisilicon/hns3/hnae3.c index fff5be8..781e5de 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.c +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.c @@ -29,8 +29,8 @@ static bool hnae3_client_match(enum hnae3_client_type client_type, return false; } -static void hnae3_set_client_init_flag(struct hnae3_client *client, - struct hnae3_ae_dev *ae_dev, int inited) +void hnae3_set_client_init_flag(struct hnae3_client *client, + struct hnae3_ae_dev *ae_dev, int inited) { switch (client->type) { case HNAE3_CLIENT_KNIC: @@ -46,6 +46,7 @@ static void hnae3_set_client_init_flag(struct hnae3_client *client, break; } } +EXPORT_SYMBOL(hnae3_set_client_init_flag); static int hnae3_get_client_init_flag(struct hnae3_client *client, struct hnae3_ae_dev *ae_dev) @@ -86,14 +87,11 @@ 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, ret = %d\n", ret); - return ret; - } - hnae3_set_client_init_flag(client, ae_dev, 1); - return 0; + return ret; } if (hnae3_get_client_init_flag(client, ae_dev)) { diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index c48c187..17db631 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -523,4 +523,7 @@ 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); + +void hnae3_set_client_init_flag(struct hnae3_client *client, + struct hnae3_ae_dev *ae_dev, int inited); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 141da18..cf365d4 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -5171,6 +5171,8 @@ static int hclge_init_client_instance(struct hnae3_client *client, goto clear_nic; } + hnae3_set_client_init_flag(client, ae_dev, 1); + if (hdev->roce_client && hnae3_dev_roce_supported(hdev)) { struct hnae3_client *rc = hdev->roce_client; @@ -5182,6 +5184,9 @@ static int hclge_init_client_instance(struct hnae3_client *client, ret = rc->ops->init_instance(&vport->roce); if (ret) goto clear_roce; + + hnae3_set_client_init_flag(hdev->roce_client, + ae_dev, 1); } break; @@ -5193,6 +5198,8 @@ static int hclge_init_client_instance(struct hnae3_client *client, if (ret) goto clear_nic; + hnae3_set_client_init_flag(client, ae_dev, 1); + break; case HNAE3_CLIENT_ROCE: if (hnae3_dev_roce_supported(hdev)) { @@ -5208,6 +5215,8 @@ static int hclge_init_client_instance(struct hnae3_client *client, ret = client->ops->init_instance(&vport->roce); if (ret) goto clear_roce; + + hnae3_set_client_init_flag(client, ae_dev, 1); } } } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index 88cff5f..166a2cf 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -1626,6 +1626,8 @@ static int hclgevf_init_client_instance(struct hnae3_client *client, if (ret) goto clear_nic; + hnae3_set_client_init_flag(client, ae_dev, 1); + if (hdev->roce_client && hnae3_dev_roce_supported(hdev)) { struct hnae3_client *rc = hdev->roce_client; @@ -1635,6 +1637,9 @@ static int hclgevf_init_client_instance(struct hnae3_client *client, ret = rc->ops->init_instance(&hdev->roce); if (ret) goto clear_roce; + + hnae3_set_client_init_flag(hdev->roce_client, ae_dev, + 1); } break; case HNAE3_CLIENT_UNIC: @@ -1644,6 +1649,8 @@ static int hclgevf_init_client_instance(struct hnae3_client *client, ret = client->ops->init_instance(&hdev->nic); if (ret) goto clear_nic; + + hnae3_set_client_init_flag(client, ae_dev, 1); break; case HNAE3_CLIENT_ROCE: if (hnae3_dev_roce_supported(hdev)) { @@ -1660,6 +1667,8 @@ static int hclgevf_init_client_instance(struct hnae3_client *client, if (ret) goto clear_roce; } + + hnae3_set_client_init_flag(client, ae_dev, 1); } return 0;