Skip to content

Commit 482d234

Browse files
l00436852gregkh
authored andcommitted
RDMA/hns: Bugfix for calculation of extended sge
[ Upstream commit d34895c ] Page alignment is required when setting the number of extended sge according to the hardware's achivement. If the space of needed extended sge is greater than one page, the roundup_pow_of_two() can ensure that. But if the needed extended sge isn't 0 and can not be filled in a whole page, the driver should align it specifically. Fixes: 54d6638 ("RDMA/hns: Optimize WQE buffer size calculating process") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Yangyang Li <[email protected]> Signed-off-by: Weihang Li <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent a5c7bc6 commit 482d234

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/infiniband/hw/hns/hns_roce_qp.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,12 @@ static int set_extend_sge_param(struct hns_roce_dev *hr_dev, u32 sq_wqe_cnt,
432432
}
433433

434434
hr_qp->sge.sge_shift = HNS_ROCE_SGE_SHIFT;
435-
hr_qp->sge.sge_cnt = cnt;
435+
436+
/* If the number of extended sge is not zero, they MUST use the
437+
* space of HNS_HW_PAGE_SIZE at least.
438+
*/
439+
hr_qp->sge.sge_cnt = cnt ?
440+
max(cnt, (u32)HNS_HW_PAGE_SIZE / HNS_ROCE_SGE_SIZE) : 0;
436441

437442
return 0;
438443
}

0 commit comments

Comments
 (0)