ec226c2
From 0042e1e7a03a2fb5d6c464c03ce84d55b31add11 Mon Sep 17 00:00:00 2001
ec226c2
From: Matt Roper <matthew.d.roper@intel.com>
ec226c2
Date: Thu, 12 May 2016 07:05:55 -0700
0903551
Subject: [PATCH 01/17] drm/i915: Reorganize WM structs/unions in CRTC state
0903551
ec226c2
Reorganize the nested structures and unions we have for pipe watermark
ec226c2
data in intel_crtc_state so that platform-specific data can be added in
ec226c2
a more sensible manner (and save a bit of memory at the same time).
0903551
ec226c2
The change basically changes the organization from:
0903551
ec226c2
        union {
ec226c2
                struct intel_pipe_wm ilk;
ec226c2
                struct intel_pipe_wm skl;
ec226c2
        } optimal;
0903551
ec226c2
        struct intel_pipe_wm intermediate /* ILK-only */
0903551
ec226c2
to
0903551
ec226c2
        union {
ec226c2
                struct {
ec226c2
                        struct intel_pipe_wm intermediate;
ec226c2
                        struct intel_pipe_wm optimal;
ec226c2
                } ilk;
0903551
ec226c2
                struct {
ec226c2
                        struct intel_pipe_wm optimal;
ec226c2
                } skl;
ec226c2
        }
0903551
ec226c2
There should be no functional change here, but it will allow us to add
ec226c2
more platform-specific fields going forward (and more easily extend to
ec226c2
other platform types like VLV).
0903551
ec226c2
While we're at it, let's move the entire watermark substructure out to
ec226c2
its own structure definition to make the code slightly more readable.
0903551
ec226c2
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
ec226c2
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
ec226c2
Link: http://patchwork.freedesktop.org/patch/msgid/1463061971-19638-2-git-send-email-matthew.d.roper@intel.com
0903551
---
ec226c2
 drivers/gpu/drm/i915/intel_display.c |  2 +-
ec226c2
 drivers/gpu/drm/i915/intel_drv.h     | 61 +++++++++++++++++++++---------------
ec226c2
 drivers/gpu/drm/i915/intel_pm.c      | 18 +++++------
ec226c2
 3 files changed, 45 insertions(+), 36 deletions(-)
0903551
ec226c2
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
ec226c2
index d19b392..4633aec 100644
ec226c2
--- a/drivers/gpu/drm/i915/intel_display.c
ec226c2
+++ b/drivers/gpu/drm/i915/intel_display.c
ec226c2
@@ -12027,7 +12027,7 @@ static int intel_crtc_atomic_check(struct drm_crtc *crtc,
ec226c2
 		}
ec226c2
 	} else if (dev_priv->display.compute_intermediate_wm) {
ec226c2
 		if (HAS_PCH_SPLIT(dev_priv) && INTEL_GEN(dev_priv) < 9)
ec226c2
-			pipe_config->wm.intermediate = pipe_config->wm.optimal.ilk;
ec226c2
+			pipe_config->wm.ilk.intermediate = pipe_config->wm.ilk.optimal;
ec226c2
 	}
ec226c2
 
