From patchwork Thu Dec 7 11:42:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junxian Huang X-Patchwork-Id: 175091 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4721311vqy; Thu, 7 Dec 2023 03:46:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IF4ffyMgeXJsPNatSpIfA1XZbILDjxhaNaubhmDSlUVbynVyZzCPkNldalhwXJxkBt9MBe/ X-Received: by 2002:a05:6a20:2595:b0:18f:97c:5b89 with SMTP id k21-20020a056a20259500b0018f097c5b89mr1886752pzd.87.1701949586638; Thu, 07 Dec 2023 03:46:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701949586; cv=none; d=google.com; s=arc-20160816; b=WJodCXFh/dolbT+x63qcgLl52ceftjBb+c5W3lXscRVr05p3SLAw21bxEF1psallWL 0BQLshHRI1E1nLziZx8Q8kURrSWJQyqM3JQPmBbcugf4m4kHsGiXH//beew8ST3xfrfw 7dAzcH+DQGuFSMLM4ROkUCfMwl0ujp/Tj4vLSuIeAiy2MWNOgc0cqfr06vcIzTZCgvsn r2+f3V5dnLoK2c+XjzWKOAUO/tt+QLNhFmIsYNx4xMskKepCq6lzVdoaeq65iduXeNL5 grL0a5mVggRqKazmK9cO0QjLnWYexmMquaeCLCZSZElzs+OX6Sw545WZBH2FjEB78pHX QC0A== 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=4h8jetIDTiMMxcaqV48eppm/9fnxYPXbIamxBD/c+Mo=; fh=KWvyQxL3Ff+3WPSMjlYu+P4255AmcMULAsFol6M1vNI=; b=IoHx1zSaQlO4pZCJ8Mhx+9UcgXbKbH19idq6KZuhclagZDGvByXOjIQjbTWXQYTyA6 hJIajWduE4MZqL9w7TrpuwGuTeKOL8/CxbHfxvcoAZPsdU+X/KmP8MjZdhmbLn/WwFoH TatymsEfoZAXDLJM9QHIGeo1lVtojliOhisuJq/1SMSNZIjwM9jGx/MvHsfEIpA9m9eY EtfiOOtpIDhbe1tRfTsrbfE1AqZtZt28w4fhxeMkVTb+OHDhLFoAXawJE8Rh2pJ+YWs+ DWnu43Ymw21XywWkVCDbxoCp7a1QmMCrcMkFKSgQvnutCgiwIyAzp0bQiF5WONHrd0jJ rVdA== 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:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id n8-20020a170903110800b001d1cdd8618esi1026177plh.239.2023.12.07.03.46.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 03:46:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 346BB8090272; Thu, 7 Dec 2023 03:46:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232262AbjLGLqH (ORCPT + 99 others); Thu, 7 Dec 2023 06:46:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231439AbjLGLqE (ORCPT ); Thu, 7 Dec 2023 06:46:04 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C117DD4A; Thu, 7 Dec 2023 03:46:10 -0800 (PST) Received: from kwepemi500006.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SmC6L1hJVzShwn; Thu, 7 Dec 2023 19:41:46 +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; Thu, 7 Dec 2023 19:46:08 +0800 From: Junxian Huang To: , CC: , , , Subject: [PATCH v2 for-next 1/5] RDMA/hns: Rename the interrupts Date: Thu, 7 Dec 2023 19:42:27 +0800 Message-ID: <20231207114231.2872104-2-huangjunxian6@hisilicon.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231207114231.2872104-1-huangjunxian6@hisilicon.com> References: <20231207114231.2872104-1-huangjunxian6@hisilicon.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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 agentk.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 (agentk.vger.email [0.0.0.0]); Thu, 07 Dec 2023 03:46:17 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784623489543561410 X-GMAIL-MSGID: 1784623489543561410 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 5d0a7a1394fc..4258b6daaded 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -6473,15 +6473,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 Thu Dec 7 11:42:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junxian Huang X-Patchwork-Id: 175092 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4721318vqy; Thu, 7 Dec 2023 03:46:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IHc6ucj0itQP1Ze6Q0jUrhylhpwj0MLIbrk3Y5b4qB0OZEWzdslLGl1Ofw+T7RzH7uemEtJ X-Received: by 2002:a05:6a20:3c90:b0:190:6ee:3e9a with SMTP id b16-20020a056a203c9000b0019006ee3e9amr511796pzj.108.1701949587311; Thu, 07 Dec 2023 03:46:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701949587; cv=none; d=google.com; s=arc-20160816; b=VOZQFoa3eiKCv7cOHaEjaPsWtFnNB3L3s9FJYsY2rpMCzS0i83ftxGDQiZKZcQ04sc ZVYsxuGWD1/KI2snPwlg1cguxYpBsh+xEgfa9+Tj3BlrOIu6tALsaB++GMKijKTOdx+B Ed76Qh4LeV7TEct3iccfvuoDh0cUf2zik93nQVxKCowplQsJdyhvl1fN9R5I5QhKl4no kK3Yfz5zUdmAtF5zQdOSwqKm0UvrK3cUS9OeGFl1gL6Odl+z/mp+qOBy+RMV9OjLx2At HVZyUq+GMqQb0KiSSnn5D76cNpuURFGcZghdWPBf3FTVkUfJGJTxhu1t8NqikIS5okBH HV8w== 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=ZgbsRgbMUMlEqhh5ZfKy65FqTSm42DA47B5sqf3lK6U=; fh=KWvyQxL3Ff+3WPSMjlYu+P4255AmcMULAsFol6M1vNI=; b=AYWMwlqq2dtBQm3FTR1hNlaEWf/6dG/tLx/ez6SDo198iKmKn3AwMu76HBC+4AnMQH MzcL0Ih2ai9QqtPSFASNUd7dP5lGRLBCHbokHLLsFFi+JN/9zP/U8mo7724v1jKdOOib X6xKU75Zfq1l+7eoxRlK/urlBRF0ATUqKhiZ1tpzBEk8REA6kwSe40vVtlDDDiFSJmaM 2pWjUvBui2mxvCXhAkfhEpUBelqQSOs0GqUTQPfc5aPi1xDNXxO2gs254D1uUvauMzDD nTEmFh9GiHxJ9amPzHaVdGQotkEjzIOkEOdcWPoaouvAEbFxQqXkowZ3nQ5ShOVPN/d8 K0TA== 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 bz36-20020a056a02062400b005c65c11ad0dsi1092011pgb.772.2023.12.07.03.46.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 03:46:27 -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 ED0E98034637; Thu, 7 Dec 2023 03:46:24 -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 S1379007AbjLGLqO (ORCPT + 99 others); Thu, 7 Dec 2023 06:46:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232493AbjLGLqF (ORCPT ); Thu, 7 Dec 2023 06:46:05 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7EE4137; Thu, 7 Dec 2023 03:46:10 -0800 (PST) Received: from kwepemi500006.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SmCBc4MnszYsp3; Thu, 7 Dec 2023 19:45:28 +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; Thu, 7 Dec 2023 19:46:08 +0800 From: Junxian Huang To: , CC: , , , Subject: [PATCH v2 for-next 2/5] RDMA/hns: Response dmac to userspace Date: Thu, 7 Dec 2023 19:42:28 +0800 Message-ID: <20231207114231.2872104-3-huangjunxian6@hisilicon.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231207114231.2872104-1-huangjunxian6@hisilicon.com> References: <20231207114231.2872104-1-huangjunxian6@hisilicon.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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]); Thu, 07 Dec 2023 03:46:25 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784623490255460553 X-GMAIL-MSGID: 1784623490255460553 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 fbf046982374..b4209b6aed8d 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))); + } + err_out: if (ret) atomic64_inc(&hr_dev->dfx_cnt[HNS_ROCE_DFX_AH_CREATE_ERR_CNT]); 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 Thu Dec 7 11:42: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: 175093 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4721357vqy; Thu, 7 Dec 2023 03:46:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IHjNliFl31ez4KBV0f1Vrp4uAgYa0zGRcy7aZQH4NqhpikUDUU3HXntgaXRpbyLg9Bt+LEL X-Received: by 2002:a05:6e02:1a0a:b0:35d:5995:79a2 with SMTP id s10-20020a056e021a0a00b0035d599579a2mr3084316ild.60.1701949592595; Thu, 07 Dec 2023 03:46:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701949592; cv=none; d=google.com; s=arc-20160816; b=bBernptwbwPM7ksu6bjyvrvW2HfoaKv6ioQay7XfsyRcklxjUJFt7VHnLxjWsG9Af8 ysMOo69TFTgS0DpkR0pqOHoN2ojAV+a4V6UjwH3lCDeGrJna+2/Uvu2Rep3qYbMtZH7m +VM209cgdY8XturdWv5eip2ImT3GI0oeSPsQ4mpu0Ety1K22jCwYK6gslF4OC/1VdyAT rkmtyGA1xkiracSbpIwSi0TrYs0UEsXiViRo/O6mh+Zb76c5umZjZdLbPmIM1qpmZwpL e7/GLomeeeXPDWbZQjSfZKSya3PMEqL+ZA2W1Swrs3QsinabGzTU2V2TetmN6cr37/XX sBfw== 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=SdU55afCaO3Hwwvjb43NEqYfbm19ZKxk2STDiELjGEM=; fh=KWvyQxL3Ff+3WPSMjlYu+P4255AmcMULAsFol6M1vNI=; b=iskZmXEwk5liSFLpCeVT4rsy+w/6CICqRB3jhH/Ru5Y+BpOC0E+8BVYxfObJXx9wzs 142ABR+2Ihu2C0Dnf9cVWpbSTLJ6DNyQSSn7v7qSzC8EzKjlCR2TNpSxdhMOoURgZM+G yUTUr6/h6z1eeu4ZzCoDNB69CxgZY+WQ9xD+5XUr6rOM8CfglmMtafhAnRTCsm8BfDwy i5T5dnBIPmxKrDvuiPlJGiANXSDkuVi3UitthvFZgwEKkaGWTgBdCYVkPQI0oD/AKYOl tEDPW+iucDlX9rm27mg+qPmbOFZwq9apbY5ZEaVI2MRnsJTXQz9FfQKTyhRyZQ0kmoKF 0LxA== 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 l1-20020a656801000000b005c1b5a76098si1031894pgt.771.2023.12.07.03.46.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 03:46:32 -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 0FCCF8069D94; Thu, 7 Dec 2023 03:46:30 -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 S231439AbjLGLqU (ORCPT + 99 others); Thu, 7 Dec 2023 06:46:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232494AbjLGLqF (ORCPT ); Thu, 7 Dec 2023 06:46:05 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F0AAD54; Thu, 7 Dec 2023 03:46:11 -0800 (PST) Received: from kwepemi500006.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SmC6L6rCvzShxH; Thu, 7 Dec 2023 19:41:46 +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; Thu, 7 Dec 2023 19:46:08 +0800 From: Junxian Huang To: , CC: , , , Subject: [PATCH v2 for-next 3/5] RDMA/hns: Add a max length of gid table Date: Thu, 7 Dec 2023 19:42:29 +0800 Message-ID: <20231207114231.2872104-4-huangjunxian6@hisilicon.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231207114231.2872104-1-huangjunxian6@hisilicon.com> References: <20231207114231.2872104-1-huangjunxian6@hisilicon.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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=ham 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]); Thu, 07 Dec 2023 03:46:30 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784623495868164344 X-GMAIL-MSGID: 1784623495868164344 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 4258b6daaded..93a71db527d8 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -2060,6 +2060,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; @@ -2095,8 +2096,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 Thu Dec 7 11:42: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: 175094 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4721392vqy; Thu, 7 Dec 2023 03:46:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IEUZsbi9dGRUQ80fQa18UrAG/N7gzsh6zNxOg95Rjdz2CvTqghcyCmBQ/aHqhJ0MpJd/okk X-Received: by 2002:a05:6a00:1583:b0:6ce:2731:79f4 with SMTP id u3-20020a056a00158300b006ce273179f4mr1823377pfk.42.1701949596854; Thu, 07 Dec 2023 03:46:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701949596; cv=none; d=google.com; s=arc-20160816; b=GxQ917mChFCMPjvboPDhgzG3cHZb0iR1Zd8+w5lTcYVcygPhB5UQt1k4IsUJ4kEaiE 6C9G2e1BAV7hMppImh5a/CUVdBf9L79oxEUXXsN6DD4aZPzKK+2c7tFkoBre68fDuiDx wpQfEbxCuSti9ysCHrHqOXqJXyNIF3QwLS6chfBre7rV9X87OR9ki+uvBY4eV/EjAFV1 N0q2+wcFWseRnHQ4an+pmT9jaYmHjeuA/NMrUlIfL6gJ1A1lHqZk81Oq4jSPyJAoZLrE X3v+g/ObZkOcKT7hlMCGu9l3sKJXTSQO6ajV3R+XrqfUdjv1GHvA7glb1KNjYhwV9SE4 3Paw== 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=bztLFe4FuHzw/Ej9XgmkQ60/r7H9PwMUnYfTekT2Gyc=; fh=KWvyQxL3Ff+3WPSMjlYu+P4255AmcMULAsFol6M1vNI=; b=yQlh47PhHy1fEI7WpdX8PCqfui2LUqa/dLOaS68neL/LjryTHg7wKO1FUPF+84AO3P xATH6e4G+Fa+zbFG5YnjDIiYalSBMl2lcbfK1NzCmpgXrc7e4NfuD6ezFSsgudUOQmU4 3UPon/GJlw9GddEmuFM5UWrunVzwk/wuOD+rUqH7QF1PjwfcYT1KYn4ylNFdiXxUt3Rm heYS5R6qDAJIs0sA6nLPIP9Tqe3pfJKfO7/GBm15KNpRmOM5Uvkj3/frMZVEmyWjBDxf MDpJgXywcy94/cMXkuRWkkPeo9L3XI1GqTFrmzjCsQOLQVZvXOAcMcmUWfh7D0VBx5Wz pQmg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id dn16-20020a056a00499000b006ce555313a2si1067657pfb.382.2023.12.07.03.46.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 03:46:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id EE661809A781; Thu, 7 Dec 2023 03:46:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379021AbjLGLqR (ORCPT + 99 others); Thu, 7 Dec 2023 06:46:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232506AbjLGLqF (ORCPT ); Thu, 7 Dec 2023 06:46:05 -0500 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C870519A; Thu, 7 Dec 2023 03:46:11 -0800 (PST) Received: from kwepemi500006.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SmC711lmrz1Q64T; Thu, 7 Dec 2023 19:42:21 +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; Thu, 7 Dec 2023 19:46:09 +0800 From: Junxian Huang To: , CC: , , , Subject: [PATCH v2 for-next 4/5] RDMA/hns: Remove unnecessary checks for NULL in mtr_alloc_bufs() Date: Thu, 7 Dec 2023 19:42:30 +0800 Message-ID: <20231207114231.2872104-5-huangjunxian6@hisilicon.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231207114231.2872104-1-huangjunxian6@hisilicon.com> References: <20231207114231.2872104-1-huangjunxian6@hisilicon.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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 groat.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 (groat.vger.email [0.0.0.0]); Thu, 07 Dec 2023 03:46:31 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784623500422542569 X-GMAIL-MSGID: 1784623500422542569 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 d68074b6ca17..91cd580480fe 100644 --- a/drivers/infiniband/hw/hns/hns_roce_mr.c +++ b/drivers/infiniband/hw/hns/hns_roce_mr.c @@ -686,7 +686,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 Thu Dec 7 11:42: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: 175095 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4721417vqy; Thu, 7 Dec 2023 03:46:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IHH9/hdMREjNrVf8ByHJ94Tv0VDkKeBu8neOIcsoAAHGR/bKmU7SVY/hWJ6mvt9tLD7ncGO X-Received: by 2002:a17:902:7c09:b0:1d0:8595:ea7f with SMTP id x9-20020a1709027c0900b001d08595ea7fmr5322413pll.46.1701949600544; Thu, 07 Dec 2023 03:46:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701949600; cv=none; d=google.com; s=arc-20160816; b=PylO+xtbpnfMZFREetNz4iaL5AQqPdkcwaAnb4Lcbyq6VPD6aIzjV/xKxumjaa5MDO Ft6XuVxZQN+KqhSULoQv40zwsoRLGYdKu7l1oOd4+8eFOrYMDQu7OlKUwLHVkpDPWA6F /PbnauFHG3Fu0eneAV7Hp/oL36V5BD0KnQf9bJ3B4MvFAxCV9SyVIqLi9RIg1dD4GRTv rCO/q+kZb+S33/UGmp6DE1HfxpdtpymBkiOdvO0mKSrX/GtntapjpkItlpq3G8QmcL3k cLZCLeAgVyukpfbHVKTqdJdBnceJhQJeuA+BHkgut+W2ayH7wmr1YlKZwN3V5F3UXXnz 86oQ== 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=BEcdQrr+dn6fBBxVR2xDt4B1CMQqSOwnf9q6ouQmNXk=; fh=KWvyQxL3Ff+3WPSMjlYu+P4255AmcMULAsFol6M1vNI=; b=SpWRCFkWgBV9bae57m4FPT1G+1NbrKN8013/0/c6NeLrPCnSL9dbilRFEaycAMN40Z UA3ZcALBG7vBUQ0xVejdCkzcwd0H49XQ4vW5jDOIgXGDfFhRFw/sr649Jtjbof/BN19q y/mExZokXoSg725F4sY1Q+4a1UsM+bIgUGo/SFNNVSVzqy84EYegjQ6Rke5p11IMfsc4 JZsP+gxzwEWeqr7uxyEyvE+cQIynTtcBAkM9jsyd63A9HkdxM6aYmlF7Di2y5eGiFnv2 Y2Is7v9LTAkcNR29RC76wEORI/eQH0Oo0+3XoVf6lziayRJf1YuZqvZz3n1/u64DWfiO ntFQ== 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:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id m9-20020a170902db0900b001cfb6a814aesi1050158plx.255.2023.12.07.03.46.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 03:46:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id BD63A8053C43; Thu, 7 Dec 2023 03:46:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379025AbjLGLqX (ORCPT + 99 others); Thu, 7 Dec 2023 06:46:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232498AbjLGLqF (ORCPT ); Thu, 7 Dec 2023 06:46:05 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E27BBD5C; Thu, 7 Dec 2023 03:46:11 -0800 (PST) Received: from kwepemi500006.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SmCBK6bYGzWjKL; Thu, 7 Dec 2023 19:45:13 +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; Thu, 7 Dec 2023 19:46:09 +0800 From: Junxian Huang To: , CC: , , , Subject: [PATCH v2 for-next 5/5] RDMA/hns: Fix memory leak in free_mr_init() Date: Thu, 7 Dec 2023 19:42:31 +0800 Message-ID: <20231207114231.2872104-6-huangjunxian6@hisilicon.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231207114231.2872104-1-huangjunxian6@hisilicon.com> References: <20231207114231.2872104-1-huangjunxian6@hisilicon.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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 agentk.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 (agentk.vger.email [0.0.0.0]); Thu, 07 Dec 2023 03:46:38 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784623504280203149 X-GMAIL-MSGID: 1784623504280203149 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 93a71db527d8..b8dde04bd573 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -2710,6 +2710,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);