Skip to contentSkip to conversation

lib/igt_sysfs: add asserting helpers for read/write operations

PATCH Superseded Lukasz Laguna 2 participants 2 messages Jun 26, 2023 Library code

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 lib/igt_sysfs: add asserting helpers for read/write operations

Prefix names of existing, non-asserting helpers with "__":

- igt_sysfs_get_u32 -> __igt_sysfs_get_u32
- igt_sysfs_set_u32 -> __igt_sysfs_set_u32
- igt_sysfs_get_u64 -> __igt_sysfs_get_u64
- igt_sysfs_set_u64 -> __igt_sysfs_set_u64
- igt_sysfs_get_boolean -> __igt_sysfs_get_boolean
- igt_sysfs_set_boolean -> __igt_sysfs_set_boolean

Replace all calls to don't introduce any functional changes in the existing code.

Additionally, reimplement non-asserting get helpers to return boolean result of the read operation and store the read value via pointer passed as function parameter. In previous implementation, it wasn't possible to distinguish if returned zero was a read value or failure on a read attempt.

On the occasion, fix a typo in modified debug message.

---
 lib/i915/gem_submission.c      |   4 +-
 lib/igt_pm.c                   |   2 +-
 lib/igt_sysfs.c                | 220 +++++++++++++++++++++++++--------
 lib/igt_sysfs.h                |  12 +-
 tests/i915/i915_pm_dc.c        |   6 +-
 tests/i915/i915_pm_freq_mult.c |  42 ++++---
 tests/i915/i915_pm_rps.c       |  32 ++---
 tests/i915/i915_power.c        |   9 +-
 tests/i915/perf_pmu.c          |  45 ++++---
 tests/kms_prime.c              |   2 +-
 tests/nouveau_crc.c            |   7 +-
 11 files changed, 259 insertions(+), 122 deletions(-)
lib/i915/gem_submission.c +3 -1
index adf5eb394..7d1c3970f 100644
@@ -65,12 +65,14 @@ unsigned gem_submission_method(int fd)
 	const int gen = intel_gen(intel_get_drm_devid(fd));
 	unsigned method = GEM_SUBMISSION_RINGBUF;
 	int dir;
+	uint32_t value = 0;
 
 	dir = igt_params_open(fd);
 	if (dir < 0)
 		return 0;
 
