drm/i915: Ensure plane->state->fb stays in sync with plane->fb
[deliverable/linux.git] / drivers / gpu / drm / i915 / intel_display.c
index 213b870ae06ed9ae7600327079a2a9afbfeb7630..e5c057996353b452329a7f63fdd46c936576765c 100644 (file)
@@ -2410,6 +2410,20 @@ out_unref_obj:
        return false;
 }
 
+/* Update plane->state->fb to match plane->fb after driver-internal updates */
+static void
+update_state_fb(struct drm_plane *plane)
+{
+       if (plane->fb == plane->state->fb)
+               return;
+
+       if (plane->state->fb)
+               drm_framebuffer_unreference(plane->state->fb);
+       plane->state->fb = plane->fb;
+       if (plane->state->fb)
+               drm_framebuffer_reference(plane->state->fb);
+}
+
 static void
 intel_find_plane_obj(struct intel_crtc *intel_crtc,
                     struct intel_initial_plane_config *plane_config)
@@ -2456,6 +2470,8 @@ intel_find_plane_obj(struct intel_crtc *intel_crtc,
                        break;
                }
        }
+
+       update_state_fb(intel_crtc->base.primary);
 }
 
 static void i9xx_update_primary_plane(struct drm_crtc *crtc,
@@ -6635,6 +6651,7 @@ i9xx_get_initial_plane_config(struct intel_crtc *crtc,
                      plane_config->size);
 
        crtc->base.primary->fb = fb;
+       update_state_fb(crtc->base.primary);
 }
 
 static void chv_crtc_clock_get(struct intel_crtc *crtc,
@@ -7672,6 +7689,7 @@ skylake_get_initial_plane_config(struct intel_crtc *crtc,
                      plane_config->size);
 
        crtc->base.primary->fb = fb;
+       update_state_fb(crtc->base.primary);
        return;
 
 error:
@@ -7763,6 +7781,7 @@ ironlake_get_initial_plane_config(struct intel_crtc *crtc,
                      plane_config->size);
 
        crtc->base.primary->fb = fb;
+       update_state_fb(crtc->base.primary);
 }
 
 static bool ironlake_get_pipe_config(struct intel_crtc *crtc,
@@ -9800,13 +9819,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
        drm_gem_object_reference(&obj->base);
 
        crtc->primary->fb = fb;
-
-       /* Keep state structure in sync */
-       if (crtc->primary->state->fb)
-               drm_framebuffer_unreference(crtc->primary->state->fb);
-       crtc->primary->state->fb = fb;
-       if (crtc->primary->state->fb)
-               drm_framebuffer_reference(crtc->primary->state->fb);
+       update_state_fb(crtc->primary);
 
        work->pending_flip_obj = obj;
 
@@ -9875,6 +9888,7 @@ cleanup_unpin:
 cleanup_pending:
        atomic_dec(&intel_crtc->unpin_work_count);
        crtc->primary->fb = old_fb;
+       update_state_fb(crtc->primary);
        drm_framebuffer_unreference(work->old_fb);
        drm_gem_object_unreference(&obj->base);
        mutex_unlock(&dev->struct_mutex);
@@ -13709,6 +13723,7 @@ void intel_modeset_gem_init(struct drm_device *dev)
                                  to_intel_crtc(c)->pipe);
                        drm_framebuffer_unreference(c->primary->fb);
                        c->primary->fb = NULL;
+                       update_state_fb(c->primary);
                }
        }
        mutex_unlock(&dev->struct_mutex);
This page took 0.03005 seconds and 5 git commands to generate.