Skip to contentSkip to conversation

drm/i915/cnp+: update to the new RAWCLK_FREQ recommendations

PATCH New Paulo Zanoni 2 participants 4 messages Nov 12, 2018 – Nov 13, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 drm/i915/cnp+: update to the new RAWCLK_FREQ recommendations

BSpec was updated and now there's no more "subtract 1" to the Microsecond Counter Divider field.

It seems this should help fixing some GMBUS issues. I'm not aware of any specific open bug that could be solved by this patch.

---
 drivers/gpu/drm/i915/intel_cdclk.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_cdclk.c +3 -3
index 8d74276029e6..810670976e86 100644
@@ -2660,7 +2660,7 @@ static int cnp_rawclk(struct drm_i915_private *dev_priv)
 		fraction = 200;
 	}
 
-	rawclk = CNP_RAWCLK_DIV((divider / 1000) - 1);
+	rawclk = CNP_RAWCLK_DIV(divider / 1000);
 	if (fraction)
 		rawclk |= CNP_RAWCLK_FRAC(DIV_ROUND_CLOSEST(1000,
 							    fraction) - 1);
@@ -2676,12 +2676,12 @@ static int icp_rawclk(struct drm_i915_private *dev_priv)
 
 	if (I915_READ(SFUSE_STRAP) & SFUSE_STRAP_RAW_FREQUENCY) {
 		frequency = 24000;
-		divider = 23;
+		divider = 24;
 		numerator = 0;
 		denominator = 0;
 	} else {
 		frequency = 19200;
-		divider = 18;
+		divider = 19;
 		numerator = 1;
 		denominator = 4;
 	}
Signature · 6 lines
2.14.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 2/3 drm/i915: rename CNP_RAWCLK_FRAC to CNP_RAWCLK_DEN

Although CNP names this field "Counter Fraction", what we write to the register is really the denominator for the fractional part of the divider, not the fractional part (and the field description even says that). The ICP spec renamed the field to "Counter Fraction Denominator", which makes a lot more sense. Use the more complete ICL naming because we will merge the CNP and ICP functions into a single one, which will introduce the concept of the numerator. That will make a lot more sense when you read the "num/frac = den" calculation.

---
 drivers/gpu/drm/i915/i915_reg.h    | 3 +--
 drivers/gpu/drm/i915/intel_cdclk.c | 6 +++---
 2 files changed, 4 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +1 -2
index fe4b913e46ac..16f0d73bb4fe 100644
@@ -7907,8 +7907,7 @@ enum {
 #define  CNP_RAWCLK_DIV_MASK	(0x3ff << 16)
 #define  CNP_RAWCLK_DIV(div)	((div) << 16)
 #define  CNP_RAWCLK_FRAC_MASK	(0xf << 26)
-#define  CNP_RAWCLK_FRAC(frac)	((frac) << 26)
-#define  ICP_RAWCLK_DEN(den)	((den) << 26)
+#define  CNP_RAWCLK_DEN(den)	((den) << 26)
 #define  ICP_RAWCLK_NUM(num)	((num) << 11)
 
 #define PCH_DPLL_TMR_CFG        _MMIO(0xc6208)
drivers/gpu/drm/i915/intel_cdclk.c +3 -3
index 810670976e86..928671936286 100644
@@ -2662,8 +2662,8 @@ static int cnp_rawclk(struct drm_i915_private *dev_priv)
 
 	rawclk = CNP_RAWCLK_DIV(divider / 1000);
 	if (fraction)
-		rawclk |= CNP_RAWCLK_FRAC(DIV_ROUND_CLOSEST(1000,
-							    fraction) - 1);
+		rawclk |= CNP_RAWCLK_DEN(DIV_ROUND_CLOSEST(1000,
+							   fraction) - 1);
 
 	I915_WRITE(PCH_RAWCLK_FREQ, rawclk);
 	return divider + fraction;
@@ -2687,7 +2687,7 @@ static int icp_rawclk(struct drm_i915_private *dev_priv)
 	}
 
 	rawclk = CNP_RAWCLK_DIV(divider) | ICP_RAWCLK_NUM(numerator) |
-		 ICP_RAWCLK_DEN(denominator);
+		 CNP_RAWCLK_DEN(denominator);
 
 	I915_WRITE(PCH_RAWCLK_FREQ, rawclk);
 	return frequency;
Signature · 6 lines
2.14.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

PATCH 3/3 drm/i915: add ICP support to cnp_rawclk() and kill icp_rawclk()

In reply to Paulo Zanoni

I think I'm probably the one who argued in favor of having separate implementations for both PCHs, but the calculations are actually the same, the clocks are the same and the only difference is that on ICP we write the numerator to the register.

I have previously suggested to kill cnp_rawclk() and keep the icp_rawclk() style, but Ville gave some good arguments that what's in this patch may be the better choice.

v2: Switch numerator to 1 from 1000 and adjust calculations
accordingly (Ville).

---
 drivers/gpu/drm/i915/intel_cdclk.c | 37 ++++++++-----------------------------
 1 file changed, 8 insertions(+), 29 deletions(-)
drivers/gpu/drm/i915/intel_cdclk.c +8 -29
index 928671936286..25e3aba9cded 100644
@@ -2661,36 +2661,17 @@ static int cnp_rawclk(struct drm_i915_private *dev_priv)
 	}
 
 	rawclk = CNP_RAWCLK_DIV(divider / 1000);
