diff mbox series

[for-next,2/2] RDMA/hns: Consider the bitmap full situation

Message ID 1559298484-63548-3-git-send-email-oulijun@huawei.com (mailing list archive)
State Accepted
Delegated to: Jason Gunthorpe
Headers show
Series None | expand

Commit Message

Lijun Ou May 31, 2019, 10:28 a.m. UTC
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 <oulijun@huawei.com>
---
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Jason Gunthorpe May 31, 2019, 7:11 p.m. UTC | #1
On Fri, May 31, 2019 at 06:28:04PM +0800, Lijun Ou wrote:
> 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 <oulijun@huawei.com>
> ---
>  drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)

I squashed this into the last patch, thanks

Jason
diff mbox series

Patch

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);