drm/i915: release the GTT mmaps when going into D3
authorPaulo Zanoni <paulo.r.zanoni@intel.com>
Fri, 13 Dec 2013 17:22:31 +0000 (15:22 -0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Sat, 14 Dec 2013 14:35:52 +0000 (15:35 +0100)
So we'll get a fault when someone tries to access the mmap, then we'll
wake up from D3.

v2: - Rebase
v3: - Use gtt active/inactive

Testcase: igt/pm_pc8/gem-mmap-gtt
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@gmail.com>
[danvet: Add comment + WARN as discussed with Paulo on irc.]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_drv.c
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_gem.c

index df634a42cc0c1e2f01ec494c99eff668be2720ae..aea909b2f22e545441fd4011dbf8726582259c4e 100644 (file)
@@ -917,6 +917,8 @@ static int i915_runtime_suspend(struct device *device)
 
        DRM_DEBUG_KMS("Suspending device\n");
 
+       i915_gem_release_all_mmaps(dev_priv);
+
        del_timer_sync(&dev_priv->gpu_error.hangcheck_timer);
        dev_priv->pm.suspended = true;
        intel_opregion_notify_adapter(dev, PCI_D3cold);
index ae2c80c1981b123fe40318606375f7f05f0d533e..9e4b5ca6ee7235cada79c8494ee912680b35910e 100644 (file)
@@ -2015,6 +2015,7 @@ void i915_gem_object_unpin(struct drm_i915_gem_object *obj);
 int __must_check i915_vma_unbind(struct i915_vma *vma);
 int __must_check i915_gem_object_ggtt_unbind(struct drm_i915_gem_object *obj);
 int i915_gem_object_put_pages(struct drm_i915_gem_object *obj);
+void i915_gem_release_all_mmaps(struct drm_i915_private *dev_priv);
 void i915_gem_release_mmap(struct drm_i915_gem_object *obj);
 void i915_gem_lastclose(struct drm_device *dev);
 
index e34b48e862e779e89b368d1cb04953971dc58817..c5a99c46ca9c0e2a20fc6a8ffe94accb4389404a 100644 (file)
@@ -1465,6 +1465,22 @@ out:
        return ret;
 }
 
+void i915_gem_release_all_mmaps(struct drm_i915_private *dev_priv)
+{
+       struct i915_vma *vma;
+
+       /*
+        * Only the global gtt is relevant for gtt memory mappings, so restrict
+        * list traversal to objects bound into the global address space. Note
+        * that the active list should be empty, but better safe than sorry.
+        */
+       WARN_ON(!list_empty(&dev_priv->gtt.base.active_list));
+       list_for_each_entry(vma, &dev_priv->gtt.base.active_list, mm_list)
+               i915_gem_release_mmap(vma->obj);
+       list_for_each_entry(vma, &dev_priv->gtt.base.inactive_list, mm_list)
+               i915_gem_release_mmap(vma->obj);
+}
+
 /**
  * i915_gem_release_mmap - remove physical page mappings
  * @obj: obj in question