drm/i915: Restore memory mapping for DPT FBs across system suspend/resume
authorImre Deak <imre.deak@intel.com>
Mon, 1 Nov 2021 18:35:51 +0000 (20:35 +0200)
committerImre Deak <imre.deak@intel.com>
Wed, 3 Nov 2021 09:07:24 +0000 (11:07 +0200)
At least during hibernation the DPT mappings are lost with all stolen
memory content, so suspend/resume these mappings similarly to GGTT
mappings.

This fixes a problem where the restoring modeset during system resume fails
with pipe faults if a tiled framebuffer was active before suspend.

v2: Clarify the way restore works in intel_dpt_resume()'s Docbook entry.
    (Chris)

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Vunny Sodhi <vunny.sodhi@intel.com>
Reported-and-tested-by: Vunny Sodhi <vunny.sodhi@intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211101183551.3580546-2-imre.deak@intel.com
drivers/gpu/drm/i915/display/intel_dpt.c
drivers/gpu/drm/i915/display/intel_dpt.h
drivers/gpu/drm/i915/i915_drv.c

index 8f7b1f7..5675578 100644 (file)
@@ -167,6 +167,58 @@ void intel_dpt_unpin(struct i915_address_space *vm)
        i915_vma_put(dpt->vma);
 }
 
+/**
+ * intel_dpt_resume - restore the memory mapping for all DPT FBs during system resume
+ * @i915: device instance
+ *
+ * Restore the memory mapping during system resume for all framebuffers which
+ * are mapped to HW via a GGTT->DPT page table. The content of these page
+ * tables are not stored in the hibernation image during S4 and S3RST->S4
+ * transitions, so here we reprogram the PTE entries in those tables.
+ *
+ * This function must be called after the mappings in GGTT have been restored calling
+ * i915_ggtt_resume().
+ */
+void intel_dpt_resume(struct drm_i915_private *i915)
+{
+       struct drm_framebuffer *drm_fb;
+
+       mutex_lock(&i915->drm.mode_config.fb_lock);
+       drm_for_each_fb(drm_fb, &i915->drm) {
+               struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb);
+
+               if (fb->dpt_vm)
+                       i915_ggtt_resume_vm(fb->dpt_vm);
+       }
+       mutex_unlock(&i915->drm.mode_config.fb_lock);
+}
+
+/**
+ * intel_dpt_suspend - suspend the memory mapping for all DPT FBs during system suspend
+ * @i915: device instance
+ *
+ * Suspend the memory mapping during system suspend for all framebuffers which
+ * are mapped to HW via a GGTT->DPT page table.
+ *
+ * This function must be called before the mappings in GGTT are suspended calling
+ * i915_ggtt_suspend().
+ */
+void intel_dpt_suspend(struct drm_i915_private *i915)
+{
+       struct drm_framebuffer *drm_fb;
+
+       mutex_lock(&i915->drm.mode_config.fb_lock);
+
+       drm_for_each_fb(drm_fb, &i915->drm) {
+               struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb);
+
+               if (fb->dpt_vm)
+                       i915_ggtt_suspend_vm(fb->dpt_vm);
+       }
+
+       mutex_unlock(&i915->drm.mode_config.fb_lock);
+}
+
 struct i915_address_space *
 intel_dpt_create(struct intel_framebuffer *fb)
 {
index 45142b8..e18a9f7 100644 (file)
@@ -6,6 +6,8 @@
 #ifndef __INTEL_DPT_H__
 #define __INTEL_DPT_H__
 
+struct drm_i915_private;
+
 struct i915_address_space;
 struct i915_vma;
 struct intel_framebuffer;
@@ -13,6 +15,8 @@ struct intel_framebuffer;
 void intel_dpt_destroy(struct i915_address_space *vm);
 struct i915_vma *intel_dpt_pin(struct i915_address_space *vm);
 void intel_dpt_unpin(struct i915_address_space *vm);
+void intel_dpt_suspend(struct drm_i915_private *i915);
+void intel_dpt_resume(struct drm_i915_private *i915);
 struct i915_address_space *
 intel_dpt_create(struct intel_framebuffer *fb);
 
index 1e5b75a..4a054aa 100644 (file)
@@ -51,6 +51,7 @@
 #include "display/intel_dmc.h"
 #include "display/intel_display_types.h"
 #include "display/intel_dp.h"
+#include "display/intel_dpt.h"
 #include "display/intel_fbdev.h"
 #include "display/intel_hotplug.h"
 #include "display/intel_overlay.h"
@@ -1128,6 +1129,8 @@ static int i915_drm_suspend(struct drm_device *dev)
 
        intel_suspend_hw(dev_priv);
 
+       /* Must be called before GGTT is suspended. */
+       intel_dpt_suspend(dev_priv);
        i915_ggtt_suspend(&dev_priv->ggtt);
 
        i915_save_display(dev_priv);
@@ -1244,6 +1247,8 @@ static int i915_drm_resume(struct drm_device *dev)
                drm_err(&dev_priv->drm, "failed to re-enable GGTT\n");
 
        i915_ggtt_resume(&dev_priv->ggtt);
+       /* Must be called after GGTT is resumed. */
+       intel_dpt_resume(dev_priv);
 
        intel_dmc_ucode_resume(dev_priv);