drm/i915: Move drm_framebuffer_unreference out of struct_mutex for takeover
authorTvrtko Ursulin <tvrtko.ursulin@intel.com>
Mon, 13 Apr 2015 15:03:03 +0000 (16:03 +0100)
committerJani Nikula <jani.nikula@intel.com>
Tue, 14 Apr 2015 13:09:05 +0000 (16:09 +0300)
intel_user_framebuffer_destroy() requires the struct_mutex for its
object bookkeeping, so this means that all calls to
drm_framebuffer_unreference must be held without that lock.

This is a simplified version of the identically named patch by Chris Wilson.

    Regression from commit ab8d66752a9c28cd6c94fa173feacdfc1554aa03
    Author: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
    Date:   Mon Feb 2 15:44:15 2015 +0000

        drm/i915: Track old framebuffer instead of object

v2: Bikeshedding.

References: https://bugs.freedesktop.org/show_bug.cgi?id=89166
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
drivers/gpu/drm/i915/intel_display.c

index 5b32b682bc3e9c8c03d355f59db81f86ed348f0a..d547d9c8dda2226909fcdbc5193dde4e2013246a 100644 (file)
@@ -14259,6 +14259,7 @@ void intel_modeset_gem_init(struct drm_device *dev)
        struct drm_i915_private *dev_priv = dev->dev_private;
        struct drm_crtc *c;
        struct drm_i915_gem_object *obj;
+       int ret;
 
        mutex_lock(&dev->struct_mutex);
        intel_init_gt_powersave(dev);
@@ -14283,16 +14284,18 @@ void intel_modeset_gem_init(struct drm_device *dev)
         * pinned & fenced.  When we do the allocation it's too early
         * for this.
         */
-       mutex_lock(&dev->struct_mutex);
        for_each_crtc(dev, c) {
                obj = intel_fb_obj(c->primary->fb);
                if (obj == NULL)
                        continue;
 
-               if (intel_pin_and_fence_fb_obj(c->primary,
-                                              c->primary->fb,
-                                              c->primary->state,
-                                              NULL)) {
+               mutex_lock(&dev->struct_mutex);
+               ret = intel_pin_and_fence_fb_obj(c->primary,
+                                                c->primary->fb,
+                                                c->primary->state,
+                                                NULL);
+               mutex_unlock(&dev->struct_mutex);
+               if (ret) {
                        DRM_ERROR("failed to pin boot fb on pipe %d\n",
                                  to_intel_crtc(c)->pipe);
                        drm_framebuffer_unreference(c->primary->fb);
@@ -14300,7 +14303,6 @@ void intel_modeset_gem_init(struct drm_device *dev)
                        update_state_fb(c->primary);
                }
        }
-       mutex_unlock(&dev->struct_mutex);
 
        intel_backlight_register(dev);
 }