drm/i915: Fix context runtime accounting
authorjsg <jsg@openbsd.org>
Mon, 17 Apr 2023 05:13:20 +0000 (05:13 +0000)
committerjsg <jsg@openbsd.org>
Mon, 17 Apr 2023 05:13:20 +0000 (05:13 +0000)
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

index 682f9a6..c93b715 100644 (file)
@@ -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);
        }