]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/gpu/drm/i915/display/intel_display.c
drm/i915: Avoid calling i915_gem_object_unbind holding object lock
[linux.git] / drivers / gpu / drm / i915 / display / intel_display.c
index be7f2cab21bafaa2993aafb175235087732d244d..37760a3814020ce490e698454e3d97a8b53627a5 100644 (file)
@@ -171,7 +171,6 @@ static void ironlake_pfit_disable(const struct intel_crtc_state *old_crtc_state)
 static void ironlake_pfit_enable(const struct intel_crtc_state *crtc_state);
 static void intel_modeset_setup_hw_state(struct drm_device *dev,
                                         struct drm_modeset_acquire_ctx *ctx);
-static void intel_pre_disable_primary_noatomic(struct drm_crtc *crtc);
 
 struct intel_limit {
        struct {
@@ -562,6 +561,12 @@ is_trans_port_sync_master(const struct intel_crtc_state *crtc_state)
                crtc_state->sync_mode_slaves_mask);
 }
 
+static bool
+is_trans_port_sync_slave(const struct intel_crtc_state *crtc_state)
+{
+       return crtc_state->master_transcoder != INVALID_TRANSCODER;
+}
+
 /*
  * Platform specific helpers to calculate the port PLL loopback- (clock.m),
  * and post-divider (clock.p) values, pre- (clock.vco) and post-divided fast
@@ -2160,19 +2165,18 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
         * pin/unpin/fence and not more.
         */
        wakeref = intel_runtime_pm_get(&dev_priv->runtime_pm);
-       i915_gem_object_lock(obj);
 
        atomic_inc(&dev_priv->gpu_error.pending_fb_pin);
 
-       pinctl = 0;
-
-       /* Valleyview is definitely limited to scanning out the first
+       /*
+        * Valleyview is definitely limited to scanning out the first
         * 512MiB. Lets presume this behaviour was inherited from the
         * g4x display engine and that all earlier gen are similarly
         * limited. Testing suggests that it is a little more
         * complicated than this. For example, Cherryview appears quite
         * happy to scanout from anywhere within its global aperture.
         */
+       pinctl = 0;
        if (HAS_GMCH(dev_priv))
                pinctl |= PIN_MAPPABLE;
 
@@ -2184,7 +2188,8 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
        if (uses_fence && i915_vma_is_map_and_fenceable(vma)) {
                int ret;
 
-               /* Install a fence for tiled scan-out. Pre-i965 always needs a
+               /*
+                * Install a fence for tiled scan-out. Pre-i965 always needs a
                 * fence, whereas 965+ only requires a fence if using
                 * framebuffer compression.  For simplicity, we always, when
                 * possible, install a fence as the cost is not that onerous.
@@ -2214,8 +2219,6 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
        i915_vma_get(vma);
 err:
        atomic_dec(&dev_priv->gpu_error.pending_fb_pin);
-
-       i915_gem_object_unlock(obj);
        intel_runtime_pm_put(&dev_priv->runtime_pm, wakeref);
        return vma;
 }
@@ -3212,6 +3215,7 @@ static void fixup_active_planes(struct intel_crtc_state *crtc_state)
 static void intel_plane_disable_noatomic(struct intel_crtc *crtc,
                                         struct intel_plane *plane)
 {
+       struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
        struct intel_crtc_state *crtc_state =
                to_intel_crtc_state(crtc->base.state);
        struct intel_plane_state *plane_state =
@@ -3227,7 +3231,27 @@ static void intel_plane_disable_noatomic(struct intel_crtc *crtc,
        crtc_state->min_cdclk[plane->id] = 0;
 
        if (plane->id == PLANE_PRIMARY)
-               intel_pre_disable_primary_noatomic(&crtc->base);
+               hsw_disable_ips(crtc_state);
+
+       /*
+        * Vblank time updates from the shadow to live plane control register
+        * are blocked if the memory self-refresh mode is active at that
+        * moment. So to make sure the plane gets truly disabled, disable
+        * first the self-refresh mode. The self-refresh enable bit in turn
+        * will be checked/applied by the HW only at the next frame start
+        * event which is after the vblank start event, so we need to have a
+        * wait-for-vblank between disabling the plane and the pipe.
+        */
+       if (HAS_GMCH(dev_priv) &&
+           intel_set_memory_cxsr(dev_priv, false))
+               intel_wait_for_vblank(dev_priv, crtc->pipe);
+
+       /*
+        * Gen2 reports pipe underruns whenever all planes are disabled.
+        * So disable underrun reporting before all the planes get disabled.
+        */
+       if (IS_GEN(dev_priv, 2) && !crtc_state->active_planes)
+               intel_set_cpu_fifo_underrun_reporting(dev_priv, crtc->pipe, false);
 
        intel_disable_plane(plane, crtc_state);
 }
@@ -5908,39 +5932,6 @@ static void intel_crtc_dpms_overlay_disable(struct intel_crtc *intel_crtc)
         */
 }
 
