Commit 75f66490 authored by Jouni Högander's avatar Jouni Högander Committed by Stanislav Lisovskiy
Browse files

drm/i915/display: Ensure PSR gets disabled if no encoders in new state



Currently PSR is left enabled when all planes are disabled if there
is no attached encoder in new state. This seems to be causing FIFO
underruns.

Fix this by checking if encoder exists in new crtc state and disable
PSR if it doesn't.

v2: Unify disable logic with existing

Cc: Mika Kahola <mika.kahola@intel.com>
Reported-by: default avatarStanislav Lisovskiy <stanislav.lisovskiy@intel.com>
Signed-off-by: default avatarJouni Högander <jouni.hogander@intel.com>
Signed-off-by: default avatarStanislav Lisovskiy <stanislav.lisovskiy@intel.com>
Reviewed-by: default avatarStanislav Lisovskiy <stanislav.lisovskiy@intel.com>
Signed-off-by: default avatarStanislav Lisovskiy <stanislav.lisovskiy@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220711111750.881552-1-jouni.hogander@intel.com
parent 859161b9
Loading
Loading
Loading
Loading
+31 −22
Original line number Diff line number Diff line
@@ -1863,15 +1863,20 @@ void intel_psr_pre_plane_update(struct intel_atomic_state *state,
				struct intel_crtc *crtc)
{
	struct drm_i915_private *i915 = to_i915(state->base.dev);
	const struct intel_crtc_state *crtc_state =
		intel_atomic_get_new_crtc_state(state, crtc);
	struct intel_encoder *encoder;
	struct intel_crtc_state *new_crtc_state, *old_crtc_state;
	int i;

	if (!HAS_PSR(i915))
		return;

	for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state,
					    new_crtc_state, i) {
		struct intel_encoder *encoder;
		u32 old_new_encoder_mask = old_crtc_state->uapi.encoder_mask |
			new_crtc_state->uapi.encoder_mask;

		for_each_intel_encoder_mask_with_psr(state->base.dev, encoder,
					     crtc_state->uapi.encoder_mask) {
						     old_new_encoder_mask) {
			struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
			struct intel_psr *psr = &intel_dp->psr;
			bool needs_to_disable = false;
@@ -1883,11 +1888,14 @@ void intel_psr_pre_plane_update(struct intel_atomic_state *state,
			 * - PSR disabled in new state
			 * - All planes will go inactive
			 * - Changing between PSR versions
			 * - Encoder isn't present in new mask
			 */
		needs_to_disable |= intel_crtc_needs_modeset(crtc_state);
		needs_to_disable |= !crtc_state->has_psr;
		needs_to_disable |= !crtc_state->active_planes;
		needs_to_disable |= crtc_state->has_psr2 != psr->psr2_enabled;
			needs_to_disable |= intel_crtc_needs_modeset(new_crtc_state);
			needs_to_disable |= !new_crtc_state->has_psr;
			needs_to_disable |= !new_crtc_state->active_planes;
			needs_to_disable |= new_crtc_state->has_psr2 != psr->psr2_enabled;
			needs_to_disable |= !(new_crtc_state->uapi.encoder_mask &
					      drm_encoder_mask(&(encoder)->base));

			if (psr->enabled && needs_to_disable)
				intel_psr_disable_locked(intel_dp);
@@ -1895,6 +1903,7 @@ void intel_psr_pre_plane_update(struct intel_atomic_state *state,
			mutex_unlock(&psr->lock);
		}
	}
}

static void _intel_psr_post_plane_update(const struct intel_atomic_state *state,
					 const struct intel_crtc_state *crtc_state)