Commit e8a07de5 authored by Weihang Li's avatar Weihang Li Committed by Doug Ledford

RDMA/hns: Fix wrong parameters when initial mtt of srq->idx_que

The parameters npages used to initial mtt of srq->idx_que shouldn't be
same with srq's. And page_shift should be calculated from idx_buf_pg_sz.
This patch fixes above issues and use field named npage and page_shift
in hns_roce_buf instead of two temporary variables to let us use them
anywhere.

Fixes: 18df508c ("RDMA/hns: Remove if-else judgment statements for creating srq")
Signed-off-by: default avatarWeihang Li <liweihang@hisilicon.com>
Link: https://lore.kernel.org/r/1567566885-23088-3-git-send-email-liweihang@hisilicon.comSigned-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 9f7d7064
...@@ -180,8 +180,7 @@ static int create_user_srq(struct hns_roce_srq *srq, struct ib_udata *udata, ...@@ -180,8 +180,7 @@ static int create_user_srq(struct hns_roce_srq *srq, struct ib_udata *udata,
{ {
struct hns_roce_dev *hr_dev = to_hr_dev(srq->ibsrq.device); struct hns_roce_dev *hr_dev = to_hr_dev(srq->ibsrq.device);
struct hns_roce_ib_create_srq ucmd; struct hns_roce_ib_create_srq ucmd;
u32 page_shift; struct hns_roce_buf *buf;
u32 npages;
int ret; int ret;
if (ib_copy_from_udata(&ucmd, udata, sizeof(ucmd))) if (ib_copy_from_udata(&ucmd, udata, sizeof(ucmd)))
...@@ -191,11 +190,13 @@ static int create_user_srq(struct hns_roce_srq *srq, struct ib_udata *udata, ...@@ -191,11 +190,13 @@ static int create_user_srq(struct hns_roce_srq *srq, struct ib_udata *udata,
if (IS_ERR(srq->umem)) if (IS_ERR(srq->umem))
return PTR_ERR(srq->umem); return PTR_ERR(srq->umem);
npages = (ib_umem_page_count(srq->umem) + buf = &srq->buf;
(1 << hr_dev->caps.srqwqe_buf_pg_sz) - 1) / buf->npages = (ib_umem_page_count(srq->umem) +
(1 << hr_dev->caps.srqwqe_buf_pg_sz); (1 << hr_dev->caps.srqwqe_buf_pg_sz) - 1) /
page_shift = PAGE_SHIFT + hr_dev->caps.srqwqe_buf_pg_sz; (1 << hr_dev->caps.srqwqe_buf_pg_sz);
ret = hns_roce_mtt_init(hr_dev, npages, page_shift, &srq->mtt); buf->page_shift = PAGE_SHIFT + hr_dev->caps.srqwqe_buf_pg_sz;
ret = hns_roce_mtt_init(hr_dev, buf->npages, buf->page_shift,
&srq->mtt);
if (ret) if (ret)
goto err_user_buf; goto err_user_buf;
...@@ -212,9 +213,12 @@ static int create_user_srq(struct hns_roce_srq *srq, struct ib_udata *udata, ...@@ -212,9 +213,12 @@ static int create_user_srq(struct hns_roce_srq *srq, struct ib_udata *udata,
goto err_user_srq_mtt; goto err_user_srq_mtt;
} }
ret = hns_roce_mtt_init(hr_dev, ib_umem_page_count(srq->idx_que.umem), buf = &srq->idx_que.idx_buf;
PAGE_SHIFT, &srq->idx_que.mtt); buf->npages = DIV_ROUND_UP(ib_umem_page_count(srq->idx_que.umem),
1 << hr_dev->caps.idx_buf_pg_sz);
buf->page_shift = PAGE_SHIFT + hr_dev->caps.idx_buf_pg_sz;
ret = hns_roce_mtt_init(hr_dev, buf->npages, buf->page_shift,
&srq->idx_que.mtt);
if (ret) { if (ret) {
dev_err(hr_dev->dev, "hns_roce_mtt_init error for idx que\n"); dev_err(hr_dev->dev, "hns_roce_mtt_init error for idx que\n");
goto err_user_idx_mtt; goto err_user_idx_mtt;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment