From acea238e2dd62b2a77e0ca301c16682a2f45aac8 Mon Sep 17 00:00:00 2001 From: Junxian Huang Date: Sun, 28 Sep 2025 15:49:24 +0800 Subject: [PATCH 1/2] RDMA/hns: Fix wrong WQE data when QP wraps around MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ID0KK4 ---------------------------------------------------------------------- When QP wraps around, WQE data from the previous use at the same position still remains. Driver does not clear the WQE currently, causing that the fields that are not explicitly assigned retain stale values, and are issued to HW by mistake. This issue only has a real impact when the current WQE’s opcode is FRMR while the previous use at the same position wasn't, because the field parsing of an FRMR WQE is different from other opcodes. Therefore, for performance reasons, fix the problem by clearing only the two fields in the FRMR WQE that are not explicitly assigned currently, instead of clearing the entire WQE. Fixes: 68a997c5d28c ("RDMA/hns: Add FRMR support for hip08") Signed-off-by: Junxian Huang Signed-off-by: Donghua Huang --- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index a6f29ca2283d..2bde40ed626e 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -167,6 +167,8 @@ static void set_frmr_seg(struct hns_roce_v2_rc_send_wqe *rc_sq_wqe, hr_reg_write(fseg, FRMR_PBL_BUF_PG_SZ, to_hr_hw_page_shift(mr->pbl_mtr->hem_cfg.buf_pg_shift)); hr_reg_clear(fseg, FRMR_BLK_MODE); + hr_reg_clear(fseg, FRMR_BLOCK_SIZE); + hr_reg_clear(fseg, FRMR_ZBVA); } static void set_atomic_seg(const struct ib_send_wr *wr, -- Gitee From 766a79a6b4920ba04ec4e8e15883d88a7db87dd2 Mon Sep 17 00:00:00 2001 From: Chengchang Tang Date: Fri, 26 Apr 2024 11:25:52 +0800 Subject: [PATCH 2/2] RDMA/hns: Fix soft lockup in ib_umem_release() driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ID0KK4 ---------------------------------------------------------------------- ib_umem_release() may have poor performance when there is a lot of concurrency. This leads to soft lockup in concurrent scenarios. Call trace: page_counter_cancel+0x30/0xc0 page_counter_uncharge+0x30/0x4c uncharge_batch+0xd8/0x1a0 mem_cgroup_uncharge+0x54/0x80 __put_page+0x70/0xa4 put_page_refs+0x104/0x110 put_compound_head+0x134/0x150 unpin_user_page_range_dirty_lock+0x214/0x340 __ib_umem_release+0x88/0xc0 ib_umem_release.part.0+0x28/0xf0 ib_umem_release+0x20/0x40 free_mr_pbl+0x4c/0x9c [hns_roce_hw_v2] hns_roce_dereg_mr+0x48/0x120 [hns_roce_hw_v2] ib_dereg_mr_user+0x4c/0x140 uverbs_free_mr+0x1c/0x30 destroy_hw_idr_uobject+0x30/0x90 uverbs_destroy_uobject+0x44/0x210 __uverbs_cleanup_ufile+0xb4/0x11c uverbs_destroy_ufile_hw+0x4c/0x120 ib_uverbs_close+0x28/0x100 __fput+0xb8/0x260 ____fput+0x14/0x1c task_work_run+0xd0/0x1a0 do_exit+0x1ac/0x450 do_group_exit+0x3c/0x124 get_signal+0x1e0/0x71c do_signal+0x148/0x1f4 do_notify_resume+0x150/0x1d0 work_pending+0xc/0x50 Add a scheduling point to solve the soft lockup. Fixes: eb8ffbfed50e ("[PATCH] IB uverbs: memory pinning implementation") Signed-off-by: Chengchang Tang Signed-off-by: Donghua Huang --- drivers/infiniband/core/umem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c index 2ed282cd2940..d1f45c22a6c3 100644 --- a/drivers/infiniband/core/umem.c +++ b/drivers/infiniband/core/umem.c @@ -58,9 +58,11 @@ static void __ib_umem_release(struct ib_device *dev, struct ib_umem *umem, int d ib_dma_unmap_sg(dev, umem->sg_head.sgl, umem->sg_nents, DMA_BIDIRECTIONAL); - for_each_sg(umem->sg_head.sgl, sg, umem->sg_nents, i) + for_each_sg(umem->sg_head.sgl, sg, umem->sg_nents, i) { + cond_resched(); unpin_user_page_range_dirty_lock(sg_page(sg), DIV_ROUND_UP(sg->length, PAGE_SIZE), make_dirty); + } sg_free_table(&umem->sg_head); } -- Gitee