Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,9 @@ static int amdgpu_cs_vm_handling(struct amdgpu_cs_parser *p)
}
}

if (!amdgpu_vm_ready(vm))
return -EINVAL;

r = amdgpu_vm_clear_freed(adev, vm, NULL);
if (r)
return r;
Expand Down
15 changes: 11 additions & 4 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,22 +502,29 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm,
* Check if all VM PDs/PTs are ready for updates
*
* Returns:
* True if VM is not evicting.
* True if VM is not evicting and all VM entities are not stopped
*/
bool amdgpu_vm_ready(struct amdgpu_vm *vm)
{
bool empty;
bool ret;

amdgpu_vm_eviction_lock(vm);
ret = !vm->evicting;
amdgpu_vm_eviction_unlock(vm);

spin_lock(&vm->status_lock);
empty = list_empty(&vm->evicted);
ret &= list_empty(&vm->evicted);
spin_unlock(&vm->status_lock);

return ret && empty;
spin_lock(&vm->immediate.lock);
ret &= !vm->immediate.stopped;
spin_unlock(&vm->immediate.lock);

spin_lock(&vm->delayed.lock);
ret &= !vm->delayed.stopped;
spin_unlock(&vm->delayed.lock);

return ret;
}

/**
Expand Down
Loading