All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH igt] igt/perf: Use igt_sysfs rather than opencoding
@ 2017-12-08 14:49 Chris Wilson
  2017-12-08 15:22 ` ✗ Fi.CI.BAT: warning for " Patchwork
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Wilson @ 2017-12-08 14:49 UTC (permalink / raw)
  To: intel-gfx; +Cc: Matthew Auld

As igt_sysfs exists to provide convenience routine for parsing files
found in the device's sysfs dir, use it.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: Matthew Auld <matthew.auld@intel.com>
---
 tests/perf.c | 98 +++++++++++-------------------------------------------------
 1 file changed, 18 insertions(+), 80 deletions(-)

diff --git a/tests/perf.c b/tests/perf.c
index 8c20fbe09..f3dc45629 100644
--- a/tests/perf.c
+++ b/tests/perf.c
@@ -39,6 +39,7 @@
 #include <math.h>
 
 #include "igt.h"
+#include "igt_sysfs.h"
 #include "drm.h"
 
 IGT_TEST_DESCRIPTION("Test the i915 perf metrics streaming interface");
@@ -278,6 +279,7 @@ static bool hsw_undefined_a_counters[45] = {
 static bool gen8_undefined_a_counters[45];
 
 static int drm_fd = -1;
+static int sysfs = -1;
 static int pm_fd = -1;
 static int stream_fd = -1;
 static uint32_t devid;
@@ -425,67 +427,16 @@ write_u64_file(const char *file, uint64_t val)
 	close(fd);
 }
 
-static uint64_t
+static unsigned long
 sysfs_read(const char *file)
 {
-	char buf[512];
-
-	snprintf(buf, sizeof(buf), "/sys/class/drm/card%d/%s", card, file);
-
-	return read_u64_file(buf);
-}
-
-static char *
-read_debugfs_record(int device, const char *file, const char *key)
-{
-	FILE *fp;
-	int fd;
-	char *line = NULL;
-	size_t line_buf_size = 0;
-	int len = 0;
-	int key_len = strlen(key);
-	char *value = NULL;
+	unsigned long value;
 
-	fd = igt_debugfs_open(device, file, O_RDONLY);
-	fp = fdopen(fd, "r");
-	igt_require(fp);
+	igt_assert(igt_sysfs_scanf(sysfs, file, "%lu", &value) == 1);
 
-	while ((len = getline(&line, &line_buf_size, fp)) > 0) {
-
-		if (line[len - 1] == '\n')
-			line[len - 1] = '\0';
-
-		if (strncmp(key, line, key_len) == 0 &&
-		    line[key_len] == ':' &&
-		    line[key_len + 1] == ' ')
-		{
-			value = strdup(line + key_len + 2);
-			goto done;
-		}
-	}
-
-	igt_assert(!"reached");
-done:
-	free(line);
-	fclose(fp);
-	close(fd);
 	return value;
 }
 
-static uint64_t
-read_debugfs_u64_record(int fd, const char *file, const char *key)
-{
-	char *str_val = read_debugfs_record(fd, file, key);
-	uint64_t val;
-
-	igt_require(str_val);
-
-	val = strtoull(str_val, NULL, 0);
-	free(str_val);
-
-	return val;
-}
-
 /* XXX: For Haswell this utility is only applicable to the render basic
  * metric set.
  *
@@ -4032,15 +3983,9 @@ gen8_test_single_ctx_render_target_writes_a_counter(void)
 	} while (WEXITSTATUS(child_ret) == EAGAIN);
 }
 
-static bool
-rc6_enabled(void)
+static unsigned long rc6_residency_ms(void)
 {
-	char *rc6_status = read_debugfs_record(drm_fd, "i915_drpc_info",
-					       "RC6 Enabled");
-	bool enabled = strcmp(rc6_status, "yes") == 0;
-
-	free(rc6_status);
-	return enabled;
+	return sysfs_read("power/rc6_residency_ms");
 }
 
 static void
@@ -4060,32 +4005,25 @@ test_rc6_disable(void)
 		.num_properties = sizeof(properties) / 16,
 		.properties_ptr = to_user_pointer(properties),
 	};
-	uint64_t n_events_start, n_events_end;
+	unsigned long n_events_start, n_events_end;
+	unsigned long rc6_enabled;
 
-	igt_skip_on(!rc6_enabled());
+	rc6_enabled = 0;
+	igt_sysfs_scanf(sysfs, "power/rc6_enable", "%lu", &rc6_enabled);
+	igt_require(rc6_enabled);
 
 	stream_fd = __perf_open(drm_fd, &param, false);
 
-	n_events_start = read_debugfs_u64_record(drm_fd, "i915_drpc_info",
-						 "RC6 residency since boot");
-
+	n_events_start = rc6_residency_ms();
 	nanosleep(&(struct timespec){ .tv_sec = 0, .tv_nsec = 500000000 }, NULL);
-
-	n_events_end = read_debugfs_u64_record(drm_fd, "i915_drpc_info",
-					       "RC6 residency since boot");
-
+	n_events_end = rc6_residency_ms();
 	igt_assert_eq(n_events_end - n_events_start, 0);
 
 	__perf_close(stream_fd);
 
-	n_events_start = read_debugfs_u64_record(drm_fd, "i915_drpc_info",
-						 "RC6 residency since boot");
-
+	n_events_start = rc6_residency_ms();
 	nanosleep(&(struct timespec){ .tv_sec = 1, .tv_nsec = 0 }, NULL);
-
-	n_events_end = read_debugfs_u64_record(drm_fd, "i915_drpc_info",
-					       "RC6 residency since boot");
-
+	n_events_end = rc6_residency_ms();
 	igt_assert_neq(n_events_end - n_events_start, 0);
 }
 
@@ -4544,9 +4482,9 @@ igt_main
 		 * should have closed drm_fd...
 		 */
 		igt_assert_eq(drm_fd, -1);
-		drm_fd = drm_open_driver_render(DRIVER_INTEL);
+		drm_fd = drm_open_driver(DRIVER_INTEL);
 		devid = intel_get_drm_devid(drm_fd);
-		card = drm_get_card();
+		sysfs = igt_sysfs_open(drm_fd, &card);
 
 		igt_require(init_sys_info());
 
-- 
2.15.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* ✗ Fi.CI.BAT: warning for igt/perf: Use igt_sysfs rather than opencoding
  2017-12-08 14:49 [PATCH igt] igt/perf: Use igt_sysfs rather than opencoding Chris Wilson
@ 2017-12-08 15:22 ` Patchwork
  0 siblings, 0 replies; 2+ messages in thread
