Commit cf667aec authored by Matthew Brost's avatar Matthew Brost Committed by Rodrigo Vivi

drm/xe: Decrement fault mode counts in xe_vm_close_and_put

Rather waiting for the VM to be destroyed (all refs to VM go to zero),
drop the fault mode counts when the VM is closed in xe_vm_close_and_put.
This avoids a window where user space can create a faulting VM, close
it, and a subsequent creation of a non-faulting VM fails.

v2 (Lucas): Drop VLK reference in commit message
Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Suggested-by: default avatarNiranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
Signed-off-by: default avatarMatthew Brost <matthew.brost@intel.com>
Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
parent ef5e3c2f
...@@ -1427,6 +1427,13 @@ void xe_vm_close_and_put(struct xe_vm *vm) ...@@ -1427,6 +1427,13 @@ void xe_vm_close_and_put(struct xe_vm *vm)
XE_WARN_ON(!list_empty(&vm->extobj.list)); XE_WARN_ON(!list_empty(&vm->extobj.list));
up_write(&vm->lock); up_write(&vm->lock);
mutex_lock(&xe->usm.lock);
if (vm->flags & XE_VM_FLAG_FAULT_MODE)
xe->usm.num_vm_in_fault_mode--;
else if (!(vm->flags & XE_VM_FLAG_MIGRATION))
xe->usm.num_vm_in_non_fault_mode--;
mutex_unlock(&xe->usm.lock);
xe_vm_put(vm); xe_vm_put(vm);
} }
...@@ -1469,18 +1476,10 @@ static void vm_destroy_work_func(struct work_struct *w) ...@@ -1469,18 +1476,10 @@ static void vm_destroy_work_func(struct work_struct *w)
} }
xe_vm_unlock(vm, &ww); xe_vm_unlock(vm, &ww);
mutex_lock(&xe->usm.lock);
if (vm->flags & XE_VM_FLAG_FAULT_MODE)
xe->usm.num_vm_in_fault_mode--;
else if (!(vm->flags & XE_VM_FLAG_MIGRATION))
xe->usm.num_vm_in_non_fault_mode--;
mutex_unlock(&xe->usm.lock);
trace_xe_vm_free(vm); trace_xe_vm_free(vm);
dma_fence_put(vm->rebind_fence); dma_fence_put(vm->rebind_fence);
dma_resv_fini(&vm->resv); dma_resv_fini(&vm->resv);
kfree(vm); kfree(vm);
} }
void xe_vm_free(struct kref *ref) void xe_vm_free(struct kref *ref)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment