drm/i915: The shrinker already acquires struct_mutex, so call it unlocked
authorChris Wilson <chris@chris-wilson.co.uk>
Fri, 7 Apr 2017 10:25:49 +0000 (11:25 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Fri, 7 Apr 2017 11:25:11 +0000 (12:25 +0100)
The shrinker is prepared to be called unlocked (and at other times with
struct_mutex held for DIRECT_RECLAIM) so we can skip acquiring the
struct_mutex prior to calling the shrinker during freeze. This improves
our ability to shrink as we can be more aggressive when we know the
caller isn't holding struct_mutex.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170407102552.5781-1-chris@chris-wilson.co.uk
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
drivers/gpu/drm/i915/i915_gem.c

index 391aa69097f1da056413f5ea8c1e859b39dc40a9..372183e21c722be9e928054ac27b4981a7f06ac4 100644 (file)
@@ -4864,9 +4864,10 @@ void i915_gem_load_cleanup(struct drm_i915_private *dev_priv)
 
 int i915_gem_freeze(struct drm_i915_private *dev_priv)
 {
-       mutex_lock(&dev_priv->drm.struct_mutex);
+       /* Discard all purgeable objects, let userspace recover those as
+        * required after resuming.
+        */
        i915_gem_shrink_all(dev_priv);
-       mutex_unlock(&dev_priv->drm.struct_mutex);
 
        return 0;
 }
@@ -4891,12 +4892,12 @@ int i915_gem_freeze_late(struct drm_i915_private *dev_priv)
         * we update that state just before writing out the image.
         *
         * To try and reduce the hibernation image, we manually shrink
-        * the objects as well.
+        * the objects as well, see i915_gem_freeze()
         */
 
-       mutex_lock(&dev_priv->drm.struct_mutex);
        i915_gem_shrink(dev_priv, -1UL, I915_SHRINK_UNBOUND);
 
+       mutex_lock(&dev_priv->drm.struct_mutex);
        for (p = phases; *p; p++) {
                list_for_each_entry(obj, *p, global_link) {
                        obj->base.read_domains = I915_GEM_DOMAIN_CPU;