From: Patchwork @ 2017-12-08 15:22 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: igt/perf: Use igt_sysfs rather than opencoding
URL   : https://patchwork.freedesktop.org/series/35092/
State : warning

== Summary ==

IGT patchset tested on top of latest successful build
2fc64acf8a4465d5eab3d6cfec9b3c1b5df30d73 igt/perf_pmu: Tweak wait_for_rc6, yet again

with latest DRM-Tip kernel build CI_DRM_3483
b5f297e08432 drm-tip: 2017y-12m-08d-13h-53m-36s UTC integration manifest

No testlist changes.

Test debugfs_test:
        Subgroup read_all_entries:
                dmesg-warn -> DMESG-FAIL (fi-elk-e7500) fdo#103989
Test gem_mmap_gtt:
        Subgroup basic-small-bo-tiledx:
                pass       -> FAIL       (fi-gdg-551) fdo#102575
Test kms_pipe_crc_basic:
        Subgroup suspend-read-crc-pipe-a:
                dmesg-warn -> PASS       (fi-kbl-r) fdo#104172
        Subgroup suspend-read-crc-pipe-b:
                pass       -> DMESG-WARN (fi-kbl-r)

fdo#103989 https://bugs.freedesktop.org/show_bug.cgi?id=103989
fdo#102575 https://bugs.freedesktop.org/show_bug.cgi?id=102575
fdo#104172 https://bugs.freedesktop.org/show_bug.cgi?id=104172

fi-bdw-5557u     total:288  pass:267  dwarn:0   dfail:0   fail:0   skip:21  time:444s
fi-bdw-gvtdvm    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:447s
fi-blb-e6850     total:288  pass:223  dwarn:1   dfail:0   fail:0   skip:64  time:382s
fi-bsw-n3050     total:288  pass:242  dwarn:0   dfail:0   fail:0   skip:46  time:525s
fi-bwr-2160      total:288  pass:183  dwarn:0   dfail:0   fail:0   skip:105 time:283s
fi-bxt-dsi       total:288  pass:258  dwarn:0   dfail:0   fail:0   skip:30  time:505s
fi-bxt-j4205     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:509s
fi-byt-j1900     total:288  pass:253  dwarn:0   dfail:0   fail:0   skip:35  time:494s
fi-byt-n2820     total:288  pass:249  dwarn:0   dfail:0   fail:0   skip:39  time:477s
fi-elk-e7500     total:224  pass:163  dwarn:14  dfail:1   fail:0   skip:45 
fi-gdg-551       total:288  pass:178  dwarn:1   dfail:0   fail:1   skip:108 time:269s
fi-glk-1         total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:545s
fi-hsw-4770      total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:360s
fi-hsw-4770r     total:288  pass:224  dwarn:0   dfail:0   fail:0   skip:64  time:264s
fi-ilk-650       total:288  pass:228  dwarn:0   dfail:0   fail:0   skip:60  time:395s
fi-ivb-3520m     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:469s
fi-ivb-3770      total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:447s
fi-kbl-7500u     total:288  pass:263  dwarn:1   dfail:0   fail:0   skip:24  time:491s
fi-kbl-7560u     total:288  pass:269  dwarn:0   dfail:0   fail:0   skip:19  time:530s
fi-kbl-7567u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:486s
fi-kbl-r         total:288  pass:260  dwarn:1   dfail:0   fail:0   skip:27  time:534s
fi-skl-6260u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:456s
fi-skl-6600u     total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:551s
fi-skl-6700hq    total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:573s
fi-skl-6700k     total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:519s
fi-skl-6770hq    total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:500s
fi-skl-gvtdvm    total:288  pass:265  dwarn:0   dfail:0   fail:0   skip:23  time:446s
fi-snb-2520m     total:288  pass:249  dwarn:0   dfail:0   fail:0   skip:39  time:562s
fi-snb-2600      total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:415s
Blacklisted hosts:
fi-cfl-s2        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:611s
fi-cnl-y         total:11   pass:10   dwarn:0   dfail:0   fail:0   skip:0  
fi-glk-dsi       total:288  pass:186  dwarn:1   dfail:4   fail:1   skip:96  time:416s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_624/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-12-08 15:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-08 14:49 [PATCH igt] igt/perf: Use igt_sysfs rather than opencoding Chris Wilson
2017-12-08 15:22 ` ✗ Fi.CI.BAT: warning for " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.