Skip to contentSkip to conversation

Update bxt_sanitize_cdclk() for Xe2_LPD

PATCH Superseded Gustavo Sousa 3 participants 14 messages Jan 4, 2024 – Jan 5, 2024

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Update bxt_sanitize_cdclk() for Xe2_LPD

This series fixes an issue observed during module load due to missing bits in bxt_sanitize_cdclk() specific to Xe2_LPD.

The first patch contains the fix itself. The subsequent patches refactor the code so that bxt_sanitize_cdclk() and _bxt_set_cdclk() use the same function for deriving the value for CDCLK_CTL, hopefully making it harder for the same kind of problem to happen again.

Gustavo Sousa (4):
drm/i915/xe2lpd: Update bxt_sanitize_cdclk() drm/i915/cdclk: Extract bxt_cdclk_ctl() drm/i915/cdclk: Reorder bxt_sanitize_cdclk() drm/i915/cdclk: Re-use bxt_cdclk_ctl() when sanitizing

 drivers/gpu/drm/i915/display/intel_cdclk.c | 100 ++++++++++-----------
 1 file changed, 48 insertions(+), 52 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/4 drm/i915/xe2lpd: Update bxt_sanitize_cdclk()

With Xe2_LPD, there were changes to the way CDCLK_CTL must be programmed. Those were reflected on _bxt_set_cdclk() with commit 3d3696c0fed1 ("drm/i915/lnl: Start using CDCLK through PLL"), but bxt_sanitize_cdclk() was left out.

This was causing some issues when loading the driver with a pre-existing active display configuration: the driver would mistakenly take the current value of CDCLK_CTL as wrong and the sanitization would be triggered.

In a scenario where the display was already configured with a high CDCLKC and had plane(s) enabled, FIFO underrun errors were reported, because the current sanitization code selects the minimum possible CDCLK.

Fix that by updating bxt_sanitize_cdclk() to match the changes made in _bxt_set_cdclk(). Ideally, we would have a common function to derive the value for CDCLK_CTL, but that can be done in a future change.

---
 drivers/gpu/drm/i915/display/intel_cdclk.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_cdclk.c +4 -1
index c5fecde7afa8..0012e3171f3f 100644
@@ -2071,7 +2071,10 @@ static void bxt_sanitize_cdclk(struct drm_i915_private *dev_priv)
 	if (vco != dev_priv->display.cdclk.hw.vco)
 		goto sanitize;
 
-	expected = skl_cdclk_decimal(cdclk);
+	if (DISPLAY_VER(dev_priv) >= 20)
+		expected = MDCLK_SOURCE_SEL_CDCLK_PLL;
+	else
+		expected = skl_cdclk_decimal(cdclk);
 
 	/* Figure out what CD2X divider we should be using for this cdclk */
 	if (HAS_CDCLK_SQUASH(dev_priv))
Signature · 1 line
2.43.0
Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] drm/i915/xe2lpd: Update bxt_sanitize_cdclk()

Quoted 15 lines · Gustavo Sousa

With Xe2_LPD, there were changes to the way CDCLK_CTL must be programmed. Those were reflected on _bxt_set_cdclk() with commit 3d3696c0fed1 ("drm/i915/lnl: Start using CDCLK through PLL"), but bxt_sanitize_cdclk() was left out.

This was causing some issues when loading the driver with a pre-existing active display configuration: the driver would mistakenly take the current value of CDCLK_CTL as wrong and the sanitization would be triggered.

In a scenario where the display was already configured with a high CDCLKC and had plane(s) enabled, FIFO underrun errors were reported, because the current sanitization code selects the minimum possible CDCLK.

Quoted 5 lines

Fix that by updating bxt_sanitize_cdclk() to match the changes made in _bxt_set_cdclk(). Ideally, we would have a common function to derive the value for CDCLK_CTL, but that can be done in a future change.

Quoted 23 lines
---
 drivers/gpu/drm/i915/display/intel_cdclk.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_cdclk.c +4 -1
index c5fecde7afa8..0012e3171f3f 100644
@@ -2071,7 +2071,10 @@ static void bxt_sanitize_cdclk(struct drm_i915_private *dev_priv)
 	if (vco != dev_priv->display.cdclk.hw.vco)
 		goto sanitize;
 
-	expected = skl_cdclk_decimal(cdclk);
+	if (DISPLAY_VER(dev_priv) >= 20)
+		expected = MDCLK_SOURCE_SEL_CDCLK_PLL;
+	else
+		expected = skl_cdclk_decimal(cdclk);
 
 	/* Figure out what CD2X divider we should be using for this cdclk */
 	if (HAS_CDCLK_SQUASH(dev_priv))
Signature · 1 line
2.43.0
Signature · 4 lines
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation
#3 lore raw

PATCH 2/4 drm/i915/cdclk: Extract bxt_cdclk_ctl()

In reply to Gustavo Sousa

This makes the code better readable and will be used later in bxt_sanitize_cdclk().

---
 drivers/gpu/drm/i915/display/intel_cdclk.c | 57 +++++++++++++---------
 1 file changed, 35 insertions(+), 22 deletions(-)
drivers/gpu/drm/i915/display/intel_cdclk.c +35 -22
index 0012e3171f3f..b9354ad46fee 100644
@@ -1900,15 +1900,47 @@ static bool pll_enable_wa_needed(struct drm_i915_private *dev_priv)
 		dev_priv->display.cdclk.hw.vco > 0;
 }
 
