Skip to content

Commit 1033099

Browse files
icklejlahtine-intel
authored andcommitted
drm/i915/gt: Do not restore invalid RS state
Only restore valid resource streamer state from the context image, i.e. avoid restoring if we know the image is invalid. Closes: https://gitlab.freedesktop.org/drm/intel/issues/446 Signed-off-by: Chris Wilson <[email protected]> Reviewed-by: Matthew Auld <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Cc: [email protected] (cherry picked from commit ecfcd2d) Signed-off-by: Joonas Lahtinen <[email protected]>
1 parent f4b1889 commit 1033099

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

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

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,14 +1413,6 @@ static inline int mi_set_context(struct i915_request *rq, u32 flags)
14131413
int len;
14141414
u32 *cs;
14151415

1416-
flags |= MI_MM_SPACE_GTT;
1417-
if (IS_HASWELL(i915))
1418-
/* These flags are for resource streamer on HSW+ */
1419-
flags |= HSW_MI_RS_SAVE_STATE_EN | HSW_MI_RS_RESTORE_STATE_EN;
1420-
else
1421-
/* We need to save the extended state for powersaving modes */
1422-
flags |= MI_SAVE_EXT_STATE_EN | MI_RESTORE_EXT_STATE_EN;
1423-
14241416
len = 4;
14251417
if (IS_GEN(i915, 7))
14261418
len += 2 + (num_engines ? 4 * num_engines + 6 : 0);
@@ -1589,22 +1581,21 @@ static int switch_context(struct i915_request *rq)
15891581
}
15901582

15911583
if (ce->state) {
1592-
u32 hw_flags;
1584+
u32 flags;
15931585

15941586
GEM_BUG_ON(rq->engine->id != RCS0);
15951587

1596-
/*
1597-
* The kernel context(s) is treated as pure scratch and is not
1598-
* expected to retain any state (as we sacrifice it during
1599-
* suspend and on resume it may be corrupted). This is ok,
1600-
* as nothing actually executes using the kernel context; it
1601-
* is purely used for flushing user contexts.
1602-
*/
1603-
hw_flags = 0;
1604-
if (i915_gem_context_is_kernel(rq->gem_context))
1605-
hw_flags = MI_RESTORE_INHIBIT;
1588+
/* For resource streamer on HSW+ and power context elsewhere */
1589+
BUILD_BUG_ON(HSW_MI_RS_SAVE_STATE_EN != MI_SAVE_EXT_STATE_EN);
1590+
BUILD_BUG_ON(HSW_MI_RS_RESTORE_STATE_EN != MI_RESTORE_EXT_STATE_EN);
1591+
1592+
flags = MI_SAVE_EXT_STATE_EN | MI_MM_SPACE_GTT;
1593+
if (!i915_gem_context_is_kernel(rq->gem_context))
1594+
flags |= MI_RESTORE_EXT_STATE_EN;
1595+
else
1596+
flags |= MI_RESTORE_INHIBIT;
16061597

1607-
ret = mi_set_context(rq, hw_flags);
1598+
ret = mi_set_context(rq, flags);
16081599
if (ret)
16091600
return ret;
16101601
}

0 commit comments

Comments
 (0)