Skip to contentSkip to conversation

drm/i915/rps: Centralize computation of freq caps

PATCH New Ashutosh Dixit 2 participants 4 messages Mar 22, 2022

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

PATCH 1/1 drm/i915/rps: Centralize computation of freq caps

Freq caps (i.e. RP0, RP1 and RPn frequencies) are read from HW. However the formats (bit positions, widths, registers and units) of these vary for different generations with even more variations arriving in the future. In order not to have to do identical computation for these caps in multiple places, here we centralize the computation of these caps. This makes the code cleaner and also more extensible for the future.

v2: Clarify that caps are in "hw units" in comments (Lucas De Marchi)

---
 drivers/gpu/drm/i915/gt/intel_gt_pm_debugfs.c |  24 +----
 drivers/gpu/drm/i915/gt/intel_rps.c           | 101 ++++++++++--------
 drivers/gpu/drm/i915/gt/intel_rps.h           |   2 +-
 drivers/gpu/drm/i915/gt/intel_rps_types.h     |  10 ++
 drivers/gpu/drm/i915/gt/uc/intel_guc_slpc.c   |  14 +--
 5 files changed, 79 insertions(+), 72 deletions(-)
drivers/gpu/drm/i915/gt/intel_gt_pm_debugfs.c +5 -19
index 31dbb2b96738..f5fbb74ed076 100644
@@ -342,17 +342,16 @@ void intel_gt_pm_frequency_dump(struct intel_gt *gt, struct drm_printer *p)
 	} else if (GRAPHICS_VER(i915) >= 6) {
 		u32 rp_state_limits;
 		u32 gt_perf_status;
-		u32 rp_state_cap;
+		struct intel_rps_freq_caps caps;
 		u32 rpmodectl, rpinclimit, rpdeclimit;
 		u32 rpstat, cagf, reqf;
 		u32 rpcurupei, rpcurup, rpprevup;
 		u32 rpcurdownei, rpcurdown, rpprevdown;
 		u32 rpupei, rpupt, rpdownei, rpdownt;
 		u32 pm_ier, pm_imr, pm_isr, pm_iir, pm_mask;
-		int max_freq;
 
 		rp_state_limits = intel_uncore_read(uncore, GEN6_RP_STATE_LIMITS);
-		rp_state_cap = intel_rps_read_state_cap(rps);
+		intel_rps_get_freq_caps(rps, &caps);
 		if (IS_GEN9_LP(i915))
 			gt_perf_status = intel_uncore_read(uncore, BXT_GT_PERF_STATUS);
 		else
@@ -474,25 +473,12 @@ void intel_gt_pm_frequency_dump(struct intel_gt *gt, struct drm_printer *p)
 		drm_printf(p, "RP DOWN THRESHOLD: %d (%lldns)\n",
 			   rpdownt, intel_gt_pm_interval_to_ns(gt, rpdownt));
 
-		max_freq = (IS_GEN9_LP(i915) ? rp_state_cap >> 0 :
-			    rp_state_cap >> 16) & 0xff;
-		max_freq *= (IS_GEN9_BC(i915) ||
-			     GRAPHICS_VER(i915) >= 11 ? GEN9_FREQ_SCALER : 1);
 		drm_printf(p, "Lowest (RPN) frequency: %dMHz\n",
-			   intel_gpu_freq(rps, max_freq));
-
-		max_freq = (rp_state_cap & 0xff00) >> 8;
-		max_freq *= (IS_GEN9_BC(i915) ||
-			     GRAPHICS_VER(i915) >= 11 ? GEN9_FREQ_SCALER : 1);
+			   intel_gpu_freq(rps, caps.min_freq));
 		drm_printf(p, "Nominal (RP1) frequency: %dMHz\n",
-			   intel_gpu_freq(rps, max_freq));
-
-		max_freq = (IS_GEN9_LP(i915) ? rp_state_cap >> 16 :
-			    rp_state_cap >> 0) & 0xff;
-		max_freq *= (IS_GEN9_BC(i915) ||
-			     GRAPHICS_VER(i915) >= 11 ? GEN9_FREQ_SCALER : 1);
+			   intel_gpu_freq(rps, caps.rp1_freq));
 		drm_printf(p, "Max non-overclocked (RP0) frequency: %dMHz\n",
-			   intel_gpu_freq(rps, max_freq));
+			   intel_gpu_freq(rps, caps.rp0_freq));
 		drm_printf(p, "Max overclocked frequency: %dMHz\n",
 			   intel_gpu_freq(rps, rps->max_freq));
 
