All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gustavo Sousa <gustavo.sousa@intel.com>
To: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org
Cc: Lucas De Marchi <lucas.demarchi@intel.com>,
	vinod.govindapillai@intel.com, stanislav.lisovskiy@intel.com,
	Matt Roper <matthew.d.roper@intel.com>
Subject: [PATCH 5/8] drm/i915: Add mdclk_cdclk_ratio to intel_dbuf_state
Date: Mon,  4 Mar 2024 15:30:24 -0300	[thread overview]
Message-ID: <20240304183028.195057-6-gustavo.sousa@intel.com> (raw)
In-Reply-To: <20240304183028.195057-1-gustavo.sousa@intel.com>

CDCLK programming Xe2LPD always selects the CDCLK PLL as source for the
MDCLK. Because of that, the ratio between MDCLK and CDCLK is not be
constant anymore. As such, make sure to have the current ratio available
in intel_dbuf_state so that it can be used during dbuf programming.

Note that we write-lock the global state instead of serializing to a
hardware commit because a change in the ratio should be rather handled
in the CDCLK change sequence, which will need to take care of updating
the necessary registers in that case. We will implement that in upcoming
changes.

That said, changes in the MBus joining state should be handled by the
DBUF/MBUS logic, just like it is already done, but the logic will need
to know the ratio to properly update the registers.

Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
---
 drivers/gpu/drm/i915/display/intel_cdclk.c   | 26 ++++++++++++++++++++
 drivers/gpu/drm/i915/display/intel_cdclk.h   |  2 ++
 drivers/gpu/drm/i915/display/skl_watermark.c | 18 +++++++++++++-
 drivers/gpu/drm/i915/display/skl_watermark.h |  3 +++
 4 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/display/intel_cdclk.c b/drivers/gpu/drm/i915/display/intel_cdclk.c
index cdf3ae766f9e..04a6e9806254 100644
--- a/drivers/gpu/drm/i915/display/intel_cdclk.c
+++ b/drivers/gpu/drm/i915/display/intel_cdclk.c
@@ -39,6 +39,7 @@
 #include "intel_pcode.h"
 #include "intel_psr.h"
 #include "intel_vdsc.h"
