Skip to content

Commit 79d5208

Browse files
wangxi11jgunthorpe
authored andcommitted
RDMA/hns: Fix wrong PBL offset when VA is not aligned to PAGE_SIZE
ROCE uses "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 smaller than the PAGE_SIZE, this will lead the HW to access the wrong memory because the offset is smaller than expected. Fixes: 9b2cf76 ("RDMA/hns: Optimize PBL buffer allocation process") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Xi Wang <[email protected]> Signed-off-by: Weihang Li <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 7b9bd73 commit 79d5208

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/infiniband/hw/hns/hns_roce_mr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ static int alloc_mr_pbl(struct hns_roce_dev *hr_dev, struct hns_roce_mr *mr,
120120

121121
mr->pbl_hop_num = is_fast ? 1 : hr_dev->caps.pbl_hop_num;
122122
buf_attr.page_shift = is_fast ? PAGE_SHIFT :
123-
hr_dev->caps.pbl_buf_pg_sz + HNS_HW_PAGE_SHIFT;
123+
hr_dev->caps.pbl_buf_pg_sz + PAGE_SHIFT;
124124
buf_attr.region[0].size = length;
125125
buf_attr.region[0].hopnum = mr->pbl_hop_num;
126126
buf_attr.region_count = 1;

0 commit comments

Comments
 (0)