drivers/gpu/drm/i915/gt/intel_rps.c +58 -43

162 lines not on this page · raw message

drivers/gpu/drm/i915/gt/intel_rps.h +1 -1
index ba1ed9f7ecda..529774c55eb6 100644
@@ -45,7 +45,7 @@ u32 intel_rps_get_rp1_frequency(struct intel_rps *rps);
 u32 intel_rps_get_rpn_frequency(struct intel_rps *rps);
 u32 intel_rps_read_punit_req(struct intel_rps *rps);
 u32 intel_rps_read_punit_req_frequency(struct intel_rps *rps);
-u32 intel_rps_read_state_cap(struct intel_rps *rps);
+void intel_rps_get_freq_caps(struct intel_rps *rps, struct intel_rps_freq_caps *caps);
 void intel_rps_raise_unslice(struct intel_rps *rps);
 void intel_rps_lower_unslice(struct intel_rps *rps);
 
drivers/gpu/drm/i915/gt/intel_rps_types.h +10 -0
index 3941d8551f52..4f7a351e0997 100644
@@ -37,6 +37,16 @@ enum {
 	INTEL_RPS_TIMER,
 };
 
+/*
+ * Freq caps exposed by HW, values are in "hw units" and intel_gpu_freq()
+ * should be used to convert to MHz
+ */
+struct intel_rps_freq_caps {
+	u8 rp0_freq;		/* non-overclocked max frequency */
+	u8 rp1_freq;		/* "less than" RP0 power/freqency */
+	u8 min_freq;		/* aka RPn, minimum frequency */
+};
+
 struct intel_rps {
 	struct mutex lock; /* protects enabling and the worker */
 
drivers/gpu/drm/i915/gt/uc/intel_guc_slpc.c +5 -9
index 9f032c65a488..aec5e986cb13 100644
@@ -582,16 +582,12 @@ static int slpc_use_fused_rp0(struct intel_guc_slpc *slpc)
 static void slpc_get_rp_values(struct intel_guc_slpc *slpc)
 {
 	struct intel_rps *rps = &slpc_to_gt(slpc)->rps;
-	u32 rp_state_cap;
+	struct intel_rps_freq_caps caps;
 
-	rp_state_cap = intel_rps_read_state_cap(rps);
-
-	slpc->rp0_freq = REG_FIELD_GET(RP0_CAP_MASK, rp_state_cap) *
-					GT_FREQUENCY_MULTIPLIER;
-	slpc->rp1_freq = REG_FIELD_GET(RP1_CAP_MASK, rp_state_cap) *
-					GT_FREQUENCY_MULTIPLIER;
-	slpc->min_freq = REG_FIELD_GET(RPN_CAP_MASK, rp_state_cap) *
-					GT_FREQUENCY_MULTIPLIER;
+	intel_rps_get_freq_caps(rps, &caps);
+	slpc->rp0_freq = intel_gpu_freq(rps, caps.rp0_freq);
+	slpc->rp1_freq = intel_gpu_freq(rps, caps.rp1_freq);
+	slpc->min_freq = intel_gpu_freq(rps, caps.min_freq);
 
 	if (!slpc->boost_freq)
 		slpc->boost_freq = slpc->rp0_freq;
Signature · 1 line
2.34.1
#1 lore raw

[Intel-gfx] ✗ Fi.CI.SPARSE: warning for drm/i915/rps: Centralize computation of freq caps (rev3)

== Series Details ==

== Series Details ==

Series: drm/i915/rps: Centralize computation of freq caps (rev3)
URL : https://patchwork.freedesktop.org/series/101606/
State : warning

== Summary ==

$ dim sparse --fast origin/drm-tip
Sparse version: v0.6.2
Fast mode used, each commit won't be checked separately.
#2 lore raw

[Intel-gfx] ✗ Fi.CI.DOCS: warning for drm/i915/rps: Centralize computation of freq caps (rev3)

In reply to Ashutosh Dixit
== Series Details ==

== Series Details ==

Series: drm/i915/rps: Centralize computation of freq caps (rev3)
URL : https://patchwork.freedesktop.org/series/101606/
State : warning

== Summary ==

$ make htmldocs 2>&1 > /dev/null | grep i915
./drivers/gpu/drm/i915/display/intel_drrs.c:1: warning: 'intel_drrs_enable' not found
./drivers/gpu/drm/i915/display/intel_drrs.c:1: warning: 'intel_drrs_disable' not found
#3 lore raw

[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915/rps: Centralize computation of freq caps (rev3)

In reply to Ashutosh Dixit
== Series Details ==

== Series Details ==

Series: drm/i915/rps: Centralize computation of freq caps (rev3)
URL : https://patchwork.freedesktop.org/series/101606/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_11397 -> Patchwork_22647
====================================================

Summary
-------

**FAILURE**

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

If you think the reported changes have nothing to do with the changes introduced in Patchwork_22647, please notify your bug team 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_22647/index.html

Participating hosts (48 -> 41)
------------------------------

Additional (1): fi-pnv-d510
Missing (8): shard-tglu fi-hsw-4200u shard-rkl fi-bsw-cyan fi-ctg-p8600 bat-rpls-2 bat-jsl-2 fi-bdw-samus

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

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

### IGT changes ###

#### Possible regressions ####

* igt@i915_selftest@live@gt_engines:
- fi-rkl-guc: [PASS][1] -> [INCOMPLETE][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11397/fi-rkl-guc/igt@i915_selftest@live@gt_engines.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22647/fi-rkl-guc/igt@i915_selftest@live@gt_engines.html

#### Suppressed ####

The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.

* igt@kms_flip@basic-flip-vs-wf_vblank@a-dp1:
- {bat-adlm-1}: [PASS][3] -> [INCOMPLETE][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11397/bat-adlm-1/igt@kms_flip@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22647/bat-adlm-1/igt@kms_flip@[email protected]

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

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

### IGT changes ###

#### Issues hit ####

* igt@gem_huc_copy@huc-copy:
- fi-pnv-d510: NOTRUN -> [SKIP][5] ([fdo#109271]) +57 similar issues
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22647/fi-pnv-d510/igt@[email protected]

* igt@i915_selftest@live@gt_engines:
- bat-dg1-6: [PASS][6] -> [INCOMPLETE][7] ([i915#4418])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11397/bat-dg1-6/igt@i915_selftest@live@gt_engines.html
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22647/bat-dg1-6/igt@i915_selftest@live@gt_engines.html

* igt@kms_pipe_crc_basic@compare-crc-sanitycheck-pipe-c:
- fi-pnv-d510: NOTRUN -> [SKIP][8] ([fdo#109271] / [i915#5341])
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22647/fi-pnv-d510/igt@[email protected]

* igt@runner@aborted:
- bat-dg1-6: NOTRUN -> [FAIL][9] ([i915#4312] / [i915#5257])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22647/bat-dg1-6/igt@[email protected]
- fi-rkl-guc: NOTRUN -> [FAIL][10] ([i915#4312])
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22647/fi-rkl-guc/igt@[email protected]

#### Possible fixes ####

* igt@gem_exec_suspend@basic-s0@smem:
- fi-glk-dsi: [DMESG-WARN][11] ([i915#2943]) -> [PASS][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11397/fi-glk-dsi/igt@gem_exec_suspend@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22647/fi-glk-dsi/igt@gem_exec_suspend@[email protected]

* igt@kms_busy@basic@flip:
- {bat-adlp-6}: [DMESG-WARN][13] ([i915#3576]) -> [PASS][14]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11397/bat-adlp-6/igt@kms_busy@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22647/bat-adlp-6/igt@kms_busy@[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#2943]: https://gitlab.freedesktop.org/drm/intel/issues/2943
[i915#3303]: https://gitlab.freedesktop.org/drm/intel/issues/3303
[i915#3576]: https://gitlab.freedesktop.org/drm/intel/issues/3576
[i915#4312]: https://gitlab.freedesktop.org/drm/intel/issues/4312
[i915#4391]: https://gitlab.freedesktop.org/drm/intel/issues/4391
[i915#4418]: https://gitlab.freedesktop.org/drm/intel/issues/4418
[i915#4785]: https://gitlab.freedesktop.org/drm/intel/issues/4785
[i915#5257]: https://gitlab.freedesktop.org/drm/intel/issues/5257
[i915#5339]: https://gitlab.freedesktop.org/drm/intel/issues/5339
[i915#5341]: https://gitlab.freedesktop.org/drm/intel/issues/5341
[i915#5342]: https://gitlab.freedesktop.org/drm/intel/issues/5342

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

* Linux: CI_DRM_11397 -> Patchwork_22647

CI-20190529: 20190529
CI_DRM_11397: 056d47eaf6ea753fa2e21da31f9cbd8b721bbb7b @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_6387: 04d012b18355b53798af5a55a8915afb1a421bba @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_22647: 60e5fa34ecb96a07d6c736eb31692ac5681f3bbf @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

60e5fa34ecb9 drm/i915/rps: Centralize computation of freq caps

== Logs ==

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