drm/amdgpu: fix clearing mappings for BOs that are always valid in VM
authorjsg <jsg@openbsd.org>
Wed, 26 Jul 2023 06:31:05 +0000 (06:31 +0000)
committerjsg <jsg@openbsd.org>
Wed, 26 Jul 2023 06:31:05 +0000 (06:31 +0000)
From Samuel Pitoiset
91e69e67d401eb67178ce5992ddc9b1046b39ee7 in linux-6.1.y/6.1.40
ea2c3c08554601b051d91403a241266e1cf490a5 in mainline linux

sys/dev/pci/drm/amd/amdgpu/amdgpu_vm.c

index 1d6ff4d..54e47f3 100644 (file)
@@ -1730,18 +1730,30 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev,
 
        /* Insert partial mapping before the range */
        if (!list_empty(&before->list)) {
+               struct amdgpu_bo *bo = before->bo_va->base.bo;
+
                amdgpu_vm_it_insert(before, &vm->va);
                if (before->flags & AMDGPU_PTE_PRT)
                        amdgpu_vm_prt_get(adev);
+
+               if (bo && bo->tbo.base.resv == vm->root.bo->tbo.base.resv &&
+                   !before->bo_va->base.moved)
+                       amdgpu_vm_bo_moved(&before->bo_va->base);
        } else {
                kfree(before);
        }
 
        /* Insert partial mapping after the range */
        if (!list_empty(&after->list)) {
+               struct amdgpu_bo *bo = after->bo_va->base.bo;
+
                amdgpu_vm_it_insert(after, &vm->va);
                if (after->flags & AMDGPU_PTE_PRT)
                        amdgpu_vm_prt_get(adev);
+
+               if (bo && bo->tbo.base.resv == vm->root.bo->tbo.base.resv &&
+                   !after->bo_va->base.moved)
+                       amdgpu_vm_bo_moved(&after->bo_va->base);
        } else {
                kfree(after);
        }