Skip to contentSkip to conversation

drm/i915/rps: Add frequency translation helpers

PATCH In review Andi Shyti 3 participants 4 messages Dec 4, 2019

Subsystems (2)
lore
Share & tools
lore

Andi Shyti

author
#0 lore raw

PATCH 1/1 drm/i915/rps: Add frequency translation helpers

Add two helpers that for reading the actual GT's frequency. The two helpers are:

- intel_cagf_read: reads the frequency and returns it not normalized

- intel_cagf_freq_read: provides the frequency in Hz.

Use the above helpers in sysfs and debugfs.

---
 drivers/gpu/drm/i915/gt/intel_rps.c | 22 ++++++++++++++++++++++
 drivers/gpu/drm/i915/gt/intel_rps.h |  2 ++
 drivers/gpu/drm/i915/i915_debugfs.c | 21 +++++----------------
 drivers/gpu/drm/i915/i915_sysfs.c   | 14 ++------------
 4 files changed, 31 insertions(+), 28 deletions(-)
drivers/gpu/drm/i915/gt/intel_rps.c +22 -0
index 08a38a3b90b0..72c3dd976e32 100644
@@ -1682,6 +1682,28 @@ u32 intel_get_cagf(struct intel_rps *rps, u32 rpstat)
 	return  cagf;
 }
 
+u32 intel_cagf_read(struct intel_rps *rps)
+{
+	struct drm_i915_private *i915 = rps_to_i915(rps);
+	u32 freq;
+
+	if (IS_VALLEYVIEW(i915) || IS_CHERRYVIEW(i915)) {
+		vlv_punit_get(i915);
+		freq = vlv_punit_read(i915, PUNIT_REG_GPU_FREQ_STS);
+		vlv_punit_put(i915);
+
+		return (freq >> 8) & 0xff;
+	}
+
+	return intel_get_cagf(rps, intel_uncore_read(rps_to_gt(rps)->uncore,
+						     GEN6_RPSTAT1));
+}
+
+u32 intel_cagf_freq_read(struct intel_rps *rps)
+{
+	return intel_gpu_freq(rps, intel_cagf_read(rps));
+}
+
 /* External interface for intel_ips.ko */
 
 static struct drm_i915_private __rcu *ips_mchdev;
drivers/gpu/drm/i915/gt/intel_rps.h +2 -0
index 9518c66c9792..338f8924cd0f 100644
@@ -30,6 +30,8 @@ void intel_rps_mark_interactive(struct intel_rps *rps, bool interactive);
 int intel_gpu_freq(struct intel_rps *rps, int val);
 int intel_freq_opcode(struct intel_rps *rps, int val);
 u32 intel_get_cagf(struct intel_rps *rps, u32 rpstat1);
+u32 intel_cagf_read(struct intel_rps *rps);
+u32 intel_cagf_freq_read(struct intel_rps *rps);
 
 void gen5_rps_irq_handler(struct intel_rps *rps);
 void gen6_rps_irq_handler(struct intel_rps *rps, u32 pm_iir);
drivers/gpu/drm/i915/i915_debugfs.c +5 -16
index eb80a2c4b55b..3f1d0e2e7576 100644
@@ -891,7 +891,7 @@ static int i915_frequency_info(struct seq_file *m, void *unused)
 		rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI) & GEN6_CURIAVG_MASK;
 		rpcurdown = I915_READ(GEN6_RP_CUR_DOWN) & GEN6_CURBSYTAVG_MASK;
 		rpprevdown = I915_READ(GEN6_RP_PREV_DOWN) & GEN6_CURBSYTAVG_MASK;
-		cagf = intel_gpu_freq(rps, intel_get_cagf(rps, rpstat));
+		cagf = intel_cagf_freq_read(rps);
 
 		intel_uncore_forcewake_put(&dev_priv->uncore, FORCEWAKE_ALL);
 
