Takashi Iwai 76b060
From eef173954432fe0612acb63421a95deb41155cdc Mon Sep 17 00:00:00 2001
Takashi Iwai 76b060
From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= <ville.syrjala@linux.intel.com>
Takashi Iwai 76b060
Date: Fri, 4 Feb 2022 16:18:16 +0200
Takashi Iwai 76b060
Subject: [PATCH] drm/i915: Allow !join_mbus cases for adlp+ dbuf configuration
Takashi Iwai 76b060
Mime-version: 1.0
Takashi Iwai 76b060
Content-type: text/plain; charset=UTF-8
Takashi Iwai 76b060
Content-transfer-encoding: 8bit
Takashi Iwai 76b060
Git-commit: 8fd5a26e43859547790a7995494c952b708ab3b5
Takashi Iwai 76b060
Patch-mainline: v5.17-rc4
Takashi Iwai 76b060
References: bsc#1193640
Takashi Iwai 76b060
Takashi Iwai 76b060
Reintroduce the !join_mbus single pipe cases for adlp+.
Takashi Iwai 76b060
Takashi Iwai 76b060
Due to the mbus relative dbuf offsets in PLANE_BUF_CFG we
Takashi Iwai 76b060
need to know the actual slices used by the pipe when doing
Takashi Iwai 76b060
readout, even when mbus joining isn't enabled. Accurate
Takashi Iwai 76b060
readout will be needed to properly sanitize invalid BIOS
Takashi Iwai 76b060
dbuf configurations.
Takashi Iwai 76b060
Takashi Iwai 76b060
This will also make it much easier to play around with the
Takashi Iwai 76b060
!join_mbus configs for testin/workaround purposes.
Takashi Iwai 76b060
Takashi Iwai 76b060
Cc: <stable@vger.kernel.org> # v5.14+
Takashi Iwai 76b060
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Takashi Iwai 76b060
Link: https://patchwork.freedesktop.org/patch/msgid/20220204141818.1900-1-ville.syrjala@linux.intel.com
Takashi Iwai 76b060
Reviewed-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
Takashi Iwai 76b060
Acked-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai 76b060
Takashi Iwai 76b060
---
Takashi Iwai 76b060
 drivers/gpu/drm/i915/intel_pm.c | 66 +++++++++++++++++++++++----------
Takashi Iwai 76b060
 1 file changed, 46 insertions(+), 20 deletions(-)
Takashi Iwai 76b060
Takashi Iwai 76b060
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
Takashi Iwai 76b060
index 859be750fb22..2eb70ec38f6e 100644
Takashi Iwai 76b060
--- a/drivers/gpu/drm/i915/intel_pm.c
Takashi Iwai 76b060
+++ b/drivers/gpu/drm/i915/intel_pm.c
Takashi Iwai 76b060
@@ -4695,6 +4695,10 @@ static const struct dbuf_slice_conf_entry dg2_allowed_dbufs[] = {
Takashi Iwai 76b060
 };
Takashi Iwai 76b060
 