-	if (igt_sysfs_get_u32(dir, "enable_guc") & 1) {
+	__igt_sysfs_get_u32(dir, "enable_guc", &value);
+	if (value & 1) {
 		method = GEM_SUBMISSION_GUC;
 	} else if (gen >= 8) {
 		method = GEM_SUBMISSION_EXECLISTS;
lib/igt_pm.c +1 -1
index 18c84bf3a..ba591f0f8 100644
@@ -1415,5 +1415,5 @@ void igt_pm_ignore_slpc_efficient_freq(int i915, int gtfd, bool val)
 		return;
 
 	igt_require(igt_sysfs_has_attr(gtfd, "slpc_ignore_eff_freq"));
-	igt_assert(igt_sysfs_set_u32(gtfd, "slpc_ignore_eff_freq", val));
+	igt_sysfs_set_u32(gtfd, "slpc_ignore_eff_freq", val);
 }
lib/igt_sysfs.c +167 -53

325 lines not on this page · raw message

lib/igt_sysfs.h +9 -3
index 978b6906e..658a633f4 100644
@@ -114,14 +114,20 @@ int igt_sysfs_vprintf(int dir, const char *attr, const char *fmt, va_list ap)
 int igt_sysfs_printf(int dir, const char *attr, const char *fmt, ...)
 	__attribute__((format(printf,3,4)));
 
+bool __igt_sysfs_get_u32(int dir, const char *attr, uint32_t *value);
 uint32_t igt_sysfs_get_u32(int dir, const char *attr);
-bool igt_sysfs_set_u32(int dir, const char *attr, uint32_t value);
+bool __igt_sysfs_set_u32(int dir, const char *attr, uint32_t value);
+void igt_sysfs_set_u32(int dir, const char *attr, uint32_t value);
 
+bool __igt_sysfs_get_u64(int dir, const char *attr, uint64_t *value);
 uint64_t igt_sysfs_get_u64(int dir, const char *attr);
-bool igt_sysfs_set_u64(int dir, const char *attr, uint64_t value);
+bool __igt_sysfs_set_u64(int dir, const char *attr, uint64_t value);
+void igt_sysfs_set_u64(int dir, const char *attr, uint64_t value);
 
+bool __igt_sysfs_get_boolean(int dir, const char *attr, bool *value);
 bool igt_sysfs_get_boolean(int dir, const char *attr);
-bool igt_sysfs_set_boolean(int dir, const char *attr, bool value);
+bool __igt_sysfs_set_boolean(int dir, const char *attr, bool value);
+void igt_sysfs_set_boolean(int dir, const char *attr, bool value);
 
 void bind_fbcon(bool enable);
 void kick_snd_hda_intel(void);
tests/i915/i915_pm_dc.c +3 -3
index 2bb07ba8b..b83cafbd5 100644
@@ -533,8 +533,8 @@ static void setup_dc9_dpms(data_t *data, int dc_target)
 	int prev_dc = 0, prev_rpm, sysfs_fd;
 
 	igt_require((sysfs_fd = open(KMS_HELPER, O_RDONLY)) >= 0);
-	kms_poll_saved_state = igt_sysfs_get_boolean(sysfs_fd, "poll");
-	igt_sysfs_set_boolean(sysfs_fd, "poll", KMS_POLL_DISABLE);
+	__igt_sysfs_get_boolean(sysfs_fd, "poll", &kms_poll_saved_state);
+	__igt_sysfs_set_boolean(sysfs_fd, "poll", KMS_POLL_DISABLE);
 	close(sysfs_fd);
 	if (DC9_RESETS_DC_COUNTERS(data->devid)) {
 		prev_dc = read_dc_counter(data->debugfs_fd, dc_target);
@@ -629,7 +629,7 @@ static void kms_poll_state_restore(int sig)
 
 	sysfs_fd = open(KMS_HELPER, O_RDONLY);
 	if (sysfs_fd >= 0) {
-		igt_sysfs_set_boolean(sysfs_fd, "poll", kms_poll_saved_state);
+		__igt_sysfs_set_boolean(sysfs_fd, "poll", kms_poll_saved_state);
 		close(sysfs_fd);
 	}
 }
tests/i915/i915_pm_freq_mult.c +23 -19

94 lines not on this page · raw message

tests/i915/i915_pm_rps.c +16 -16
index eaacc7c90..bb0b0530d 100644
@@ -720,7 +720,7 @@ static void fence_order(int i915)
 		.buffer_count = ARRAY_SIZE(obj),
 	};
 	uint64_t wr, rw;
-	int min, max;
+	uint32_t min = 0, max = 0;
 	double freq;
 	int sysfs;
 
@@ -742,14 +742,14 @@ static void fence_order(int i915)
 	 */
 
 	sysfs = igt_sysfs_open(i915);
-	min = igt_sysfs_get_u32(sysfs, "gt_RPn_freq_mhz");
-	max = igt_sysfs_get_u32(sysfs, "gt_RP0_freq_mhz");
+	__igt_sysfs_get_u32(sysfs, "gt_RPn_freq_mhz", &min);
+	__igt_sysfs_get_u32(sysfs, "gt_RP0_freq_mhz", &max);
 	igt_require(max > min);
 
 	/* Only allow ourselves to upclock via waitboosting */
-	igt_sysfs_printf(sysfs, "gt_min_freq_mhz", "%d", min);
-	igt_sysfs_printf(sysfs, "gt_max_freq_mhz", "%d", min);
-	igt_sysfs_printf(sysfs, "gt_boost_freq_mhz", "%d", max);
+	igt_sysfs_printf(sysfs, "gt_min_freq_mhz", "%u", min);
+	igt_sysfs_printf(sysfs, "gt_max_freq_mhz", "%u", min);
+	igt_sysfs_printf(sysfs, "gt_boost_freq_mhz", "%u", max);
 
 	/* Warm up to bind the vma */
 	__fence_order(i915, &obj[0], &execbuf, 0, 0, &freq);
@@ -763,8 +763,8 @@ static void fence_order(int i915)
 	gem_close(i915, obj[0].handle);
 	gem_close(i915, obj[1].handle);
 
-	igt_sysfs_printf(sysfs, "gt_min_freq_mhz", "%d", min);
-	igt_sysfs_printf(sysfs, "gt_max_freq_mhz", "%d", max);
+	igt_sysfs_printf(sysfs, "gt_min_freq_mhz", "%u", min);
+	igt_sysfs_printf(sysfs, "gt_max_freq_mhz", "%u", max);
 
 	close(sysfs);
 