+#include "skl_watermark.h"
 #include "vlv_sideband.h"
 
 /**
@@ -1891,6 +1892,22 @@ static u32 xe2lpd_mdclk_source_sel(struct drm_i915_private *i915)
 	return MDCLK_SOURCE_SEL_CD2XCLK;
 }
 
+u8 intel_mdclk_cdclk_ratio(struct drm_i915_private *i915,
+			   const struct intel_cdclk_config *cdclk_config)
+{
+	u32 source_sel = xe2lpd_mdclk_source_sel(i915);
+
+	switch (source_sel) {
+	case MDCLK_SOURCE_SEL_CD2XCLK:
+		return 2;
+	case MDCLK_SOURCE_SEL_CDCLK_PLL:
+		return DIV_ROUND_UP(cdclk_config->vco, cdclk_config->cdclk);
+	default:
+		MISSING_CASE(source_sel);
+		return 2;
+	}
+}
+
 static bool cdclk_compute_crawl_and_squash_midpoint(struct drm_i915_private *i915,
 						    const struct intel_cdclk_config *old_cdclk_config,
 						    const struct intel_cdclk_config *new_cdclk_config,
@@ -3281,6 +3298,15 @@ int intel_modeset_calc_cdclk(struct intel_atomic_state *state)
 			    "Modeset required for cdclk change\n");
 	}
 
+	if (intel_mdclk_cdclk_ratio(dev_priv, &old_cdclk_state->actual) !=
+	    intel_mdclk_cdclk_ratio(dev_priv, &new_cdclk_state->actual)) {
+		u8 ratio = intel_mdclk_cdclk_ratio(dev_priv, &new_cdclk_state->actual);
+
+		ret = intel_dbuf_state_set_mdclk_cdclk_ratio(state, ratio);
+		if (ret)
+			return ret;
+	}
+
 	drm_dbg_kms(&dev_priv->drm,
 		    "New cdclk calculated to be logical %u kHz, actual %u kHz\n",
 		    new_cdclk_state->logical.cdclk,
diff --git a/drivers/gpu/drm/i915/display/intel_cdclk.h b/drivers/gpu/drm/i915/display/intel_cdclk.h
index fa301495e7f1..8e6e302bd599 100644
--- a/drivers/gpu/drm/i915/display/intel_cdclk.h
+++ b/drivers/gpu/drm/i915/display/intel_cdclk.h
@@ -62,6 +62,8 @@ void intel_update_cdclk(struct drm_i915_private *dev_priv);
 u32 intel_read_rawclk(struct drm_i915_private *dev_priv);
 bool intel_cdclk_clock_changed(const struct intel_cdclk_config *a,
 			       const struct intel_cdclk_config *b);
+u8 intel_mdclk_cdclk_ratio(struct drm_i915_private *i915,
+			   const struct intel_cdclk_config *cdclk_config);
 void intel_set_cdclk_pre_plane_update(struct intel_atomic_state *state);
 void intel_set_cdclk_post_plane_update(struct intel_atomic_state *state);
 void intel_cdclk_dump_config(struct drm_i915_private *i915,
diff --git a/drivers/gpu/drm/i915/display/skl_watermark.c b/drivers/gpu/drm/i915/display/skl_watermark.c
index d9e49cd60d3a..4410e21888ad 100644
--- a/drivers/gpu/drm/i915/display/skl_watermark.c
+++ b/drivers/gpu/drm/i915/display/skl_watermark.c
@@ -3057,6 +3057,8 @@ static void skl_wm_get_hw_state(struct drm_i915_private *i915)
 	if (HAS_MBUS_JOINING(i915))
 		dbuf_state->joined_mbus = intel_de_read(i915, MBUS_CTL) & MBUS_JOIN;
 
+	dbuf_state->mdclk_cdclk_ratio = intel_mdclk_cdclk_ratio(i915, &i915->display.cdclk.hw);
+
 	for_each_intel_crtc(&i915->drm, crtc) {
 		struct intel_crtc_state *crtc_state =
 			to_intel_crtc_state(crtc->base.state);
@@ -3530,6 +3532,19 @@ int intel_dbuf_init(struct drm_i915_private *i915)
 	return 0;
 }
 
+int intel_dbuf_state_set_mdclk_cdclk_ratio(struct intel_atomic_state *state, u8 ratio)
+{
+	struct intel_dbuf_state *dbuf_state;
+
+	dbuf_state = intel_atomic_get_dbuf_state(state);
+	if (IS_ERR(dbuf_state))
+		return PTR_ERR(dbuf_state);
+
+	dbuf_state->mdclk_cdclk_ratio = ratio;
+
+	return intel_atomic_lock_global_state(&dbuf_state->base);
+}
+
 static void intel_dbuf_mdclk_cdclk_ratio_update(struct drm_i915_private *i915,
 						u8 ratio,
 						bool joined_mbus)
@@ -3574,7 +3589,8 @@ static void update_mbus_pre_enable(struct intel_atomic_state *state)
 		     MBUS_HASHING_MODE_MASK | MBUS_JOIN |
 		     MBUS_JOIN_PIPE_SELECT_MASK, mbus_ctl);
 
-	intel_dbuf_mdclk_cdclk_ratio_update(i915, 2, dbuf_state->joined_mbus);
+	intel_dbuf_mdclk_cdclk_ratio_update(i915, dbuf_state->mdclk_cdclk_ratio,
+					    dbuf_state->joined_mbus);
 }
 
 void intel_dbuf_pre_plane_update(struct intel_atomic_state *state)
diff --git a/drivers/gpu/drm/i915/display/skl_watermark.h b/drivers/gpu/drm/i915/display/skl_watermark.h
index e3d1d74a7b17..fed4d12df584 100644
--- a/drivers/gpu/drm/i915/display/skl_watermark.h
+++ b/drivers/gpu/drm/i915/display/skl_watermark.h
@@ -58,6 +58,7 @@ struct intel_dbuf_state {
 	u8 slices[I915_MAX_PIPES];
 	u8 enabled_slices;
 	u8 active_pipes;
+	u8 mdclk_cdclk_ratio;
 	bool joined_mbus;
 };
 
@@ -71,6 +72,8 @@ intel_atomic_get_dbuf_state(struct intel_atomic_state *state);
 	to_intel_dbuf_state(intel_atomic_get_new_global_obj_state(state, &to_i915(state->base.dev)->display.dbuf.obj))
 
 int intel_dbuf_init(struct drm_i915_private *i915);
+int intel_dbuf_state_set_mdclk_cdclk_ratio(struct intel_atomic_state *state, u8 ratio);
+
 void intel_dbuf_pre_plane_update(struct intel_atomic_state *state);
 void intel_dbuf_post_plane_update(struct intel_atomic_state *state);
 void intel_mbus_dbox_update(struct intel_atomic_state *state);
-- 
2.44.0


  parent reply	other threads:[~2024-03-04 18:31 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-04 18:30 [PATCH 0/8] Enable LNL display Gustavo Sousa
2024-03-04 18:30 ` [PATCH 1/8] drm/i915/cdclk: Rename lnl_cdclk_table to xe2lpd_cdclk_table Gustavo Sousa
2024-03-04 21:44   ` Matt Roper
2024-03-04 18:30 ` [PATCH 2/8] drm/i915/cdclk: Add and use xe2lpd_mdclk_source_sel() Gustavo Sousa
2024-03-04 21:58   ` Matt Roper
2024-03-05 14:40     ` Gustavo Sousa
2024-03-08 15:30       ` Gustavo Sousa
2024-03-04 18:30 ` [PATCH 3/8] drm/i915/cdclk: Only compute squash waveform when necessary Gustavo Sousa
2024-03-04 22:04   ` Matt Roper
2024-03-05 14:42     ` Gustavo Sousa
2024-03-04 18:30 ` [PATCH 4/8] drm/i915: Extract intel_dbuf_mdclk_cdclk_ratio_update() Gustavo Sousa
2024-03-04 22:11   ` Matt Roper
2024-03-04 18:30 ` Gustavo Sousa [this message]
2024-03-04 23:25   ` [PATCH 5/8] drm/i915: Add mdclk_cdclk_ratio to intel_dbuf_state Matt Roper
2024-03-05 14:44     ` Gustavo Sousa
2024-03-04 18:30 ` [PATCH 6/8] drm/i915/xe2lpd: Support MDCLK:CDCLK ratio changes Gustavo Sousa
2024-03-11 21:01   ` Lisovskiy, Stanislav
2024-03-11 21:13     ` Gustavo Sousa
2024-03-12  8:27       ` Lisovskiy, Stanislav
2024-03-04 18:30 ` [PATCH 7/8] drm/i915/xe2lpd: Load DMC Gustavo Sousa
2024-03-04 19:50   ` Lucas De Marchi
2024-03-04 20:06     ` Gustavo Sousa
2024-03-04 18:30 ` [PATCH 8/8] drm/xe/lnl: Enable display support Gustavo Sousa
2024-03-04 19:53   ` Lucas De Marchi
2024-03-04 19:41 ` ✓ CI.Patch_applied: success for Enable LNL display Patchwork
2024-03-04 19:42 ` ✗ CI.checkpatch: warning " Patchwork
2024-03-04 19:43 ` ✓ CI.KUnit: success " Patchwork
2024-03-04 19:54 ` ✓ CI.Build: " Patchwork
2024-03-04 19:55 ` ✓ CI.Hooks: " Patchwork
2024-03-04 19:57 ` ✗ CI.checksparse: warning " Patchwork
2024-03-04 20:30 ` ✓ CI.BAT: success " Patchwork
2024-03-05  3:29 ` ✗ Fi.CI.CHECKPATCH: warning " Patchwork
2024-03-05  3:29 ` ✗ Fi.CI.SPARSE: " Patchwork
2024-03-05  3:48 ` ✗ Fi.CI.BAT: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240304183028.195057-6-gustavo.sousa@intel.com \
    --to=gustavo.sousa@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=lucas.demarchi@intel.com \
    --cc=matthew.d.roper@intel.com \
    --cc=stanislav.lisovskiy@intel.com \
    --cc=vinod.govindapillai@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.