The "moved" VM state is a bit unfortunately named, because BOs can end
up in this state without being physically moved. While we need to
invalidate every mapping when BOs are physically moved, in some other
cases like PRT binds/unbinds there is no need to refresh mappings except
those affected by the bind.

Full invalidation of all BO mappings manifested as severe regressions in
PRT bind performance, which this patch fixes. The offending patch is
53f0235c0284 ("drm/amdgpu: restructure VM state machine v4") in the
amd-staging-drm-next tree, although it has not yet propagated anywhere
else.

Signed-off-by: Natalie Vock <[email protected]>
---
v2: Move setting of vm_bo->moved out of amdgpu_vm_bo_moved (Christian)
v3: Set moved = true in a few more places (Christian)
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index b523a7b97d6f1..9ddeb984beff7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -232,7 +232,6 @@ static void amdgpu_vm_bo_moved(struct amdgpu_vm_bo_base 
*vm_bo)
                vm_bo->moved = false;
                list_move(&vm_bo->vm_status, &lists->idle);
        } else {
-               vm_bo->moved = true;
                list_move(&vm_bo->vm_status, &lists->moved);
        }
        amdgpu_vm_bo_unlock_lists(vm_bo);
@@ -597,6 +596,7 @@ int amdgpu_vm_validate(struct amdgpu_device *adev, struct 
amdgpu_vm *vm,
                        return r;
 
                vm->update_funcs->map_table(to_amdgpu_bo_vm(bo_base->bo));
+               bo_base->moved = true;
                amdgpu_vm_bo_moved(bo_base);
        }
 
@@ -614,6 +614,7 @@ int amdgpu_vm_validate(struct amdgpu_device *adev, struct 
amdgpu_vm *vm,
                if (r)
                        return r;
 
+               bo_base->moved = true;
                amdgpu_vm_bo_moved(bo_base);
        }
 
@@ -634,6 +635,7 @@ int amdgpu_vm_validate(struct amdgpu_device *adev, struct 
amdgpu_vm *vm,
                if (r)
                        return r;
 
+               bo_base->moved = true;
                amdgpu_vm_bo_moved(bo_base);
 
                /* It's a bit inefficient to always jump back to the start, but
@@ -2270,6 +2272,7 @@ void amdgpu_vm_bo_invalidate(struct amdgpu_bo *bo, bool 
evicted)
 
                if (bo_base->moved)
                        continue;
+               bo_base->moved = true;
                amdgpu_vm_bo_moved(bo_base);
        }
 }
-- 
2.54.0

Reply via email to