From patchwork Wed Nov 29 09:44:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junxian Huang X-Patchwork-Id: 171211 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp227078vqn; Wed, 29 Nov 2023 01:48:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IEpkXngr+5bCwIX/AcqwR/QiaZo/Y3MEmQEP1dXnuH2AeICaKA+Ai2jSAdyuEbS0jW2eaVO X-Received: by 2002:a05:6808:1a85:b0:3b8:60c2:8032 with SMTP id bm5-20020a0568081a8500b003b860c28032mr11084864oib.20.1701251304301; Wed, 29 Nov 2023 01:48:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701251304; cv=none; d=google.com; s=arc-20160816; b=vOFEUtv6h12gSX0hAAyosWBgbl2nYMRhizsMrSZ7L4EYaxo0g9ev/TVL5hk4CJMVOa yVD1JnJcVrZ3QU/Zn0ojfVNHQnHhM41coVgZrzwenLaVuwlPBNyDYtvXMcFpnZNXT/gc rQz8Ryy/2LCocZraltbk1tFA1gMar8Qlz3rFGWevbaKFmdwITM713zXYPY1IvBqXg7U8 8VbeDid4fEMdNQIzrTyv7KBy06FBpGU5KxdgKyIoke5wESIhCKhEaydLV5ikw75Vn2e9 MfWbRF1aR7s18MdeQIxG1YNEXA/ZxUb1X3lIs7cgqubtbFYxINJf4KZ3bpojk/yJ79Ec o2KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=DslqwWasc5dXLuSNcQ+0fxNTn4+nOS5dpXOGlVDc8WI=; fh=KWvyQxL3Ff+3WPSMjlYu+P4255AmcMULAsFol6M1vNI=; b=yIIMNvRc8tlamUwUjq2AnFt5bM+Id0wf9BdNfr1NatbkNV/Q6AQrDE49Wp3c598yky nzUjQv8cLcHepqm4tcO+FPbB0FlOfq0uBkrRyliroNpoarGbwkaa+v9tGzzHeXO9sFQl wldA3idpGVjmjDgs//5qFQpq/merIz1ErO6ytzkS6p22qxiUsVJJiJSgW02RwESgMukk gsm+0dGi5f9ABzm6iP+lcYkymK0QNf2z3W8nl166J15DHPYdgrwqFKREcQPRwroPmOzh FtDFMmsrX2NaI3KTXbvLHrOuMuJ9JIRNh1+FY3hHKnzabiyqfJe+LK+htWyN8GFam2dA YGHQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id y21-20020a63e255000000b0058974d3c296si14464744pgj.815.2023.11.29.01.48.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 01:48:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 24D8C80ACFF2; Wed, 29 Nov 2023 01:48:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229586AbjK2JsK (ORCPT + 99 others); Wed, 29 Nov 2023 04:48:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbjK2JsE (ORCPT ); Wed, 29 Nov 2023 04:48:04 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E810D1999; Wed, 29 Nov 2023 01:48:09 -0800 (PST) Received: from kwepemi500006.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SgDtj25spzsRSW; Wed, 29 Nov 2023 17:44:29 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemi500006.china.huawei.com (7.221.188.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 29 Nov 2023 17:48:07 +0800 From: Junxian Huang To: , CC: , , , Subject: [PATCH for-rc 1/6] RDMA/hns: Rename the interrupts Date: Wed, 29 Nov 2023 17:44:29 +0800 Message-ID: <20231129094434.134528-2-huangjunxian6@hisilicon.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231129094434.134528-1-huangjunxian6@hisilicon.com> References: <20231129094434.134528-1-huangjunxian6@hisilicon.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemi500006.china.huawei.com (7.221.188.68) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 29 Nov 2023 01:48:19 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783891287693723545 X-GMAIL-MSGID: 1783891287693723545 From: Chengchang Tang Now, different devices may have the same interrupt name, which makes it difficult for users to distinguish between these interrupts. Modify the naming style to be consistent with our network devices. Before: "hns-aeq-0" "hns-ceq-0" ... Now: "hns-0000:35:00.0-aeq-0" "hns-0000:35:00.0-ceq-0" ... Signed-off-by: Chengchang Tang Signed-off-by: Junxian Huang --- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index 2bca9560f32d..1ceeedfa225f 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -6457,15 +6457,16 @@ static int __hns_roce_request_irq(struct hns_roce_dev *hr_dev, int irq_num, /* irq contains: abnormal + AEQ + CEQ */ for (j = 0; j < other_num; j++) snprintf((char *)hr_dev->irq_names[j], HNS_ROCE_INT_NAME_LEN, - "hns-abn-%d", j); + "hns-%s-abn-%d", pci_name(hr_dev->pci_dev), j); for (j = other_num; j < (other_num + aeq_num); j++) snprintf((char *)hr_dev->irq_names[j], HNS_ROCE_INT_NAME_LEN, - "hns-aeq-%d", j - other_num); + "hns-%s-aeq-%d", pci_name(hr_dev->pci_dev), j - other_num); for (j = (other_num + aeq_num); j < irq_num; j++) snprintf((char *)hr_dev->irq_names[j], HNS_ROCE_INT_NAME_LEN, - "hns-ceq-%d", j - other_num - aeq_num); + "hns-%s-ceq-%d", pci_name(hr_dev->pci_dev), + j - other_num - aeq_num); for (j = 0; j < irq_num; j++) { if (j < other_num) From patchwork Wed Nov 29 09:44:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junxian Huang X-Patchwork-Id: 171216 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp227316vqn; Wed, 29 Nov 2023 01:49:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IG6myabnL0fuEGS6exes33A69gw+F5Ecml9AzxktlL+O/VF2OJtsbGZUmKAuGy++PX/gP7Y X-Received: by 2002:a05:6a00:391d:b0:6cd:a145:6703 with SMTP id fh29-20020a056a00391d00b006cda1456703mr7127977pfb.2.1701251343637; Wed, 29 Nov 2023 01:49:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701251343; cv=none; d=google.com; s=arc-20160816; b=zQs9FnbcM+MKcRaceLYcZ307FuxGbmHZCTmkZEbpINcZfCPaWj9VLfVuSzURY31Ri5 p/aJQibLljQF7OYaff+2t5qO0GECur33DX5n9omPlF6a8bMwHzp5XhZRDC8ACiQSlhly 8NHOxfUa4H2c7YaiGqh8pzO3EUD5N76kKxHOlr7m6DCB1FO9d0OxkMXKxCYbmbRaT0x2 tL5raNUFyC1jGAvv5v7JzQi/nJt9FlRxQVPn/mg39tuHgCCMNv/B3hkllkS3N78WZNbO 2/PTZXRDGbUmAG2RC6tOoqMM95VTZZW5mo0OfV/bNT9Mg3cpMHwmwylXZqQs284b3CXL MksA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=a9Ut8GSbSITiZkJy2z0+aKg0zYLnCn2Ax24C02Ipy3s=; fh=KWvyQxL3Ff+3WPSMjlYu+P4255AmcMULAsFol6M1vNI=; b=x90xC5a/LP4Ewa4nYjRJKdBRGO4AOw46C1UQKOwsvXBqZXI/A+o6iOXP7RsUcMVreE Oph5nfVt1hiWAAca1WEEjbywpfl65rubiRtk9GelfgKE+2AhGjBmGN32I04xRlohrJXm VjXfN8Zx6hrYPJebn/LUfRt0eL4hKNZ3wS7ranimpEG92SLrn4Zpcirl83XpS6ftMYe+ 3yzHoom/hVBrtshXWjr6LRj7Vo1lvzoYJ79PmZx3M1Bk2Q79VU0FifdRMwhbUD+ngH3B U7bJWtrkKbUcg0RZX56UwPVJIzAcCcH9L1UAOhw6c4gcr2ztCiC8Gt4eQutXA9RyfCMf l4sw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id e190-20020a6369c7000000b005c278464e08si13132787pgc.275.2023.11.29.01.49.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 01:49:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 1431080ACFF1; Wed, 29 Nov 2023 01:49:01 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230179AbjK2Js2 (ORCPT + 99 others); Wed, 29 Nov 2023 04:48:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229873AbjK2JsF (ORCPT ); Wed, 29 Nov 2023 04:48:05 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 031A819AB; Wed, 29 Nov 2023 01:48:10 -0800 (PST) Received: from kwepemi500006.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SgDyJ4hZ5zvR8t; Wed, 29 Nov 2023 17:47:36 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemi500006.china.huawei.com (7.221.188.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 29 Nov 2023 17:48:07 +0800 From: Junxian Huang To: , CC: , , , Subject: [PATCH for-rc 2/6] RDMA/hns: Response dmac to userspace Date: Wed, 29 Nov 2023 17:44:30 +0800 Message-ID: <20231129094434.134528-3-huangjunxian6@hisilicon.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231129094434.134528-1-huangjunxian6@hisilicon.com> References: <20231129094434.134528-1-huangjunxian6@hisilicon.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemi500006.china.huawei.com (7.221.188.68) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 29 Nov 2023 01:49:01 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783891328726297296 X-GMAIL-MSGID: 1783891328726297296 While creating AH, dmac is already resolved in kernel. Response dmac to userspace so that userspace doesn't need to resolve dmac repeatedly. Signed-off-by: Junxian Huang --- drivers/infiniband/hw/hns/hns_roce_ah.c | 7 +++++++ include/uapi/rdma/hns-abi.h | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/drivers/infiniband/hw/hns/hns_roce_ah.c b/drivers/infiniband/hw/hns/hns_roce_ah.c index 3df032ddda18..e839a83c4b8f 100644 --- a/drivers/infiniband/hw/hns/hns_roce_ah.c +++ b/drivers/infiniband/hw/hns/hns_roce_ah.c @@ -57,6 +57,7 @@ int hns_roce_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *init_attr, struct rdma_ah_attr *ah_attr = init_attr->ah_attr; const struct ib_global_route *grh = rdma_ah_read_grh(ah_attr); struct hns_roce_dev *hr_dev = to_hr_dev(ibah->device); + struct hns_roce_ib_create_ah_resp resp = {}; struct hns_roce_ah *ah = to_hr_ah(ibah); int ret = 0; u32 max_sl; @@ -97,6 +98,12 @@ int hns_roce_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *init_attr, ah->av.vlan_en = ah->av.vlan_id < VLAN_N_VID; } + if (udata) { + memcpy(resp.dmac, ah_attr->roce.dmac, ETH_ALEN); + ret = ib_copy_to_udata(udata, &resp, + min(udata->outlen, sizeof(resp))); + } + return ret; } diff --git a/include/uapi/rdma/hns-abi.h b/include/uapi/rdma/hns-abi.h index ce0f37f83416..c996e151081e 100644 --- a/include/uapi/rdma/hns-abi.h +++ b/include/uapi/rdma/hns-abi.h @@ -125,4 +125,9 @@ struct hns_roce_ib_alloc_pd_resp { __u32 pdn; }; +struct hns_roce_ib_create_ah_resp { + __u8 dmac[6]; + __u8 reserved[2]; +}; + #endif /* HNS_ABI_USER_H */ From patchwork Wed Nov 29 09:44:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junxian Huang X-Patchwork-Id: 171213 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp227168vqn; Wed, 29 Nov 2023 01:48:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IFivpVNuVTvgN39TezlMIBxv0XezhWbQbo4NULkwaoca9GJ4YeICQTvxvxPlFZUNby/UqO6 X-Received: by 2002:a05:6830:6b42:b0:6bb:1c30:6f3c with SMTP id dc2-20020a0568306b4200b006bb1c306f3cmr22393107otb.0.1701251317454; Wed, 29 Nov 2023 01:48:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701251317; cv=none; d=google.com; s=arc-20160816; b=eBysmiDH+a/0YhgTHNdF8RTZa4gZJp7Krtne4GKF6+6ul+1EvbssePKwYg1H9u1728 6cAXkranLHJDJsyqbJTk+E1OqLa3efU1+gjTB3TdlqJ+Ieq2lTqBNMPIei59ijls9o3y cvXmNn9m8O6TVdGZGyNn64worN8uErTX3WOXbNHxgbztLORF9MrTQex85ePqAFobkffS Y1QuWKMISZ/kMPHhrP0IDMHYkoU91YU4d9UaEorHWrL28B5ArNFb/yWcTC5xtxHB2Spb jLLNnXih633qw6etl6icCgOU/Nn9nZcIW0YxfIWmtWtaFObhtjad2EBZy85MgyX8280a XRdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=P2rgTryUC7omMha5X6EMcPqS1AlWzrwrifAdAslVYwg=; fh=KWvyQxL3Ff+3WPSMjlYu+P4255AmcMULAsFol6M1vNI=; b=V77XkFclh8RjTM8emoO97780jseDPfNHj3QdVD3XqGO9xnnqvNlm3PqiXm42SNiAP3 mHaiU0BfFgOVYk+GDlptvDtHk8USXhArbvaEcPcSl9LoGyBq/G4yNCMLOKrCGNjLjJN+ m8Wdab1laiz+e/z8AOYi3Iz+qHwHuW0/4E/Rv0TGAsp8j8ClHFn5pb7NSZwPisXFXzmo YbxKzYUFWA7ydQ+J52mMiMr+2xhKNzkdbQuB8zR+8o2VEvk+/KVXqQDW1Suws3voIsSx EvZfdcxa/KZ1zqKbhZnrm6FUUw92OdnQDtHY3E5J3wNZ5NyXZrfaMXlhwzlaXsb5lb94 WUNA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id l190-20020a6325c7000000b0056f7f18bbfdsi14106395pgl.632.2023.11.29.01.48.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 01:48:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id DDD53803C977; Wed, 29 Nov 2023 01:48:32 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230267AbjK2JsW (ORCPT + 99 others); Wed, 29 Nov 2023 04:48:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229940AbjK2JsF (ORCPT ); Wed, 29 Nov 2023 04:48:05 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4811819B6; Wed, 29 Nov 2023 01:48:10 -0800 (PST) Received: from kwepemi500006.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SgDyJ70R0zvR9X; Wed, 29 Nov 2023 17:47:36 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemi500006.china.huawei.com (7.221.188.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 29 Nov 2023 17:48:08 +0800 From: Junxian Huang To: , CC: , , , Subject: [PATCH for-rc 3/6] RDMA/hns: Add a max length of gid table Date: Wed, 29 Nov 2023 17:44:31 +0800 Message-ID: <20231129094434.134528-4-huangjunxian6@hisilicon.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231129094434.134528-1-huangjunxian6@hisilicon.com> References: <20231129094434.134528-1-huangjunxian6@hisilicon.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemi500006.china.huawei.com (7.221.188.68) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 29 Nov 2023 01:48:33 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783891301507042804 X-GMAIL-MSGID: 1783891301507042804 IB-core and rdma-core restrict the sgid_index specified by users, which is uint8_t/u8 data type, to only be within the range of 0-255, so it's meaningless to support excessively large gid_table_len. On the other hand, ib-core creates as many sysfs gid files as gid_table_len, most of which are not only useless because of the reason above, but also greatly increase the traversal time of the sysfs gid files for applications. This patch limits the maximum length of gid table to 256. Signed-off-by: Junxian Huang --- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index 1ceeedfa225f..8126922b4e21 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -2055,6 +2055,7 @@ static void set_hem_page_size(struct hns_roce_dev *hr_dev) /* Apply all loaded caps before setting to hardware */ static void apply_func_caps(struct hns_roce_dev *hr_dev) { +#define MAX_GID_TBL_LEN 256 struct hns_roce_caps *caps = &hr_dev->caps; struct hns_roce_v2_priv *priv = hr_dev->priv; @@ -2090,8 +2091,14 @@ static void apply_func_caps(struct hns_roce_dev *hr_dev) caps->gmv_entry_sz = HNS_ROCE_V3_GMV_ENTRY_SZ; caps->gmv_hop_num = HNS_ROCE_HOP_NUM_0; - caps->gid_table_len[0] = caps->gmv_bt_num * - (HNS_HW_PAGE_SIZE / caps->gmv_entry_sz); + + /* It's meaningless to support excessively large gid_table_len, + * as the type of sgid_index in kernel struct ib_global_route + * and userspace struct ibv_global_route are u8/uint8_t (0-255). + */ + caps->gid_table_len[0] = min_t(u32, MAX_GID_TBL_LEN, + caps->gmv_bt_num * + (HNS_HW_PAGE_SIZE / caps->gmv_entry_sz)); caps->gmv_entry_num = caps->gmv_bt_num * (PAGE_SIZE / caps->gmv_entry_sz); From patchwork Wed Nov 29 09:44:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junxian Huang X-Patchwork-Id: 171214 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp227188vqn; Wed, 29 Nov 2023 01:48:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IEeh8WunVQTPE/LSi1t8yXmrQFScQcKzU1pCGpVm8G+1XGMIGIVgxPQi9pojQ05ItjA2K8S X-Received: by 2002:a05:6e02:12c1:b0:35c:c916:892b with SMTP id i1-20020a056e0212c100b0035cc916892bmr11279806ilm.4.1701251319719; Wed, 29 Nov 2023 01:48:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701251319; cv=none; d=google.com; s=arc-20160816; b=x8C0qw1c7aSn71NB+WFzXgAV8EVPsTbIZVQO8si60nLo3S+/Fl6DwvDlfyYl8xtw9x hVQymFym4SZU9j4oiABvgQU+itRdWjxqXD1Xo7EbfQ2kFa0fkvFSlhjtpC7y2Rlf+uHs QGLHZmR25qixZniB6pYB/9Pnl+slDZZKiz8n2LSqc5gwXcHPQZVhaBA0GbgdYMSWM5hE Qb6xOvV5AgJiezFKKzKo6tNhCK8hiUQYoosg3ajj6uYtqnJpbmHHWX/IB1WSDI5cNcYU f+bdRi3j5W1lA5yQ44ZJfgfdmsIiBOkhMOp6DuzlH5g9TCCskvQTg+p+wrL8BJzTA/+r lnlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=UKN523bBpFfhqNntK4E+t7LG85lba0F7vKfTvsWv+V8=; fh=KWvyQxL3Ff+3WPSMjlYu+P4255AmcMULAsFol6M1vNI=; b=K+XBJTSQHYTFrahqBsWhYxcVJiiUVswiwCjE6AByb+IEqKaCI9A2MigFiBQ44o6KpH iyVlZOWjvJnPPq7XSx5Y+aiCNdDBkbGlZV7dTXigx2/u31pKdZP4VEpLwCmvNpktnFpC C8psQfhYotbOkqn/203NjcgB/5YS5ODXDbd8mzlE0q/02IBIu+F7nYifwvqcstew/62l 2OSWe6SvzZ+gW1ZJMBSuxWx4q6vUpBUYzytOpV3LBuZyMzaVycSS0x0OlOLqzyfpwCk+ osbrCMdOnQst/EfRp9BEsw+iGPxcsaOg2lsmJ4+qAwSdasx3jSZuPI1WLqi2ZCPsMtFQ RHwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id j191-20020a6380c8000000b0057d7cff25b8si13268571pgd.198.2023.11.29.01.48.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 01:48:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 766D7805A5EB; Wed, 29 Nov 2023 01:48:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230260AbjK2JsP (ORCPT + 99 others); Wed, 29 Nov 2023 04:48:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229722AbjK2JsF (ORCPT ); Wed, 29 Nov 2023 04:48:05 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8150219BA; Wed, 29 Nov 2023 01:48:10 -0800 (PST) Received: from kwepemi500006.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SgDy46qc4zWhsd; Wed, 29 Nov 2023 17:47:24 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemi500006.china.huawei.com (7.221.188.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 29 Nov 2023 17:48:08 +0800 From: Junxian Huang To: , CC: , , , Subject: [PATCH for-rc 4/6] RDMA/hns: Remove unnecessary checks for NULL in mtr_alloc_bufs() Date: Wed, 29 Nov 2023 17:44:32 +0800 Message-ID: <20231129094434.134528-5-huangjunxian6@hisilicon.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231129094434.134528-1-huangjunxian6@hisilicon.com> References: <20231129094434.134528-1-huangjunxian6@hisilicon.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemi500006.china.huawei.com (7.221.188.68) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 29 Nov 2023 01:48:37 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783891303786016810 X-GMAIL-MSGID: 1783891303786016810 From: Chengchang Tang ib_umem_get() never return NULL. Fixes: 3c873161a0d7 ("RDMA/hns: Add support for addressing when hopnum is 0") Signed-off-by: Chengchang Tang Signed-off-by: Junxian Huang --- drivers/infiniband/hw/hns/hns_roce_mr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c b/drivers/infiniband/hw/hns/hns_roce_mr.c index 14376490ac22..e71988a6c277 100644 --- a/drivers/infiniband/hw/hns/hns_roce_mr.c +++ b/drivers/infiniband/hw/hns/hns_roce_mr.c @@ -674,7 +674,7 @@ static int mtr_alloc_bufs(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr, mtr->kmem = NULL; mtr->umem = ib_umem_get(ibdev, user_addr, total_size, buf_attr->user_access); - if (IS_ERR_OR_NULL(mtr->umem)) { + if (IS_ERR(mtr->umem)) { ibdev_err(ibdev, "failed to get umem, ret = %ld.\n", PTR_ERR(mtr->umem)); return -ENOMEM; From patchwork Wed Nov 29 09:44:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junxian Huang X-Patchwork-Id: 171212 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp227119vqn; Wed, 29 Nov 2023 01:48:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IFGfHYk+b4hnG3gzTsfjzSMPEs9lfzENbw1Q82Ld+G2rm6b3igS1SfhoXKgPIUzuPaVbxB1 X-Received: by 2002:a05:6358:5284:b0:169:9586:9195 with SMTP id g4-20020a056358528400b0016995869195mr19055038rwa.31.1701251310847; Wed, 29 Nov 2023 01:48:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701251310; cv=none; d=google.com; s=arc-20160816; b=JCWZeCxCu+TcoyrbKAjdh+2ka5+mlCJPyuVmUlARD3/h7bipgTkikD9dpvxDIKlwTU GRkr8WbBunwyRfvY0m7Zjvw6iFFFSE8C23yjdq7HFfgkANpdAYuR4d1gRIm9QMyd6uJ9 eqQsmJnusPl3s0lfpapV1MOOvFDaTSg3MfkUAJupBDuLvLJUjLGBEO84RJF1GY2APsv4 33IF4Zb1rBIp2+UCa7vn9lqU7catk/gAQq7FkimCdjHK8wu1hXc6Z9ajJO6BCZovnf/Z ELAAGioc3oyJCYeC9Pp8LEGIWJWNdKCpVJSaoftgKt+VtsXjIhN4QhGjquNNY9gF3ktW pCVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ldwZpovtywSD1PD1lfHfav/Vz6ZSCZ5gOTnq6KoNzWc=; fh=KWvyQxL3Ff+3WPSMjlYu+P4255AmcMULAsFol6M1vNI=; b=CGZeaYeC7V8obgMeX89wXPL+EsOVp+yotDSnW7zp5pji+o0htcB6bgCl5nYrNp0I65 Y/Dc4Mubi/j+76MlQKfjQHtrURSxR37royMoNZi86nQ69CimuYdG58mvqpPAcq64tUg/ W+w0+gisHR7zdaHUOsWCtM2rJ0vAEV3pHW+JYwvQ4n//2s8RYpwTjN5ibQDGXEJm9+dp ZbPS/42xEWM0GJONIULQx6LdrZ3uDAAdwjwr+7c3O0od5/g84s8kiCE3rcJBFzUDEVKZ ZNztIihsrWLzpiQ267HSfd3MfA12fbvwcNapbBc276wyXSl1D52+YGTqOEgqACRY/uWA h5sw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id bz3-20020a056a02060300b005be09a118d3si15609055pgb.143.2023.11.29.01.48.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 01:48:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 1A0548031E16; Wed, 29 Nov 2023 01:48:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230298AbjK2JsT (ORCPT + 99 others); Wed, 29 Nov 2023 04:48:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229753AbjK2JsF (ORCPT ); Wed, 29 Nov 2023 04:48:05 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F08ABD6C; Wed, 29 Nov 2023 01:48:10 -0800 (PST) Received: from kwepemi500006.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SgDy52WpmzWh99; Wed, 29 Nov 2023 17:47:25 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemi500006.china.huawei.com (7.221.188.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 29 Nov 2023 17:48:08 +0800 From: Junxian Huang To: , CC: , , , Subject: [PATCH for-rc 5/6] RDMA/hns: Fix memory leak in free_mr_init() Date: Wed, 29 Nov 2023 17:44:33 +0800 Message-ID: <20231129094434.134528-6-huangjunxian6@hisilicon.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231129094434.134528-1-huangjunxian6@hisilicon.com> References: <20231129094434.134528-1-huangjunxian6@hisilicon.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemi500006.china.huawei.com (7.221.188.68) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 29 Nov 2023 01:48:29 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783891294431020409 X-GMAIL-MSGID: 1783891294431020409 From: Chengchang Tang When a reserved QP fails to be created, the memory of the remaining created reserved QPs is leaked. Fixes: 70f92521584f ("RDMA/hns: Use the reserved loopback QPs to free MR before destroying MPT") Signed-off-by: Chengchang Tang Signed-off-by: Junxian Huang --- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index 8126922b4e21..538f3e8949fc 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -2705,6 +2705,10 @@ static int free_mr_alloc_res(struct hns_roce_dev *hr_dev) return 0; create_failed_qp: + for (i--; i >= 0; i--) { + hns_roce_v2_destroy_qp(&free_mr->rsv_qp[i]->ibqp, NULL); + kfree(free_mr->rsv_qp[i]); + } hns_roce_destroy_cq(cq, NULL); kfree(cq); From patchwork Wed Nov 29 09:44:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junxian Huang X-Patchwork-Id: 171215 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp227211vqn; Wed, 29 Nov 2023 01:48:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGAEoE1Ii1l3NdPfCnK35Z1/ypA/D/Jk7muqHTSC/OSzxvpGvNOXJyXCv2/DGJV8vrohAbp X-Received: by 2002:a9d:7a96:0:b0:6d8:1780:f1cf with SMTP id l22-20020a9d7a96000000b006d81780f1cfmr14601346otn.4.1701251324157; Wed, 29 Nov 2023 01:48:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701251324; cv=none; d=google.com; s=arc-20160816; b=OiJNcOoHHFNSKUnmtBrWX5zjemJjVu0/yOjkqXQhY8qGOUMYjBBAaqGLA4eoqEOEh1 S6/ULXey7Ey84QPJR8PACRCqLEO9m8co0jRMPrOpir1rNVEC1o2BWjQQHtU5bmBCyjim 1kxLDLgha/nsyq7YOrbU/1aElo4hAAQjNmJOfpMNX/On1wG5uUxUqt9nLQYao3hOBZBd 4PLsAWdl97p9ZWkCL4abQXaE9op893XBYVu+YA5k78Tv6I2xr3gUZC/xZZbgjv8Ksvxj oG9irC4dDLaIwavQUk/OyPLIGGP0fSVsA8Z1gr6eJBwqHL3zdwNtGaybZqUivb5+35p1 KIGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=0d3BOyTzUZEI5X0+/fp24DMujKau3vF7VHTOu9dDR/k=; fh=KWvyQxL3Ff+3WPSMjlYu+P4255AmcMULAsFol6M1vNI=; b=CIrbpwb47dxIRlLfh384Yyo1eoVrgKHt+XMPzAgDe4vvaW0pfdW50lOdTbxl+M3dwZ YAiI0aVb8s4dCZ86SSbNlilbJjTM++KyBezHVQV4eEWk+oihrFuoDkg5+I15DnHMKwtM NvOVlO+lFU4vC1xbOz8kXu0xMeCgxIb46MHN2X8ygW+wFoeEylgTPbO5oV6/RrDuPWNq 1U7dS7K6iTd3F5ejG6gP16oRVVxGwMWRzt8R7U9wJHJ3bbBz+074857BbS+O4ENxgy5o nOh2J/s7e9+M8ki6n+A1rg+ZwyJSJHFtx0y9IvFnq9njLka7+zG3TxuhH0STgYgI2pwA gdQg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id 13-20020a63114d000000b005b96af23fecsi14601086pgr.496.2023.11.29.01.48.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 01:48:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 1892F8031E2A; Wed, 29 Nov 2023 01:48:42 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231160AbjK2Jsb (ORCPT + 99 others); Wed, 29 Nov 2023 04:48:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229974AbjK2JsG (ORCPT ); Wed, 29 Nov 2023 04:48:06 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C719719BC; Wed, 29 Nov 2023 01:48:11 -0800 (PST) Received: from kwepemi500006.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4SgDsL5CSTzMnVg; Wed, 29 Nov 2023 17:43:18 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemi500006.china.huawei.com (7.221.188.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 29 Nov 2023 17:48:09 +0800 From: Junxian Huang To: , CC: , , , Subject: [PATCH for-rc 6/6] RDMA/hns: Improve the readability of free mr uninit Date: Wed, 29 Nov 2023 17:44:34 +0800 Message-ID: <20231129094434.134528-7-huangjunxian6@hisilicon.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231129094434.134528-1-huangjunxian6@hisilicon.com> References: <20231129094434.134528-1-huangjunxian6@hisilicon.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemi500006.china.huawei.com (7.221.188.68) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 29 Nov 2023 01:48:42 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783891308647126485 X-GMAIL-MSGID: 1783891308647126485 From: Chengchang Tang Extract uninit functions of free mr qp, cq and pd to improve readability. Signed-off-by: Chengchang Tang Signed-off-by: Junxian Huang --- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 73 ++++++++++++++-------- 1 file changed, 47 insertions(+), 26 deletions(-) diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index 538f3e8949fc..be02034a8818 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -2573,6 +2573,19 @@ static struct ib_pd *free_mr_init_pd(struct hns_roce_dev *hr_dev) return pd; } +static void free_mr_uninit_pd(struct hns_roce_dev *hr_dev) +{ + struct hns_roce_v2_priv *priv = hr_dev->priv; + struct hns_roce_v2_free_mr *free_mr = &priv->free_mr; + + if (!free_mr->rsv_pd) + return; + + hns_roce_dealloc_pd(&free_mr->rsv_pd->ibpd, NULL); + kfree(free_mr->rsv_pd); + free_mr->rsv_pd = NULL; +} + static struct ib_cq *free_mr_init_cq(struct hns_roce_dev *hr_dev) { struct hns_roce_v2_priv *priv = hr_dev->priv; @@ -2607,6 +2620,19 @@ static struct ib_cq *free_mr_init_cq(struct hns_roce_dev *hr_dev) return cq; } +static void free_mr_uninit_cq(struct hns_roce_dev *hr_dev) +{ + struct hns_roce_v2_priv *priv = hr_dev->priv; + struct hns_roce_v2_free_mr *free_mr = &priv->free_mr; + + if (!free_mr->rsv_cq) + return; + + hns_roce_destroy_cq(&free_mr->rsv_cq->ib_cq, NULL); + kfree(free_mr->rsv_cq); + free_mr->rsv_cq = NULL; +} + static int free_mr_init_qp(struct hns_roce_dev *hr_dev, struct ib_cq *cq, struct ib_qp_init_attr *init_attr, int i) { @@ -2638,6 +2664,19 @@ static int free_mr_init_qp(struct hns_roce_dev *hr_dev, struct ib_cq *cq, return 0; } +static void free_mr_uninit_qp(struct hns_roce_dev *hr_dev, int i) +{ + struct hns_roce_v2_priv *priv = hr_dev->priv; + struct hns_roce_v2_free_mr *free_mr = &priv->free_mr; + + if (!free_mr->rsv_qp[i]) + return; + + hns_roce_v2_destroy_qp(&free_mr->rsv_qp[i]->ibqp, NULL); + kfree(free_mr->rsv_qp[i]); + free_mr->rsv_qp[i] = NULL; +} + static void free_mr_exit(struct hns_roce_dev *hr_dev) { struct hns_roce_v2_priv *priv = hr_dev->priv; @@ -2645,26 +2684,12 @@ static void free_mr_exit(struct hns_roce_dev *hr_dev) struct ib_qp *qp; int i; - for (i = 0; i < ARRAY_SIZE(free_mr->rsv_qp); i++) { - if (free_mr->rsv_qp[i]) { - qp = &free_mr->rsv_qp[i]->ibqp; - hns_roce_v2_destroy_qp(qp, NULL); - kfree(free_mr->rsv_qp[i]); - free_mr->rsv_qp[i] = NULL; - } - } + for (i = 0; i < ARRAY_SIZE(free_mr->rsv_qp); i++) + free_mr_uninit_qp(hr_dev, i); - if (free_mr->rsv_cq) { - hns_roce_destroy_cq(&free_mr->rsv_cq->ib_cq, NULL); - kfree(free_mr->rsv_cq); - free_mr->rsv_cq = NULL; - } + free_mr_uninit_cq(hr_dev); - if (free_mr->rsv_pd) { - hns_roce_dealloc_pd(&free_mr->rsv_pd->ibpd, NULL); - kfree(free_mr->rsv_pd); - free_mr->rsv_pd = NULL; - } + free_mr_uninit_pd(hr_dev); } static int free_mr_alloc_res(struct hns_roce_dev *hr_dev) @@ -2705,16 +2730,12 @@ static int free_mr_alloc_res(struct hns_roce_dev *hr_dev) return 0; create_failed_qp: - for (i--; i >= 0; i--) { - hns_roce_v2_destroy_qp(&free_mr->rsv_qp[i]->ibqp, NULL); - kfree(free_mr->rsv_qp[i]); - } - hns_roce_destroy_cq(cq, NULL); - kfree(cq); + for (i--; i >= 0; i--) + free_mr_uninit_qp(hr_dev, i); + free_mr_uninit_cq(hr_dev); create_failed_cq: - hns_roce_dealloc_pd(pd, NULL); - kfree(pd); + free_mr_uninit_pd(hr_dev); return ret; }