-
-/* FIXME get rid of this and use pre_plane_update */
-static void
-intel_pre_disable_primary_noatomic(struct drm_crtc *crtc)
-{
-       struct drm_device *dev = crtc->dev;
-       struct drm_i915_private *dev_priv = to_i915(dev);
-       struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-       enum pipe pipe = intel_crtc->pipe;
-
-       /*
-        * Gen2 reports pipe underruns whenever all planes are disabled.
-        * So disable underrun reporting before all the planes get disabled.
-        */
-       if (IS_GEN(dev_priv, 2))
-               intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, false);
-
-       hsw_disable_ips(to_intel_crtc_state(crtc->state));
-
-       /*
-        * Vblank time updates from the shadow to live plane control register
-        * are blocked if the memory self-refresh mode is active at that
-        * moment. So to make sure the plane gets truly disabled, disable
-        * first the self-refresh mode. The self-refresh enable bit in turn
-        * will be checked/applied by the HW only at the next frame start
-        * event which is after the vblank start event, so we need to have a
-        * wait-for-vblank between disabling the plane and the pipe.
-        */
-       if (HAS_GMCH(dev_priv) &&
-           intel_set_memory_cxsr(dev_priv, false))
-               intel_wait_for_vblank(dev_priv, pipe);
-}
-
 static bool hsw_pre_update_disable_ips(const struct intel_crtc_state *old_crtc_state,
                                       const struct intel_crtc_state *new_crtc_state)
 {
@@ -14234,7 +14225,7 @@ void intel_crtc_arm_fifo_underrun(struct intel_crtc *crtc,
 {
        struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
 
-       if (!IS_GEN(dev_priv, 2))
+       if (!IS_GEN(dev_priv, 2) || crtc_state->active_planes)
                intel_set_cpu_fifo_underrun_reporting(dev_priv, crtc->pipe, true);
 
        if (crtc_state->has_pch_encoder) {
@@ -14406,77 +14397,47 @@ static void intel_old_crtc_state_disables(struct intel_atomic_state *state,
                dev_priv->display.initial_watermarks(state, crtc);
 }
 
-static void intel_trans_port_sync_modeset_disables(struct intel_atomic_state *state,
-                                                  struct intel_crtc *crtc,
-                                                  struct intel_crtc_state *old_crtc_state,
-                                                  struct intel_crtc_state *new_crtc_state)
-{
-       struct intel_crtc *slave_crtc = intel_get_slave_crtc(new_crtc_state);
-       struct intel_crtc_state *new_slave_crtc_state =
-               intel_atomic_get_new_crtc_state(state, slave_crtc);
-       struct intel_crtc_state *old_slave_crtc_state =
-               intel_atomic_get_old_crtc_state(state, slave_crtc);
-
-       WARN_ON(!slave_crtc || !new_slave_crtc_state ||
-               !old_slave_crtc_state);
-
-       /* Disable Slave first */
-       intel_pre_plane_update(state, slave_crtc);
-       if (old_slave_crtc_state->hw.active)
-               intel_old_crtc_state_disables(state,
-                                             old_slave_crtc_state,
-                                             new_slave_crtc_state,
-                                             slave_crtc);
-
-       /* Disable Master */
-       intel_pre_plane_update(state, crtc);
-       if (old_crtc_state->hw.active)
-               intel_old_crtc_state_disables(state,
-                                             old_crtc_state,
-                                             new_crtc_state,
-                                             crtc);
-}
-
 static void intel_commit_modeset_disables(struct intel_atomic_state *state)
 {
        struct intel_crtc_state *new_crtc_state, *old_crtc_state;
        struct intel_crtc *crtc;
+       u32 handled = 0;
        int i;
 
-       /*
-        * Disable CRTC/pipes in reverse order because some features(MST in
-        * TGL+) requires master and slave relationship between pipes, so it
-        * should always pick the lowest pipe as master as it will be enabled
-        * first and disable in the reverse order so the master will be the
-        * last one to be disabled.
-        */
-       for_each_oldnew_intel_crtc_in_state_reverse(state, crtc, old_crtc_state,
-                                                   new_crtc_state, i) {
+       /* Only disable port sync slaves */
+       for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state,
+                                           new_crtc_state, i) {
                if (!needs_modeset(new_crtc_state))
                        continue;
 
+               if (!old_crtc_state->hw.active)
+                       continue;
+
                /* In case of Transcoder port Sync master slave CRTCs can be
                 * assigned in any order and we need to make sure that
                 * slave CRTCs are disabled first and then master CRTC since
                 * Slave vblanks are masked till Master Vblanks.
                 */
-               if (is_trans_port_sync_mode(old_crtc_state)) {
-                       if (is_trans_port_sync_master(old_crtc_state))
-                               intel_trans_port_sync_modeset_disables(state,
-                                                                      crtc,
-                                                                      old_crtc_state,
-                                                                      new_crtc_state);
-                       else
-                               continue;
-               } else {
-                       intel_pre_plane_update(state, crtc);
+               if (!is_trans_port_sync_slave(old_crtc_state))
+                       continue;
 
-                       if (old_crtc_state->hw.active)
-                               intel_old_crtc_state_disables(state,
-                                                             old_crtc_state,
-                                                             new_crtc_state,
-                                                             crtc);
-               }
+               intel_pre_plane_update(state, crtc);
+               intel_old_crtc_state_disables(state, old_crtc_state,
+                                             new_crtc_state, crtc);
+               handled |= BIT(crtc->pipe);
+       }
+
+       /* Disable everything else left on */
+       for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state,
+                                           new_crtc_state, i) {
+               if (!needs_modeset(new_crtc_state) ||
+                   (handled & BIT(crtc->pipe)))
+                       continue;
+
+               intel_pre_plane_update(state, crtc);
+               if (old_crtc_state->hw.active)
+                       intel_old_crtc_state_disables(state, old_crtc_state,
+                                                     new_crtc_state, crtc);
        }
 }
 
@@ -14616,7 +14577,7 @@ static void skl_commit_modeset_enables(struct intel_atomic_state *state)
 
        for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i)
                /* ignore allocations for crtc's that have been turned off. */
-               if (new_crtc_state->hw.active)
+               if (!needs_modeset(new_crtc_state) && new_crtc_state->hw.active)
                        entries[i] = old_crtc_state->wm.skl.ddb;
 
        /* If 2nd DBuf slice required, enable it here */