+static u32 bxt_cdclk_ctl(struct drm_i915_private *i915,
+			 const struct intel_cdclk_config *cdclk_config,
+			 enum pipe pipe)
+{
+	int cdclk = cdclk_config->cdclk;
+	int vco = cdclk_config->vco;
+	int unsquashed_cdclk;
+	u16 waveform;
+	u32 val;
+
+	waveform = cdclk_squash_waveform(i915, cdclk);
+
+	unsquashed_cdclk = DIV_ROUND_CLOSEST(cdclk * cdclk_squash_len,
+					     cdclk_squash_divider(waveform));
+
+	val = bxt_cdclk_cd2x_div_sel(i915, unsquashed_cdclk, vco) |
+		bxt_cdclk_cd2x_pipe(i915, pipe);
+
+	/*
+	 * Disable SSA Precharge when CD clock frequency < 500 MHz,
+	 * enable otherwise.
+	 */
+	if ((IS_GEMINILAKE(i915) || IS_BROXTON(i915)) &&
+	    cdclk >= 500000)
+		val |= BXT_CDCLK_SSA_PRECHARGE_ENABLE;
+
+	if (DISPLAY_VER(i915) >= 20)
+		val |= MDCLK_SOURCE_SEL_CDCLK_PLL;
+	else
+		val |= skl_cdclk_decimal(cdclk);
+
+	return val;
+}
+
 static void _bxt_set_cdclk(struct drm_i915_private *dev_priv,
 			   const struct intel_cdclk_config *cdclk_config,
 			   enum pipe pipe)
 {
 	int cdclk = cdclk_config->cdclk;
 	int vco = cdclk_config->vco;
-	int unsquashed_cdclk;
 	u16 waveform;
-	u32 val;
 
 	if (HAS_CDCLK_CRAWL(dev_priv) && dev_priv->display.cdclk.hw.vco > 0 && vco > 0 &&
 	    !cdclk_pll_is_unknown(dev_priv->display.cdclk.hw.vco)) {
@@ -1925,29 +1957,10 @@ static void _bxt_set_cdclk(struct drm_i915_private *dev_priv,
 
 	waveform = cdclk_squash_waveform(dev_priv, cdclk);
 
-	unsquashed_cdclk = DIV_ROUND_CLOSEST(cdclk * cdclk_squash_len,
-					     cdclk_squash_divider(waveform));
-
 	if (HAS_CDCLK_SQUASH(dev_priv))
 		dg2_cdclk_squash_program(dev_priv, waveform);
 
-	val = bxt_cdclk_cd2x_div_sel(dev_priv, unsquashed_cdclk, vco) |
-		bxt_cdclk_cd2x_pipe(dev_priv, pipe);
-
-	/*
-	 * Disable SSA Precharge when CD clock frequency < 500 MHz,
-	 * enable otherwise.
-	 */
-	if ((IS_GEMINILAKE(dev_priv) || IS_BROXTON(dev_priv)) &&
-	    cdclk >= 500000)
-		val |= BXT_CDCLK_SSA_PRECHARGE_ENABLE;
-
-	if (DISPLAY_VER(dev_priv) >= 20)
-		val |= MDCLK_SOURCE_SEL_CDCLK_PLL;
-	else
-		val |= skl_cdclk_decimal(cdclk);
-
-	intel_de_write(dev_priv, CDCLK_CTL, val);
+	intel_de_write(dev_priv, CDCLK_CTL, bxt_cdclk_ctl(dev_priv, cdclk_config, pipe));
 
 	if (pipe != INVALID_PIPE)
 		intel_crtc_wait_for_next_vblank(intel_crtc_for_pipe(dev_priv, pipe));
Signature · 1 line
2.43.0
Reviewed-by on v1 2/4
#4 lore raw

Re: [PATCH 2/4] drm/i915/cdclk: Extract bxt_cdclk_ctl()

Quoted 4 lines · Gustavo Sousa

This makes the code better readable and will be used later in bxt_sanitize_cdclk().

Quoted 92 lines
---
 drivers/gpu/drm/i915/display/intel_cdclk.c | 57 +++++++++++++---------
 1 file changed, 35 insertions(+), 22 deletions(-)
drivers/gpu/drm/i915/display/intel_cdclk.c +35 -22
index 0012e3171f3f..b9354ad46fee 100644
@@ -1900,15 +1900,47 @@ static bool pll_enable_wa_needed(struct drm_i915_private *dev_priv)
 		dev_priv->display.cdclk.hw.vco > 0;
 }
 
+static u32 bxt_cdclk_ctl(struct drm_i915_private *i915,
+			 const struct intel_cdclk_config *cdclk_config,
+			 enum pipe pipe)
+{
+	int cdclk = cdclk_config->cdclk;
+	int vco = cdclk_config->vco;
+	int unsquashed_cdclk;
+	u16 waveform;
+	u32 val;
+
+	waveform = cdclk_squash_waveform(i915, cdclk);
+
+	unsquashed_cdclk = DIV_ROUND_CLOSEST(cdclk * cdclk_squash_len,
+					     cdclk_squash_divider(waveform));
+
+	val = bxt_cdclk_cd2x_div_sel(i915, unsquashed_cdclk, vco) |
+		bxt_cdclk_cd2x_pipe(i915, pipe);
+
+	/*
+	 * Disable SSA Precharge when CD clock frequency < 500 MHz,
+	 * enable otherwise.
+	 */
+	if ((IS_GEMINILAKE(i915) || IS_BROXTON(i915)) &&
+	    cdclk >= 500000)
+		val |= BXT_CDCLK_SSA_PRECHARGE_ENABLE;
+
+	if (DISPLAY_VER(i915) >= 20)
+		val |= MDCLK_SOURCE_SEL_CDCLK_PLL;
+	else
+		val |= skl_cdclk_decimal(cdclk);
+
+	return val;
+}
+
 static void _bxt_set_cdclk(struct drm_i915_private *dev_priv,
 			   const struct intel_cdclk_config *cdclk_config,
 			   enum pipe pipe)
 {
 	int cdclk = cdclk_config->cdclk;
 	int vco = cdclk_config->vco;
-	int unsquashed_cdclk;
 	u16 waveform;
-	u32 val;
 
 	if (HAS_CDCLK_CRAWL(dev_priv) && dev_priv->display.cdclk.hw.vco > 0 && vco > 0 &&
 	    !cdclk_pll_is_unknown(dev_priv->display.cdclk.hw.vco)) {
@@ -1925,29 +1957,10 @@ static void _bxt_set_cdclk(struct drm_i915_private *dev_priv,
 
 	waveform = cdclk_squash_waveform(dev_priv, cdclk);
 
-	unsquashed_cdclk = DIV_ROUND_CLOSEST(cdclk * cdclk_squash_len,
-					     cdclk_squash_divider(waveform));
-
 	if (HAS_CDCLK_SQUASH(dev_priv))
 		dg2_cdclk_squash_program(dev_priv, waveform);
 
-	val = bxt_cdclk_cd2x_div_sel(dev_priv, unsquashed_cdclk, vco) |
-		bxt_cdclk_cd2x_pipe(dev_priv, pipe);
-
-	/*
-	 * Disable SSA Precharge when CD clock frequency < 500 MHz,
-	 * enable otherwise.
-	 */
-	if ((IS_GEMINILAKE(dev_priv) || IS_BROXTON(dev_priv)) &&
-	    cdclk >= 500000)
-		val |= BXT_CDCLK_SSA_PRECHARGE_ENABLE;
-
-	if (DISPLAY_VER(dev_priv) >= 20)
-		val |= MDCLK_SOURCE_SEL_CDCLK_PLL;
-	else
-		val |= skl_cdclk_decimal(cdclk);
-
-	intel_de_write(dev_priv, CDCLK_CTL, val);
+	intel_de_write(dev_priv, CDCLK_CTL, bxt_cdclk_ctl(dev_priv, cdclk_config, pipe));
 
 	if (pipe != INVALID_PIPE)
 		intel_crtc_wait_for_next_vblank(intel_crtc_for_pipe(dev_priv, pipe));
Signature · 1 line
2.43.0
Signature · 4 lines
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation
#5 lore raw

PATCH 3/4 drm/i915/cdclk: Reorder bxt_sanitize_cdclk()

In reply to Gustavo Sousa

Make the sequence of steps more logical by grouping things related to the check on the value of CDCLK_CTL into a single "block". Also, this will make an upcoming change replacing that block with a single function call easier to follow.

---
 drivers/gpu/drm/i915/display/intel_cdclk.c | 24 +++++++++++-----------
 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/display/intel_cdclk.c +12 -12
index b9354ad46fee..fbe9aba41c35 100644
@@ -2060,13 +2060,23 @@ static void bxt_sanitize_cdclk(struct drm_i915_private *dev_priv)
 	    dev_priv->display.cdclk.hw.cdclk == dev_priv->display.cdclk.hw.bypass)
 		goto sanitize;
 
-	/* DPLL okay; verify the cdclock
-	 *
+	/* Make sure this is a legal cdclk value for the platform */
+	cdclk = bxt_calc_cdclk(dev_priv, dev_priv->display.cdclk.hw.cdclk);
+	if (cdclk != dev_priv->display.cdclk.hw.cdclk)
+		goto sanitize;
+
+	/* Make sure the VCO is correct for the cdclk */
+	vco = bxt_calc_cdclk_pll_vco(dev_priv, cdclk);
+	if (vco != dev_priv->display.cdclk.hw.vco)
+		goto sanitize;
+
+	/*
 	 * Some BIOS versions leave an incorrect decimal frequency value and
 	 * set reserved MBZ bits in CDCLK_CTL at least during exiting from S4,
 	 * so sanitize this register.
 	 */
 	cdctl = intel_de_read(dev_priv, CDCLK_CTL);
+
 	/*
 	 * Let's ignore the pipe field, since BIOS could have configured the
 	 * dividers both synching to an active pipe, or asynchronously
@@ -2074,16 +2084,6 @@ static void bxt_sanitize_cdclk(struct drm_i915_private *dev_priv)
 	 */
 	cdctl &= ~bxt_cdclk_cd2x_pipe(dev_priv, INVALID_PIPE);
 
-	/* Make sure this is a legal cdclk value for the platform */
-	cdclk = bxt_calc_cdclk(dev_priv, dev_priv->display.cdclk.hw.cdclk);
-	if (cdclk != dev_priv->display.cdclk.hw.cdclk)
-		goto sanitize;
-
-	/* Make sure the VCO is correct for the cdclk */
-	vco = bxt_calc_cdclk_pll_vco(dev_priv, cdclk);
-	if (vco != dev_priv->display.cdclk.hw.vco)
-		goto sanitize;
-
 	if (DISPLAY_VER(dev_priv) >= 20)
 		expected = MDCLK_SOURCE_SEL_CDCLK_PLL;
 	else
Signature · 1 line
2.43.0
Reviewed-by on v1 3/4
#6 lore raw

Re: [PATCH 3/4] drm/i915/cdclk: Reorder bxt_sanitize_cdclk()

Quoted 6 lines · Gustavo Sousa

Make the sequence of steps more logical by grouping things related to the check on the value of CDCLK_CTL into a single "block". Also, this will make an upcoming change replacing that block with a single function call easier to follow.

Quoted 54 lines
---
 drivers/gpu/drm/i915/display/intel_cdclk.c | 24 +++++++++++-----------
 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/display/intel_cdclk.c +12 -12
index b9354ad46fee..fbe9aba41c35 100644
@@ -2060,13 +2060,23 @@ static void bxt_sanitize_cdclk(struct drm_i915_private *dev_priv)
 	    dev_priv->display.cdclk.hw.cdclk == dev_priv->display.cdclk.hw.bypass)
 		goto sanitize;
 
-	/* DPLL okay; verify the cdclock
-	 *
+	/* Make sure this is a legal cdclk value for the platform */
+	cdclk = bxt_calc_cdclk(dev_priv, dev_priv->display.cdclk.hw.cdclk);
+	if (cdclk != dev_priv->display.cdclk.hw.cdclk)
+		goto sanitize;
+
+	/* Make sure the VCO is correct for the cdclk */
+	vco = bxt_calc_cdclk_pll_vco(dev_priv, cdclk);
+	if (vco != dev_priv->display.cdclk.hw.vco)
+		goto sanitize;
+
+	/*
 	 * Some BIOS versions leave an incorrect decimal frequency value and
 	 * set reserved MBZ bits in CDCLK_CTL at least during exiting from S4,
 	 * so sanitize this register.
 	 */
 	cdctl = intel_de_read(dev_priv, CDCLK_CTL);
+
 	/*
 	 * Let's ignore the pipe field, since BIOS could have configured the
 	 * dividers both synching to an active pipe, or asynchronously
@@ -2074,16 +2084,6 @@ static void bxt_sanitize_cdclk(struct drm_i915_private *dev_priv)
 	 */
 	cdctl &= ~bxt_cdclk_cd2x_pipe(dev_priv, INVALID_PIPE);
 
-	/* Make sure this is a legal cdclk value for the platform */
-	cdclk = bxt_calc_cdclk(dev_priv, dev_priv->display.cdclk.hw.cdclk);
-	if (cdclk != dev_priv->display.cdclk.hw.cdclk)
-		goto sanitize;
-
-	/* Make sure the VCO is correct for the cdclk */
-	vco = bxt_calc_cdclk_pll_vco(dev_priv, cdclk);
-	if (vco != dev_priv->display.cdclk.hw.vco)
-		goto sanitize;
-
 	if (DISPLAY_VER(dev_priv) >= 20)
 		expected = MDCLK_SOURCE_SEL_CDCLK_PLL;
 	else
Signature · 1 line
2.43.0
Signature · 4 lines
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation
#7 lore raw

PATCH 4/4 drm/i915/cdclk: Re-use bxt_cdclk_ctl() when sanitizing

In reply to Gustavo Sousa

That's the function responsible for deriving that register's value; use it.

---
 drivers/gpu/drm/i915/display/intel_cdclk.c | 26 +++-------------------
 1 file changed, 3 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/display/intel_cdclk.c +3 -23
index fbe9aba41c35..26200ee3e23f 100644
@@ -2051,7 +2051,7 @@ static void bxt_set_cdclk(struct drm_i915_private *dev_priv,
 static void bxt_sanitize_cdclk(struct drm_i915_private *dev_priv)
 {
 	u32 cdctl, expected;
-	int cdclk, clock, vco;
+	int cdclk, vco;
 
 	intel_update_cdclk(dev_priv);
 	intel_cdclk_dump_config(dev_priv, &dev_priv->display.cdclk.hw, "Current CDCLK");
@@ -2076,6 +2076,7 @@ static void bxt_sanitize_cdclk(struct drm_i915_private *dev_priv)
 	 * so sanitize this register.
 	 */
 	cdctl = intel_de_read(dev_priv, CDCLK_CTL);
+	expected = bxt_cdclk_ctl(dev_priv, &dev_priv->display.cdclk.hw, INVALID_PIPE);
 
 	/*
 	 * Let's ignore the pipe field, since BIOS could have configured the
@@ -2083,28 +2084,7 @@ static void bxt_sanitize_cdclk(struct drm_i915_private *dev_priv)
 	 * (PIPE_NONE).
 	 */
 	cdctl &= ~bxt_cdclk_cd2x_pipe(dev_priv, INVALID_PIPE);
-
-	if (DISPLAY_VER(dev_priv) >= 20)
-		expected = MDCLK_SOURCE_SEL_CDCLK_PLL;
-	else
-		expected = skl_cdclk_decimal(cdclk);
-
-	/* Figure out what CD2X divider we should be using for this cdclk */
-	if (HAS_CDCLK_SQUASH(dev_priv))
-		clock = dev_priv->display.cdclk.hw.vco / 2;
-	else
-		clock = dev_priv->display.cdclk.hw.cdclk;
-
-	expected |= bxt_cdclk_cd2x_div_sel(dev_priv, clock,
-					   dev_priv->display.cdclk.hw.vco);
-
-	/*
-	 * Disable SSA Precharge when CD clock frequency < 500 MHz,
-	 * enable otherwise.
-	 */
-	if ((IS_GEMINILAKE(dev_priv) || IS_BROXTON(dev_priv)) &&
-	    dev_priv->display.cdclk.hw.cdclk >= 500000)
-		expected |= BXT_CDCLK_SSA_PRECHARGE_ENABLE;
+	expected &= ~bxt_cdclk_cd2x_pipe(dev_priv, INVALID_PIPE);
 
 	if (cdctl == expected)
 		/* All well; nothing to sanitize */
Signature · 1 line
2.43.0
Reviewed-by on v1 4/4
#8 lore raw

Re: [PATCH 4/4] drm/i915/cdclk: Re-use bxt_cdclk_ctl() when sanitizing

Quoted 4 lines · Gustavo Sousa

That's the function responsible for deriving that register's value; use it.

Quoted 58 lines
---
 drivers/gpu/drm/i915/display/intel_cdclk.c | 26 +++-------------------
 1 file changed, 3 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/display/intel_cdclk.c +3 -23
index fbe9aba41c35..26200ee3e23f 100644
@@ -2051,7 +2051,7 @@ static void bxt_set_cdclk(struct drm_i915_private *dev_priv,
 static void bxt_sanitize_cdclk(struct drm_i915_private *dev_priv)
 {
 	u32 cdctl, expected;
-	int cdclk, clock, vco;
+	int cdclk, vco;
 
 	intel_update_cdclk(dev_priv);
 	intel_cdclk_dump_config(dev_priv, &dev_priv->display.cdclk.hw, "Current CDCLK");
@@ -2076,6 +2076,7 @@ static void bxt_sanitize_cdclk(struct drm_i915_private *dev_priv)
 	 * so sanitize this register.
 	 */
 	cdctl = intel_de_read(dev_priv, CDCLK_CTL);
+	expected = bxt_cdclk_ctl(dev_priv, &dev_priv->display.cdclk.hw, INVALID_PIPE);
 
 	/*
 	 * Let's ignore the pipe field, since BIOS could have configured the
@@ -2083,28 +2084,7 @@ static void bxt_sanitize_cdclk(struct drm_i915_private *dev_priv)
 	 * (PIPE_NONE).
 	 */
 	cdctl &= ~bxt_cdclk_cd2x_pipe(dev_priv, INVALID_PIPE);
-
-	if (DISPLAY_VER(dev_priv) >= 20)
-		expected = MDCLK_SOURCE_SEL_CDCLK_PLL;
-	else
-		expected = skl_cdclk_decimal(cdclk);
-
-	/* Figure out what CD2X divider we should be using for this cdclk */
-	if (HAS_CDCLK_SQUASH(dev_priv))
-		clock = dev_priv->display.cdclk.hw.vco / 2;
-	else
-		clock = dev_priv->display.cdclk.hw.cdclk;
-
-	expected |= bxt_cdclk_cd2x_div_sel(dev_priv, clock,
-					   dev_priv->display.cdclk.hw.vco);
-
-	/*
-	 * Disable SSA Precharge when CD clock frequency < 500 MHz,
-	 * enable otherwise.
-	 */
-	if ((IS_GEMINILAKE(dev_priv) || IS_BROXTON(dev_priv)) &&
-	    dev_priv->display.cdclk.hw.cdclk >= 500000)
-		expected |= BXT_CDCLK_SSA_PRECHARGE_ENABLE;
+	expected &= ~bxt_cdclk_cd2x_pipe(dev_priv, INVALID_PIPE);
 
 	if (cdctl == expected)
 		/* All well; nothing to sanitize */
Signature · 1 line
2.43.0
Signature · 4 lines
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation
#9 lore raw

Re: [PATCH 4/4] drm/i915/cdclk: Re-use bxt_cdclk_ctl() when sanitizing

Quoted 7 lines · Matt Roper
Quoted 4 lines · Gustavo Sousa

That's the function responsible for deriving that register's value; use it.

Forgot to mention...I think it's a bit jarring when the commit message starts out referring to something in the headline ("That's the function..."). It's probably a bit better to just re-state the function name in the commit message again rather than assuming both get read together.

Matt

Quoted 65 lines
Quoted 59 lines
---
 drivers/gpu/drm/i915/display/intel_cdclk.c | 26 +++-------------------
 1 file changed, 3 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/display/intel_cdclk.c +3 -23
index fbe9aba41c35..26200ee3e23f 100644
@@ -2051,7 +2051,7 @@ static void bxt_set_cdclk(struct drm_i915_private *dev_priv,
 static void bxt_sanitize_cdclk(struct drm_i915_private *dev_priv)
 {
 	u32 cdctl, expected;
-	int cdclk, clock, vco;
+	int cdclk, vco;
 
 	intel_update_cdclk(dev_priv);
 	intel_cdclk_dump_config(dev_priv, &dev_priv->display.cdclk.hw, "Current CDCLK");
@@ -2076,6 +2076,7 @@ static void bxt_sanitize_cdclk(struct drm_i915_private *dev_priv)
 	 * so sanitize this register.
 	 */
 	cdctl = intel_de_read(dev_priv, CDCLK_CTL);
+	expected = bxt_cdclk_ctl(dev_priv, &dev_priv->display.cdclk.hw, INVALID_PIPE);
 
 	/*
 	 * Let's ignore the pipe field, since BIOS could have configured the
@@ -2083,28 +2084,7 @@ static void bxt_sanitize_cdclk(struct drm_i915_private *dev_priv)
 	 * (PIPE_NONE).
 	 */
 	cdctl &= ~bxt_cdclk_cd2x_pipe(dev_priv, INVALID_PIPE);
-
-	if (DISPLAY_VER(dev_priv) >= 20)
-		expected = MDCLK_SOURCE_SEL_CDCLK_PLL;
-	else
-		expected = skl_cdclk_decimal(cdclk);
-
-	/* Figure out what CD2X divider we should be using for this cdclk */
-	if (HAS_CDCLK_SQUASH(dev_priv))
-		clock = dev_priv->display.cdclk.hw.vco / 2;
-	else
-		clock = dev_priv->display.cdclk.hw.cdclk;
-
-	expected |= bxt_cdclk_cd2x_div_sel(dev_priv, clock,
-					   dev_priv->display.cdclk.hw.vco);
-
-	/*
-	 * Disable SSA Precharge when CD clock frequency < 500 MHz,
-	 * enable otherwise.
-	 */
-	if ((IS_GEMINILAKE(dev_priv) || IS_BROXTON(dev_priv)) &&
-	    dev_priv->display.cdclk.hw.cdclk >= 500000)
-		expected |= BXT_CDCLK_SSA_PRECHARGE_ENABLE;
+	expected &= ~bxt_cdclk_cd2x_pipe(dev_priv, INVALID_PIPE);
 
 	if (cdctl == expected)
 		/* All well; nothing to sanitize */
Signature · 1 line
2.43.0
Signature · 4 lines
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation
Signature · 4 lines
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation
#10 lore raw

Re: [PATCH 4/4] drm/i915/cdclk: Re-use bxt_cdclk_ctl() when sanitizing

Quoting Matt Roper (2024-01-04 20:52:32-03:00)

Quoted 7 lines · Matt Roper
Quoted 6 lines · Gustavo Sousa
Quoted 4 lines

That's the function responsible for deriving that register's value; use it.

Quoted 7 lines
Quoted 1 line

Forgot to mention...I think it's a bit jarring when the commit message starts out referring to something in the headline ("That's the function..."). It's probably a bit better to just re-state the function name in the commit message again rather than assuming both get read together.

Thanks for the suggestion!

I have sent a v2 updating the body of commit messages, not only for this one but also for two more patches. I have kept your r-b's. Let me know if that's okay.

--
Gustavo Sousa

Quoted 75 lines

Matt

Quoted 65 lines
Quoted 59 lines
---
 drivers/gpu/drm/i915/display/intel_cdclk.c | 26 +++-------------------
 1 file changed, 3 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/display/intel_cdclk.c +3 -23
index fbe9aba41c35..26200ee3e23f 100644
@@ -2051,7 +2051,7 @@ static void bxt_set_cdclk(struct drm_i915_private *dev_priv,
 static void bxt_sanitize_cdclk(struct drm_i915_private *dev_priv)
 {
         u32 cdctl, expected;
-        int cdclk, clock, vco;
+        int cdclk, vco;
 
         intel_update_cdclk(dev_priv);
         intel_cdclk_dump_config(dev_priv, &dev_priv->display.cdclk.hw, "Current CDCLK");
@@ -2076,6 +2076,7 @@ static void bxt_sanitize_cdclk(struct drm_i915_private *dev_priv)
          * so sanitize this register.
          */
         cdctl = intel_de_read(dev_priv, CDCLK_CTL);
+        expected = bxt_cdclk_ctl(dev_priv, &dev_priv->display.cdclk.hw, INVALID_PIPE);
 
         /*
          * Let's ignore the pipe field, since BIOS could have configured the
@@ -2083,28 +2084,7 @@ static void bxt_sanitize_cdclk(struct drm_i915_private *dev_priv)
          * (PIPE_NONE).
          */
         cdctl &= ~bxt_cdclk_cd2x_pipe(dev_priv, INVALID_PIPE);
-
-        if (DISPLAY_VER(dev_priv) >= 20)
-                expected = MDCLK_SOURCE_SEL_CDCLK_PLL;
-        else
-                expected = skl_cdclk_decimal(cdclk);
-
-        /* Figure out what CD2X divider we should be using for this cdclk */
-        if (HAS_CDCLK_SQUASH(dev_priv))
-                clock = dev_priv->display.cdclk.hw.vco / 2;
-        else
-                clock = dev_priv->display.cdclk.hw.cdclk;
-
-        expected |= bxt_cdclk_cd2x_div_sel(dev_priv, clock,
-                                           dev_priv->display.cdclk.hw.vco);
-
-        /*
-         * Disable SSA Precharge when CD clock frequency < 500 MHz,
-         * enable otherwise.
-         */
-        if ((IS_GEMINILAKE(dev_priv) || IS_BROXTON(dev_priv)) &&
-            dev_priv->display.cdclk.hw.cdclk >= 500000)
-                expected |= BXT_CDCLK_SSA_PRECHARGE_ENABLE;
+        expected &= ~bxt_cdclk_cd2x_pipe(dev_priv, INVALID_PIPE);
 
         if (cdctl == expected)
                 /* All well; nothing to sanitize */
Signature · 1 line
2.43.0
Signature · 4 lines
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation
Signature · 4 lines
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation
#11 lore raw

Re: [PATCH 4/4] drm/i915/cdclk: Re-use bxt_cdclk_ctl() when sanitizing

Quoted 16 lines · Gustavo Sousa

Quoting Matt Roper (2024-01-04 20:52:32-03:00)

Quoted 7 lines · Matt Roper
Quoted 6 lines · Gustavo Sousa
Quoted 4 lines

That's the function responsible for deriving that register's value; use it.

Quoted 7 lines
Quoted 1 line

Forgot to mention...I think it's a bit jarring when the commit message starts out referring to something in the headline ("That's the function..."). It's probably a bit better to just re-state the function name in the commit message again rather than assuming both get read together.

Quoted 4 lines

Thanks for the suggestion!

I have sent a v2 updating the body of commit messages, not only for this one but also for two more patches. I have kept your r-b's. Let me know if that's okay.

Yep, the r-b's still apply. Thanks.

Matt

Quoted 79 lines

--
Gustavo Sousa

Quoted 75 lines

Matt

Quoted 65 lines
Quoted 59 lines
---
 drivers/gpu/drm/i915/display/intel_cdclk.c | 26 +++-------------------
 1 file changed, 3 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/display/intel_cdclk.c +3 -23
index fbe9aba41c35..26200ee3e23f 100644
@@ -2051,7 +2051,7 @@ static void bxt_set_cdclk(struct drm_i915_private *dev_priv,
 static void bxt_sanitize_cdclk(struct drm_i915_private *dev_priv)
 {
         u32 cdctl, expected;
-        int cdclk, clock, vco;
+        int cdclk, vco;
 
         intel_update_cdclk(dev_priv);
         intel_cdclk_dump_config(dev_priv, &dev_priv->display.cdclk.hw, "Current CDCLK");
@@ -2076,6 +2076,7 @@ static void bxt_sanitize_cdclk(struct drm_i915_private *dev_priv)
          * so sanitize this register.
          */
         cdctl = intel_de_read(dev_priv, CDCLK_CTL);
+        expected = bxt_cdclk_ctl(dev_priv, &dev_priv->display.cdclk.hw, INVALID_PIPE);
 
         /*
          * Let's ignore the pipe field, since BIOS could have configured the
@@ -2083,28 +2084,7 @@ static void bxt_sanitize_cdclk(struct drm_i915_private *dev_priv)
          * (PIPE_NONE).
          */
         cdctl &= ~bxt_cdclk_cd2x_pipe(dev_priv, INVALID_PIPE);
-
-        if (DISPLAY_VER(dev_priv) >= 20)
-                expected = MDCLK_SOURCE_SEL_CDCLK_PLL;
-        else
-                expected = skl_cdclk_decimal(cdclk);
-
-        /* Figure out what CD2X divider we should be using for this cdclk */
-        if (HAS_CDCLK_SQUASH(dev_priv))
-                clock = dev_priv->display.cdclk.hw.vco / 2;
-        else
-                clock = dev_priv->display.cdclk.hw.cdclk;
-
-        expected |= bxt_cdclk_cd2x_div_sel(dev_priv, clock,
-                                           dev_priv->display.cdclk.hw.vco);
-
-        /*
-         * Disable SSA Precharge when CD clock frequency < 500 MHz,
-         * enable otherwise.
-         */
-        if ((IS_GEMINILAKE(dev_priv) || IS_BROXTON(dev_priv)) &&
-            dev_priv->display.cdclk.hw.cdclk >= 500000)
-                expected |= BXT_CDCLK_SSA_PRECHARGE_ENABLE;
+        expected &= ~bxt_cdclk_cd2x_pipe(dev_priv, INVALID_PIPE);
 
         if (cdctl == expected)
                 /* All well; nothing to sanitize */
Signature · 1 line
2.43.0
Signature · 4 lines
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation
Signature · 4 lines
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation
Signature · 4 lines
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation
#12 lore raw

✗ Fi.CI.BAT: failure for Update bxt_sanitize_cdclk() for Xe2_LPD

In reply to Gustavo Sousa
== Series Details ==

== Series Details ==

Series: Update bxt_sanitize_cdclk() for Xe2_LPD
URL : https://patchwork.freedesktop.org/series/128175/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_14076 -> Patchwork_128175v1
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_128175v1 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes
introduced in Patchwork_128175v1, please notify your bug team ([email protected]) to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_128175v1/index.html

Participating hosts (38 -> 17)
------------------------------

ERROR: It appears as if the changes made in Patchwork_128175v1 prevented too many machines from booting.

Additional (1): bat-kbl-2
Missing (22): fi-rkl-11600 fi-snb-2520m bat-rpls-3 bat-adls-6 fi-pnv-d510 fi-blb-e6850 fi-skl-6600u fi-bsw-n3050 fi-ilk-650 fi-ivb-3770 fi-elk-e7500 bat-rplp-1 bat-jsl-3 fi-kbl-7567u bat-dg1-7 fi-skl-guc bat-jsl-1 bat-mtlp-6 fi-tgl-1115g4 fi-cfl-guc fi-cfl-8109u bat-dg2-14

Known issues
------------

Here are the changes found in Patchwork_128175v1 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@fbdev@info:
- bat-kbl-2: NOTRUN -> [SKIP][1] ([fdo#109271] / [i915#1849])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_128175v1/bat-kbl-2/igt@[email protected]

* igt@gem_lmem_swapping@parallel-random-engines:
- bat-kbl-2: NOTRUN -> [SKIP][2] ([fdo#109271]) +36 other tests skip
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_128175v1/bat-kbl-2/igt@[email protected]

* igt@i915_selftest@live@workarounds:
- bat-dg2-11: [PASS][3] -> [DMESG-FAIL][4] ([i915#9500])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14076/bat-dg2-11/igt@i915_selftest@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_128175v1/bat-dg2-11/igt@i915_selftest@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[i915#1849]: https://gitlab.freedesktop.org/drm/intel/issues/1849
[i915#9500]: https://gitlab.freedesktop.org/drm/intel/issues/9500

Build changes
-------------

* Linux: CI_DRM_14076 -> Patchwork_128175v1

CI-20190529: 20190529
CI_DRM_14076: 6fb23c8c47c3c76c9ea4e62d3e4244eb42a6d081 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7655: ddf7cf40a00caa7d02f3729e1e50f78f102463d9 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_128175v1: 6fb23c8c47c3c76c9ea4e62d3e4244eb42a6d081 @ git://anongit.freedesktop.org/gfx-ci/linux

### Linux commits

828d7c8a65d8 drm/i915/cdclk: Re-use bxt_cdclk_ctl() when sanitizing bc69f75f43c2 drm/i915/cdclk: Reorder bxt_sanitize_cdclk() ad0655315b55 drm/i915/cdclk: Extract bxt_cdclk_ctl() cb932418fd32 drm/i915/xe2lpd: Update bxt_sanitize_cdclk()

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_128175v1/index.html

#13 lore raw

✗ Fi.CI.BAT: failure for Update bxt_sanitize_cdclk() for Xe2_LPD (rev2)

In reply to Gustavo Sousa
== Series Details ==

== Series Details ==

Series: Update bxt_sanitize_cdclk() for Xe2_LPD (rev2)
URL : https://patchwork.freedesktop.org/series/128175/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_14080 -> Patchwork_128175v2
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_128175v2 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes
introduced in Patchwork_128175v2, please notify your bug team ([email protected]) to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_128175v2/index.html

Participating hosts (39 -> 37)
------------------------------

Additional (1): fi-bsw-n3050
Missing (3): bat-mtlp-8 fi-snb-2520m fi-pnv-d510

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in Patchwork_128175v2:

### IGT changes ###

#### Possible regressions ####

* igt@i915_selftest@live@hangcheck:
- bat-adlm-1: [PASS][1] -> [ABORT][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14080/bat-adlm-1/igt@i915_selftest@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_128175v2/bat-adlm-1/igt@i915_selftest@[email protected]

Known issues
------------

Here are the changes found in Patchwork_128175v2 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@gem_lmem_swapping@random-engines:
- fi-bsw-n3050: NOTRUN -> [SKIP][3] ([fdo#109271]) +15 other tests skip
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_128175v2/fi-bsw-n3050/igt@[email protected]

* igt@kms_pm_backlight@basic-brightness@edp-1:
- bat-rplp-1: NOTRUN -> [ABORT][4] ([i915#8668])
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_128175v2/bat-rplp-1/igt@kms_pm_backlight@[email protected]

#### Possible fixes ####

* igt@i915_selftest@live@gt_engines:
- {bat-adls-6}: [TIMEOUT][5] -> [PASS][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14080/bat-adls-6/igt@i915_selftest@live@gt_engines.html
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_128175v2/bat-adls-6/igt@i915_selftest@live@gt_engines.html

* igt@i915_selftest@live@workarounds:
- bat-dg2-11: [DMESG-FAIL][7] ([i915#9500]) -> [PASS][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14080/bat-dg2-11/igt@i915_selftest@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_128175v2/bat-dg2-11/igt@i915_selftest@[email protected]

* igt@i915_suspend@basic-s2idle-without-i915:
- {bat-adls-6}: [WARN][9] -> [PASS][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14080/bat-adls-6/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_128175v2/bat-adls-6/igt@[email protected]

* igt@kms_pipe_crc_basic@read-crc-frame-sequence@pipe-d-edp-1:
- bat-rplp-1: [ABORT][11] ([i915#8668]) -> [PASS][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14080/bat-rplp-1/igt@kms_pipe_crc_basic@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_128175v2/bat-rplp-1/igt@kms_pipe_crc_basic@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[i915#5591]: https://gitlab.freedesktop.org/drm/intel/issues/5591
[i915#8668]: https://gitlab.freedesktop.org/drm/intel/issues/8668
[i915#9500]: https://gitlab.freedesktop.org/drm/intel/issues/9500

Build changes
-------------

* Linux: CI_DRM_14080 -> Patchwork_128175v2

CI-20190529: 20190529
CI_DRM_14080: d7426b5fc261046501ca418fe0e69ad1d6ba59be @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7656: 149297384db8cab03928c12b37ae1bb61089bdad @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_128175v2: d7426b5fc261046501ca418fe0e69ad1d6ba59be @ git://anongit.freedesktop.org/gfx-ci/linux

### Linux commits

e269e5deb362 drm/i915/cdclk: Re-use bxt_cdclk_ctl() when sanitizing 6359e3e24ac0 drm/i915/cdclk: Reorder bxt_sanitize_cdclk() a3c3a4b05ba4 drm/i915/cdclk: Extract bxt_cdclk_ctl() 77281063fd43 drm/i915/xe2lpd: Update bxt_sanitize_cdclk()

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_128175v2/index.html