Takashi Iwai 76b060
 static const struct dbuf_slice_conf_entry adlp_allowed_dbufs[] = {
Takashi Iwai 76b060
+	/*
Takashi Iwai 76b060
+	 * Keep the join_mbus cases first so check_mbus_joined()
Takashi Iwai 76b060
+	 * will prefer them over the !join_mbus cases.
Takashi Iwai 76b060
+	 */
Takashi Iwai 76b060
 	{
Takashi Iwai 76b060
 		.active_pipes = BIT(PIPE_A),
Takashi Iwai 76b060
 		.dbuf_mask = {
Takashi Iwai 76b060
@@ -4709,6 +4713,20 @@ static const struct dbuf_slice_conf_entry adlp_allowed_dbufs[] = {
Takashi Iwai 76b060
 		},
Takashi Iwai 76b060
 		.join_mbus = true,
Takashi Iwai 76b060
 	},
Takashi Iwai 76b060
+	{
Takashi Iwai 76b060
+		.active_pipes = BIT(PIPE_A),
Takashi Iwai 76b060
+		.dbuf_mask = {
Takashi Iwai 76b060
+			[PIPE_A] = BIT(DBUF_S1) | BIT(DBUF_S2),
Takashi Iwai 76b060
+		},
Takashi Iwai 76b060
+		.join_mbus = false,
Takashi Iwai 76b060
+	},
Takashi Iwai 76b060
+	{
Takashi Iwai 76b060
+		.active_pipes = BIT(PIPE_B),
Takashi Iwai 76b060
+		.dbuf_mask = {
Takashi Iwai 76b060
+			[PIPE_B] = BIT(DBUF_S3) | BIT(DBUF_S4),
Takashi Iwai 76b060
+		},
Takashi Iwai 76b060
+		.join_mbus = false,
Takashi Iwai 76b060
+	},
Takashi Iwai 76b060
 	{
Takashi Iwai 76b060
 		.active_pipes = BIT(PIPE_A) | BIT(PIPE_B),
Takashi Iwai 76b060
 		.dbuf_mask = {
Takashi Iwai 76b060
@@ -4825,13 +4843,14 @@ static bool adlp_check_mbus_joined(u8 active_pipes)
Takashi Iwai 76b060
 	return check_mbus_joined(active_pipes, adlp_allowed_dbufs);
Takashi Iwai 76b060
 }
Takashi Iwai 76b060
 
Takashi Iwai 76b060
-static u8 compute_dbuf_slices(enum pipe pipe, u8 active_pipes,
Takashi Iwai 76b060
+static u8 compute_dbuf_slices(enum pipe pipe, u8 active_pipes, bool join_mbus,
Takashi Iwai 76b060
 			      const struct dbuf_slice_conf_entry *dbuf_slices)
Takashi Iwai 76b060
 {
Takashi Iwai 76b060
 	int i;
Takashi Iwai 76b060
 
Takashi Iwai 76b060
 	for (i = 0; i < dbuf_slices[i].active_pipes; i++) {
Takashi Iwai 76b060
-		if (dbuf_slices[i].active_pipes == active_pipes)
Takashi Iwai 76b060
+		if (dbuf_slices[i].active_pipes == active_pipes &&
Takashi Iwai 76b060
+		    dbuf_slices[i].join_mbus == join_mbus)
Takashi Iwai 76b060
 			return dbuf_slices[i].dbuf_mask[pipe];
Takashi Iwai 76b060
 	}
Takashi Iwai 76b060
 	return 0;
Takashi Iwai 76b060
@@ -4842,7 +4861,7 @@ static u8 compute_dbuf_slices(enum pipe pipe, u8 active_pipes,
Takashi Iwai 76b060
  * returns correspondent DBuf slice mask as stated in BSpec for particular
Takashi Iwai 76b060
  * platform.
Takashi Iwai 76b060
  */
Takashi Iwai 76b060
-static u8 icl_compute_dbuf_slices(enum pipe pipe, u8 active_pipes)
Takashi Iwai 76b060
+static u8 icl_compute_dbuf_slices(enum pipe pipe, u8 active_pipes, bool join_mbus)
Takashi Iwai 76b060
 {
Takashi Iwai 76b060
 	/*
Takashi Iwai 76b060
 	 * FIXME: For ICL this is still a bit unclear as prev BSpec revision
Takashi Iwai 76b060
@@ -4856,37 +4875,41 @@ static u8 icl_compute_dbuf_slices(enum pipe pipe, u8 active_pipes)
Takashi Iwai 76b060
 	 * still here - we will need it once those additional constraints
Takashi Iwai 76b060
 	 * pop up.
Takashi Iwai 76b060
 	 */
Takashi Iwai 76b060
-	return compute_dbuf_slices(pipe, active_pipes, icl_allowed_dbufs);
Takashi Iwai 76b060
+	return compute_dbuf_slices(pipe, active_pipes, join_mbus,
Takashi Iwai 76b060
+				   icl_allowed_dbufs);
Takashi Iwai 76b060
 }
Takashi Iwai 76b060
 
Takashi Iwai 76b060
-static u8 tgl_compute_dbuf_slices(enum pipe pipe, u8 active_pipes)
Takashi Iwai 76b060
+static u8 tgl_compute_dbuf_slices(enum pipe pipe, u8 active_pipes, bool join_mbus)
Takashi Iwai 76b060
 {
Takashi Iwai 76b060
-	return compute_dbuf_slices(pipe, active_pipes, tgl_allowed_dbufs);
Takashi Iwai 76b060
+	return compute_dbuf_slices(pipe, active_pipes, join_mbus,
Takashi Iwai 76b060
+				   tgl_allowed_dbufs);
Takashi Iwai 76b060
 }
Takashi Iwai 76b060
 
Takashi Iwai 76b060
-static u32 adlp_compute_dbuf_slices(enum pipe pipe, u32 active_pipes)
Takashi Iwai 76b060
+static u8 adlp_compute_dbuf_slices(enum pipe pipe, u8 active_pipes, bool join_mbus)
Takashi Iwai 76b060
 {
Takashi Iwai 76b060
-	return compute_dbuf_slices(pipe, active_pipes, adlp_allowed_dbufs);
Takashi Iwai 76b060
+	return compute_dbuf_slices(pipe, active_pipes, join_mbus,
Takashi Iwai 76b060
+				   adlp_allowed_dbufs);
Takashi Iwai 76b060
 }
Takashi Iwai 76b060
 
Takashi Iwai 76b060
-static u32 dg2_compute_dbuf_slices(enum pipe pipe, u32 active_pipes)
Takashi Iwai 76b060
+static u8 dg2_compute_dbuf_slices(enum pipe pipe, u8 active_pipes, bool join_mbus)
Takashi Iwai 76b060
 {
Takashi Iwai 76b060
-	return compute_dbuf_slices(pipe, active_pipes, dg2_allowed_dbufs);
Takashi Iwai 76b060
+	return compute_dbuf_slices(pipe, active_pipes, join_mbus,
Takashi Iwai 76b060
+				   dg2_allowed_dbufs);
Takashi Iwai 76b060
 }
Takashi Iwai 76b060
 
Takashi Iwai 76b060
-static u8 skl_compute_dbuf_slices(struct intel_crtc *crtc, u8 active_pipes)
Takashi Iwai 76b060
+static u8 skl_compute_dbuf_slices(struct intel_crtc *crtc, u8 active_pipes, bool join_mbus)
Takashi Iwai 76b060
 {
Takashi Iwai 76b060
 	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
Takashi Iwai 76b060
 	enum pipe pipe = crtc->pipe;
Takashi Iwai 76b060
 
Takashi Iwai 76b060
 	if (IS_DG2(dev_priv))
Takashi Iwai 76b060
-		return dg2_compute_dbuf_slices(pipe, active_pipes);
Takashi Iwai 76b060
+		return dg2_compute_dbuf_slices(pipe, active_pipes, join_mbus);
Takashi Iwai 76b060
 	else if (IS_ALDERLAKE_P(dev_priv))
Takashi Iwai 76b060
-		return adlp_compute_dbuf_slices(pipe, active_pipes);
Takashi Iwai 76b060
+		return adlp_compute_dbuf_slices(pipe, active_pipes, join_mbus);
Takashi Iwai 76b060
 	else if (DISPLAY_VER(dev_priv) == 12)
Takashi Iwai 76b060
-		return tgl_compute_dbuf_slices(pipe, active_pipes);
Takashi Iwai 76b060
+		return tgl_compute_dbuf_slices(pipe, active_pipes, join_mbus);
Takashi Iwai 76b060
 	else if (DISPLAY_VER(dev_priv) == 11)
Takashi Iwai 76b060
-		return icl_compute_dbuf_slices(pipe, active_pipes);
Takashi Iwai 76b060
+		return icl_compute_dbuf_slices(pipe, active_pipes, join_mbus);
Takashi Iwai 76b060
 	/*
Takashi Iwai 76b060
 	 * For anything else just return one slice yet.
Takashi Iwai 76b060
 	 * Should be extended for other platforms.
Takashi Iwai 76b060
@@ -6139,11 +6162,16 @@ skl_compute_ddb(struct intel_atomic_state *state)
Takashi Iwai 76b060
 			return ret;
Takashi Iwai 76b060
 	}
Takashi Iwai 76b060
 
Takashi Iwai 76b060
+	if (IS_ALDERLAKE_P(dev_priv))
Takashi Iwai 76b060
+		new_dbuf_state->joined_mbus =
Takashi Iwai 76b060
+			adlp_check_mbus_joined(new_dbuf_state->active_pipes);
Takashi Iwai 76b060
+
Takashi Iwai 76b060
 	for_each_intel_crtc(&dev_priv->drm, crtc) {
Takashi Iwai 76b060
 		enum pipe pipe = crtc->pipe;
Takashi Iwai 76b060
 
Takashi Iwai 76b060
 		new_dbuf_state->slices[pipe] =
Takashi Iwai 76b060
-			skl_compute_dbuf_slices(crtc, new_dbuf_state->active_pipes);
Takashi Iwai 76b060
+			skl_compute_dbuf_slices(crtc, new_dbuf_state->active_pipes,
Takashi Iwai 76b060
+						new_dbuf_state->joined_mbus);
Takashi Iwai 76b060
 
Takashi Iwai 76b060
 		if (old_dbuf_state->slices[pipe] == new_dbuf_state->slices[pipe])
Takashi Iwai 76b060
 			continue;
Takashi Iwai 76b060
@@ -6155,9 +6183,6 @@ skl_compute_ddb(struct intel_atomic_state *state)
Takashi Iwai 76b060
 
Takashi Iwai 76b060
 	new_dbuf_state->enabled_slices = intel_dbuf_enabled_slices(new_dbuf_state);
Takashi Iwai 76b060
 
Takashi Iwai 76b060
-	if (IS_ALDERLAKE_P(dev_priv))
Takashi Iwai 76b060
-		new_dbuf_state->joined_mbus = adlp_check_mbus_joined(new_dbuf_state->active_pipes);
Takashi Iwai 76b060
-
Takashi Iwai 76b060
 	if (old_dbuf_state->enabled_slices != new_dbuf_state->enabled_slices ||
Takashi Iwai 76b060
 	    old_dbuf_state->joined_mbus != new_dbuf_state->joined_mbus) {
Takashi Iwai 76b060
 		ret = intel_atomic_serialize_global_state(&new_dbuf_state->base);
Takashi Iwai 76b060
@@ -6658,7 +6683,8 @@ void skl_wm_get_hw_state(struct drm_i915_private *dev_priv)
Takashi Iwai 76b060
 		}
Takashi Iwai 76b060
 
Takashi Iwai 76b060
 		dbuf_state->slices[pipe] =
Takashi Iwai 76b060
-			skl_compute_dbuf_slices(crtc, dbuf_state->active_pipes);
Takashi Iwai 76b060
+			skl_compute_dbuf_slices(crtc, dbuf_state->active_pipes,
Takashi Iwai 76b060
+						dbuf_state->joined_mbus);
Takashi Iwai 76b060
 
Takashi Iwai 76b060
 		dbuf_state->weight[pipe] = intel_crtc_ddb_weight(crtc_state);
Takashi Iwai 76b060
 
Takashi Iwai 76b060
-- 
Takashi Iwai 76b060
2.31.1
Takashi Iwai 76b060