Skip to contentSkip to conversation

i915/i915_hwmon: Measure dGfx power with hwmon

PATCH In review Ashutosh Dixit 2 participants 3 messages Jan 14, 2023 – Jan 17, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i915/i915_hwmon: Measure dGfx power with hwmon

In several instances (e.g. when investigating GPU power limits) it is very useful to be able to measure GPU power easily. Since we already have all ingridients for doing so, add a couple of hwmon tests to measure dGfx power when idle and power under load.

v2: Changed tests names from hwmon-power-idle/busy to power-idle/busy

---
 tests/i915/i915_hwmon.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
tests/i915/i915_hwmon.c +39 -0
index 6d9937e99dc..aec503919d5 100644
@@ -6,11 +6,40 @@
 #include <dirent.h>
 #include <sys/stat.h>
 #include "igt.h"
+#include "i915/gem.h"
+#include "igt_power.h"
 #include "igt_hwmon.h"
 #include "igt_sysfs.h"
 
 IGT_TEST_DESCRIPTION("Tests for i915 hwmon");
 
+static void hwmon_power(int i915, bool load)
+{
+	const intel_ctx_t *ctx = intel_ctx_create_all_physical(i915);
+	struct power_sample sample[2];
+	int sleep_duration_sec = 3;
+	struct igt_power gpu;
+	igt_spin_t *spin;
+
+	gem_quiescent_gpu(i915);
+	if (load) {
+		spin = igt_spin_new(i915, .ctx = ctx, .engine = ALL_ENGINES,
+				    .flags = IGT_SPIN_POLL_RUN);
+		/* Wait till at least one spinner starts */
+		igt_spin_busywait_until_started(spin);
+	}
+
+	igt_assert(!igt_power_open(i915, &gpu, "gpu"));
+	igt_power_get_energy(&gpu, &sample[0]);
+	usleep(sleep_duration_sec * USEC_PER_SEC);
+	igt_power_get_energy(&gpu, &sample[1]);
+	igt_info("Measured power: %g mW\n", igt_power_get_mW(&gpu, &sample[0], &sample[1]));
+
+	igt_power_close(&gpu);
+	igt_free_spins(i915);
+	intel_ctx_destroy(i915, ctx);
+}
+
 static void hwmon_read(int hwm)
 {
 	struct dirent *de;
@@ -81,6 +110,16 @@ igt_main
 		hwmon_write(hwm);
 	}
 
