Skip to content

Commit dc34215

Browse files
tursulinjnikula
authored andcommitted
drm/i915: Fix context runtime accounting
When considering whether to mark one context as stopped and another as started we need to look at whether the previous and new _contexts_ are different and not just requests. Otherwise the software tracked context start time was incorrectly updated to the most recent lite-restore time- stamp, which was in some cases resulting in active time going backward, until the context switch (typically the heartbeat pulse) would synchronise with the hardware tracked context runtime. Easiest use case to observe this behaviour was with a full screen clients with close to 100% engine load. Signed-off-by: Tvrtko Ursulin <[email protected]> Fixes: bb6287c ("drm/i915: Track context current active time") Cc: <[email protected]> # v5.19+ Reviewed-by: Matthew Auld <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] [tursulin: Fix spelling in commit msg.] (cherry picked from commit b3e7005) Signed-off-by: Jani Nikula <[email protected]>
1 parent dc30c01 commit dc34215

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

drivers/gpu/drm/i915/gt/intel_execlists_submission.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,6 +2018,8 @@ process_csb(struct intel_engine_cs *engine, struct i915_request **inactive)
20182018
* inspecting the queue to see if we need to resumbit.
20192019
*/
20202020
if (*prev != *execlists->active) { /* elide lite-restores */
2021+
struct intel_context *prev_ce = NULL, *active_ce = NULL;
2022+
20212023
/*
20222024
* Note the inherent discrepancy between the HW runtime,
20232025
* recorded as part of the context switch, and the CPU
@@ -2029,9 +2031,15 @@ process_csb(struct intel_engine_cs *engine, struct i915_request **inactive)
20292031
* and correct overselves later when updating from HW.
20302032
*/
20312033
if (*prev)
2032-
lrc_runtime_stop((*prev)->context);
2034+
prev_ce = (*prev)->context;
20332035
if (*execlists->active)
2034-
lrc_runtime_start((*execlists->active)->context);
2036+
active_ce = (*execlists->active)->context;
2037+
if (prev_ce != active_ce) {
2038+
if (prev_ce)
2039+
lrc_runtime_stop(prev_ce);
2040+
if (active_ce)
2041+
lrc_runtime_start(active_ce);
2042+
}
20352043
new_timeslice(execlists);
20362044
}
20372045

0 commit comments

Comments
 (0)