@@ -830,7 +830,7 @@ static void engine_order(int i915)
 	uint64_t forward, backward, both;
 	unsigned int num_engines;
 	const intel_ctx_t *ctx;
-	int min, max;
+	uint32_t min = 0, max = 0;
 	double freq;
 	int sysfs;
 
@@ -862,14 +862,14 @@ static void engine_order(int i915)
 	execbuf.rsvd1 = ctx->id;
 
 	sysfs = igt_sysfs_open(i915);
-	min = igt_sysfs_get_u32(sysfs, "gt_RPn_freq_mhz");
-	max = igt_sysfs_get_u32(sysfs, "gt_RP0_freq_mhz");
+	__igt_sysfs_get_u32(sysfs, "gt_RPn_freq_mhz", &min);
+	__igt_sysfs_get_u32(sysfs, "gt_RP0_freq_mhz", &max);
 	igt_require(max > min);
 
 	/* Only allow ourselves to upclock via waitboosting */
-	igt_sysfs_printf(sysfs, "gt_min_freq_mhz", "%d", min);
-	igt_sysfs_printf(sysfs, "gt_max_freq_mhz", "%d", min);
-	igt_sysfs_printf(sysfs, "gt_boost_freq_mhz", "%d", max);
+	igt_sysfs_printf(sysfs, "gt_min_freq_mhz", "%u", min);
+	igt_sysfs_printf(sysfs, "gt_max_freq_mhz", "%u", min);
+	igt_sysfs_printf(sysfs, "gt_boost_freq_mhz", "%u", max);
 
 	/* Warm up to bind the vma */
 	gem_execbuf(i915, &execbuf);
@@ -893,8 +893,8 @@ static void engine_order(int i915)
 	gem_close(i915, obj[1].handle);
 	intel_ctx_destroy(i915, ctx);
 
-	igt_sysfs_printf(sysfs, "gt_min_freq_mhz", "%d", min);
-	igt_sysfs_printf(sysfs, "gt_max_freq_mhz", "%d", max);
+	igt_sysfs_printf(sysfs, "gt_min_freq_mhz", "%u", min);
+	igt_sysfs_printf(sysfs, "gt_max_freq_mhz", "%u", max);
 
 	close(sysfs);
 
tests/i915/i915_power.c +5 -4
index 3675b9d6d..f3d64d84f 100644
@@ -38,7 +38,8 @@ static void sanity(int i915)
 	double idle, busy;
 	igt_spin_t *spin;
 	uint64_t ahnd;
-	int dir, gt, req, act;
+	int dir, gt;
+	uint32_t req = 0, act = 0;
 
 #define DURATION_SEC 2
 
@@ -58,9 +59,9 @@ static void sanity(int i915)
 	igt_spin_busywait_until_started(spin);
 	busy = measure_power(&pwr, DURATION_SEC);
 	i915_for_each_gt(i915, dir, gt) {
-		req = igt_sysfs_get_u32(dir, "rps_cur_freq_mhz");
-		act = igt_sysfs_get_u32(dir, "rps_act_freq_mhz");
-		igt_info("gt %d: req MHz: %d, act MHz: %d\n", gt, req, act);
+		__igt_sysfs_get_u32(dir, "rps_cur_freq_mhz", &req);
+		__igt_sysfs_get_u32(dir, "rps_act_freq_mhz", &act);
+		igt_info("gt %d: req MHz: %u, act MHz: %u\n", gt, req, act);
 	}
 	igt_free_spins(i915);
 	put_ahnd(ahnd);
tests/i915/perf_pmu.c +26 -19

77 lines not on this page · raw message

tests/kms_prime.c +1 -1
index dd5ab993e..ea2a6a4ab 100644
@@ -341,7 +341,7 @@ static void kms_poll_state_restore(void)
 	int sysfs_fd;
 
 	igt_assert((sysfs_fd = open(KMS_HELPER, O_RDONLY)) >= 0);
-	igt_sysfs_set_boolean(sysfs_fd, "poll", kms_poll_saved_state);
+	__igt_sysfs_set_boolean(sysfs_fd, "poll", kms_poll_saved_state);
 	close(sysfs_fd);
 
 }
