]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
RDMA/hns: Disassociate mmap pages for all uctx when HW is being reset
authorChengchang Tang <tangchengchang@huawei.com>
Fri, 27 Sep 2024 10:33:23 +0000 (18:33 +0800)
committerLeon Romanovsky <leon@kernel.org>
Mon, 7 Oct 2024 05:53:23 +0000 (08:53 +0300)
When HW is being reset, userspace should not ring doorbell otherwise
it may lead to abnormal consequence such as RAS.

Disassociate mmap pages for all uctx to prevent userspace from ringing
doorbell to HW. Since all resources will be destroyed during HW reset,
no new mmap is allowed after HW reset is completed.

Fixes: 9a4435375cd1 ("IB/hns: Add driver files for hns RoCE driver")
Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
Link: https://patch.msgid.link/20240927103323.1897094-3-huangjunxian6@hisilicon.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/hns/hns_roce_hw_v2.c
drivers/infiniband/hw/hns/hns_roce_main.c

index 24e906b9d3ae137f8f4e29624ffd3e384b0aa310..f1feaa79f78eee35cd6e109f74b25205544189ce 100644 (file)
@@ -7017,6 +7017,7 @@ static void hns_roce_hw_v2_uninit_instance(struct hnae3_handle *handle,
 
        handle->rinfo.instance_state = HNS_ROCE_STATE_NON_INIT;
 }
+
 static int hns_roce_hw_v2_reset_notify_down(struct hnae3_handle *handle)
 {
        struct hns_roce_dev *hr_dev;
@@ -7035,6 +7036,9 @@ static int hns_roce_hw_v2_reset_notify_down(struct hnae3_handle *handle)
 
        hr_dev->active = false;
        hr_dev->dis_db = true;
+
+       rdma_user_mmap_disassociate(&hr_dev->ib_dev);
+
        hr_dev->state = HNS_ROCE_DEVICE_STATE_RST_DOWN;
 
        return 0;
index 4cb0af73358708e016e5825100343f15995b1690..49315f39361ded1553e1222e3ff3e425517d2ef1 100644 (file)
@@ -466,6 +466,11 @@ static int hns_roce_mmap(struct ib_ucontext *uctx, struct vm_area_struct *vma)
        pgprot_t prot;
        int ret;
 
+       if (hr_dev->dis_db) {
+               atomic64_inc(&hr_dev->dfx_cnt[HNS_ROCE_DFX_MMAP_ERR_CNT]);
+               return -EPERM;
+       }
+
        rdma_entry = rdma_user_mmap_entry_get_pgoff(uctx, vma->vm_pgoff);
        if (!rdma_entry) {
                atomic64_inc(&hr_dev->dfx_cnt[HNS_ROCE_DFX_MMAP_ERR_CNT]);