-	if (fraction)
-		rawclk |= CNP_RAWCLK_DEN(DIV_ROUND_CLOSEST(1000,
-							   fraction) - 1);
+	if (fraction) {
+		int numerator = 1;
 
-	I915_WRITE(PCH_RAWCLK_FREQ, rawclk);
-	return divider + fraction;
-}
-
-static int icp_rawclk(struct drm_i915_private *dev_priv)
-{
-	u32 rawclk;
-	int divider, numerator, denominator, frequency;
-
-	if (I915_READ(SFUSE_STRAP) & SFUSE_STRAP_RAW_FREQUENCY) {
-		frequency = 24000;
-		divider = 24;
-		numerator = 0;
-		denominator = 0;
-	} else {
-		frequency = 19200;
-		divider = 19;
-		numerator = 1;
-		denominator = 4;
+		rawclk |= CNP_RAWCLK_DEN(DIV_ROUND_CLOSEST(numerator * 1000,
+							   fraction) - 1);
+		if (HAS_PCH_ICP(dev_priv))
+			rawclk |= ICP_RAWCLK_NUM(numerator);
 	}
 
-	rawclk = CNP_RAWCLK_DIV(divider) | ICP_RAWCLK_NUM(numerator) |
-		 CNP_RAWCLK_DEN(denominator);
-
 	I915_WRITE(PCH_RAWCLK_FREQ, rawclk);
-	return frequency;
+	return divider + fraction;
 }
 
 static int pch_rawclk(struct drm_i915_private *dev_priv)
@@ -2740,9 +2721,7 @@ static int g4x_hrawclk(struct drm_i915_private *dev_priv)
  */
 void intel_update_rawclk(struct drm_i915_private *dev_priv)
 {
-	if (HAS_PCH_ICP(dev_priv))
-		dev_priv->rawclk_freq = icp_rawclk(dev_priv);
-	else if (HAS_PCH_CNP(dev_priv))
+	if (HAS_PCH_CNP(dev_priv) || HAS_PCH_ICP(dev_priv))
 		dev_priv->rawclk_freq = cnp_rawclk(dev_priv);
 	else if (HAS_PCH_SPLIT(dev_priv))
 		dev_priv->rawclk_freq = pch_rawclk(dev_priv);
Signature · 6 lines
2.14.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

✓ Fi.CI.BAT: success for series starting with [CI,1/3] drm/i915/cnp+: update to the new RAWCLK_FREQ recommendations

In reply to Paulo Zanoni
== Series Details ==

== Series Details ==

Series: series starting with [CI,1/3] drm/i915/cnp+: update to the new RAWCLK_FREQ recommendations
URL : https://patchwork.freedesktop.org/series/52397/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_5127 -> Patchwork_10809 =

== Summary - SUCCESS ==

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/52397/revisions/1/mbox/

== Known issues ==

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

=== IGT changes ===

    ==== Issues hit ====

    igt@drv_selftest@live_contexts:
      fi-icl-u:           NOTRUN -> DMESG-FAIL (fdo#108569)

    igt@kms_pipe_crc_basic@nonblocking-crc-pipe-a:
      fi-byt-clapper:     PASS -> FAIL (fdo#107362)

    
    ==== Possible fixes ====

    igt@gem_exec_suspend@basic-s4-devices:
      fi-glk-dsi:         FAIL -> PASS +2

    igt@kms_pipe_crc_basic@read-crc-pipe-a:
      fi-byt-clapper:     FAIL (fdo#107362) -> PASS

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
      fi-blb-e6850:       INCOMPLETE (fdo#107718) -> PASS

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c:
      fi-glk-dsi:         FAIL (fdo#103375) -> PASS +3
      fi-icl-u:           INCOMPLETE (fdo#107713) -> PASS

    igt@pm_rpm@module-reload:
      fi-glk-dsi:         INCOMPLETE (fdo#103359, k.org#198133) -> PASS +1

fdo#103359 https://bugs.freedesktop.org/show_bug.cgi?id=103359
fdo#103375 https://bugs.freedesktop.org/show_bug.cgi?id=103375
fdo#107362 https://bugs.freedesktop.org/show_bug.cgi?id=107362
fdo#107713 https://bugs.freedesktop.org/show_bug.cgi?id=107713
fdo#107718 https://bugs.freedesktop.org/show_bug.cgi?id=107718
fdo#108569 https://bugs.freedesktop.org/show_bug.cgi?id=108569
k.org#198133 https://bugzilla.kernel.org/show_bug.cgi?id=198133

== Participating hosts (51 -> 45) ==

Missing (6): fi-kbl-soraka fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-apl-guc fi-ctg-p8600

== Build changes ==

* Linux: CI_DRM_5127 -> Patchwork_10809

CI_DRM_5127: 31b5aaa2364ba86baf1293c69c5dcab446ef3a0e @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4714: cab148ca3ec904a94d0cd43476cf7e1f8663f906 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_10809: 832c6dbb012cad016c297a60fd0a6d059d6863ca @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

832c6dbb012c drm/i915: add ICP support to cnp_rawclk() and kill icp_rawclk() a8d56d3b560e drm/i915: rename CNP_RAWCLK_FRAC to CNP_RAWCLK_DEN df30c850c63e drm/i915/cnp+: update to the new RAWCLK_FREQ recommendations

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_10809/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx