From d72ae701214aa8318604192ac48c31c920bba593 Mon Sep 17 00:00:00 2001 From: Yangyang Li Date: Thu, 23 Dec 2021 14:52:13 +0800 Subject: [PATCH] libhns: Bugfix for calculation of extended sge 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. Signed-off-by: Guofeng Yue --- providers/hns/hns_roce_u_verbs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/providers/hns/hns_roce_u_verbs.c b/providers/hns/hns_roce_u_verbs.c index abff0921..30ab072a 100644 --- a/providers/hns/hns_roce_u_verbs.c +++ b/providers/hns/hns_roce_u_verbs.c @@ -939,7 +939,12 @@ static void set_extend_sge_param(struct hns_roce_device *hr_dev, } qp->ex_sge.sge_shift = HNS_ROCE_SGE_SHIFT; - qp->ex_sge.sge_cnt = cnt; + + /* If the number of extended sge is not zero, they MUST use the + * space of HNS_HW_PAGE_SIZE at least. + */ + qp->ex_sge.sge_cnt = cnt ? + max(cnt, HNS_HW_PAGE_SIZE / HNS_ROCE_SGE_SIZE) : 0; } static void hns_roce_set_qp_params(struct ibv_qp_init_attr_ex *attr, -- 2.33.0