drm/i915: Make plane fb tracking work correctly, v2.
authorMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Wed, 23 Sep 2015 11:27:08 +0000 (13:27 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Mon, 19 Oct 2015 09:31:41 +0000 (11:31 +0200)
atomic->disabled_planes is a hack that had to exist because
prepare_fb was only called when a new fb was set. This messed
up fb tracking in some circumstances like aborts from
interruptible waits. As a result interruptible waiting in
prepare_plane_fb was forbidden, but other errors could still
cause frontbuffer tracking to be messed up.

Now that prepare_fb is always called, this hack is no longer
required and prepare_fb may fail without consequences.

Changes since v1:
- Clean up a few fb tracking warnings by changing plane->fb to
  plane->state->fb.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Ander Conselvan de Oliveira <conselvan2@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_drv.h

index 82128b95785cb63c4c5c443102d01ce7dee2f5b4..8b98694896516a237e586d746bb6c7fc3777841f 100644 (file)
@@ -4805,17 +4805,6 @@ static void intel_pre_plane_update(struct intel_crtc *crtc)
        struct drm_device *dev = crtc->base.dev;
        struct drm_i915_private *dev_priv = dev->dev_private;
        struct intel_crtc_atomic_commit *atomic = &crtc->atomic;
-       struct drm_plane *p;
-
-       /* Track fb's for any planes being disabled */
-       drm_for_each_plane_mask(p, dev, atomic->disabled_planes) {
-               struct intel_plane *plane = to_intel_plane(p);
-
-               mutex_lock(&dev->struct_mutex);
-               i915_gem_track_fb(intel_fb_obj(plane->base.fb), NULL,
-                                 plane->frontbuffer_bit);
-               mutex_unlock(&dev->struct_mutex);
-       }
 
        if (atomic->wait_for_flips)
                intel_crtc_wait_for_pending_flips(&crtc->base);
@@ -11599,14 +11588,6 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
                        return ret;
        }
 
-       /*
-        * Disabling a plane is always okay; we just need to update
-        * fb tracking in a special way since cleanup_fb() won't
-        * get called by the plane helpers.
-        */
-       if (old_plane_state->base.fb && !fb)
-               intel_crtc->atomic.disabled_planes |= 1 << i;
-
        was_visible = old_plane_state->visible;
        visible = to_intel_plane_state(plane_state)->visible;
 
@@ -13354,15 +13335,17 @@ intel_prepare_plane_fb(struct drm_plane *plane,
        struct drm_framebuffer *fb = new_state->fb;
        struct intel_plane *intel_plane = to_intel_plane(plane);
        struct drm_i915_gem_object *obj = intel_fb_obj(fb);
-       struct drm_i915_gem_object *old_obj = intel_fb_obj(plane->fb);
+       struct drm_i915_gem_object *old_obj = intel_fb_obj(plane->state->fb);
        int ret = 0;
 
-       if (!obj)
+       if (!obj && !old_obj)
                return 0;
 
        mutex_lock(&dev->struct_mutex);
 
-       if (plane->type == DRM_PLANE_TYPE_CURSOR &&
+       if (!obj) {
+               ret = 0;
+       } else if (plane->type == DRM_PLANE_TYPE_CURSOR &&
            INTEL_INFO(dev)->cursor_needs_physical) {
                int align = IS_I830(dev) ? 16 * 1024 : 256;
                ret = i915_gem_object_attach_phys(obj, align);
@@ -13392,17 +13375,23 @@ intel_cleanup_plane_fb(struct drm_plane *plane,
                       const struct drm_plane_state *old_state)
 {
        struct drm_device *dev = plane->dev;
-       struct drm_i915_gem_object *obj = intel_fb_obj(old_state->fb);
+       struct intel_plane *intel_plane = to_intel_plane(plane);
+       struct drm_i915_gem_object *old_obj = intel_fb_obj(old_state->fb);
+       struct drm_i915_gem_object *obj = intel_fb_obj(plane->state->fb);
 
-       if (!obj)
+       if (!obj && !old_obj)
                return;
 
-       if (plane->type != DRM_PLANE_TYPE_CURSOR ||
-           !INTEL_INFO(dev)->cursor_needs_physical) {
-               mutex_lock(&dev->struct_mutex);
+       mutex_lock(&dev->struct_mutex);
+       if (old_obj && (plane->type != DRM_PLANE_TYPE_CURSOR ||
+           !INTEL_INFO(dev)->cursor_needs_physical))
                intel_unpin_fb_obj(old_state->fb, old_state);
-               mutex_unlock(&dev->struct_mutex);
-       }
+
+       /* prepare_fb aborted? */
+       if ((old_obj && (old_obj->frontbuffer_bits & intel_plane->frontbuffer_bit)) ||
+           (obj && !(obj->frontbuffer_bits & intel_plane->frontbuffer_bit)))
+               i915_gem_track_fb(old_obj, obj, intel_plane->frontbuffer_bit);
+       mutex_unlock(&dev->struct_mutex);
 }
 
 int
index d1d35c79edfdbecfaeacad1be53a1eaf8c9efd8e..27dccf35f9bc0213e93fd34d0d31a84db3f9b072 100644 (file)
@@ -515,7 +515,6 @@ struct intel_crtc_atomic_commit {
        bool disable_cxsr;
        bool pre_disable_primary;
        bool update_wm_pre, update_wm_post;
-       unsigned disabled_planes;
 
        /* Sleepable operations to perform after commit */
        unsigned fb_bits;