+	igt_describe("Measure idle power using hwmon");
+	igt_subtest("power-idle") {
+		hwmon_power(fd, false);
+	}
+
+	igt_describe("Measure power with load using hwmon");
+	igt_subtest("power-busy") {
+		hwmon_power(fd, true);
+	}
+
 	igt_fixture {
 		close(hwm);
 		close(fd);
Signature · 1 line
2.38.0
#1 lore raw

[igt-dev] ✗ Fi.CI.BAT: failure for i915/i915_hwmon: Measure dGfx power with hwmon (rev3)

== Series Details ==

== Series Details ==

Series: i915/i915_hwmon: Measure dGfx power with hwmon (rev3)
URL : https://patchwork.freedesktop.org/series/112828/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_12585 -> IGTPW_8342
====================================================

Summary
-------

**FAILURE**

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

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

Participating hosts (44 -> 43)
------------------------------

Additional (1): fi-rkl-11600
Missing (2): fi-kbl-soraka fi-snb-2520m

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

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

### IGT changes ###

#### Possible regressions ####

* igt@i915_selftest@live@execlists:
- fi-bsw-kefka: [PASS][1] -> [INCOMPLETE][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12585/fi-bsw-kefka/igt@i915_selftest@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8342/fi-bsw-kefka/igt@i915_selftest@[email protected]

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

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

### IGT changes ###

#### Issues hit ####

* igt@debugfs_test@basic-hwmon:
- fi-rkl-11600: NOTRUN -> [SKIP][3] ([i915#7456])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8342/fi-rkl-11600/igt@[email protected]

* igt@gem_huc_copy@huc-copy:
- fi-rkl-11600: NOTRUN -> [SKIP][4] ([i915#2190])
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8342/fi-rkl-11600/igt@[email protected]

* igt@gem_lmem_swapping@basic:
- fi-rkl-11600: NOTRUN -> [SKIP][5] ([i915#4613]) +3 similar issues
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8342/fi-rkl-11600/igt@[email protected]

* igt@gem_tiled_pread_basic:
- fi-rkl-11600: NOTRUN -> [SKIP][6] ([i915#3282])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8342/fi-rkl-11600/igt@gem_tiled_pread_basic.html

* igt@i915_pm_backlight@basic-brightness:
- fi-rkl-11600: NOTRUN -> [SKIP][7] ([i915#7561])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8342/fi-rkl-11600/igt@[email protected]

* igt@i915_suspend@basic-s3-without-i915:
- fi-rkl-11600: NOTRUN -> [INCOMPLETE][8] ([i915#4817])
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8342/fi-rkl-11600/igt@[email protected]

* igt@kms_chamelium_hpd@dp-hpd-fast:
- fi-rkl-11600: NOTRUN -> [SKIP][9] ([i915#7828]) +7 similar issues
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8342/fi-rkl-11600/igt@[email protected]

* igt@kms_cursor_legacy@basic-busy-flip-before-cursor:
- fi-rkl-11600: NOTRUN -> [SKIP][10] ([i915#4103])
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8342/fi-rkl-11600/igt@[email protected]

* igt@kms_force_connector_basic@force-load-detect:
- fi-rkl-11600: NOTRUN -> [SKIP][11] ([fdo#109285] / [i915#4098])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8342/fi-rkl-11600/igt@[email protected]

* igt@kms_psr@primary_page_flip:
- fi-rkl-11600: NOTRUN -> [SKIP][12] ([i915#1072]) +3 similar issues
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8342/fi-rkl-11600/igt@kms_psr@primary_page_flip.html

* igt@kms_setmode@basic-clone-single-crtc:
- fi-rkl-11600: NOTRUN -> [SKIP][13] ([i915#3555] / [i915#4098])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8342/fi-rkl-11600/igt@[email protected]

* igt@prime_vgem@basic-read:
- fi-rkl-11600: NOTRUN -> [SKIP][14] ([fdo#109295] / [i915#3291] / [i915#3708]) +2 similar issues
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8342/fi-rkl-11600/igt@[email protected]

* igt@prime_vgem@basic-userptr:
- fi-rkl-11600: NOTRUN -> [SKIP][15] ([fdo#109295] / [i915#3301] / [i915#3708])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8342/fi-rkl-11600/igt@[email protected]

* igt@runner@aborted:
- fi-bsw-kefka: NOTRUN -> [FAIL][16] ([fdo#109271] / [i915#4312])
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8342/fi-bsw-kefka/igt@[email protected]

#### Possible fixes ####

* igt@i915_selftest@live@gt_pm:
- {bat-rpls-2}: [DMESG-FAIL][17] ([i915#4258]) -> [PASS][18]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12585/bat-rpls-2/igt@i915_selftest@live@gt_pm.html
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8342/bat-rpls-2/igt@i915_selftest@live@gt_pm.html

* igt@i915_selftest@live@hangcheck:
- {bat-dg2-11}: [INCOMPLETE][19] ([i915#7834]) -> [PASS][20]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12585/bat-dg2-11/igt@i915_selftest@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8342/bat-dg2-11/igt@i915_selftest@[email protected]

* igt@i915_selftest@live@requests:
- {bat-rpls-1}: [INCOMPLETE][21] ([i915#6257]) -> [PASS][22]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12585/bat-rpls-1/igt@i915_selftest@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8342/bat-rpls-1/igt@i915_selftest@[email protected]

* igt@i915_selftest@live@reset:
- {bat-rpls-2}: [DMESG-FAIL][23] ([i915#4983]) -> [PASS][24]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12585/bat-rpls-2/igt@i915_selftest@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8342/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).

[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[fdo#109295]: https://bugs.freedesktop.org/show_bug.cgi?id=109295
[i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
[i915#1845]: https://gitlab.freedesktop.org/drm/intel/issues/1845
[i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
[i915#3282]: https://gitlab.freedesktop.org/drm/intel/issues/3282
[i915#3291]: https://gitlab.freedesktop.org/drm/intel/issues/3291
[i915#3301]: https://gitlab.freedesktop.org/drm/intel/issues/3301
[i915#3555]: https://gitlab.freedesktop.org/drm/intel/issues/3555
[i915#3708]: https://gitlab.freedesktop.org/drm/intel/issues/3708
[i915#4098]: https://gitlab.freedesktop.org/drm/intel/issues/4098
[i915#4103]: https://gitlab.freedesktop.org/drm/intel/issues/4103
[i915#4137]: https://gitlab.freedesktop.org/drm/intel/issues/4137
[i915#4258]: https://gitlab.freedesktop.org/drm/intel/issues/4258
[i915#4312]: https://gitlab.freedesktop.org/drm/intel/issues/4312
[i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
[i915#4817]: https://gitlab.freedesktop.org/drm/intel/issues/4817
[i915#4983]: https://gitlab.freedesktop.org/drm/intel/issues/4983
[i915#6257]: https://gitlab.freedesktop.org/drm/intel/issues/6257
[i915#6367]: https://gitlab.freedesktop.org/drm/intel/issues/6367
[i915#7359]: https://gitlab.freedesktop.org/drm/intel/issues/7359
[i915#7456]: https://gitlab.freedesktop.org/drm/intel/issues/7456
[i915#7561]: https://gitlab.freedesktop.org/drm/intel/issues/7561
[i915#7625]: https://gitlab.freedesktop.org/drm/intel/issues/7625
[i915#7828]: https://gitlab.freedesktop.org/drm/intel/issues/7828
[i915#7834]: https://gitlab.freedesktop.org/drm/intel/issues/7834
[i915#7852]: https://gitlab.freedesktop.org/drm/intel/issues/7852

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

* CI: CI-20190529 -> None
* IGT: IGT_7119 -> IGTPW_8342

CI-20190529: 20190529
CI_DRM_12585: 68d139b609a97a83e7c231189d4864aba4e1679b @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_8342: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8342/index.html
IGT_7119: 1e6d24e6dfa42b22f950f7d5e436b8f9acf8747f @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git

Testlist changes
----------------

+igt@i915_hwmon@power-busy
+igt@i915_hwmon@power-idle
-igt@i915_hwmon@hwmon-power-busy
-igt@i915_hwmon@hwmon-power-idle

== Logs ==

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

#2 lore raw
In reply to Ashutosh Dixit
Quoted 7 lines · Ashutosh Dixit

In several instances (e.g. when investigating GPU power limits) it is very useful to be able to measure GPU power easily. Since we already have all ingridients for doing so, add a couple of hwmon tests to measure dGfx power when idle and power under load.

v2: Changed tests names from hwmon-power-idle/busy to power-idle/busy

One issue I thought with this patch was that the IGT power library works for both integrated as well as discrete. Therefore to add this power measurement only for dGfx/hwmon is unnecessarily restrictive.

Therefore I have now removed this dGfx/hwmon restriction and submitted a new patch here where power measurement should now work for both integrated and discrete:

https://patchwork.freedesktop.org/series/112962/

Thanks.
--
Ashutosh