tests/nouveau_crc.c +5 -2
index 785d39bde..1016be240 100644
@@ -264,15 +264,18 @@ static void test_ctx_flip_threshold_reset_after_capture(data_t *data)
 {
 	igt_pipe_crc_t *pipe_crc;
 	const int fd = data->drm_fd;
+	uint32_t value = 0;
 
 	pipe_crc = igt_pipe_crc_new(fd, data->pipe, IGT_PIPE_CRC_SOURCE_AUTO);
 
 	set_crc_flip_threshold(data, 5);
 	igt_pipe_crc_start(pipe_crc);
-	igt_assert_eq(igt_sysfs_get_u32(data->nv_crc_dir, "flip_threshold"), 5);
+	__igt_sysfs_get_u32(data->nv_crc_dir, "flip_threshold", &value);
+	igt_assert_eq(value, 5);
 	igt_pipe_crc_stop(pipe_crc);
 
-	igt_assert_neq(igt_sysfs_get_u32(data->nv_crc_dir, "flip_threshold"), 5);
+	__igt_sysfs_get_u32(data->nv_crc_dir, "flip_threshold", &value);
+	igt_assert_neq(value, 5);
 	igt_pipe_crc_free(pipe_crc);
 }
 
Signature · 1 line
2.40.0
#1 lore raw

[igt-dev] ✗ Fi.CI.BAT: failure for lib/igt_sysfs: add asserting helpers for read/write operations (rev4)

== Series Details ==

== Series Details ==

Series: lib/igt_sysfs: add asserting helpers for read/write operations (rev4)
URL : https://patchwork.freedesktop.org/series/119507/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_13324 -> IGTPW_9260
====================================================

Summary
-------

**FAILURE**

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

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

Participating hosts (40 -> 41)
------------------------------

Additional (3): fi-kbl-soraka bat-dg1-8 bat-adlp-11
Missing (2): bat-rpls-2 fi-snb-2520m

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

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

### IGT changes ###

#### Possible regressions ####

