From c62ceef898e9548e44c0bb31204eec34977ef97c Mon Sep 17 00:00:00 2001 From: wenglianfa Date: Wed, 21 Feb 2024 11:02:23 +0800 Subject: [PATCH 1/2] RDMA/hns: fix error return in hns_roce_v2_modify_srq() driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I9FAYN ------------------------------------ When none of the conditions of the 'if' block are met, 0 should be returned instead of -EOPNOTSUPP. Fixes: 5e7ecc38d89b ("RDMA/hns: Support SW stats with debugfs") Signed-off-by: wenglianfa Signed-off-by: Zihao Xue --- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index 2c03f556f8e0..dbdf3b4081b1 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -6346,11 +6346,13 @@ static int hns_roce_v2_modify_srq(struct ib_srq *ibsrq, struct hns_roce_srq_context *srq_context; struct hns_roce_srq_context *srqc_mask; struct hns_roce_cmd_mailbox *mailbox; - int ret = -EOPNOTSUPP; + int ret = 0; /* Resizing SRQs is not supported yet */ - if (srq_attr_mask & IB_SRQ_MAX_WR) + if (srq_attr_mask & IB_SRQ_MAX_WR) { + ret = -EOPNOTSUPP; goto out; + } if (srq_attr_mask & IB_SRQ_LIMIT) { if (srq_attr->srq_limit > srq->wqe_cnt) { -- Gitee From b3315e6cec09265342537e5e226de4028c6cec4f Mon Sep 17 00:00:00 2001 From: Junxian Huang Date: Tue, 19 Mar 2024 21:33:54 +0800 Subject: [PATCH 2/2] RDMA/hns: Fix incorrect iteration number of DCA umem sg entries driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I9FAYN ------------------------------------ RDMA uses sg list to describe umem buffer. While mapping IOVA in IOMMU, an sg entry may be concatenated with the previous entry if certain length and boundary conditions are met. IOMMU will always return the number of sg entries after the concatenation, and the dma address of a concatenated entry defaults to DMA_MAPPING_ERROR (0xFFFFFFFFFFFFFFFF). But currently in DCA mode, hns RoCE driver still use the originally allocated number of the sg entries to iterate sg list. This causes that the driver may access the concatenated sg entries and fill DMA_MAPPING_ERROR to HW, triggering SMMU translation fault and RAS. Use the entry number returned by IOMMU to set the maximum iteration number of DCA umem sg entries to fix this problem, instead of the originally allocated number. Fixes: 12aa71f83089 ("RDMA/hns: Add DCA support for kernel space") Fixes: f44a2f97d82a ("RDMA/hns: Introduce DCA for RC QP") Signed-off-by: Junxian Huang Signed-off-by: Zihao Xue --- drivers/infiniband/hw/hns/hns_roce_dca.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/hw/hns/hns_roce_dca.c b/drivers/infiniband/hw/hns/hns_roce_dca.c index 12bf7668f8d4..dc5c6365df2e 100644 --- a/drivers/infiniband/hw/hns/hns_roce_dca.c +++ b/drivers/infiniband/hw/hns/hns_roce_dca.c @@ -175,8 +175,7 @@ static void init_dca_umem_states(struct hns_dca_page_state *states, int count, int i = 0; pre_addr = 0; - rdma_for_each_block(umem->sg_head.sgl, &biter, - umem->sg_head.nents, HNS_HW_PAGE_SIZE) { + rdma_umem_for_each_dma_block(umem, &biter, HNS_HW_PAGE_SIZE) { cur_addr = rdma_block_iter_dma_address(&biter); if (i < count) { if (cur_addr - pre_addr != HNS_HW_PAGE_SIZE) @@ -276,8 +275,7 @@ static int get_alloced_umem_proc(struct dca_mem *mem, int index, void *param) struct ib_block_iter biter; u32 i = 0; - rdma_for_each_block(umem->sg_head.sgl, &biter, - umem->sg_head.nents, HNS_HW_PAGE_SIZE) { + rdma_umem_for_each_dma_block(umem, &biter, HNS_HW_PAGE_SIZE) { if (dca_page_is_allocated(&states[i], attr->buf_id)) { attr->pages[attr->total++] = rdma_block_iter_dma_address(&biter); -- Gitee