summaryrefslogtreecommitdiff
path: root/tests/i915/gem_lmem_swapping.c
diff options
context:
space:
mode:
authorPetri Latvala <petri.latvala@intel.com>2022-04-19 16:00:57 +0300
committerPetri Latvala <petri.latvala@intel.com>2022-04-20 13:26:40 +0300
commita44d1d4c9e7198a2d59d7dcaae38e340f7cadcf9 (patch)
tree4a14144da762279e2f690459053cbb241da5fd51 /tests/i915/gem_lmem_swapping.c
parent04262fc75ff3ec42f4db0c929d46b7cd5083911f (diff)
gem_lmem_swapping: Check requirements before module unload
To prevent a needless unload-load cycle, check for lmem before the unload if i915 is already loaded. Also check that the device is there at all so we get a better error message than EBADFD from require_gem. Signed-off-by: Petri Latvala <petri.latvala@intel.com> Cc: Matthew Auld <matthew.auld@intel.com> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> Acked-by: Matthew Auld <matthew.auld@intel.com>
Diffstat (limited to 'tests/i915/gem_lmem_swapping.c')
-rw-r--r--tests/i915/gem_lmem_swapping.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/i915/gem_lmem_swapping.c b/tests/i915/gem_lmem_swapping.c
index 60588d0f..e58a1f50 100644
--- a/tests/i915/gem_lmem_swapping.c
+++ b/tests/i915/gem_lmem_swapping.c
@@ -756,10 +756,29 @@ igt_main_args("", long_options, help_str, opt_handler, NULL)
struct intel_execution_engine2 *e;
char *tmp;
+ /*
+ * If the driver is already loaded, check that it has
+ * lmem before unloading to prevent a needless
+ * unload-load cycle on integrated platforms.
+ */
+ if (igt_kmod_is_loaded("i915")) {
+ i915 = __drm_open_driver(DRIVER_INTEL);
+ igt_require_fd(i915);
+ igt_require_gem(i915);
+ igt_require(gem_has_lmem(i915));
+ close(i915);
+ }
+
igt_i915_driver_unload();
igt_assert_eq(igt_i915_driver_load("lmem_size=4096"), 0);
i915 = __drm_open_driver(DRIVER_INTEL);
+ igt_require_fd(i915);
+ /*
+ * Even if we did the lmem check above, do it again in
+ * case the reload messed something up (as unlikely it
+ * is)
+ */
igt_require_gem(i915);
igt_require(gem_has_lmem(i915));