From patchwork Sun Feb 3 09:06:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lijun Ou X-Patchwork-Id: 10794597 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0EDDA6C2 for ; Sun, 3 Feb 2019 09:06:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC4D92AE69 for ; Sun, 3 Feb 2019 09:06:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DAD972ADA5; Sun, 3 Feb 2019 09:06:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E9432ADA5 for ; Sun, 3 Feb 2019 09:06:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727586AbfBCJGS (ORCPT ); Sun, 3 Feb 2019 04:06:18 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:3167 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726871AbfBCJGS (ORCPT ); Sun, 3 Feb 2019 04:06:18 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 06A1F62B7781721D7D40; Sun, 3 Feb 2019 17:06:17 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.408.0; Sun, 3 Feb 2019 17:06:08 +0800 From: Lijun Ou To: , CC: , , Subject: [PATCH rdma-core 1/2] libhns: Bugfix for allocating srq buffer fail Date: Sun, 3 Feb 2019 17:06:44 +0800 Message-ID: <1549184805-237600-2-git-send-email-oulijun@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1549184805-237600-1-git-send-email-oulijun@huawei.com> References: <1549184805-237600-1-git-send-email-oulijun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When create srq, it needs to allocate the enough buffer space for storing srqwqe. if allocate fail, it needs to free some memory source have created successful. Here fixes the bug with freeing bitmap of idx queue. Fixes: 22d53621d9b0 ("libhns: Add verb of creating srq for hip08 user mode") Signed-off-by: Lijun Ou --- providers/hns/hns_roce_u_verbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/hns/hns_roce_u_verbs.c b/providers/hns/hns_roce_u_verbs.c index 6f54066..aa791e0 100644 --- a/providers/hns/hns_roce_u_verbs.c +++ b/providers/hns/hns_roce_u_verbs.c @@ -573,7 +573,7 @@ err_srq_buf: hns_roce_free_buf(&srq->buf); err_idx_que: - free(&srq->idx_que.bitmap); + free(srq->idx_que.bitmap); hns_roce_free_buf(&srq->idx_que.buf); out: free(srq); From patchwork Sun Feb 3 09:06:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lijun Ou X-Patchwork-Id: 10794601 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 533CB746 for ; Sun, 3 Feb 2019 09:06:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 417652ADA5 for ; Sun, 3 Feb 2019 09:06:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 35D452AE69; Sun, 3 Feb 2019 09:06:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D077D2AFE4 for ; Sun, 3 Feb 2019 09:06:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727595AbfBCJGT (ORCPT ); Sun, 3 Feb 2019 04:06:19 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:3168 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727212AbfBCJGS (ORCPT ); Sun, 3 Feb 2019 04:06:18 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 0ACBFE6219DE81E008D4; Sun, 3 Feb 2019 17:06:17 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.408.0; Sun, 3 Feb 2019 17:06:08 +0800 From: Lijun Ou To: , CC: , , Subject: [PATCH rdma-core 2/2] libhns: Bugfix for allocating and freeing sq db buffer Date: Sun, 3 Feb 2019 17:06:45 +0800 Message-ID: <1549184805-237600-3-git-send-email-oulijun@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1549184805-237600-1-git-send-email-oulijun@huawei.com> References: <1549184805-237600-1-git-send-email-oulijun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When flush cqe, it needs to allocate sq db buffer for storing sq pi pointer and using when modifying qp to error state. It needs to free sq db buffer when destroying qp. These operations will be triggered, depending on whether or not there is sq. However, when sq sge number is zero, the sq maybe exist. Fixes: e1726e934574("libhns: Support flush cqe for hip08 in user space") Signed-off-by: Lijun Ou --- providers/hns/hns_roce_u_hw_v2.c | 2 +- providers/hns/hns_roce_u_verbs.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c index d00bd42..7938b96 100644 --- a/providers/hns/hns_roce_u_hw_v2.c +++ b/providers/hns/hns_roce_u_hw_v2.c @@ -1141,7 +1141,7 @@ static int hns_roce_u_v2_destroy_qp(struct ibv_qp *ibqp) if (qp->rq.max_gs) hns_roce_free_db(to_hr_ctx(ibqp->context), qp->rdb, HNS_ROCE_QP_TYPE_DB); - if (qp->sq.max_gs) + if (qp->sq.wqe_cnt) hns_roce_free_db(to_hr_ctx(ibqp->context), qp->sdb, HNS_ROCE_QP_TYPE_DB); diff --git a/providers/hns/hns_roce_u_verbs.c b/providers/hns/hns_roce_u_verbs.c index aa791e0..05c2a8e 100644 --- a/providers/hns/hns_roce_u_verbs.c +++ b/providers/hns/hns_roce_u_verbs.c @@ -845,7 +845,7 @@ struct ibv_qp *hns_roce_u_create_qp(struct ibv_pd *pd, } if ((to_hr_dev(pd->context->device)->hw_version != HNS_ROCE_HW_VER1) && - attr->cap.max_send_sge) { + attr->cap.max_send_wr) { qp->sdb = hns_roce_alloc_db(context, HNS_ROCE_QP_TYPE_DB); if (!qp->sdb) goto err_free; @@ -916,7 +916,7 @@ err_rq_db: err_sq_db: if ((to_hr_dev(pd->context->device)->hw_version != HNS_ROCE_HW_VER1) && - attr->cap.max_send_sge) + attr->cap.max_send_wr) hns_roce_free_db(context, qp->sdb, HNS_ROCE_QP_TYPE_DB); err_free: