drm/xe: Add timeout to preempt fences
Subsystems (2)
Matthew Brost
maintainerPATCH v2 1/1 drm/xe: Add timeout to preempt fences
To adhere to dma fencing rules that fences must signal within a reasonable amount of time, add a 5 second timeout to preempt fences. If this timeout occurs, kill the associated VM as this fatal to the VM.
v2:
- Add comment for smp_wmb (Checkpatch)
- Fix kernel doc typo (Inspection)
- Add comment for killed check (Niranjana)
Cc Niranjana Vishwanathapura <[email protected]>
Signed-off-by Matthew Brost <[email protected]>
Reviewed-by Niranjana Vishwanathapura <[email protected]>
--- drivers/gpu/drm/xe/xe_exec_queue_types.h | 6 ++-- drivers/gpu/drm/xe/xe_execlist.c | 3 +- drivers/gpu/drm/xe/xe_guc_submit.c | 41 ++++++++++++++++++++---- drivers/gpu/drm/xe/xe_preempt_fence.c | 14 +++++++- drivers/gpu/drm/xe/xe_vm.c | 10 +++++- drivers/gpu/drm/xe/xe_vm.h | 2 ++ 6 files changed, 65 insertions(+), 11 deletions(-)
drivers/gpu/drm/xe/xe_exec_queue_types.h +4 -2
@@ -172,9 +172,11 @@ struct xe_exec_queue_ops {int (*suspend)(struct xe_exec_queue *q);/** * @suspend_wait: Wait for an exec queue to suspend executing, should be -* call after suspend. +* call after suspend. In dma-fencing path thus must return within a +* reasonable amount of time. A non-zero return shall indicate an error +* waiting for suspend. */ -void (*suspend_wait)(struct xe_exec_queue *q); +int (*suspend_wait)(struct xe_exec_queue *q);/** * @resume: Resume exec queue execution, exec queue must be in a suspended * state and dma fence returned from most recent suspend call must be
drivers/gpu/drm/xe/xe_execlist.c +2 -1
@@ -422,10 +422,11 @@ static int execlist_exec_queue_suspend(struct xe_exec_queue *q)return 0 ; } -static void execlist_exec_queue_suspend_wait (struct xe_exec_queue *q) +static int execlist_exec_queue_suspend_wait (struct xe_exec_queue *q) {/* NIY */ +return 0 ; }static void execlist_exec_queue_resume (struct xe_exec_queue *q)
drivers/gpu/drm/xe/xe_guc_submit.c +35 -6
68 lines not on this page · raw message
drivers/gpu/drm/xe/xe_preempt_fence.c +13 -1
@@ -16,11 +16,23 @@ static void preempt_fence_work_func(struct work_struct *w)struct xe_preempt_fence *pfence =container_of (w,typeof (*pfence), preempt_work);struct xe_exec_queue *q = pfence->q; +int err =0 ;if (pfence->error)dma_fence_set_error (&pfence->base, pfence->error); +else if (!q->ops->reset_status (q)) + err = q->ops->suspend_wait (q);else - q->ops->suspend_wait (q); +dma_fence_set_error (&pfence->base, -ENOENT ); + +if (err) { +dma_fence_set_error (&pfence->base, err); + +down_write (&q->vm->lock); +xe_vm_kill (q->vm, false); +up_write (&q->vm->lock); + } +dma_fence_signal (&pfence->base);/*
drivers/gpu/drm/xe/xe_vm.c +9 -1
@@ -311,7 +311,15 @@ int __xe_vm_userptr_needs_repin(struct xe_vm *vm)#define XE_VM_REBIND_RETRY_TIMEOUT_MS 1000 -static void xe_vm_kill (struct xe_vm *vm,bool unlocked) +/** +* xe_vm_kill() - VM Kill +* @vm: The VM. +* @unlocked: Flag indicates the VM's dma-resv is not held +* +* Kill the VM by setting banned flag indicated VM is no longer available for +* use. If in preempt fence mode, also kill all exec queue attached to the VM. +*/ +void xe_vm_kill (struct xe_vm *vm,bool unlocked) {struct xe_exec_queue *q;
drivers/gpu/drm/xe/xe_vm.h +2 -0
@@ -259,6 +259,8 @@ static inline struct dma_resv *xe_vm_resv(struct xe_vm *vm)return drm_gpuvm_resv (&vm->gpuvm); } +void xe_vm_kill (struct xe_vm *vm,bool unlocked); +/** * xe_vm_assert_held(vm) - Assert that the vm's reservation object is held. * @vm: The vm
Signature · 1 line
2.34.1