* igt@i915_pm_rpm@basic-pci-d3-state:
- bat-mtlp-8: [PASS][1] -> [ABORT][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13324/bat-mtlp-8/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9260/bat-mtlp-8/igt@[email protected]

#### Suppressed ####

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

* {igt@xe_create@create-massive-size}:
- {bat-dg1-8}: NOTRUN -> [FAIL][3] +2 similar issues
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9260/bat-dg1-8/igt@[email protected]

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

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

### IGT changes ###

#### Issues hit ####

* igt@core_auth@basic-auth:
- bat-adlp-11: NOTRUN -> [ABORT][4] ([i915#8011])
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9260/bat-adlp-11/igt@[email protected]

* igt@gem_exec_suspend@basic-s0@smem:
- bat-jsl-3: [PASS][5] -> [ABORT][6] ([i915#5122])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13324/bat-jsl-3/igt@gem_exec_suspend@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9260/bat-jsl-3/igt@gem_exec_suspend@[email protected]

* igt@gem_huc_copy@huc-copy:
- fi-kbl-soraka: NOTRUN -> [SKIP][7] ([fdo#109271] / [i915#2190])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9260/fi-kbl-soraka/igt@[email protected]

* igt@gem_lmem_swapping@basic:
- fi-kbl-soraka: NOTRUN -> [SKIP][8] ([fdo#109271] / [i915#4613]) +3 similar issues
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9260/fi-kbl-soraka/igt@[email protected]

* igt@i915_module_load@load:
- bat-adlp-11: NOTRUN -> [DMESG-WARN][9] ([i915#4423])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9260/bat-adlp-11/igt@[email protected]

* igt@i915_selftest@live@gt_pm:
- fi-kbl-soraka: NOTRUN -> [DMESG-FAIL][10] ([i915#1886] / [i915#7913])
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9260/fi-kbl-soraka/igt@i915_selftest@live@gt_pm.html

* igt@i915_suspend@basic-s3-without-i915:
- bat-jsl-3: [PASS][11] -> [FAIL][12] ([fdo#103375])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13324/bat-jsl-3/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9260/bat-jsl-3/igt@[email protected]

* igt@kms_chamelium_hpd@common-hpd-after-suspend:
- bat-dg2-11: NOTRUN -> [SKIP][13] ([i915#7828])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9260/bat-dg2-11/igt@[email protected]

* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-atomic:
- fi-kbl-soraka: NOTRUN -> [SKIP][14] ([fdo#109271]) +14 similar issues
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9260/fi-kbl-soraka/igt@[email protected]

* igt@kms_psr@primary_mmap_gtt:
- bat-rplp-1: NOTRUN -> [SKIP][15] ([i915#1072])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9260/bat-rplp-1/igt@kms_psr@primary_mmap_gtt.html

* igt@kms_setmode@basic-clone-single-crtc:
- bat-rplp-1: NOTRUN -> [ABORT][16] ([i915#4579] / [i915#8260])
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9260/bat-rplp-1/igt@[email protected]
- fi-kbl-soraka: NOTRUN -> [SKIP][17] ([fdo#109271] / [i915#4579])
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9260/fi-kbl-soraka/igt@[email protected]

#### Possible fixes ####

* igt@i915_selftest@live@workarounds:
- bat-mtlp-6: [DMESG-FAIL][18] ([i915#6763]) -> [PASS][19]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13324/bat-mtlp-6/igt@i915_selftest@[email protected]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9260/bat-mtlp-6/igt@i915_selftest@[email protected]
- bat-dg2-11: [INCOMPLETE][20] ([i915#7913]) -> [PASS][21]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13324/bat-dg2-11/igt@i915_selftest@[email protected]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9260/bat-dg2-11/igt@i915_selftest@[email protected]

#### Warnings ####

* igt@kms_psr@sprite_plane_onoff:
- bat-rplp-1: [ABORT][22] ([i915#8442] / [i915#8712]) -> [SKIP][23] ([i915#1072])
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13324/bat-rplp-1/igt@kms_psr@sprite_plane_onoff.html
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9260/bat-rplp-1/igt@kms_psr@sprite_plane_onoff.html

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

[fdo#103375]: https://bugs.freedesktop.org/show_bug.cgi?id=103375
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
[i915#1845]: https://gitlab.freedesktop.org/drm/intel/issues/1845
[i915#1886]: https://gitlab.freedesktop.org/drm/intel/issues/1886
[i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
[i915#3637]: https://gitlab.freedesktop.org/drm/intel/issues/3637
[i915#4078]: https://gitlab.freedesktop.org/drm/intel/issues/4078
[i915#4391]: https://gitlab.freedesktop.org/drm/intel/issues/4391
[i915#4423]: https://gitlab.freedesktop.org/drm/intel/issues/4423
[i915#4579]: https://gitlab.freedesktop.org/drm/intel/issues/4579
[i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
[i915#5122]: https://gitlab.freedesktop.org/drm/intel/issues/5122
[i915#6763]: https://gitlab.freedesktop.org/drm/intel/issues/6763
[i915#7828]: https://gitlab.freedesktop.org/drm/intel/issues/7828
[i915#7913]: https://gitlab.freedesktop.org/drm/intel/issues/7913
[i915#8011]: https://gitlab.freedesktop.org/drm/intel/issues/8011
[i915#8213]: https://gitlab.freedesktop.org/drm/intel/issues/8213
[i915#8260]: https://gitlab.freedesktop.org/drm/intel/issues/8260
[i915#8442]: https://gitlab.freedesktop.org/drm/intel/issues/8442
[i915#8513]: https://gitlab.freedesktop.org/drm/intel/issues/8513
[i915#8676]: https://gitlab.freedesktop.org/drm/intel/issues/8676
[i915#8678]: https://gitlab.freedesktop.org/drm/intel/issues/8678
[i915#8679]: https://gitlab.freedesktop.org/drm/intel/issues/8679
[i915#8698]: https://gitlab.freedesktop.org/drm/intel/issues/8698
[i915#8699]: https://gitlab.freedesktop.org/drm/intel/issues/8699
[i915#8700]: https://gitlab.freedesktop.org/drm/intel/issues/8700
[i915#8712]: https://gitlab.freedesktop.org/drm/intel/issues/8712

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

* CI: CI-20190529 -> None
* IGT: IGT_7351 -> IGTPW_9260

CI-20190529: 20190529
CI_DRM_13324: d0f10363d9fd8f1cb22a020a878f76c627389355 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_9260: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9260/index.html
IGT_7351: d8dc96b95c60e4737fdfa1664ce9b1dcebfdef60 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git

== Logs ==

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