From 324b5becfe4de99fe7508a0a3eb51845d7e90069 Mon Sep 17 00:00:00 2001 From: Xi Wang Date: Fri, 17 May 2019 16:56:04 +0800 Subject: [PATCH] RDMA/hns: fix mtr search failure when wqe offset is invalid driver inclusion category: bugfix bugzilla: NA CVE: NA Currently, the rq offset is invalid when the rq depth is zero and sq depth not zero, this will lead the mtr searching fail. This patch fixes it by adding the invalid wqe offset checking when an empty mtt is found. Fixes: 5c42b537063d ("RDMA/hns:Fix bug when wqe num is larger than 16384") Feature or Bugfix:Bugfix Signed-off-by: wangxi Signed-off-by: Xi Wang Reviewed-by: oulijun Reviewed-by: liuyixian Reviewed-by: Yang Yingliang Signed-off-by: Yang Yingliang --- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 5 ++++- 1 file changed, 4 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 ff490abf84d7..e7226cf5c0eb 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -3987,6 +3987,9 @@ static bool check_wqe_rq_mtt_count(struct hns_roce_dev *hr_dev, { struct device *dev = hr_dev->dev; + if (hr_qp->rq.wqe_cnt < 1) + return true; + if (mtt_cnt < 1) { dev_err(dev, "qp(0x%lx) rqwqe buf ba find failed\n", hr_qp->qpn); @@ -4268,7 +4271,7 @@ static int modify_qp_rtr_to_rts(struct ib_qp *ibqp, return -EINVAL; } - if (hr_qp->sge.offset) { + if (hr_qp->sge.sge_cnt > 0) { page_size = 1 << (hr_dev->caps.mtt_buf_pg_sz + PAGE_SHIFT); count = hns_roce_mtr_find(hr_dev, &hr_qp->mtr, hr_qp->sge.offset / page_size, -- GitLab