From 301ad44cdf1b868b1ab89096721da91fa8541fdc Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Thu, 2 Mar 2017 10:37:11 +0100 Subject: 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 Reviewed-by: Robert Foss Acked-by: Chris Wilson --- lib/intel_os.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/intel_os.c') diff --git a/lib/intel_os.c b/lib/intel_os.c index 924ac7e7..e5dea6e5 100644 --- a/lib/intel_os.c +++ b/lib/intel_os.c @@ -97,8 +97,11 @@ intel_get_avail_ram_mb(void) #ifdef HAVE_STRUCT_SYSINFO_TOTALRAM /* Linux */ struct sysinfo sysinf; + int fd; - intel_purge_vm_caches(); + fd = drm_open_driver(DRIVER_INTEL); + intel_purge_vm_caches(fd); + close(fd); igt_assert(sysinfo(&sysinf) == 0); retval = sysinf.freeram; @@ -292,11 +295,11 @@ void intel_require_memory(uint64_t count, uint64_t size, unsigned mode) igt_skip_on_simulation(); } -void intel_purge_vm_caches(void) +void intel_purge_vm_caches(int drm_fd) { int fd; - igt_drop_caches_set(DROP_SHRINK_ALL); + igt_drop_caches_set(drm_fd, DROP_SHRINK_ALL); fd = open("/proc/sys/vm/drop_caches", O_WRONLY); if (fd >= 0) { -- cgit v1.2.3