drm/xe: Use Xe ordered workqueue for rebind worker
authorMatthew Brost <matthew.brost@intel.com>
Fri, 9 Jun 2023 18:19:30 +0000 (11:19 -0700)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Tue, 19 Dec 2023 23:35:21 +0000 (18:35 -0500)
A mix of the system unbound wq and Xe ordered wq was used for the
rebind, only use the Xe ordered wq. This will ensure only 1 rebind is
occuring at a time providing a somewhat clunky work around for short
comings in TTM wrt to memory contention. Once the TTM memory contention
is resolved we should be able to use a dedicated non-ordered workqueue.

Also add helper to queue rebind worker to avoid using wrong workqueue
going forward.

Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/xe_preempt_fence.c
drivers/gpu/drm/xe/xe_vm.c
drivers/gpu/drm/xe/xe_vm.h

index 78ad8c209873606c97aa255515b75b1af7ebcf0b..219eefeb90ff7c2dbf3d1d61b5685a84cea170c6 100644 (file)
@@ -25,7 +25,7 @@ static void preempt_fence_work_func(struct work_struct *w)
        dma_fence_signal(&pfence->base);
        dma_fence_end_signalling(cookie);
 
-       queue_work(system_unbound_wq, &e->vm->preempt.rebind_work);
+       xe_vm_queue_rebind_worker(e->vm);
 
        xe_engine_put(e);
 }
index fa4778bfd063955199a6d5afef7c7572d930c43b..be629783050f13d67de51909b724b1672f4d711c 100644 (file)
@@ -3086,8 +3086,7 @@ int xe_vm_bind_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
 
                        /* Rebinds may have been blocked, give worker a kick */
                        if (xe_vm_in_compute_mode(vm))
-                               queue_work(vm->xe->ordered_wq,
-                                          &vm->preempt.rebind_work);
+                               xe_vm_queue_rebind_worker(vm);
                }
 
                goto put_engine;
index 372f26153209b9dbbdb8ef07692691e9b34b7904..bb29968568412a28991ef8c3e78052ff7e34afa5 100644 (file)
@@ -124,6 +124,12 @@ int xe_vma_userptr_pin_pages(struct xe_vma *vma);
 
 int xe_vma_userptr_check_repin(struct xe_vma *vma);
 
+static inline void xe_vm_queue_rebind_worker(struct xe_vm *vm)
+{
+       XE_WARN_ON(!xe_vm_in_compute_mode(vm));
+       queue_work(vm->xe->ordered_wq, &vm->preempt.rebind_work);
+}
+
 /*
  * XE_ONSTACK_TV is used to size the tv_onstack array that is input
  * to xe_vm_lock_dma_resv() and xe_vm_unlock_dma_resv().