Skip to content

Commit

Permalink
drm/i915: Perform GGTT restore much earlier during resume
Browse files Browse the repository at this point in the history
As soon as we re-enable the various functions within the HW, they may go
off and read data via a GGTT offset. Hence, if we have not yet restored
the GGTT PTE before then, they may read and even *write* random locations
in memory.

Detected by DMAR faults during resume.

Signed-off-by: Chris Wilson <[email protected]>
Cc: Mika Kuoppala <[email protected]>
Cc: Martin Peres <[email protected]>
Cc: Joonas Lahtinen <[email protected]>
Cc: [email protected]
Reviewed-by: Mika Kuoppala <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
(cherry picked from commit cec5ca0)
Signed-off-by: Rodrigo Vivi <[email protected]>
  • Loading branch information
ickle authored and rodrigovivi committed Oct 7, 2019
1 parent 93be1ba commit 6c76a93
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 0 additions & 3 deletions drivers/gpu/drm/i915/gem/i915_gem_pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,6 @@ void i915_gem_resume(struct drm_i915_private *i915)
mutex_lock(&i915->drm.struct_mutex);
intel_uncore_forcewake_get(&i915->uncore, FORCEWAKE_ALL);

i915_gem_restore_gtt_mappings(i915);
i915_gem_restore_fences(i915);

if (i915_gem_init_hw(i915))
goto err_wedged;

Expand Down
5 changes: 5 additions & 0 deletions drivers/gpu/drm/i915/i915_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1924,6 +1924,11 @@ static int i915_drm_resume(struct drm_device *dev)
if (ret)
DRM_ERROR("failed to re-enable GGTT\n");

mutex_lock(&dev_priv->drm.struct_mutex);
i915_gem_restore_gtt_mappings(dev_priv);
i915_gem_restore_fences(dev_priv);
mutex_unlock(&dev_priv->drm.struct_mutex);

intel_csr_ucode_resume(dev_priv);

i915_restore_state(dev_priv);
Expand Down
6 changes: 6 additions & 0 deletions drivers/gpu/drm/i915/selftests/i915_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ static void pm_resume(struct drm_i915_private *i915)
with_intel_runtime_pm(&i915->runtime_pm, wakeref) {
intel_gt_sanitize(&i915->gt, false);
i915_gem_sanitize(i915);

mutex_lock(&i915->drm.struct_mutex);
i915_gem_restore_gtt_mappings(i915);
i915_gem_restore_fences(i915);
mutex_unlock(&i915->drm.struct_mutex);

i915_gem_resume(i915);
}
}
Expand Down

0 comments on commit 6c76a93

Please sign in to comment.