All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for-rc] RDMA/hns: Fix wrong PBL offset when VA is not aligned to PAGE_SIZE
@ 2020-07-14 11:42 Weihang Li
  2020-07-16 12:56 ` Jason Gunthorpe
  0 siblings, 1 reply; 2+ messages in thread
From: Weihang Li @ 2020-07-14 11:42 UTC (permalink / raw)
  To: dledford, jgg; +Cc: leon, linux-rdma, linuxarm

From: Xi Wang <wangxi11@huawei.com>

The ROCEE use "VA % buf_page_size" to caclulate the offset in the PBL's
first page, the actual PA corresponding to the MR's VA is equal to MR's
PA plus this offset. The first PA in PBL has already been aligned to
PAGE_SIZE after calling ib_umem_get(), but the MR's VA may not. If the
buf_page_size is small than the PAGE_SIZE, this will lead the ROCEE to
access the wrong memory because the offset is smaller than expected.

Fixes: 9b2cf76c9f05 ("RDMA/hns: Optimize PBL buffer allocation process")
Signed-off-by: Xi Wang <wangxi11@huawei.com>
Signed-off-by: Weihang Li <liweihang@huawei.com>
---
 drivers/infiniband/hw/hns/hns_roce_mr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c b/drivers/infiniband/hw/hns/hns_roce_mr.c
index 0e71ebe..6b226a5 100644
--- a/drivers/infiniband/hw/hns/hns_roce_mr.c
+++ b/drivers/infiniband/hw/hns/hns_roce_mr.c
@@ -120,7 +120,7 @@ static int alloc_mr_pbl(struct hns_roce_dev *hr_dev, struct hns_roce_mr *mr,
 
 	mr->pbl_hop_num = is_fast ? 1 : hr_dev->caps.pbl_hop_num;
 	buf_attr.page_shift = is_fast ? PAGE_SHIFT :
-			      hr_dev->caps.pbl_buf_pg_sz + HNS_HW_PAGE_SHIFT;
+			      hr_dev->caps.pbl_buf_pg_sz + PAGE_SHIFT;
 	buf_attr.region[0].size = length;
 	buf_attr.region[0].hopnum = mr->pbl_hop_num;
 	buf_attr.region_count = 1;
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH for-rc] RDMA/hns: Fix wrong PBL offset when VA is not aligned to PAGE_SIZE
  2020-07-14 11:42 [PATCH for-rc] RDMA/hns: Fix wrong PBL offset when VA is not aligned to PAGE_SIZE Weihang Li
@ 2020-07-16 12:56 ` Jason Gunthorpe
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Gunthorpe @ 2020-07-16 12:56 UTC (permalink / raw)
  To: Weihang Li; +Cc: dledford, leon, linux-rdma, linuxarm

On Tue, Jul 14, 2020 at 07:42:15PM +0800, Weihang Li wrote:
> From: Xi Wang <wangxi11@huawei.com>
> 
> The ROCEE use "VA % buf_page_size" to caclulate the offset in the PBL's
> first page, the actual PA corresponding to the MR's VA is equal to MR's
> PA plus this offset. The first PA in PBL has already been aligned to
> PAGE_SIZE after calling ib_umem_get(), but the MR's VA may not. If the
> buf_page_size is small than the PAGE_SIZE, this will lead the ROCEE to
> access the wrong memory because the offset is smaller than expected.
> 
> Fixes: 9b2cf76c9f05 ("RDMA/hns: Optimize PBL buffer allocation process")
> Signed-off-by: Xi Wang <wangxi11@huawei.com>
> Signed-off-by: Weihang Li <liweihang@huawei.com>
> ---
>  drivers/infiniband/hw/hns/hns_roce_mr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied to for-rc, thanks

Jason

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-16 12:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-14 11:42 [PATCH for-rc] RDMA/hns: Fix wrong PBL offset when VA is not aligned to PAGE_SIZE Weihang Li
2020-07-16 12:56 ` Jason Gunthorpe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.