From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A1D9C35671 for ; Sat, 22 Feb 2020 07:22:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 78B0D2071E for ; Sat, 22 Feb 2020 07:22:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726943AbgBVHWc (ORCPT ); Sat, 22 Feb 2020 02:22:32 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:10665 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726930AbgBVHWc (ORCPT ); Sat, 22 Feb 2020 02:22:32 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 538E9229D9C42FA529A5; Sat, 22 Feb 2020 15:22:29 +0800 (CST) Received: from [127.0.0.1] (10.40.168.149) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.439.0; Sat, 22 Feb 2020 15:22:19 +0800 Subject: Re: [PATCH v2 for-next 7/7] RDMA/hns: Optimize qp doorbell allocation flow To: Jason Gunthorpe CC: , , , References: <1581325720-12975-1-git-send-email-liweihang@huawei.com> <1581325720-12975-8-git-send-email-liweihang@huawei.com> <20200219005225.GA25540@ziepe.ca> <04b1c2e6-a3e1-9e29-708d-4ae29c1e1602@huawei.com> <20200219131901.GP31668@ziepe.ca> From: Weihang Li Message-ID: <2032cac3-b31f-8f86-64d2-a931b973fdfa@huawei.com> Date: Sat, 22 Feb 2020 15:22:18 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20200219131901.GP31668@ziepe.ca> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.40.168.149] X-CFilter-Loop: Reflected Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org On 2020/2/19 21:19, Jason Gunthorpe wrote: > On Wed, Feb 19, 2020 at 04:14:36PM +0800, Weihang Li wrote: >> >> >> On 2020/2/19 8:52, Jason Gunthorpe wrote: >>> On Mon, Feb 10, 2020 at 05:08:40PM +0800, Weihang Li wrote: >>>> From: Xi Wang >>>> >>>> Encapsulate the kernel qp doorbell allocation related code into 2 >>>> functions: alloc_qp_db() and free_qp_db(). >>>> >>>> Signed-off-by: Xi Wang >>>> Signed-off-by: Weihang Li >>>> drivers/infiniband/hw/hns/hns_roce_qp.c | 214 +++++++++++++++++--------------- >>>> 1 file changed, 113 insertions(+), 101 deletions(-) >>>> >>>> diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c >>>> index ad34187..46785f1 100644 >>>> +++ b/drivers/infiniband/hw/hns/hns_roce_qp.c >>>> @@ -844,6 +844,96 @@ static void free_qp_buf(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp) >>>> free_rq_inline_buf(hr_qp); >>>> } >>>> >>>> +#define user_qp_has_sdb(hr_dev, init_attr, udata, resp, ucmd) \ >>>> + ((hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_SQ_RECORD_DB) && \ >>>> + udata->outlen >= sizeof(*resp) && \ >>>> + hns_roce_qp_has_sq(init_attr) && udata->inlen >= sizeof(*ucmd)) >>>> + >>>> +#define user_qp_has_rdb(hr_dev, init_attr, udata, resp) \ >>>> + ((hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) && \ >>>> + udata->outlen >= sizeof(*resp) && \ >>>> + hns_roce_qp_has_rq(init_attr)) >>>> + >>>> +#define kernel_qp_has_rdb(hr_dev, init_attr) \ >>>> + ((hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) && \ >>>> + hns_roce_qp_has_rq(init_attr)) >>> >>> static inline functions not defines please >>> >> >> OK, I will change them into inline functions. >> >>> Also, these tests against inline and outlen look very strange. What >>> are they doing? >>> >>> Jason >>> >> >> These judgement about inlen and outlen is for compatibility reasons, >> previous discussions can be found at: >> >> https://patchwork.kernel.org/patch/10172233/ > > Something is wrong, it should be testing the legnth using a > field_offset_off kind of scheme, not sizeof(*resp) > > Jason > Hi Jason, Do you means udata->outlen >= sizeof(*resp) should be changed into: udata->out_len >= offsetof(typeof(*resp), cap_flags) If yes, I will fix other similar codes with this issue in hns drivers. Thanks Weihang