]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
drm/i915: Stop clobbering old crtc state during state check
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 4 Oct 2023 15:55:57 +0000 (18:55 +0300)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Fri, 6 Oct 2023 20:58:33 +0000 (23:58 +0300)
The state checker overwrites the old crtc state with the
current hardware state. While that does save a kmalloc() it seems
rather dubious as there might still be something that we need
in the old crtc state.

Stop doing that and just allocate a temporary state for the state
checker. Should the extra malloc during the commit phase turn out
too annoying we could of course preallocate one for each crtc, but
let's proceed with the straightforward approch for now.

And while at it let's mark the new crtc state as const to make
sure the state checker doesn't mess it up.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231004155607.7719-3-ville.syrjala@linux.intel.com
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
drivers/gpu/drm/i915/display/intel_modeset_verify.c

index 138144a65a457d8104d6779ca672df0cdbcd34e6..92b55b4fb74e0180e82fabc8500922660c0b44d8 100644 (file)
@@ -156,21 +156,20 @@ verify_encoder_state(struct drm_i915_private *dev_priv, struct intel_atomic_stat
 }
 
 static void
-verify_crtc_state(struct intel_crtc *crtc,
-                 struct intel_crtc_state *old_crtc_state,
-                 struct intel_crtc_state *new_crtc_state)
+verify_crtc_state(struct intel_atomic_state *state,
+                 struct intel_crtc *crtc)
 {
        struct drm_device *dev = crtc->base.dev;
        struct drm_i915_private *dev_priv = to_i915(dev);
-       struct intel_encoder *encoder;
-       struct intel_crtc_state *pipe_config = old_crtc_state;
-       struct drm_atomic_state *state = old_crtc_state->uapi.state;
+       const struct intel_crtc_state *new_crtc_state =
+               intel_atomic_get_new_crtc_state(state, crtc);
+       struct intel_crtc_state *pipe_config;
        struct intel_crtc *master_crtc;
+       struct intel_encoder *encoder;
 
-       __drm_atomic_helper_crtc_destroy_state(&old_crtc_state->uapi);
-       intel_crtc_free_hw_state(old_crtc_state);
-       intel_crtc_state_reset(old_crtc_state, crtc);
-       old_crtc_state->uapi.state = state;
+       pipe_config = intel_crtc_state_alloc(crtc);
+       if (!pipe_config)
+               return;
 
        drm_dbg_kms(&dev_priv->drm, "[CRTC:%d:%s]\n", crtc->base.base.id,
                    crtc->base.name);
@@ -236,7 +235,7 @@ void intel_modeset_verify_crtc(struct intel_crtc *crtc,
 
        intel_wm_state_verify(crtc, new_crtc_state);
        verify_connector_state(state, crtc);
-       verify_crtc_state(crtc, old_crtc_state, new_crtc_state);
+       verify_crtc_state(state, crtc);
        intel_shared_dpll_state_verify(crtc, old_crtc_state, new_crtc_state);
        intel_mpllb_state_verify(state, new_crtc_state);
        intel_c10pll_state_verify(state, new_crtc_state);