@@ -1633,21 +1633,11 @@ static int i915_rps_boost_info(struct seq_file *m, void *data)
 {
 	struct drm_i915_private *dev_priv = node_to_i915(m->private);
 	struct intel_rps *rps = &dev_priv->gt.rps;
-	u32 act_freq = rps->cur_freq;
+	u32 act_freq;
 	intel_wakeref_t wakeref;
 
-	with_intel_runtime_pm_if_in_use(&dev_priv->runtime_pm, wakeref) {
-		if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
-			vlv_punit_get(dev_priv);
-			act_freq = vlv_punit_read(dev_priv,
-						  PUNIT_REG_GPU_FREQ_STS);
-			vlv_punit_put(dev_priv);
-			act_freq = (act_freq >> 8) & 0xff;
-		} else {
-			act_freq = intel_get_cagf(rps,
-						  I915_READ(GEN6_RPSTAT1));
-		}
-	}
+	with_intel_runtime_pm_if_in_use(&dev_priv->runtime_pm, wakeref)
+		act_freq = intel_cagf_freq_read(rps);
 
 	seq_printf(m, "RPS enabled? %d\n", rps->enabled);
 	seq_printf(m, "GPU busy? %s\n", yesno(dev_priv->gt.awake));
@@ -1655,8 +1645,7 @@ static int i915_rps_boost_info(struct seq_file *m, void *data)
 		   atomic_read(&rps->num_waiters));
 	seq_printf(m, "Interactive? %d\n", READ_ONCE(rps->power.interactive));
 	seq_printf(m, "Frequency requested %d, actual %d\n",
-		   intel_gpu_freq(rps, rps->cur_freq),
-		   intel_gpu_freq(rps, act_freq));
+		   intel_gpu_freq(rps, rps->cur_freq), act_freq);
 	seq_printf(m, "  min hard:%d, soft:%d; max soft:%d, hard:%d\n",
 		   intel_gpu_freq(rps, rps->min_freq),
 		   intel_gpu_freq(rps, rps->min_freq_softlimit),
drivers/gpu/drm/i915/i915_sysfs.c +2 -12
index 65476909d1bf..176cdb139f0b 100644
@@ -265,20 +265,10 @@ static ssize_t gt_act_freq_mhz_show(struct device *kdev,
 	u32 freq;
 
 	wakeref = intel_runtime_pm_get(&dev_priv->runtime_pm);
-
-	if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
-		vlv_punit_get(dev_priv);
-		freq = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS);
-		vlv_punit_put(dev_priv);
-
-		freq = (freq >> 8) & 0xff;
-	} else {
-		freq = intel_get_cagf(rps, I915_READ(GEN6_RPSTAT1));
-	}
-
+	freq = intel_cagf_freq_read(rps);
 	intel_runtime_pm_put(&dev_priv->runtime_pm, wakeref);
 
-	return snprintf(buf, PAGE_SIZE, "%d\n", intel_gpu_freq(rps, freq));
+	return snprintf(buf, PAGE_SIZE, "%d\n", freq);
 }
 
 static ssize_t gt_cur_freq_mhz_show(struct device *kdev,
Signature · 6 lines
2.24.0

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

Quoting Andi Shyti (2019-12-04 10:30:14)

Quoted 103 lines

Add two helpers that for reading the actual GT's frequency. The two helpers are:

- intel_cagf_read: reads the frequency and returns it not normalized

- intel_cagf_freq_read: provides the frequency in Hz.

Use the above helpers in sysfs and debugfs.

---
 drivers/gpu/drm/i915/gt/intel_rps.c | 22 ++++++++++++++++++++++
 drivers/gpu/drm/i915/gt/intel_rps.h |  2 ++
 drivers/gpu/drm/i915/i915_debugfs.c | 21 +++++----------------
 drivers/gpu/drm/i915/i915_sysfs.c   | 14 ++------------
 4 files changed, 31 insertions(+), 28 deletions(-)
drivers/gpu/drm/i915/gt/intel_rps.c +22 -0
index 08a38a3b90b0..72c3dd976e32 100644
@@ -1682,6 +1682,28 @@ u32 intel_get_cagf(struct intel_rps *rps, u32 rpstat)
        return  cagf;
 }
 
