Skip to contentSkip to conversation

drm/i915/gt: Add sysfs RAPL PL1 interface

PATCH In review Sujaritha Sundaresan 4 participants 6 messages Jan 31, 2023

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

PATCH v2 1/1 drm/i915/gt: Add sysfs RAPL PL1 interface

Adding sysfs attribute rapl_pl1_freq_mhz. This shows the RAPL PL1 FREQUENCY LIMIT.

---
 drivers/gpu/drm/i915/gt/intel_gt_regs.h     |  4 ++++
 drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c | 15 +++++++++++++++
 drivers/gpu/drm/i915/gt/intel_rps.c         | 18 ++++++++++++++++++
 drivers/gpu/drm/i915/gt/intel_rps.h         |  1 +
 4 files changed, 38 insertions(+)
drivers/gpu/drm/i915/gt/intel_gt_regs.h +4 -0
index 7fa18a3b3957..1c78fc89a37a 100644
@@ -1656,6 +1656,10 @@
 #define GT0_PACKAGE_POWER_SKU_UNIT		_MMIO(0x250068)
 #define GT0_PLATFORM_ENERGY_STATUS		_MMIO(0x25006c)
 
+#define XEHPSDV_RAPL_PL1_FREQ_LIMIT		_MMIO(0x250070)
+#define MTL_RAPL_PL1_FREQ_LIMIT		_MMIO(0x281070)
+#define   RAPL_PL1_FREQ_LIMIT_MASK		REG_GENMASK(15, 0)
+
 /*
  * Standalone Media's non-engine GT registers are located at their regular GT
  * offsets plus 0x380000.  This extra offset is stored inside the intel_uncore
drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c +15 -0
index 28f27091cd3b..0b52962e2856 100644
@@ -451,6 +451,16 @@ static ssize_t punit_req_freq_mhz_show(struct kobject *kobj,
 	return sysfs_emit(buff, "%u\n", preq);
 }
 
+static ssize_t rapl_pl1_freq_mhz_show(struct kobject *kobj,
+				      struct kobj_attribute *attr,
+				      char *buff)
+{
+	struct intel_gt *gt = intel_gt_sysfs_get_drvdata(kobj, attr->attr.name);
+	u32 rapl_pl1 = intel_rps_read_rapl_pl1(&gt->rps);
+
+	return sysfs_emit(buff, "%u\n", rapl_pl1);
+}
+
 struct intel_gt_bool_throttle_attr {
 	struct attribute attr;
 	ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr,
@@ -480,6 +490,7 @@ struct intel_gt_bool_throttle_attr attr_##sysfs_func__ = { \
 }
 
 INTEL_GT_ATTR_RO(punit_req_freq_mhz);
+INTEL_GT_ATTR_RO(rapl_pl1_freq_mhz);
 static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_status, GT0_PERF_LIMIT_REASONS_MASK);
 static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_pl1, POWER_LIMIT_1_MASK);
 static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_pl2, POWER_LIMIT_2_MASK);
@@ -744,6 +755,10 @@ void intel_gt_sysfs_pm_init(struct intel_gt *gt, struct kobject *kobj)
 	if (ret)
 		gt_warn(gt, "failed to create punit_req_freq_mhz sysfs (%pe)", ERR_PTR(ret));
 
+	ret = sysfs_create_file(kobj, &attr_rapl_pl1_freq_mhz.attr);
+	if (ret)
+		gt_warn(gt, "failed to create rapl_pl1_freq_mhz sysfs (%pe)", ERR_PTR(ret));
+
 	if (i915_mmio_reg_valid(intel_gt_perf_limit_reasons_reg(gt))) {
 		ret = sysfs_create_files(kobj, throttle_reason_attrs);
 		if (ret)
drivers/gpu/drm/i915/gt/intel_rps.c +18 -0
index f5d7b5126433..f66d6f47f2cf 100644
@@ -2202,6 +2202,24 @@ u32 intel_rps_get_max_frequency(struct intel_rps *rps)
 		return intel_gpu_freq(rps, rps->max_freq_softlimit);
 }
 
+u32 intel_rps_read_rapl_pl1(struct intel_rps *rps)
+{
+	struct drm_i915_private *i915 = rps_to_i915(rps);
+	u32 rapl_pl1;
+	u32 rapl;
+
+	if (IS_METEORLAKE(i915))
+		rapl_pl1 = intel_uncore_read(rps_to_gt(rps)->uncore, MTL_RAPL_PL1_FREQ_LIMIT);
+	else if (IS_XEHPSDV(i915))
+		rapl_pl1  = intel_uncore_read(rps_to_gt(rps)->uncore, XEHPSDV_RAPL_PL1_FREQ_LIMIT);
+
+
+	if (IS_METEORLAKE(i915) || IS_XEHPSDV(i915))
+		rapl = REG_FIELD_GET(RAPL_PL1_FREQ_LIMIT_MASK, rapl_pl1);
+
+	return rapl;
+}
+
 /**
  * intel_rps_get_max_raw_freq - returns the max frequency in some raw format.
  * @rps: the intel_rps structure
drivers/gpu/drm/i915/gt/intel_rps.h +1 -0
index c622962c6bef..c37d297c9d82 100644
@@ -51,6 +51,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_rapl_pl1(struct intel_rps *rps);
 u32 intel_rps_read_rpstat(struct intel_rps *rps);
 u32 intel_rps_read_rpstat_fw(struct intel_rps *rps);
 void gen6_rps_get_freq_caps(struct intel_rps *rps, struct intel_rps_freq_caps *caps);
Signature · 1 line
2.34.1
#1 lore raw

[Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915/gt: Add sysfs RAPL PL1 interface (rev2)

== Series Details ==

== Series Details ==

Series: drm/i915/gt: Add sysfs RAPL PL1 interface (rev2)
URL : https://patchwork.freedesktop.org/series/110476/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_12670 -> Patchwork_110476v2
====================================================

Summary
-------

**SUCCESS**

No regressions found.

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

Participating hosts (25 -> 24)
------------------------------

Missing (1): fi-snb-2520m

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

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

### IGT changes ###

#### Possible fixes ####

* igt@i915_selftest@live@gt_heartbeat:
- fi-apl-guc: [DMESG-FAIL][1] ([i915#5334]) -> [PASS][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12670/fi-apl-guc/igt@i915_selftest@live@gt_heartbeat.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110476v2/fi-apl-guc/igt@i915_selftest@live@gt_heartbeat.html

* igt@i915_selftest@live@guc:
- {bat-rpls-2}: [DMESG-WARN][3] ([i915#7852]) -> [PASS][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12670/bat-rpls-2/igt@i915_selftest@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110476v2/bat-rpls-2/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).

[i915#3546]: https://gitlab.freedesktop.org/drm/intel/issues/3546
[i915#4983]: https://gitlab.freedesktop.org/drm/intel/issues/4983
[i915#5334]: https://gitlab.freedesktop.org/drm/intel/issues/5334
[i915#7852]: https://gitlab.freedesktop.org/drm/intel/issues/7852

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

* Linux: CI_DRM_12670 -> Patchwork_110476v2

CI-20190529: 20190529
CI_DRM_12670: d98d1a109aa7df08b5398b29e2e90ba50b3f680a @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7143: c7b12dcc460fc2348e1fa7f4dcb791bb82e29e44 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_110476v2: d98d1a109aa7df08b5398b29e2e90ba50b3f680a @ git://anongit.freedesktop.org/gfx-ci/linux

### Linux commits

f08812595c7d drm/i915/gt: Add sysfs RAPL PL1 interface

== Logs ==

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

#2 lore raw
In reply to Sujaritha Sundaresan
Thank you for the patch! Perhaps something to improve:

Hi Sujaritha,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm-tip/drm-tip]

url:    https://github.com/intel-lab-lkp/linux/commits/Sujaritha-Sundaresan/drm-i915-gt-Add-sysfs-RAPL-PL1-interface/20230131-152446
base:   git://anongit.freedesktop.org/drm/drm-tip drm-tip
patch link:    https://lore.kernel.org/r/20230131062550.11901-1-sujaritha.sundaresan%40intel.com
patch subject: [Intel-gfx] [PATCH v2] drm/i915/gt: Add sysfs RAPL PL1 interface
config: x86_64-rhel-8.3-rust (https://download.01.org/0day-ci/archive/20230131/[email protected]/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/562c57549ee00ea298f9023380d44526d6d68921
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Sujaritha-Sundaresan/drm-i915-gt-Add-sysfs-RAPL-PL1-interface/20230131-152446 git checkout 562c57549ee00ea298f9023380d44526d6d68921
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/i915/gt/intel_rps.c:2217:6: warning: variable 'rapl' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
           if (IS_METEORLAKE(i915) || IS_XEHPSDV(i915))
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/i915/i915_drv.h:565:33: note: expanded from macro 'IS_METEORLAKE'
   #define IS_METEORLAKE(dev_priv) IS_PLATFORM(dev_priv, INTEL_METEORLAKE)
                                   ^
   drivers/gpu/drm/i915/gt/intel_rps.c:2220:9: note: uninitialized use occurs here
           return rapl;
                  ^~~~
   drivers/gpu/drm/i915/gt/intel_rps.c:2217:2: note: remove the 'if' if its condition is always true
           if (IS_METEORLAKE(i915) || IS_XEHPSDV(i915))
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/i915/gt/intel_rps.c:2209:10: note: initialize the variable 'rapl' to silence this warning
           u32 rapl;
                   ^
                    = 0

1 warning generated.

vim +2217 drivers/gpu/drm/i915/gt/intel_rps.c

2204
2205 u32 intel_rps_read_rapl_pl1(struct intel_rps *rps)
2206 {
2207 struct drm_i915_private *i915 = rps_to_i915(rps);
2208 u32 rapl_pl1;
2209 u32 rapl;
2210
2211 if (IS_METEORLAKE(i915))
2212 rapl_pl1 = intel_uncore_read(rps_to_gt(rps)->uncore, MTL_RAPL_PL1_FREQ_LIMIT);
2213 else if (IS_XEHPSDV(i915))
2214 rapl_pl1 = intel_uncore_read(rps_to_gt(rps)->uncore, XEHPSDV_RAPL_PL1_FREQ_LIMIT);
2215
2216

> 2217		if (IS_METEORLAKE(i915) || IS_XEHPSDV(i915))

2218 rapl = REG_FIELD_GET(RAPL_PL1_FREQ_LIMIT_MASK, rapl_pl1);
2219
2220 return rapl;
2221 }
2222

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
#3 lore raw

[Intel-gfx] ✓ Fi.CI.IGT: success for drm/i915/gt: Add sysfs RAPL PL1 interface (rev2)

In reply to Sujaritha Sundaresan
== Series Details ==

== Series Details ==

Series: drm/i915/gt: Add sysfs RAPL PL1 interface (rev2)
URL : https://patchwork.freedesktop.org/series/110476/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_12670_full -> Patchwork_110476v2_full
====================================================

Summary
-------

**SUCCESS**

No regressions found.

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

Participating hosts (10 -> 11)
------------------------------

Additional (1): shard-rkl0

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

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

### IGT changes ###

#### Issues hit ####

* igt@perf@oa-exponents:
- shard-glk: [PASS][1] -> [ABORT][2] ([i915#5213])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12670/shard-glk3/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110476v2/shard-glk7/igt@[email protected]

#### Possible fixes ####

* igt@api_intel_bb@object-reloc-keep-cache:
- {shard-rkl}: [SKIP][3] ([i915#3281]) -> [PASS][4] +2 similar issues
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12670/shard-rkl-6/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110476v2/shard-rkl-5/igt@[email protected]

* igt@fbdev@info:
- {shard-rkl}: [SKIP][5] ([i915#2582]) -> [PASS][6] +1 similar issue
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12670/shard-rkl-2/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110476v2/shard-rkl-6/igt@[email protected]

* igt@gem_ctx_exec@basic-nohangcheck:
- {shard-rkl}: [FAIL][7] ([i915#6268]) -> [PASS][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12670/shard-rkl-6/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110476v2/shard-rkl-5/igt@[email protected]

* igt@gem_ctx_persistence@engines-hang@bcs0:
- {shard-rkl}: [SKIP][9] ([i915#6252]) -> [PASS][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12670/shard-rkl-5/igt@gem_ctx_persistence@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110476v2/shard-rkl-1/igt@gem_ctx_persistence@[email protected]

* igt@gem_exec_fair@basic-pace-share@rcs0:
- {shard-rkl}: [FAIL][11] ([i915#2842]) -> [PASS][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12670/shard-rkl-6/igt@gem_exec_fair@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110476v2/shard-rkl-3/igt@gem_exec_fair@[email protected]

* igt@gem_userptr_blits@forbidden-operations:
- {shard-rkl}: [SKIP][13] ([i915#3282]) -> [PASS][14] +3 similar issues
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12670/shard-rkl-6/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110476v2/shard-rkl-5/igt@[email protected]

* igt@gen9_exec_parse@basic-rejected-ctx-param:
- {shard-rkl}: [SKIP][15] ([i915#2527]) -> [PASS][16]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12670/shard-rkl-6/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110476v2/shard-rkl-5/igt@[email protected]

* igt@kms_big_fb@y-tiled-addfb-size-offset-overflow:
- {shard-rkl}: [SKIP][17] ([i915#1845] / [i915#4098]) -> [PASS][18] +17 similar issues
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12670/shard-rkl-2/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110476v2/shard-rkl-6/igt@[email protected]

* igt@kms_fbcon_fbt@psr-suspend:
- {shard-rkl}: [SKIP][19] ([i915#3955]) -> [PASS][20]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12670/shard-rkl-4/igt@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110476v2/shard-rkl-6/igt@[email protected]

* igt@kms_flip@2x-plain-flip-fb-recreate@ac-hdmi-a1-hdmi-a2:
- shard-glk: [FAIL][21] ([i915#2122]) -> [PASS][22]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12670/shard-glk4/igt@kms_flip@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110476v2/shard-glk4/igt@kms_flip@[email protected]

* igt@kms_flip@flip-vs-expired-vblank@c-hdmi-a2:
- shard-glk: [FAIL][23] ([i915#79]) -> [PASS][24]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12670/shard-glk3/igt@kms_flip@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110476v2/shard-glk3/igt@kms_flip@[email protected]

* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-mmap-gtt:
- {shard-rkl}: [SKIP][25] ([i915#1849] / [i915#4098]) -> [PASS][26] +14 similar issues
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12670/shard-rkl-1/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-mmap-gtt.html
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110476v2/shard-rkl-6/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-mmap-gtt.html

* igt@kms_psr@sprite_mmap_gtt:
- {shard-rkl}: [SKIP][27] ([i915#1072]) -> [PASS][28] +1 similar issue
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12670/shard-rkl-2/igt@kms_psr@sprite_mmap_gtt.html
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110476v2/shard-rkl-6/igt@kms_psr@sprite_mmap_gtt.html

* igt@kms_psr_stress_test@flip-primary-invalidate-overlay:
- {shard-rkl}: [SKIP][29] ([i915#5461]) -> [PASS][30] +1 similar issue
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12670/shard-rkl-2/igt@[email protected]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110476v2/shard-rkl-6/igt@[email protected]

* igt@kms_universal_plane@disable-primary-vs-flip-pipe-b:
- {shard-rkl}: [SKIP][31] ([i915#1845] / [i915#4070] / [i915#4098]) -> [PASS][32]
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12670/shard-rkl-2/igt@[email protected]
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110476v2/shard-rkl-6/igt@[email protected]

* igt@testdisplay:
- {shard-rkl}: [SKIP][33] ([i915#4098]) -> [PASS][34] +1 similar issue
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12670/shard-rkl-4/[email protected]
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_110476v2/shard-rkl-6/[email protected]

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

[fdo#109274]: https://bugs.freedesktop.org/show_bug.cgi?id=109274
[fdo#109279]: https://bugs.freedesktop.org/show_bug.cgi?id=109279
[fdo#109280]: https://bugs.freedesktop.org/show_bug.cgi?id=109280
[fdo#109283]: https://bugs.freedesktop.org/show_bug.cgi?id=109283
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[fdo#109289]: https://bugs.freedesktop.org/show_bug.cgi?id=109289
[fdo#109295]: https://bugs.freedesktop.org/show_bug.cgi?id=109295
[fdo#109302]: https://bugs.freedesktop.org/show_bug.cgi?id=109302
[fdo#109307]: https://bugs.freedesktop.org/show_bug.cgi?id=109307
[fdo#109309]: https://bugs.freedesktop.org/show_bug.cgi?id=109309
[fdo#109315]: https://bugs.freedesktop.org/show_bug.cgi?id=109315
[fdo#109506]: https://bugs.freedesktop.org/show_bug.cgi?id=109506
[fdo#109642]: https://bugs.freedesktop.org/show_bug.cgi?id=109642
[fdo#110189]: https://bugs.freedesktop.org/show_bug.cgi?id=110189
[fdo#110723]: https://bugs.freedesktop.org/show_bug.cgi?id=110723
[fdo#111068]: https://bugs.freedesktop.org/show_bug.cgi?id=111068
[fdo#111614]: https://bugs.freedesktop.org/show_bug.cgi?id=111614
[fdo#111615]: https://bugs.freedesktop.org/show_bug.cgi?id=111615
[fdo#111644]: https://bugs.freedesktop.org/show_bug.cgi?id=111644
[fdo#111656]: https://bugs.freedesktop.org/show_bug.cgi?id=111656
[fdo#111825]: https://bugs.freedesktop.org/show_bug.cgi?id=111825
[fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
[fdo#112054]: https://bugs.freedesktop.org/show_bug.cgi?id=112054
[i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
[i915#132]: https://gitlab.freedesktop.org/drm/intel/issues/132
[i915#1397]: https://gitlab.freedesktop.org/drm/intel/issues/1397
[i915#1825]: https://gitlab.freedesktop.org/drm/intel/issues/1825
[i915#1839]: https://gitlab.freedesktop.org/drm/intel/issues/1839
[i915#1845]: https://gitlab.freedesktop.org/drm/intel/issues/1845
[i915#1849]: https://gitlab.freedesktop.org/drm/intel/issues/1849
[i915#1937]: https://gitlab.freedesktop.org/drm/intel/issues/1937
[i915#2122]: https://gitlab.freedesktop.org/drm/intel/issues/2122
[i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
[i915#2437]: https://gitlab.freedesktop.org/drm/intel/issues/2437
[i915#2527]: https://gitlab.freedesktop.org/drm/intel/issues/2527
[i915#2575]: https://gitlab.freedesktop.org/drm/intel/issues/2575
[i915#2582]: https://gitlab.freedesktop.org/drm/intel/issues/2582
[i915#2587]: https://gitlab.freedesktop.org/drm/intel/issues/2587
[i915#2658]: https://gitlab.freedesktop.org/drm/intel/issues/2658
[i915#2672]: https://gitlab.freedesktop.org/drm/intel/issues/2672
[i915#2681]: https://gitlab.freedesktop.org/drm/intel/issues/2681
[i915#2705]: https://gitlab.freedesktop.org/drm/intel/issues/2705
[i915#280]: https://gitlab.freedesktop.org/drm/intel/issues/280
[i915#2842]: https://gitlab.freedesktop.org/drm/intel/issues/2842
[i915#2856]: https://gitlab.freedesktop.org/drm/intel/issues/2856
[i915#2920]: https://gitlab.freedesktop.org/drm/intel/issues/2920
[i915#3116]: https://gitlab.freedesktop.org/drm/intel/issues/3116
[i915#315]: https://gitlab.freedesktop.org/drm/intel/issues/315
[i915#3281]: https://gitlab.freedesktop.org/drm/intel/issues/3281
[i915#3282]: https://gitlab.freedesktop.org/drm/intel/issues/3282
[i915#3297]: https://gitlab.freedesktop.org/drm/intel/issues/3297
[i915#3359]: https://gitlab.freedesktop.org/drm/intel/issues/3359
[i915#3458]: https://gitlab.freedesktop.org/drm/intel/issues/3458
[i915#3469]: https://gitlab.freedesktop.org/drm/intel/issues/3469
[i915#3528]: https://gitlab.freedesktop.org/drm/intel/issues/3528
[i915#3539]: https://gitlab.freedesktop.org/drm/intel/issues/3539
[i915#3546]: https://gitlab.freedesktop.org/drm/intel/issues/3546
[i915#3547]: https://gitlab.freedesktop.org/drm/intel/issues/3547
[i915#3555]: https://gitlab.freedesktop.org/drm/intel/issues/3555
[i915#3558]: https://gitlab.freedesktop.org/drm/intel/issues/3558
[i915#3637]: https://gitlab.freedesktop.org/drm/intel/issues/3637
[i915#3638]: https://gitlab.freedesktop.org/drm/intel/issues/3638
[i915#3689]: https://gitlab.freedesktop.org/drm/intel/issues/3689
[i915#3708]: https://gitlab.freedesktop.org/drm/intel/issues/3708
[i915#3734]: https://gitlab.freedesktop.org/drm/intel/issues/3734
[i915#3825]: https://gitlab.freedesktop.org/drm/intel/issues/3825
[i915#3886]: https://gitlab.freedesktop.org/drm/intel/issues/3886
[i915#3955]: https://gitlab.freedesktop.org/drm/intel/issues/3955
[i915#3966]: https://gitlab.freedesktop.org/drm/intel/issues/3966
[i915#4070]: https://gitlab.freedesktop.org/drm/intel/issues/4070
[i915#4077]: https://gitlab.freedesktop.org/drm/intel/issues/4077
[i915#4078]: https://gitlab.freedesktop.org/drm/intel/issues/4078
[i915#4079]: https://gitlab.freedesktop.org/drm/intel/issues/4079
[i915#4083]: https://gitlab.freedesktop.org/drm/intel/issues/4083
[i915#4098]: https://gitlab.freedesktop.org/drm/intel/issues/4098
[i915#4212]: https://gitlab.freedesktop.org/drm/intel/issues/4212
[i915#4215]: https://gitlab.freedesktop.org/drm/intel/issues/4215
[i915#426]: https://gitlab.freedesktop.org/drm/intel/issues/426
[i915#4270]: https://gitlab.freedesktop.org/drm/intel/issues/4270
[i915#433]: https://gitlab.freedesktop.org/drm/intel/issues/433
[i915#4538]: https://gitlab.freedesktop.org/drm/intel/issues/4538
[i915#4565]: https://gitlab.freedesktop.org/drm/intel/issues/4565
[i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
[i915#4767]: https://gitlab.freedesktop.org/drm/intel/issues/4767
[i915#4771]: https://gitlab.freedesktop.org/drm/intel/issues/4771
[i915#4812]: https://gitlab.freedesktop.org/drm/intel/issues/4812
[i915#4833]: https://gitlab.freedesktop.org/drm/intel/issues/4833
[i915#4852]: https://gitlab.freedesktop.org/drm/intel/issues/4852
[i915#4859]: https://gitlab.freedesktop.org/drm/intel/issues/4859
[i915#4879]: https://gitlab.freedesktop.org/drm/intel/issues/4879
[i915#4881]: https://gitlab.freedesktop.org/drm/intel/issues/4881
[i915#5176]: https://gitlab.freedesktop.org/drm/intel/issues/5176
[i915#5213]: https://gitlab.freedesktop.org/drm/intel/issues/5213
[i915#5235]: https://gitlab.freedesktop.org/drm/intel/issues/5235
[i915#5286]: https://gitlab.freedesktop.org/drm/intel/issues/5286
[i915#5288]: https://gitlab.freedesktop.org/drm/intel/issues/5288
[i915#5289]: https://gitlab.freedesktop.org/drm/intel/issues/5289
[i915#5325]: https://gitlab.freedesktop.org/drm/intel/issues/5325
[i915#533]: https://gitlab.freedesktop.org/drm/intel/issues/533
[i915#5439]: https://gitlab.freedesktop.org/drm/intel/issues/5439
[i915#5461]: https://gitlab.freedesktop.org/drm/intel/issues/5461
[i915#5563]: https://gitlab.freedesktop.org/drm/intel/issues/5563
[i915#5784]: https://gitlab.freedesktop.org/drm/intel/issues/5784
[i915#6095]: https://gitlab.freedesktop.org/drm/intel/issues/6095
[i915#6117]: https://gitlab.freedesktop.org/drm/intel/issues/6117
[i915#6252]: https://gitlab.freedesktop.org/drm/intel/issues/6252
[i915#6268]: https://gitlab.freedesktop.org/drm/intel/issues/6268
[i915#6334]: https://gitlab.freedesktop.org/drm/intel/issues/6334
[i915#6344]: https://gitlab.freedesktop.org/drm/intel/issues/6344
[i915#6433]: https://gitlab.freedesktop.org/drm/intel/issues/6433
[i915#6497]: https://gitlab.freedesktop.org/drm/intel/issues/6497
[i915#6524]: https://gitlab.freedesktop.org/drm/intel/issues/6524
[i915#658]: https://gitlab.freedesktop.org/drm/intel/issues/658
[i915#6621]: https://gitlab.freedesktop.org/drm/intel/issues/6621
[i915#6768]: https://gitlab.freedesktop.org/drm/intel/issues/6768
[i915#6944]: https://gitlab.freedesktop.org/drm/intel/issues/6944
[i915#6946]: https://gitlab.freedesktop.org/drm/intel/issues/6946
[i915#6953]: https://gitlab.freedesktop.org/drm/intel/issues/6953
[i915#7037]: https://gitlab.freedesktop.org/drm/intel/issues/7037
[i915#7116]: https://gitlab.freedesktop.org/drm/intel/issues/7116
[i915#7118]: https://gitlab.freedesktop.org/drm/intel/issues/7118
[i915#7561]: https://gitlab.freedesktop.org/drm/intel/issues/7561
[i915#7651]: https://gitlab.freedesktop.org/drm/intel/issues/7651
[i915#7697]: https://gitlab.freedesktop.org/drm/intel/issues/7697
[i915#7701]: https://gitlab.freedesktop.org/drm/intel/issues/7701
[i915#7711]: https://gitlab.freedesktop.org/drm/intel/issues/7711
[i915#7742]: https://gitlab.freedesktop.org/drm/intel/issues/7742
[i915#7828]: https://gitlab.freedesktop.org/drm/intel/issues/7828
[i915#79]: https://gitlab.freedesktop.org/drm/intel/issues/79

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

* Linux: CI_DRM_12670 -> Patchwork_110476v2

CI-20190529: 20190529
CI_DRM_12670: d98d1a109aa7df08b5398b29e2e90ba50b3f680a @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7143: c7b12dcc460fc2348e1fa7f4dcb791bb82e29e44 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_110476v2: d98d1a109aa7df08b5398b29e2e90ba50b3f680a @ git://anongit.freedesktop.org/gfx-ci/linux

== Logs ==

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

#4 lore raw
In reply to Sujaritha Sundaresan
Thank you for the patch! Yet something to improve:

Hi Sujaritha,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on drm-tip/drm-tip]

url:    https://github.com/intel-lab-lkp/linux/commits/Sujaritha-Sundaresan/drm-i915-gt-Add-sysfs-RAPL-PL1-interface/20230131-152446
base:   git://anongit.freedesktop.org/drm/drm-tip drm-tip
patch link:    https://lore.kernel.org/r/20230131062550.11901-1-sujaritha.sundaresan%40intel.com
patch subject: [Intel-gfx] [PATCH v2] drm/i915/gt: Add sysfs RAPL PL1 interface
config: i386-randconfig-a012-20230130 (https://download.01.org/0day-ci/archive/20230131/[email protected]/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/562c57549ee00ea298f9023380d44526d6d68921
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Sujaritha-Sundaresan/drm-i915-gt-Add-sysfs-RAPL-PL1-interface/20230131-152446 git checkout 562c57549ee00ea298f9023380d44526d6d68921
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/gpu/drm/i915/

If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

>> drivers/gpu/drm/i915/gt/intel_rps.c:2217:6: error: variable 'rapl' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
           if (IS_METEORLAKE(i915) || IS_XEHPSDV(i915))
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/i915/i915_drv.h:565:33: note: expanded from macro 'IS_METEORLAKE'
   #define IS_METEORLAKE(dev_priv) IS_PLATFORM(dev_priv, INTEL_METEORLAKE)
                                   ^
   drivers/gpu/drm/i915/gt/intel_rps.c:2220:9: note: uninitialized use occurs here
           return rapl;
                  ^~~~
   drivers/gpu/drm/i915/gt/intel_rps.c:2217:2: note: remove the 'if' if its condition is always true
           if (IS_METEORLAKE(i915) || IS_XEHPSDV(i915))
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/i915/gt/intel_rps.c:2209:10: note: initialize the variable 'rapl' to silence this warning
           u32 rapl;
                   ^
                    = 0

1 error generated.

vim +2217 drivers/gpu/drm/i915/gt/intel_rps.c

2204
2205 u32 intel_rps_read_rapl_pl1(struct intel_rps *rps)
2206 {
2207 struct drm_i915_private *i915 = rps_to_i915(rps);
2208 u32 rapl_pl1;
2209 u32 rapl;
2210
2211 if (IS_METEORLAKE(i915))
2212 rapl_pl1 = intel_uncore_read(rps_to_gt(rps)->uncore, MTL_RAPL_PL1_FREQ_LIMIT);
2213 else if (IS_XEHPSDV(i915))
2214 rapl_pl1 = intel_uncore_read(rps_to_gt(rps)->uncore, XEHPSDV_RAPL_PL1_FREQ_LIMIT);
2215
2216

> 2217		if (IS_METEORLAKE(i915) || IS_XEHPSDV(i915))

2218 rapl = REG_FIELD_GET(RAPL_PL1_FREQ_LIMIT_MASK, rapl_pl1);
2219
2220 return rapl;
2221 }
2222

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
#5 lore raw
In reply to Sujaritha Sundaresan
Quoted 1 line · Sujaritha Sundaresan

Hi Suja,

Quoted 2 lines

Adding sysfs attribute rapl_pl1_freq_mhz. This shows the RAPL PL1 FREQUENCY LIMIT.

For MTL do we know if this RAPL PL1 freq limit is for just the GPU or the SOC (CPU + GPU)?

Quoted 54 lines
---
 drivers/gpu/drm/i915/gt/intel_gt_regs.h     |  4 ++++
 drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c | 15 +++++++++++++++
 drivers/gpu/drm/i915/gt/intel_rps.c         | 18 ++++++++++++++++++
 drivers/gpu/drm/i915/gt/intel_rps.h         |  1 +
 4 files changed, 38 insertions(+)
drivers/gpu/drm/i915/gt/intel_gt_regs.h +4 -0
index 7fa18a3b3957..1c78fc89a37a 100644
@@ -1656,6 +1656,10 @@
 #define GT0_PACKAGE_POWER_SKU_UNIT		_MMIO(0x250068)
 #define GT0_PLATFORM_ENERGY_STATUS		_MMIO(0x25006c)
 
+#define XEHPSDV_RAPL_PL1_FREQ_LIMIT		_MMIO(0x250070)
+#define MTL_RAPL_PL1_FREQ_LIMIT		_MMIO(0x281070)
+#define   RAPL_PL1_FREQ_LIMIT_MASK		REG_GENMASK(15, 0)
+
 /*
  * Standalone Media's non-engine GT registers are located at their regular GT
  * offsets plus 0x380000.  This extra offset is stored inside the intel_uncore
drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c +11 -0
index 28f27091cd3b..0b52962e2856 100644
@@ -451,6 +451,16 @@ static ssize_t punit_req_freq_mhz_show(struct kobject *kobj,
 	return sysfs_emit(buff, "%u\n", preq);
 }
 
+static ssize_t rapl_pl1_freq_mhz_show(struct kobject *kobj,
+				      struct kobj_attribute *attr,
+				      char *buff)
+{
+	struct intel_gt *gt = intel_gt_sysfs_get_drvdata(kobj, attr->attr.name);
+	u32 rapl_pl1 = intel_rps_read_rapl_pl1(&gt->rps);
+
+	return sysfs_emit(buff, "%u\n", rapl_pl1);
+}
+
 struct intel_gt_bool_throttle_attr {
 	struct attribute attr;
 	ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr,
@@ -480,6 +490,7 @@ struct intel_gt_bool_throttle_attr attr_##sysfs_func__ = { \
 }
 
 INTEL_GT_ATTR_RO(punit_req_freq_mhz);
+INTEL_GT_ATTR_RO(rapl_pl1_freq_mhz);
 static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_status, GT0_PERF_LIMIT_REASONS_MASK);
 static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_pl1, POWER_LIMIT_1_MASK);
 static INTEL_GT_RPS_BOOL_ATTR_RO(throttle_reason_pl2, POWER_LIMIT_2_MASK);

drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c void intel_gt_sysfs_pm_init(struct intel_gt *gt, struct kobject *kobj) · line 761

Quoted 7 lines
drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c +4 -0
@@ -744,6 +755,10 @@ void intel_gt_sysfs_pm_init(struct intel_gt *gt, struct kobject *kobj)
 	if (ret)
 		gt_warn(gt, "failed to create punit_req_freq_mhz sysfs (%pe)", ERR_PTR(ret));
 
+	ret = sysfs_create_file(kobj, &attr_rapl_pl1_freq_mhz.attr);
+	if (ret)
+		gt_warn(gt, "failed to create rapl_pl1_freq_mhz sysfs (%pe)", ERR_PTR(ret));
+

As I said previously we should create the rapl_pl1_freq_mhz file only on platforms on which it is is available. So let's put the above code block inside the if () below:

	if (GRAPHICS_VER_FULL(gt->i915) >= IP_VER(12, 70) || IS_XEHPSDV(gt->i915)) {
		ret = sysfs_create_file(kobj, &attr_rapl_pl1_freq_mhz.attr);
		if (ret)
			gt_warn(gt, "failed to create rapl_pl1_freq_mhz sysfs (%pe)", ERR_PTR(ret));
	}

Where MTL graphics version is 12.70 so I am assuming this will be availble for all later products too and it will help us to not modify the code for each individual product (unless we have to).

Quoted 18 lines
drivers/gpu/drm/i915/gt/intel_gt_sysfs_pm.c +0 -0
 	if (i915_mmio_reg_valid(intel_gt_perf_limit_reasons_reg(gt))) {
 		ret = sysfs_create_files(kobj, throttle_reason_attrs);
 		if (ret)
drivers/gpu/drm/i915/gt/intel_rps.c +7 -0
index f5d7b5126433..f66d6f47f2cf 100644
@@ -2202,6 +2202,24 @@ u32 intel_rps_get_max_frequency(struct intel_rps *rps)
 		return intel_gpu_freq(rps, rps->max_freq_softlimit);
 }
 
+u32 intel_rps_read_rapl_pl1(struct intel_rps *rps)
+{
+	struct drm_i915_private *i915 = rps_to_i915(rps);
+	u32 rapl_pl1;
+	u32 rapl;
+
+	if (IS_METEORLAKE(i915))

drivers/gpu/drm/i915/gt/intel_rps.c u32 intel_rps_get_max_frequency(struct intel_rps *rps) · line 2221

Quoted 10 lines
drivers/gpu/drm/i915/gt/intel_rps.c +10 -0
+		rapl_pl1 = intel_uncore_read(rps_to_gt(rps)->uncore, MTL_RAPL_PL1_FREQ_LIMIT);
+	else if (IS_XEHPSDV(i915))
+		rapl_pl1  = intel_uncore_read(rps_to_gt(rps)->uncore, XEHPSDV_RAPL_PL1_FREQ_LIMIT);
+
+
+	if (IS_METEORLAKE(i915) || IS_XEHPSDV(i915))
+		rapl = REG_FIELD_GET(RAPL_PL1_FREQ_LIMIT_MASK, rapl_pl1);
+
+	return rapl;
+}

This should be something like this:

u32 intel_rps_read_rapl_pl1(struct intel_rps *rps)

{
	struct drm_i915_private *i915 = rps_to_i915(rps);
	i915_reg_t rgadr = INVALID_MMIO_REG;
	u32 rapl_pl1, rapl;

	if (GRAPHICS_VER_FULL(gt->i915) >= IP_VER(12, 70))
		rgadr = MTL_RAPL_PL1_FREQ_LIMIT;
	else if (IS_XEHPSDV(i915))
		rgadr = XEHPSDV_RAPL_PL1_FREQ_LIMIT;

	rapl_pl1 = rps_read_mmio(gt, rgadr);
	rapl = REG_FIELD_GET(RAPL_PL1_FREQ_LIMIT_MASK, rapl_pl1);

	return rapl;
}

rps_read_mmio is needed to take the runtime PM wakeref, we cannot use intel_uncore_read directly. Note also that we've already ensured that rapl_pl1_freq_mhz file is only available for XEHPSDV and >= 12.70.

Thanks.
--
Ashutosh

Quoted 19 lines
drivers/gpu/drm/i915/gt/intel_rps.c +1 -0
+
 /**
  * intel_rps_get_max_raw_freq - returns the max frequency in some raw format.
  * @rps: the intel_rps structure
drivers/gpu/drm/i915/gt/intel_rps.h +1 -1
index c622962c6bef..c37d297c9d82 100644
@@ -51,6 +51,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_rapl_pl1(struct intel_rps *rps);
 u32 intel_rps_read_rpstat(struct intel_rps *rps);
 u32 intel_rps_read_rpstat_fw(struct intel_rps *rps);
 void gen6_rps_get_freq_caps(struct intel_rps *rps, struct intel_rps_freq_caps *caps);
--

2.34.1