]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
i915/selftest/igt_mmap: let mmap tests run in kthread
authorMikolaj Wasiak <mikolaj.wasiak@intel.com>
Tue, 4 Mar 2025 08:43:26 +0000 (09:43 +0100)
committerAndi Shyti <andi.shyti@linux.intel.com>
Fri, 14 Mar 2025 14:30:31 +0000 (15:30 +0100)
When the driver is loaded on the system with numa nodes it might be run in
a kthread, which makes it impossible to use current->mm in the selftest.
This patch allows the selftest to use current->mm by using active_mm.

Signed-off-by: Mikolaj Wasiak <mikolaj.wasiak@intel.com>
Reviewed-by: Eugene Kobyak <eugene.kobyak@intel.com>
Reviewed-by: Krzysztof Niemiec <krzysztof.niemiec@intel.com>
Reviewed-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/2w6pt2hnemndwmanwhyn3keexa6vtha7rmo6rqoerkmyxhbrh2@ls7lndjpia6z
drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c

index 99a9ade739562ed8c2e9a9de32bb7b5655795cdf..2ef2f3db5bcc89b0c0200565e56d2b68a76dbe6e 100644 (file)
@@ -1837,6 +1837,8 @@ 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),
@@ -1848,5 +1850,15 @@ int i915_gem_mman_live_selftests(struct drm_i915_private *i915)
                SUBTEST(igt_mmap_gpu),
        };
 
-       return i915_live_subtests(tests, i915);
+       if (!current->mm) {
+               kthread_use_mm(current->active_mm);
+               unuse_mm = true;
+       }
+
+       ret = i915_live_subtests(tests, i915);
+
+       if (unuse_mm)
+               kthread_unuse_mm(current->active_mm);
+
+       return ret;
 }