diff options
author | Anna Karas <anna.karas@intel.com> | 2023-05-11 15:06:12 +0200 |
---|---|---|
committer | Kamil Konieczny <kamil.konieczny@linux.intel.com> | 2023-05-12 10:02:28 +0200 |
commit | a482779488f11c432d7ddcb1980691ab1603f356 (patch) | |
tree | 3b798fae38e0c7bcf01a4e82bca438a1d7881715 /lib/i915 | |
parent | d1cbf2bad9c2664ab8bd3bd0946510a52800912f (diff) |
lib/drmtest: Add function drm_reopen_driver()
We need an equivalent of gem_reopen_driver() in XE. In order to not
duplicate the code, move gem_reopen_driver() one directory up from
lib/i915 to lib as drm_reopen_driver() so XE can use it too.
Rename gem_reopen_driver() across files.
v2: cache xe_device after opening the driver
v3: fix incorrect indentation
Reference: VLK-46235
Signed-off-by: Anna Karas <anna.karas@intel.com>
Acked-by: Zbigniew KempczyĆski <zbigniew.kempczynski@intel.com>
Reviewed-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Diffstat (limited to 'lib/i915')
-rw-r--r-- | lib/i915/gem.c | 20 | ||||
-rw-r--r-- | lib/i915/gem.h | 2 | ||||
-rw-r--r-- | lib/i915/gem_ring.c | 2 | ||||
-rw-r--r-- | lib/i915/gem_submission.c | 4 |
4 files changed, 4 insertions, 24 deletions
diff --git a/lib/i915/gem.c b/lib/i915/gem.c index ed45a9ed5..6da3e5c93 100644 --- a/lib/i915/gem.c +++ b/lib/i915/gem.c @@ -147,7 +147,7 @@ void igt_require_gem(int i915) * of a wedged device, not for actually waiting on outstanding * requests! So create a new drm_file for the device that is clean. */ - i915 = gem_reopen_driver(i915); + i915 = drm_reopen_driver(i915); /* * Reset the global seqno at the start of each test. This ensures that @@ -189,21 +189,3 @@ void gem_quiescent_gpu(int i915) igt_drop_caches_set(i915, DROP_ACTIVE | DROP_RETIRE | DROP_IDLE | DROP_FREED); } - -/** - * gem_reopen_driver: - * @i915: re-open the i915 drm file descriptor - * - * Re-opens the drm fd which is useful in instances where a clean default - * context is needed. - */ -int gem_reopen_driver(int i915) -{ - char path[256]; - - snprintf(path, sizeof(path), "/proc/self/fd/%d", i915); - i915 = open(path, O_RDWR); - igt_assert_fd(i915); - - return i915; -} diff --git a/lib/i915/gem.h b/lib/i915/gem.h index feabac8df..06dcb5468 100644 --- a/lib/i915/gem.h +++ b/lib/i915/gem.h @@ -30,6 +30,4 @@ void igt_require_gem(int i915); void gem_quiescent_gpu(int i915); -int gem_reopen_driver(int i915); - #endif /* I915_GEM_H */ diff --git a/lib/i915/gem_ring.c b/lib/i915/gem_ring.c index 6d28b5d96..eb2c7c2c9 100644 --- a/lib/i915/gem_ring.c +++ b/lib/i915/gem_ring.c @@ -149,7 +149,7 @@ gem_measure_ring_inflight(int fd, unsigned int engine, enum measure_ring_flags f { unsigned int min = ~0u; - fd = gem_reopen_driver(fd); + fd = drm_reopen_driver(fd); /* When available, disable execbuf throttling */ fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | O_NONBLOCK); diff --git a/lib/i915/gem_submission.c b/lib/i915/gem_submission.c index 0358802ef..adf5eb394 100644 --- a/lib/i915/gem_submission.c +++ b/lib/i915/gem_submission.c @@ -30,7 +30,6 @@ #include <i915_drm.h> -#include "i915/gem.h" #include "i915/gem_create.h" #include "i915/gem_engine_topology.h" #include "i915/gem_submission.h" @@ -42,6 +41,7 @@ #include "intel_chipset.h" #include "intel_reg.h" #include "ioctl_wrappers.h" +#include "drmtest.h" /** * SECTION:gem_submission @@ -158,7 +158,7 @@ void gem_test_all_engines(int i915) }; const intel_ctx_t *ctx; - i915 = gem_reopen_driver(i915); + i915 = drm_reopen_driver(i915); igt_assert(!is_wedged(i915)); ctx = intel_ctx_create_all_physical(i915); |