diff options
author | Tomeu Vizoso <tomeu.vizoso@collabora.com> | 2017-03-02 10:37:11 +0100 |
---|---|---|
committer | Tomeu Vizoso <tomeu.vizoso@collabora.com> | 2017-03-21 15:50:54 +0100 |
commit | 301ad44cdf1b868b1ab89096721da91fa8541fdc (patch) | |
tree | ef18781db6cadae7f8f49f1fc449dc56b33448ec /tests/perf.c | |
parent | e7a0d06730f77842998368660fb45fe5c1738fda (diff) |
lib: Open debugfs files for the given DRM device
When opening a DRM debugfs file, locate the right path based on the
given DRM device FD.
This is needed so, in setups with more than one DRM device, any
operations on debugfs files affect the expected DRM device.
v2: - rebased and fixed new API additions
v3: - updated chamelium test, which was missed previously
- use the minor of the device for the debugfs path, not the major
- have a proper exit handler for calling igt_hpd_storm_reset with the
right device fd.
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Robert Foss <robert.foss@collabora.com>
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tests/perf.c')
-rw-r--r-- | tests/perf.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/tests/perf.c b/tests/perf.c index c9c5c57e..17925eea 100644 --- a/tests/perf.c +++ b/tests/perf.c @@ -297,7 +297,7 @@ sysfs_write(const char *file, uint64_t val) } static char * -read_debugfs_record(const char *file, const char *key) +read_debugfs_record(int fd, const char *file, const char *key) { FILE *fp; char *line = NULL; @@ -306,7 +306,7 @@ read_debugfs_record(const char *file, const char *key) int key_len = strlen(key); char *value = NULL; - fp = igt_debugfs_fopen(file, "r"); + fp = igt_debugfs_fopen(fd, file, "r"); igt_require(fp); while ((len = getline(&line, &line_buf_size, fp)) > 0) { @@ -332,9 +332,9 @@ done: } static uint64_t -read_debugfs_u64_record(const char *file, const char *key) +read_debugfs_u64_record(int fd, const char *file, const char *key) { - char *str_val = read_debugfs_record(file, key); + char *str_val = read_debugfs_record(fd, file, key); uint64_t val; igt_require(str_val); @@ -2137,25 +2137,25 @@ test_rc6_disable(void) .properties_ptr = to_user_pointer(properties), }; int stream_fd = __perf_open(drm_fd, ¶m); - uint64_t n_events_start = read_debugfs_u64_record("i915_drpc_info", + uint64_t n_events_start = read_debugfs_u64_record(drm_fd, "i915_drpc_info", "RC6 residency since boot"); uint64_t n_events_end; nanosleep(&(struct timespec){ .tv_sec = 0, .tv_nsec = 500000000 }, NULL); - n_events_end = read_debugfs_u64_record("i915_drpc_info", + n_events_end = read_debugfs_u64_record(drm_fd, "i915_drpc_info", "RC6 residency since boot"); igt_assert_eq(n_events_end - n_events_start, 0); close(stream_fd); - n_events_start = read_debugfs_u64_record("i915_drpc_info", + n_events_start = read_debugfs_u64_record(drm_fd, "i915_drpc_info", "RC6 residency since boot"); nanosleep(&(struct timespec){ .tv_sec = 0, .tv_nsec = 500000000 }, NULL); - n_events_end = read_debugfs_u64_record("i915_drpc_info", + n_events_end = read_debugfs_u64_record(drm_fd, "i915_drpc_info", "RC6 residency since boot"); igt_assert_neq(n_events_end - n_events_start, 0); |