From patchwork Fri May 31 10:28:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lijun Ou X-Patchwork-Id: 10969929 X-Patchwork-Delegate: jgg@ziepe.ca 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 855FC933 for ; Fri, 31 May 2019 10:25:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72E6A28B91 for ; Fri, 31 May 2019 10:25:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 610C928C80; Fri, 31 May 2019 10:25:05 +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 3EAD628B91 for ; Fri, 31 May 2019 10:25:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726376AbfEaKZD (ORCPT ); Fri, 31 May 2019 06:25:03 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:51472 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726233AbfEaKZD (ORCPT ); Fri, 31 May 2019 06:25:03 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id A8A6EFC293BAF4E22476; Fri, 31 May 2019 18:25:00 +0800 (CST) Received: from linux-ioko.site (10.71.200.31) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.439.0; Fri, 31 May 2019 18:24:51 +0800 From: Lijun Ou To: , CC: , , Subject: [PATCH for-next 2/2] RDMA/hns: Consider the bitmap full situation Date: Fri, 31 May 2019 18:28:04 +0800 Message-ID: <1559298484-63548-3-git-send-email-oulijun@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1559298484-63548-1-git-send-email-oulijun@huawei.com> References: <1559298484-63548-1-git-send-email-oulijun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.71.200.31] 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 We use a fifo queue to store srq wqe index and use bimap to just use the corresponding srq index. When bitmap is full, the srq wqe is more than the max number of srqwqe and it should return error and notify the user. It will fix the patch("RDMA/hns: Bugfix for posting multiple srq work request") Signed-off-by: Lijun Ou --- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index ca319fc..e7024b3 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -6014,7 +6014,7 @@ static int find_empty_entry(struct hns_roce_idx_que *idx_que, int wqe_idx; if (unlikely(bitmap_full(idx_que->bitmap, size))) - bitmap_zero(idx_que->bitmap, size); + return -ENOSPC; wqe_idx = find_first_zero_bit(idx_que->bitmap, size); @@ -6067,6 +6067,11 @@ static int hns_roce_v2_post_srq_recv(struct ib_srq *ibsrq, } wqe_idx = find_empty_entry(&srq->idx_que, srq->max); + if (wqe_idx < 0) { + ret = -ENOMEM; + *bad_wr = wr; + break; + } fill_idx_queue(&srq->idx_que, ind, wqe_idx); wqe = get_srq_wqe(srq, wqe_idx);