+u32 intel_cagf_read(struct intel_rps *rps)
+{
+       struct drm_i915_private *i915 = rps_to_i915(rps);
+       u32 freq;
+
+       if (IS_VALLEYVIEW(i915) || IS_CHERRYVIEW(i915)) {
+               vlv_punit_get(i915);
+               freq = vlv_punit_read(i915, PUNIT_REG_GPU_FREQ_STS);
+               vlv_punit_put(i915);
+
+               return (freq >> 8) & 0xff;
+       }
+
+       return intel_get_cagf(rps, intel_uncore_read(rps_to_gt(rps)->uncore,
+                                                    GEN6_RPSTAT1));
+}
+
+u32 intel_cagf_freq_read(struct intel_rps *rps)
+{
+       return intel_gpu_freq(rps, intel_cagf_read(rps));
+}
+
 /* External interface for intel_ips.ko */
 
 static struct drm_i915_private __rcu *ips_mchdev;
drivers/gpu/drm/i915/gt/intel_rps.h +2 -0
index 9518c66c9792..338f8924cd0f 100644
@@ -30,6 +30,8 @@ void intel_rps_mark_interactive(struct intel_rps *rps, bool interactive);
 int intel_gpu_freq(struct intel_rps *rps, int val);
 int intel_freq_opcode(struct intel_rps *rps, int val);
 u32 intel_get_cagf(struct intel_rps *rps, u32 rpstat1);
+u32 intel_cagf_read(struct intel_rps *rps);
+u32 intel_cagf_freq_read(struct intel_rps *rps);
 
 void gen5_rps_irq_handler(struct intel_rps *rps);
 void gen6_rps_irq_handler(struct intel_rps *rps, u32 pm_iir);
drivers/gpu/drm/i915/i915_debugfs.c +4 -14
index eb80a2c4b55b..3f1d0e2e7576 100644
@@ -891,7 +891,7 @@ static int i915_frequency_info(struct seq_file *m, void *unused)
                rpdownei = I915_READ(GEN6_RP_CUR_DOWN_EI) & GEN6_CURIAVG_MASK;
                rpcurdown = I915_READ(GEN6_RP_CUR_DOWN) & GEN6_CURBSYTAVG_MASK;
                rpprevdown = I915_READ(GEN6_RP_PREV_DOWN) & GEN6_CURBSYTAVG_MASK;
-               cagf = intel_gpu_freq(rps, intel_get_cagf(rps, rpstat));
+               cagf = intel_cagf_freq_read(rps);
 
                intel_uncore_forcewake_put(&dev_priv->uncore, FORCEWAKE_ALL);
 
@@ -1633,21 +1633,11 @@ static int i915_rps_boost_info(struct seq_file *m, void *data)
 {
        struct drm_i915_private *dev_priv = node_to_i915(m->private);
        struct intel_rps *rps = &dev_priv->gt.rps;
-       u32 act_freq = rps->cur_freq;
+       u32 act_freq;
        intel_wakeref_t wakeref;
 
-       with_intel_runtime_pm_if_in_use(&dev_priv->runtime_pm, wakeref) {
-               if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
-                       vlv_punit_get(dev_priv);
-                       act_freq = vlv_punit_read(dev_priv,
-                                                 PUNIT_REG_GPU_FREQ_STS);
-                       vlv_punit_put(dev_priv);
-                       act_freq = (act_freq >> 8) & 0xff;
-               } else {
-                       act_freq = intel_get_cagf(rps,
-                                                 I915_READ(GEN6_RPSTAT1));
-               }
-       }
+       with_intel_runtime_pm_if_in_use(&dev_priv->runtime_pm, wakeref)
+               act_freq = intel_cagf_freq_read(rps);
 
        seq_printf(m, "RPS enabled? %d\n", rps->enabled);
        seq_printf(m, "GPU busy? %s\n", yesno(dev_priv->gt.awake));

drivers/gpu/drm/i915/i915_debugfs.c static int i915_rps_boost_info(struct seq_file *m, void *data) · line 1651

Quoted 9 lines
drivers/gpu/drm/i915/i915_debugfs.c +1 -2
@@ -1655,8 +1645,7 @@ static int i915_rps_boost_info(struct seq_file *m, void *data)
                   atomic_read(&rps->num_waiters));
        seq_printf(m, "Interactive? %d\n", READ_ONCE(rps->power.interactive));
        seq_printf(m, "Frequency requested %d, actual %d\n",
-                  intel_gpu_freq(rps, rps->cur_freq),
-                  intel_gpu_freq(rps, act_freq));
+                  intel_gpu_freq(rps, rps->cur_freq), act_freq);
        seq_printf(m, "  min hard:%d, soft:%d; max soft:%d, hard:%d\n",
                   intel_gpu_freq(rps, rps->min_freq),
                   intel_gpu_freq(rps, rps->min_freq_softlimit),

Good start, but this needs to be rps-centric, please could you pull it under intel_rps.c as intel_rps_show (or _dump, or _print), taking a struct drm_printer to direct the output.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

author
#2 lore raw

Hi Chris,

Quoted 23 lines
Quoted 23 lines
drivers/gpu/drm/i915/i915_debugfs.c +3 -13
@@ -1633,21 +1633,11 @@ static int i915_rps_boost_info(struct seq_file *m, void *data)
 {
        struct drm_i915_private *dev_priv = node_to_i915(m->private);
        struct intel_rps *rps = &dev_priv->gt.rps;
-       u32 act_freq = rps->cur_freq;
+       u32 act_freq;
        intel_wakeref_t wakeref;
 
-       with_intel_runtime_pm_if_in_use(&dev_priv->runtime_pm, wakeref) {
-               if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
-                       vlv_punit_get(dev_priv);
-                       act_freq = vlv_punit_read(dev_priv,
-                                                 PUNIT_REG_GPU_FREQ_STS);
-                       vlv_punit_put(dev_priv);
-                       act_freq = (act_freq >> 8) & 0xff;
-               } else {
-                       act_freq = intel_get_cagf(rps,
-                                                 I915_READ(GEN6_RPSTAT1));
-               }
-       }
+       with_intel_runtime_pm_if_in_use(&dev_priv->runtime_pm, wakeref)
+               act_freq = intel_cagf_freq_read(rps);
 
Quoted 16 lines

drivers/gpu/drm/i915/i915_debugfs.c static int i915_rps_boost_info(struct seq_file *m, void *data) · line 1651

Quoted 12 lines
drivers/gpu/drm/i915/i915_debugfs.c +1 -2
        seq_printf(m, "RPS enabled? %d\n", rps->enabled);
        seq_printf(m, "GPU busy? %s\n", yesno(dev_priv->gt.awake));
@@ -1655,8 +1645,7 @@ static int i915_rps_boost_info(struct seq_file *m, void *data)
                   atomic_read(&rps->num_waiters));
        seq_printf(m, "Interactive? %d\n", READ_ONCE(rps->power.interactive));
        seq_printf(m, "Frequency requested %d, actual %d\n",
-                  intel_gpu_freq(rps, rps->cur_freq),
-                  intel_gpu_freq(rps, act_freq));
+                  intel_gpu_freq(rps, rps->cur_freq), act_freq);
        seq_printf(m, "  min hard:%d, soft:%d; max soft:%d, hard:%d\n",
                   intel_gpu_freq(rps, rps->min_freq),
                   intel_gpu_freq(rps, rps->min_freq_softlimit),

Good start, but this needs to be rps-centric, please could you pull it under intel_rps.c as intel_rps_show (or _dump, or _print), taking a struct drm_printer to direct the output.

yes, of course! There are still few rps leftovers around :)

Thanks,
Andi
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw

