[PATCH 4/4] drm/i915: Always clear INHERIT flag from crtc_state->mode

Sean Paul sean at poorly.run
Thu Oct 25 14:48:29 UTC 2018


From: Sean Paul <seanpaul at chromium.org>

After fastboot/smoothboot completes, we need to fully compute the
state, since a bunch of it is zeroed out. Everything works great if the
first commit from userspace is a modeset, intel_atomic_check checks for
a mismatch in private_flags and forces the modeset path. The modeset
path will compute the state and either do a modeset or skip it b/c the
hw is already consistent with the state.

Unfortunately, if the first commit from userspace does not contain a
user-provided mode, the private_flags in new_state->mode.private_flags
still contains the INHERIT flag. As such, the state is not computed
and we end up using the incoherent intel_state in atomic_check. On
skylake, this ends with a divide-by-zero (since active_crtcs = 0).

Cc: stable at vger.kernel.org
Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
Cc: Ville Syrjälä <ville.syrjala at linux.intel.com>
Signed-off-by: Sean Paul <seanpaul at chromium.org>
---
 drivers/gpu/drm/i915/intel_atomic.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_atomic.c b/drivers/gpu/drm/i915/intel_atomic.c
index b04952bacf77..c70ddec4e193 100644
--- a/drivers/gpu/drm/i915/intel_atomic.c
+++ b/drivers/gpu/drm/i915/intel_atomic.c
@@ -185,6 +185,14 @@ intel_crtc_duplicate_state(struct drm_crtc *crtc)
 	crtc_state->wm.need_postvbl_update = false;
 	crtc_state->fb_bits = 0;
 
+	/*
+	 * Always clear the INHERITED flag when we duplicate state. This will
+	 * ensure that the next commit after readout will recompute state and
+	 * fill out intel_state. Without this, we run the risk of non-modeset
+	 * commits reading intel_state with incomplete data.
+	 */
+	crtc_state->base.mode.private_flags &= ~I915_MODE_FLAG_INHERITED;
+
 	return &crtc_state->base;
 }
 
-- 
Sean Paul, Software Engineer, Google / Chromium OS



More information about the Intel-gfx-trybot mailing list