ec226c2
 	if (INTEL_INFO(dev)->gen >= 9) {
0903551
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
ec226c2
index 4a24b00..5a186bf 100644
0903551
--- a/drivers/gpu/drm/i915/intel_drv.h
0903551
+++ b/drivers/gpu/drm/i915/intel_drv.h
ec226c2
@@ -405,6 +405,40 @@ struct skl_pipe_wm {
0903551
 	uint32_t linetime;
0903551
 };
0903551
 
0903551
+struct intel_crtc_wm_state {
0903551
+	union {
0903551
+		struct {
0903551
+			/*
0903551
+			 * Intermediate watermarks; these can be
0903551
+			 * programmed immediately since they satisfy
0903551
+			 * both the current configuration we're
0903551
+			 * switching away from and the new
0903551
+			 * configuration we're switching to.
0903551
+			 */
0903551
+			struct intel_pipe_wm intermediate;
0903551
+
0903551
+			/*
0903551
+			 * Optimal watermarks, programmed post-vblank
0903551
+			 * when this state is committed.
0903551
+			 */
0903551
+			struct intel_pipe_wm optimal;
0903551
+		} ilk;
0903551
+
0903551
+		struct {
0903551
+			/* gen9+ only needs 1-step wm programming */
0903551
+			struct skl_pipe_wm optimal;
0903551
+		} skl;
0903551
+	};
0903551
+
0903551
+	/*
0903551
+	 * Platforms with two-step watermark programming will need to
0903551
+	 * update watermark programming post-vblank to switch from the
0903551
+	 * safe intermediate watermarks to the optimal final
0903551
+	 * watermarks.
0903551
+	 */
0903551
+	bool need_postvbl_update;
0903551
+};
0903551
+
0903551
 struct intel_crtc_state {
0903551
 	struct drm_crtc_state base;
0903551
 
ec226c2
@@ -558,32 +592,7 @@ struct intel_crtc_state {
0903551
 	/* IVB sprite scaling w/a (WaCxSRDisabledForSpriteScaling:ivb) */
0903551
 	bool disable_lp_wm;
0903551
 
0903551
-	struct {
0903551
-		/*
ec226c2
-		 * Optimal watermarks, programmed post-vblank when this state
ec226c2
-		 * is committed.
0903551
-		 */
0903551
-		union {
0903551
-			struct intel_pipe_wm ilk;
0903551
-			struct skl_pipe_wm skl;
0903551
-		} optimal;
ec226c2
-
ec226c2
-		/*
ec226c2
-		 * Intermediate watermarks; these can be programmed immediately
ec226c2
-		 * since they satisfy both the current configuration we're
ec226c2
-		 * switching away from and the new configuration we're switching
ec226c2
-		 * to.
ec226c2
-		 */
ec226c2
-		struct intel_pipe_wm intermediate;
ec226c2
-
ec226c2
-		/*
ec226c2
-		 * Platforms with two-step watermark programming will need to
ec226c2
-		 * update watermark programming post-vblank to switch from the
ec226c2
-		 * safe intermediate watermarks to the optimal final
ec226c2
-		 * watermarks.
ec226c2
-		 */
ec226c2
-		bool need_postvbl_update;
0903551
-	} wm;
0903551
+	struct intel_crtc_wm_state wm;
0903551
 
ec226c2
 	/* Gamma mode programmed on the pipe */
ec226c2
 	uint32_t gamma_mode;
0903551
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
ec226c2
index a7ef45d..4353fec 100644
0903551
--- a/drivers/gpu/drm/i915/intel_pm.c
0903551
+++ b/drivers/gpu/drm/i915/intel_pm.c
ec226c2
@@ -2309,7 +2309,7 @@ static int ilk_compute_pipe_wm(struct intel_crtc_state *cstate)
ec226c2
 	int level, max_level = ilk_wm_max_level(dev), usable_level;
ec226c2
 	struct ilk_wm_maximums max;
0903551
 
0903551
-	pipe_wm = &cstate->wm.optimal.ilk;
0903551
+	pipe_wm = &cstate->wm.ilk.optimal;
0903551
 
0903551
 	for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) {
ec226c2
 		struct intel_plane_state *ps;
ec226c2
@@ -2391,7 +2391,7 @@ static int ilk_compute_intermediate_wm(struct drm_device *dev,
ec226c2
 				       struct intel_crtc *intel_crtc,
ec226c2
 				       struct intel_crtc_state *newstate)
ec226c2
 {
ec226c2
-	struct intel_pipe_wm *a = &newstate->wm.intermediate;
ec226c2
+	struct intel_pipe_wm *a = &newstate->wm.ilk.intermediate;
ec226c2
 	struct intel_pipe_wm *b = &intel_crtc->wm.active.ilk;
ec226c2
 	int level, max_level = ilk_wm_max_level(dev);
0903551
 
ec226c2
@@ -2400,7 +2400,7 @@ static int ilk_compute_intermediate_wm(struct drm_device *dev,
ec226c2
 	 * currently active watermarks to get values that are safe both before
ec226c2
 	 * and after the vblank.
ec226c2
 	 */
ec226c2
-	*a = newstate->wm.optimal.ilk;
ec226c2
+	*a = newstate->wm.ilk.optimal;
ec226c2
 	a->pipe_enabled |= b->pipe_enabled;
ec226c2
 	a->sprites_enabled |= b->sprites_enabled;
ec226c2
 	a->sprites_scaled |= b->sprites_scaled;
ec226c2
@@ -2429,7 +2429,7 @@ static int ilk_compute_intermediate_wm(struct drm_device *dev,
ec226c2
 	 * If our intermediate WM are identical to the final WM, then we can
ec226c2
 	 * omit the post-vblank programming; only update if it's different.
ec226c2
 	 */
ec226c2
-	if (memcmp(a, &newstate->wm.optimal.ilk, sizeof(*a)) == 0)
ec226c2
+	if (memcmp(a, &newstate->wm.ilk.optimal, sizeof(*a)) == 0)
ec226c2
 		newstate->wm.need_postvbl_update = false;
0903551
 
ec226c2
 	return 0;
ec226c2
@@ -3678,7 +3678,7 @@ static void skl_update_wm(struct drm_crtc *crtc)
0903551
 	struct drm_i915_private *dev_priv = dev->dev_private;
0903551
 	struct skl_wm_values *results = &dev_priv->wm.skl_results;
0903551
 	struct intel_crtc_state *cstate = to_intel_crtc_state(crtc->state);
0903551
-	struct skl_pipe_wm *pipe_wm = &cstate->wm.optimal.skl;
0903551
+	struct skl_pipe_wm *pipe_wm = &cstate->wm.skl.optimal;
0903551
 
0903551
 
0903551
 	/* Clear all dirty flags */
ec226c2
@@ -3757,7 +3757,7 @@ static void ilk_initial_watermarks(struct intel_crtc_state *cstate)
ec226c2
 	struct intel_crtc *intel_crtc = to_intel_crtc(cstate->base.crtc);
0903551
 
ec226c2
 	mutex_lock(&dev_priv->wm.wm_mutex);
ec226c2
-	intel_crtc->wm.active.ilk = cstate->wm.intermediate;
ec226c2
+	intel_crtc->wm.active.ilk = cstate->wm.ilk.intermediate;
ec226c2
 	ilk_program_watermarks(dev_priv);
ec226c2
 	mutex_unlock(&dev_priv->wm.wm_mutex);
0903551
 }
ec226c2
@@ -3769,7 +3769,7 @@ static void ilk_optimize_watermarks(struct intel_crtc_state *cstate)
ec226c2
 
ec226c2
 	mutex_lock(&dev_priv->wm.wm_mutex);
ec226c2
 	if (cstate->wm.need_postvbl_update) {
ec226c2
-		intel_crtc->wm.active.ilk = cstate->wm.optimal.ilk;
ec226c2
+		intel_crtc->wm.active.ilk = cstate->wm.ilk.optimal;
ec226c2
 		ilk_program_watermarks(dev_priv);
ec226c2
 	}
ec226c2
 	mutex_unlock(&dev_priv->wm.wm_mutex);
ec226c2
@@ -3826,7 +3826,7 @@ static void skl_pipe_wm_get_hw_state(struct drm_crtc *crtc)
0903551
 	struct skl_wm_values *hw = &dev_priv->wm.skl_hw;
0903551
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
0903551
 	struct intel_crtc_state *cstate = to_intel_crtc_state(crtc->state);
0903551
-	struct skl_pipe_wm *active = &cstate->wm.optimal.skl;
0903551
+	struct skl_pipe_wm *active = &cstate->wm.skl.optimal;
0903551
 	enum pipe pipe = intel_crtc->pipe;
0903551
 	int level, i, max_level;
0903551
 	uint32_t temp;
ec226c2
@@ -3892,7 +3892,7 @@ static void ilk_pipe_wm_get_hw_state(struct drm_crtc *crtc)
0903551
 	struct ilk_wm_values *hw = &dev_priv->wm.hw;
0903551
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
0903551
 	struct intel_crtc_state *cstate = to_intel_crtc_state(crtc->state);
0903551
-	struct intel_pipe_wm *active = &cstate->wm.optimal.ilk;
0903551
+	struct intel_pipe_wm *active = &cstate->wm.ilk.optimal;
0903551
 	enum pipe pipe = intel_crtc->pipe;
0903551
 	static const i915_reg_t wm0_pipe_reg[] = {
0903551
 		[PIPE_A] = WM0_PIPEA_ILK,
0903551
-- 
0903551
2.7.4
0903551