Skip to content

Commit 2745bdd

Browse files
committed
drm/i915: Stop clobbering old crtc state during state check
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>
1 parent 12e03c8 commit 2745bdd

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

drivers/gpu/drm/i915/display/intel_modeset_verify.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -156,21 +156,20 @@ verify_encoder_state(struct drm_i915_private *dev_priv, struct intel_atomic_stat
156156
}
157157

158158
static void
159-
verify_crtc_state(struct intel_crtc *crtc,
160-
struct intel_crtc_state *old_crtc_state,
161-
struct intel_crtc_state *new_crtc_state)
159+
verify_crtc_state(struct intel_atomic_state *state,
160+
struct intel_crtc *crtc)
162161
{
163162
struct drm_device *dev = crtc->base.dev;
164163
struct drm_i915_private *dev_priv = to_i915(dev);
165-
struct intel_encoder *encoder;
166-
struct intel_crtc_state *pipe_config = old_crtc_state;
167-
struct drm_atomic_state *state = old_crtc_state->uapi.state;
164+
const struct intel_crtc_state *new_crtc_state =
165+
intel_atomic_get_new_crtc_state(state, crtc);
166+
struct intel_crtc_state *pipe_config;
168167
struct intel_crtc *master_crtc;
168+
struct intel_encoder *encoder;
169169

170-
__drm_atomic_helper_crtc_destroy_state(&old_crtc_state->uapi);
171-
intel_crtc_free_hw_state(old_crtc_state);
172-
intel_crtc_state_reset(old_crtc_state, crtc);
173-
old_crtc_state->uapi.state = state;
170+
pipe_config = intel_crtc_state_alloc(crtc);
171+
if (!pipe_config)
172+
return;
174173

175174
drm_dbg_kms(&dev_priv->drm, "[CRTC:%d:%s]\n", crtc->base.base.id,
176175
crtc->base.name);
@@ -236,7 +235,7 @@ void intel_modeset_verify_crtc(struct intel_crtc *crtc,
236235

237236
intel_wm_state_verify(crtc, new_crtc_state);
238237
verify_connector_state(state, crtc);
239-
verify_crtc_state(crtc, old_crtc_state, new_crtc_state);
238+
verify_crtc_state(state, crtc);
240239
intel_shared_dpll_state_verify(crtc, old_crtc_state, new_crtc_state);
241240
intel_mpllb_state_verify(state, new_crtc_state);
242241
intel_c10pll_state_verify(state, new_crtc_state);

0 commit comments

Comments
 (0)