From 8e41443e1bb7a9aa03263ab9e317ef04927be5aa Mon Sep 17 00:00:00 2001 From: Thomas Hellström Date: Tue, 14 Mar 2023 15:56:44 +0100 Subject: drm/xe/vm: Defer vm rebind until next exec if nothing to execute MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If all compute engines of a vm in compute mode are idle, defer a rebind to the next exec to avoid the VM unnecessarily trying to make memory resident and compete with other VMs for available memory space. Signed-off-by: Thomas Hellström Reviewed-by: Matthew Brost Signed-off-by: Rodrigo Vivi --- drivers/gpu/drm/xe/xe_vm.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'drivers/gpu/drm/xe/xe_vm.c') diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c index 6cc3204adaa8..207d20da5c68 100644 --- a/drivers/gpu/drm/xe/xe_vm.c +++ b/drivers/gpu/drm/xe/xe_vm.c @@ -226,6 +226,19 @@ static int wait_for_existing_preempt_fences(struct xe_vm *vm) return 0; } +static bool xe_vm_is_idle(struct xe_vm *vm) +{ + struct xe_engine *e; + + xe_vm_assert_held(vm); + list_for_each_entry(e, &vm->preempt.engines, compute.link) { + if (!xe_engine_is_idle(e)) + return false; + } + + return true; +} + static void arm_preempt_fences(struct xe_vm *vm, struct list_head *list) { struct list_head *link; @@ -548,6 +561,11 @@ retry: if (err) goto out_unlock_outer; + if (xe_vm_is_idle(vm)) { + vm->preempt.rebind_deactivated = true; + goto out_unlock; + } + /* Fresh preempt fences already installed. Everyting is running. */ if (!preempt_fences_waiting(vm)) goto out_unlock; -- cgit v1.2.3