[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915/rps: Add frequency translation helpers

In reply to Andi Shyti
== Series Details ==

== Series Details ==

Series: drm/i915/rps: Add frequency translation helpers
URL : https://patchwork.freedesktop.org/series/70427/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_7480 -> Patchwork_15578
====================================================

Summary
-------

**FAILURE**

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

If you think the reported changes have nothing to do with the changes introduced in Patchwork_15578, 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_15578/index.html

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

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

### IGT changes ###

#### Possible regressions ####

* igt@i915_selftest@live_blt:
- fi-hsw-4770: [PASS][1] -> [DMESG-FAIL][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7480/fi-hsw-4770/igt@i915_selftest@live_blt.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15578/fi-hsw-4770/igt@i915_selftest@live_blt.html

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

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

### IGT changes ###

#### Possible fixes ####

* igt@gem_exec_parallel@basic:
- {fi-tgl-u}: [INCOMPLETE][3] ([i915#476]) -> [PASS][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7480/fi-tgl-u/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15578/fi-tgl-u/igt@[email protected]

* igt@i915_pm_rpm@module-reload:
- fi-skl-6770hq: [DMESG-WARN][5] ([i915#592]) -> [PASS][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7480/fi-skl-6770hq/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15578/fi-skl-6770hq/igt@[email protected]

* igt@i915_selftest@live_gem_contexts:
- fi-skl-lmem: [INCOMPLETE][7] ([i915#424]) -> [PASS][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7480/fi-skl-lmem/igt@i915_selftest@live_gem_contexts.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15578/fi-skl-lmem/igt@i915_selftest@live_gem_contexts.html

* igt@kms_chamelium@common-hpd-after-suspend:
- fi-icl-u2: [DMESG-WARN][9] ([IGT#4] / [i915#263]) -> [PASS][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7480/fi-icl-u2/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15578/fi-icl-u2/igt@[email protected]

* igt@kms_chamelium@hdmi-hpd-fast:
- fi-kbl-7500u: [FAIL][11] ([fdo#111096] / [i915#323]) -> [PASS][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7480/fi-kbl-7500u/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15578/fi-kbl-7500u/igt@[email protected]

#### Warnings ####

* igt@i915_pm_rpm@basic-pci-d3-state:
- fi-kbl-guc: [SKIP][13] ([fdo#109271]) -> [FAIL][14] ([i915#138])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7480/fi-kbl-guc/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15578/fi-kbl-guc/igt@[email protected]

* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy:
- fi-kbl-x1275: [DMESG-WARN][15] ([i915#62] / [i915#92] / [i915#95]) -> [DMESG-WARN][16] ([i915#62] / [i915#92]) +3 similar issues
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7480/fi-kbl-x1275/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15578/fi-kbl-x1275/igt@[email protected]

* igt@kms_flip@basic-flip-vs-modeset:
- fi-kbl-x1275: [DMESG-WARN][17] ([i915#62] / [i915#92]) -> [DMESG-WARN][18] ([i915#62] / [i915#92] / [i915#95]) +5 similar issues
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7480/fi-kbl-x1275/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15578/fi-kbl-x1275/igt@[email protected]

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

[IGT#4]: https://gitlab.freedesktop.org/drm/igt-gpu-tools/issues/4
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#111096]: https://bugs.freedesktop.org/show_bug.cgi?id=111096
[i915#138]: https://gitlab.freedesktop.org/drm/intel/issues/138
[i915#263]: https://gitlab.freedesktop.org/drm/intel/issues/263
[i915#323]: https://gitlab.freedesktop.org/drm/intel/issues/323
[i915#424]: https://gitlab.freedesktop.org/drm/intel/issues/424
[i915#476]: https://gitlab.freedesktop.org/drm/intel/issues/476
[i915#592]: https://gitlab.freedesktop.org/drm/intel/issues/592
[i915#62]: https://gitlab.freedesktop.org/drm/intel/issues/62
[i915#92]: https://gitlab.freedesktop.org/drm/intel/issues/92
[i915#95]: https://gitlab.freedesktop.org/drm/intel/issues/95

Participating hosts (50 -> 47)
------------------------------

Additional (2): fi-hsw-4770r fi-tgl-guc
Missing (5): fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-byt-clapper fi-bdw-samus

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

* CI: CI-20190529 -> None
* Linux: CI_DRM_7480 -> Patchwork_15578

CI-20190529: 20190529
CI_DRM_7480: acd4664d865fde46dcd32c48ccac1b048b355bea @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5323: b0f877d06a78b9c38ed246be2537a0453b6c214f @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_15578: bc93ed258be49203e2debbe73e915f7b9e276c38 @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

bc93ed258be4 drm/i915/rps: Add frequency translation helpers

== Logs ==

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