drm/i915: Move the DSB setup/cleaup into the color code
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 23 Nov 2022 15:26:33 +0000 (17:26 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 13 Dec 2022 03:16:01 +0000 (05:16 +0200)
Since the color management code is the only user of the DSB
at the moment move the DSB prepare/cleanup there too. The
code has to anyway make decisions on whether to use the DSB
or not (and how to use it). Also we'll need a place where we
actually generate the DSB command buffer ahead of time rather
than the current situation where it gets generated too late
during the mmio programming of the hardware.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221123152638.20622-9-ville.syrjala@linux.intel.com
Reviewed-by: Uma Shankar <uma.shankar@intel.com>
drivers/gpu/drm/i915/display/intel_color.c
drivers/gpu/drm/i915/display/intel_color.h
drivers/gpu/drm/i915/display/intel_display.c
drivers/gpu/drm/i915/display/intel_display.h

index 5a4f794e1d08967e31b9d980828671d38d007839..5a8652407f308b18dc2c3e3fca4066c8ac10cd0a 100644 (file)
@@ -1389,6 +1389,16 @@ void intel_color_commit_arm(const struct intel_crtc_state *crtc_state)
        i915->display.funcs.color->color_commit_arm(crtc_state);
 }
 
+void intel_color_prepare_commit(struct intel_crtc_state *crtc_state)
+{
+       intel_dsb_prepare(crtc_state);
+}
+
+void intel_color_cleanup_commit(struct intel_crtc_state *crtc_state)
+{
+       intel_dsb_cleanup(crtc_state);
+}
+
 static bool intel_can_preload_luts(const struct intel_crtc_state *new_crtc_state)
 {
        struct intel_crtc *crtc = to_intel_crtc(new_crtc_state->uapi.crtc);
index 1c6b1755f6d270a0ab444d20e5ba5d296fb922d5..d620b5b1e2a6ebdc68e98d16c65b3ccaa7e84c09 100644 (file)
@@ -17,6 +17,8 @@ void intel_color_init_hooks(struct drm_i915_private *i915);
 int intel_color_init(struct drm_i915_private *i915);
 void intel_color_crtc_init(struct intel_crtc *crtc);
 int intel_color_check(struct intel_crtc_state *crtc_state);
+void intel_color_prepare_commit(struct intel_crtc_state *crtc_state);
+void intel_color_cleanup_commit(struct intel_crtc_state *crtc_state);
 void intel_color_commit_noarm(const struct intel_crtc_state *crtc_state);
 void intel_color_commit_arm(const struct intel_crtc_state *crtc_state);
 void intel_color_load_luts(const struct intel_crtc_state *crtc_state);
index 6cdfdae2c71230a5921ed039b1d2ac1ffed5a2fa..e75b9b2a0e015a5a99a2a085b303d81ecb961657 100644 (file)
@@ -91,7 +91,6 @@
 #include "intel_dp_link_training.h"
 #include "intel_dpio_phy.h"
 #include "intel_dpt.h"
-#include "intel_dsb.h"
 #include "intel_fbc.h"
 #include "intel_fbdev.h"
 #include "intel_fdi.h"
@@ -6929,7 +6928,7 @@ static int intel_atomic_prepare_commit(struct intel_atomic_state *state)
 
        for_each_new_intel_crtc_in_state(state, crtc, crtc_state, i) {
                if (intel_crtc_needs_color_update(crtc_state))
-                       intel_dsb_prepare(crtc_state);
+                       intel_color_prepare_commit(crtc_state);
        }
 
        return 0;
@@ -7380,24 +7379,18 @@ static void intel_atomic_commit_fence_wait(struct intel_atomic_state *intel_stat
                    &wait_reset);
 }
 
-static void intel_cleanup_dsbs(struct intel_atomic_state *state)
-{
-       struct intel_crtc_state *old_crtc_state, *new_crtc_state;
-       struct intel_crtc *crtc;
-       int i;
-
-       for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state,
-                                           new_crtc_state, i)
-               intel_dsb_cleanup(old_crtc_state);
-}
-
 static void intel_atomic_cleanup_work(struct work_struct *work)
 {
        struct intel_atomic_state *state =
                container_of(work, struct intel_atomic_state, base.commit_work);
        struct drm_i915_private *i915 = to_i915(state->base.dev);
+       struct intel_crtc_state *old_crtc_state;
+       struct intel_crtc *crtc;
+       int i;
+
+       for_each_old_intel_crtc_in_state(state, crtc, old_crtc_state, i)
+               intel_color_cleanup_commit(old_crtc_state);
 
-       intel_cleanup_dsbs(state);
        drm_atomic_helper_cleanup_planes(&i915->drm, &state->base);
        drm_atomic_helper_commit_cleanup_done(&state->base);
        drm_atomic_state_put(&state->base);
@@ -7588,6 +7581,8 @@ static void intel_atomic_commit_tail(struct intel_atomic_state *state)
                 * DSB cleanup is done in cleanup_work aligning with framebuffer
                 * cleanup. So copy and reset the dsb structure to sync with
                 * commit_done and later do dsb cleanup in cleanup_work.
+                *
+                * FIXME get rid of this funny new->old swapping
                 */
                old_crtc_state->dsb = fetch_and_zero(&new_crtc_state->dsb);
        }
@@ -7738,7 +7733,7 @@ static int intel_atomic_commit(struct drm_device *dev,
                i915_sw_fence_commit(&state->commit_ready);
 
                for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i)
-                       intel_dsb_cleanup(new_crtc_state);
+                       intel_color_cleanup_commit(new_crtc_state);
 
                drm_atomic_helper_cleanup_planes(dev, &state->base);
                intel_runtime_pm_put(&dev_priv->runtime_pm, state->wakeref);
index 714030136b7f20dbc03a6282cc62b89ab709a9b9..ef73730f32b095cb3428ff36e45eb26d1a27c26e 100644 (file)
@@ -440,6 +440,14 @@ enum hpd_pin {
             (__i)++) \
                for_each_if(plane)
 
+#define for_each_old_intel_crtc_in_state(__state, crtc, old_crtc_state, __i) \
+       for ((__i) = 0; \
+            (__i) < (__state)->base.dev->mode_config.num_crtc && \
+                    ((crtc) = to_intel_crtc((__state)->base.crtcs[__i].ptr), \
+                     (old_crtc_state) = to_intel_crtc_state((__state)->base.crtcs[__i].old_state), 1); \
+            (__i)++) \
+               for_each_if(crtc)
+
 #define for_each_new_intel_plane_in_state(__state, plane, new_plane_state, __i) \
        for ((__i) = 0; \
             (__i) < (__state)->base.dev->mode_config.num_total_plane && \