[PATCH v6 2/2] drm/i915/selftests: Run vma tests only if current->mm is present

Krzysztof Karas
2026-04-15T09:21:32Z

This set of tests require userspace memory to map objects,
so run them only if that memory is available.

Signed-off-by: Krzysztof Karas <krzysztof.karas@intel.com>
---
v5 (Janusz):
* Add warning when current->mm is missing.

v6 (Andi):
* Shorten the warning upon no current->mm.

.../gpu/drm/i915/gem/selftests/i915_gem_mman.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c
index 9d454d0b46f2..b97e0d99d92c 100644
--- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c
+++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c
@@ -1847,11 +1847,12 @@ static int igt_mmap_revoke(void *arg)
int i915_gem_mman_live_selftests(struct drm_i915_private *i915)
{
int ret;
- bool unuse_mm = false;
static const struct i915_subtest tests[] = {
SUBTEST(igt_partial_tiling),
SUBTEST(igt_smoke_tiling),
SUBTEST(igt_mmap_offset_exhaustion),
+ };
+ static const struct i915_subtest vma_tests[] = {
SUBTEST(igt_mmap),
SUBTEST(igt_mmap_migrate),
SUBTEST(igt_mmap_access),
@@ -1859,15 +1860,14 @@ int i915_gem_mman_live_selftests(struct drm_i915_private *i915)
SUBTEST(igt_mmap_gpu),
};

- if (!current->mm) {
- kthread_use_mm(current->active_mm);
- unuse_mm = true;
- }
-
ret = i915_live_subtests(tests, i915);
+ if (ret)
+ return ret;

- if (unuse_mm)
- kthread_unuse_mm(current->active_mm);
+ if (current->mm)
+ ret = i915_live_subtests(vma_tests, i915);
+ else
+ pr_warn("No current->mm.\n");

return ret;
}
--
2.43.0