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@xxxxxxxxxx> --- 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); -- 1.9.1