diff options
| author | Chris Wilson <chris@chris-wilson.co.uk> | 2020-05-05 12:34:03 +0100 |
|---|---|---|
| committer | Chris Wilson <chris@chris-wilson.co.uk> | 2020-05-07 14:19:37 +0100 |
| commit | ce0ec5c84bb4beaf578d96ea50c90d798aee11cd (patch) | |
| tree | ae8f4c0640ebdb714c86831c0613170c8f7548df /lib | |
| parent | 50868ab3c532a86aa147fb555b69a1078c572b13 (diff) | |
lib/i915: Split igt_require_gem() into i915/
igt_require_gem() is a pecularity of i915/, move it out of the core.
Similar opportunistic move of gem_reopen_driver() and
gem_quiescent_gpu().
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Makefile.sources | 2 | ||||
| -rw-r--r-- | lib/drmtest.c | 22 | ||||
| -rw-r--r-- | lib/drmtest.h | 2 | ||||
| -rw-r--r-- | lib/i915/gem.c | 117 | ||||
| -rw-r--r-- | lib/i915/gem.h | 33 | ||||
| -rw-r--r-- | lib/i915/gem_ring.c | 1 | ||||
| -rw-r--r-- | lib/i915/gem_submission.c | 22 | ||||
| -rw-r--r-- | lib/i915/gem_submission.h | 2 | ||||
| -rw-r--r-- | lib/i915/gem_vm.h | 1 | ||||
| -rw-r--r-- | lib/igt_debugfs.c | 5 | ||||
| -rw-r--r-- | lib/igt_dummyload.c | 11 | ||||
| -rw-r--r-- | lib/igt_gt.c | 3 | ||||
| -rw-r--r-- | lib/ioctl_wrappers.c | 49 | ||||
| -rw-r--r-- | lib/ioctl_wrappers.h | 1 | ||||
| -rw-r--r-- | lib/meson.build | 1 |
15 files changed, 167 insertions, 105 deletions
diff --git a/lib/Makefile.sources b/lib/Makefile.sources index 1e2c88ae..6449574c 100644 --- a/lib/Makefile.sources +++ b/lib/Makefile.sources @@ -3,6 +3,8 @@ lib_source_list = \ drmtest.c \ drmtest.h \ i830_reg.h \ + i915/gem.c \ + i915/gem.h \ i915/gem_context.c \ i915/gem_context.h \ i915/gem_engine_topology.c \ diff --git a/lib/drmtest.c b/lib/drmtest.c index d6ee39e0..85f96ae1 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -48,6 +48,7 @@ #include "drmtest.h" #include "i915_drm.h" +#include "i915/gem.h" #include "intel_chipset.h" #include "intel_io.h" #include "igt_debugfs.h" @@ -162,27 +163,6 @@ static const char *forced_driver(void) return NULL; } -#define LOCAL_I915_EXEC_VEBOX (4 << 0) -/** - * gem_quiescent_gpu: - * @fd: open i915 drm file descriptor - * - * Ensure the gpu is idle by launching a nop execbuf and stalling for it. This - * is automatically run when opening a drm device node and is also installed as - * an exit handler to have the best assurance that the test is run in a pristine - * and controlled environment. - * - * This function simply allows tests to make additional calls in-between, if so - * desired. - */ -void gem_quiescent_gpu(int fd) -{ - igt_terminate_spins(); - - igt_drop_caches_set(fd, - DROP_ACTIVE | DROP_RETIRE | DROP_IDLE | DROP_FREED); -} - static int modprobe(const char *driver) { return igt_kmod_load(driver, ""); diff --git a/lib/drmtest.h b/lib/drmtest.h index d5f0fc25..c56bfafa 100644 --- a/lib/drmtest.h +++ b/lib/drmtest.h @@ -94,8 +94,6 @@ int __drm_open_driver_another(int idx, int chipset); int __drm_open_driver(int chipset); int __drm_open_driver_render(int chipset); -void gem_quiescent_gpu(int fd); - void igt_require_amdgpu(int fd); void igt_require_intel(int fd); void igt_require_vc4(int fd); diff --git a/lib/i915/gem.c b/lib/i915/gem.c new file mode 100644 index 00000000..cabd2376 --- /dev/null +++ b/lib/i915/gem.c @@ -0,0 +1,117 @@ +/* + * Copyright © 2007,2014,2020 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +#include <fcntl.h> +#include <sys/ioctl.h> + +#include "i915/gem.h" +#include "igt.h" +#include "igt_debugfs.h" +#include "igt_sysfs.h" + +static void reset_device(int i915) +{ + int dir; + + dir = igt_debugfs_dir(i915); + igt_require(dir >= 0); + + if (ioctl(i915, DRM_IOCTL_I915_GEM_THROTTLE)) { + igt_info("Found wedged device, trying to reset and continue\n"); + igt_sysfs_set(dir, "i915_wedged", "-1"); + } + igt_sysfs_set(dir, "i915_next_seqno", "1"); + + close(dir); +} + +void igt_require_gem(int i915) +{ + int err; + + igt_require_intel(i915); + + /* + * We only want to use the throttle-ioctl for its -EIO reporting + * 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); + + /* + * Reset the global seqno at the start of each test. This ensures that + * the test will not wrap unless it explicitly sets up seqno wrapping + * itself, which avoids accidentally hanging when setting up long + * sequences of batches. + */ + reset_device(i915); + + err = 0; + if (ioctl(i915, DRM_IOCTL_I915_GEM_THROTTLE)) { + err = -errno; + igt_assume(err); + } + + close(i915); + + igt_require_f(err == 0, "Unresponsive i915/GEM device\n"); +} + +/** + * gem_quiescent_gpu: + * @i915: open i915 drm file descriptor + * + * Ensure the gpu is idle by launching a nop execbuf and stalling for it. This + * is automatically run when opening a drm device node and is also installed as + * an exit handler to have the best assurance that the test is run in a pristine + * and controlled environment. + * + * This function simply allows tests to make additional calls in-between, if so + * desired. + */ +void gem_quiescent_gpu(int i915) +{ + igt_terminate_spins(); + + 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 new file mode 100644 index 00000000..e5403f09 --- /dev/null +++ b/lib/i915/gem.h @@ -0,0 +1,33 @@ +/* + * Copyright © 2007,2014,2020 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +#ifndef I915_GEM_H +#define I915_GEM_H + +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 99f4741c..a57bf4c5 100644 --- a/lib/i915/gem_ring.c +++ b/lib/i915/gem_ring.c @@ -26,6 +26,7 @@ #include <sys/ioctl.h> #include <sys/time.h> +#include "gem.h" #include "gem_ring.h" #include "gem_submission.h" diff --git a/lib/i915/gem_submission.c b/lib/i915/gem_submission.c index 72de0c22..c5adcdc7 100644 --- a/lib/i915/gem_submission.c +++ b/lib/i915/gem_submission.c @@ -28,7 +28,9 @@ #include <i915_drm.h> +#include "i915/gem.h" #include "i915/gem_engine_topology.h" +#include "i915/gem_submission.h" #include "igt_core.h" #include "igt_gt.h" @@ -37,8 +39,6 @@ #include "intel_reg.h" #include "ioctl_wrappers.h" -#include "i915/gem_submission.h" - /** * SECTION:gem_submission * @short_description: Helpers for determining submission method @@ -159,24 +159,6 @@ bool gem_has_guc_submission(int fd) return gem_submission_method(fd) & GEM_SUBMISSION_GUC; } -/** - * gem_reopen_driver: - * @fd: 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 fd) -{ - char path[256]; - - snprintf(path, sizeof(path), "/proc/self/fd/%d", fd); - fd = open(path, O_RDWR); - igt_assert_fd(fd); - - return fd; -} - static bool is_wedged(int i915) { int err = 0; diff --git a/lib/i915/gem_submission.h b/lib/i915/gem_submission.h index acd24bcb..b030ed9f 100644 --- a/lib/i915/gem_submission.h +++ b/lib/i915/gem_submission.h @@ -48,6 +48,4 @@ void gem_require_blitter(int i915); void gem_test_engine(int fd, unsigned int engine); -int gem_reopen_driver(int fd); - #endif /* GEM_SUBMISSION_H */ diff --git a/lib/i915/gem_vm.h b/lib/i915/gem_vm.h index 27af899d..acbb663e 100644 --- a/lib/i915/gem_vm.h +++ b/lib/i915/gem_vm.h @@ -24,6 +24,7 @@ #ifndef GEM_VM_H #define GEM_VM_H +#include <stdbool.h> #include <stdint.h> bool gem_has_vm(int i915); diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c index 9e6c5c99..05067078 100644 --- a/lib/igt_debugfs.c +++ b/lib/igt_debugfs.c @@ -1110,13 +1110,10 @@ static int get_object_count(int fd) */ int igt_get_stable_obj_count(int driver) { - int obj_count; - gem_quiescent_gpu(driver); - obj_count = get_object_count(driver); /* The test relies on the system being in the same state before and * after the test so any difference in the object count is a result of * leaks during the test. */ - return obj_count; + return get_object_count(driver); } void __igt_debugfs_dump(int device, const char *filename, int level) diff --git a/lib/igt_dummyload.c b/lib/igt_dummyload.c index ae0fb937..d4cc9be6 100644 --- a/lib/igt_dummyload.c +++ b/lib/igt_dummyload.c @@ -30,19 +30,20 @@ #include <i915_drm.h> -#include "igt_core.h" #include "drmtest.h" +#include "i915/gem.h" +#include "i915/gem_engine_topology.h" +#include "i915/gem_mman.h" +#include "i915/gem_submission.h" +#include "igt_core.h" #include "igt_device.h" #include "igt_dummyload.h" #include "igt_gt.h" +#include "igt_vgem.h" #include "intel_chipset.h" #include "intel_reg.h" #include "ioctl_wrappers.h" #include "sw_sync.h" -#include "igt_vgem.h" -#include "i915/gem_engine_topology.h" -#include "i915/gem_mman.h" -#include "i915/gem_submission.h" /** * SECTION:igt_dummyload diff --git a/lib/igt_gt.c b/lib/igt_gt.c index 256c7cbc..64b62c8c 100644 --- a/lib/igt_gt.c +++ b/lib/igt_gt.c @@ -32,6 +32,8 @@ #include <fcntl.h> #include "drmtest.h" +#include "i915/gem.h" +#include "i915/gem_engine_topology.h" #include "igt_aux.h" #include "igt_core.h" #include "igt_gt.h" @@ -41,7 +43,6 @@ #include "intel_reg.h" #include "intel_chipset.h" #include "igt_dummyload.h" -#include "i915/gem_engine_topology.h" /** * SECTION:igt_gt diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c index 25d04b3e..61f93bd8 100644 --- a/lib/ioctl_wrappers.c +++ b/lib/ioctl_wrappers.c @@ -1158,55 +1158,6 @@ void gem_require_caching(int fd) errno = 0; } -static void reset_device(int fd) -{ - int dir; - - dir = igt_debugfs_dir(fd); - igt_require(dir >= 0); - - if (ioctl(fd, DRM_IOCTL_I915_GEM_THROTTLE)) { - igt_info("Found wedged device, trying to reset and continue\n"); - igt_sysfs_set(dir, "i915_wedged", "-1"); - } - igt_sysfs_set(dir, "i915_next_seqno", "1"); - - close(dir); -} - -void igt_require_gem(int fd) -{ - char path[256]; - int err; - - igt_require_intel(fd); - - /* - * We only want to use the throttle-ioctl for its -EIO reporting - * of a wedged device, not for actually waiting on outstanding - * requests! So create a new drm_file for the device that is clean. - */ - snprintf(path, sizeof(path), "/proc/self/fd/%d", fd); - fd = open(path, O_RDWR); - igt_assert_lte(0, fd); - - /* - * Reset the global seqno at the start of each test. This ensures that - * the test will not wrap unless it explicitly sets up seqno wrapping - * itself, which avoids accidentally hanging when setting up long - * sequences of batches. - */ - reset_device(fd); - - err = 0; - if (ioctl(fd, DRM_IOCTL_I915_GEM_THROTTLE)) - err = -errno; - - close(fd); - - igt_require_f(err == 0, "Unresponsive i915/GEM device\n"); -} - /** * gem_require_ring: * @fd: open i915 drm file descriptor diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h index 799d9026..9f1f5c5c 100644 --- a/lib/ioctl_wrappers.h +++ b/lib/ioctl_wrappers.h @@ -120,7 +120,6 @@ void gem_sw_finish(int fd, uint32_t handle); bool gem_bo_busy(int fd, uint32_t handle); /* feature test helpers */ -void igt_require_gem(int fd); bool gem_has_llc(int fd); bool gem_has_bsd(int fd); bool gem_has_blt(int fd); diff --git a/lib/meson.build b/lib/meson.build index e2060430..f2b845c9 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -1,5 +1,6 @@ lib_sources = [ 'drmtest.c', + 'i915/gem.c', 'i915/gem_context.c', 'i915/gem_engine_topology.c', 'i915/gem_scheduler.c', |
