From 46783629e9479f7bc615fdbc17affbfdd3c90c4e Mon Sep 17 00:00:00 2001 From: jsg Date: Mon, 17 Apr 2023 05:13:20 +0000 Subject: [PATCH] drm/i915: Fix context runtime accounting From Tvrtko Ursulin 4e29fb89f771316caed9e4d166213b10dd49eb2e in linux-6.1.y/6.1.24 dc3421560a67361442f33ec962fc6dd48895a0df in mainline linux --- sys/dev/pci/drm/i915/gt/intel_execlists_submission.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sys/dev/pci/drm/i915/gt/intel_execlists_submission.c b/sys/dev/pci/drm/i915/gt/intel_execlists_submission.c index 682f9a6a6b1..c93b715c2ae 100644 --- a/sys/dev/pci/drm/i915/gt/intel_execlists_submission.c +++ b/sys/dev/pci/drm/i915/gt/intel_execlists_submission.c @@ -2020,6 +2020,8 @@ process_csb(struct intel_engine_cs *engine, struct i915_request **inactive) * inspecting the queue to see if we need to resumbit. */ if (*prev != *execlists->active) { /* elide lite-restores */ + struct intel_context *prev_ce = NULL, *active_ce = NULL; + /* * Note the inherent discrepancy between the HW runtime, * recorded as part of the context switch, and the CPU @@ -2031,9 +2033,15 @@ process_csb(struct intel_engine_cs *engine, struct i915_request **inactive) * and correct overselves later when updating from HW. */ if (*prev) - lrc_runtime_stop((*prev)->context); + prev_ce = (*prev)->context; if (*execlists->active) - lrc_runtime_start((*execlists->active)->context); + active_ce = (*execlists->active)->context; + if (prev_ce != active_ce) { + if (prev_ce) + lrc_runtime_stop(prev_ce); + if (active_ce) + lrc_runtime_start(active_ce); + } new_timeslice(execlists); } -- 2.20.1