drm/i915/selftests: Allow for larger engine counts
authorJohn Harrison <John.C.Harrison@Intel.com>
Wed, 21 Jul 2021 22:30:32 +0000 (15:30 -0700)
committerMatt Roper <matthew.d.roper@intel.com>
Thu, 22 Jul 2021 16:37:10 +0000 (09:37 -0700)
Increasing the engine count causes a couple of local array variables
to exceed the kernel stack limit. So make them dynamic allocations
instead.

Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210721223043.834562-8-matthew.d.roper@intel.com
drivers/gpu/drm/i915/gt/selftest_execlists.c
drivers/gpu/drm/i915/gt/selftest_workarounds.c

index 73ddc6e..22a124b 100644 (file)
@@ -3561,12 +3561,16 @@ static int smoke_crescendo(struct preempt_smoke *smoke, unsigned int flags)
 #define BATCH BIT(0)
 {
        struct task_struct *tsk[I915_NUM_ENGINES] = {};
-       struct preempt_smoke arg[I915_NUM_ENGINES];
+       struct preempt_smoke *arg;
        struct intel_engine_cs *engine;
        enum intel_engine_id id;
        unsigned long count;
        int err = 0;
 
+       arg = kmalloc_array(I915_NUM_ENGINES, sizeof(*arg), GFP_KERNEL);
+       if (!arg)
+               return -ENOMEM;
+
        for_each_engine(engine, smoke->gt, id) {
                arg[id] = *smoke;
                arg[id].engine = engine;
@@ -3574,7 +3578,7 @@ static int smoke_crescendo(struct preempt_smoke *smoke, unsigned int flags)
                        arg[id].batch = NULL;
                arg[id].count = 0;
 
-               tsk[id] = kthread_run(smoke_crescendo_thread, &arg,
+               tsk[id] = kthread_run(smoke_crescendo_thread, arg,
                                      "igt/smoke:%d", id);
                if (IS_ERR(tsk[id])) {
                        err = PTR_ERR(tsk[id]);
@@ -3603,6 +3607,8 @@ static int smoke_crescendo(struct preempt_smoke *smoke, unsigned int flags)
 
        pr_info("Submitted %lu crescendo:%x requests across %d engines and %d contexts\n",
                count, flags, smoke->gt->info.num_engines, smoke->ncontext);
+
+       kfree(arg);
        return 0;
 }
 
index 7ebc4ed..7a38ce4 100644 (file)
@@ -1175,31 +1175,36 @@ live_gpu_reset_workarounds(void *arg)
 {
        struct intel_gt *gt = arg;
        intel_wakeref_t wakeref;
-       struct wa_lists lists;
+       struct wa_lists *lists;
        bool ok;
 
        if (!intel_has_gpu_reset(gt))
                return 0;
 
+       lists = kzalloc(sizeof(*lists), GFP_KERNEL);
+       if (!lists)
+               return -ENOMEM;
+
        pr_info("Verifying after GPU reset...\n");
 
        igt_global_reset_lock(gt);
        wakeref = intel_runtime_pm_get(gt->uncore->rpm);
 
-       reference_lists_init(gt, &lists);
+       reference_lists_init(gt, lists);
 
-       ok = verify_wa_lists(gt, &lists, "before reset");
+       ok = verify_wa_lists(gt, lists, "before reset");
        if (!ok)
                goto out;
 
        intel_gt_reset(gt, ALL_ENGINES, "live_workarounds");
 
-       ok = verify_wa_lists(gt, &lists, "after reset");
+       ok = verify_wa_lists(gt, lists, "after reset");
 
 out:
-       reference_lists_fini(gt, &lists);
+       reference_lists_fini(gt, lists);
        intel_runtime_pm_put(gt->uncore->rpm, wakeref);
        igt_global_reset_unlock(gt);
+       kfree(lists);
 
        return ok ? 0 : -ESRCH;
 }
@@ -1214,16 +1219,20 @@ live_engine_reset_workarounds(void *arg)
        struct igt_spinner spin;
        struct i915_request *rq;
        intel_wakeref_t wakeref;
-       struct wa_lists lists;
+       struct wa_lists *lists;
        int ret = 0;
 
        if (!intel_has_reset_engine(gt))
                return 0;
 
+       lists = kzalloc(sizeof(*lists), GFP_KERNEL);
+       if (!lists)
+               return -ENOMEM;
+
        igt_global_reset_lock(gt);
        wakeref = intel_runtime_pm_get(gt->uncore->rpm);
 
-       reference_lists_init(gt, &lists);
+       reference_lists_init(gt, lists);
 
        for_each_engine(engine, gt, id) {
                bool ok;
@@ -1235,7 +1244,7 @@ live_engine_reset_workarounds(void *arg)
                        break;
                }
 
-               ok = verify_wa_lists(gt, &lists, "before reset");
+               ok = verify_wa_lists(gt, lists, "before reset");
                if (!ok) {
                        ret = -ESRCH;
                        goto err;
@@ -1247,7 +1256,7 @@ live_engine_reset_workarounds(void *arg)
                        goto err;
                }
 
-               ok = verify_wa_lists(gt, &lists, "after idle reset");
+               ok = verify_wa_lists(gt, lists, "after idle reset");
                if (!ok) {
                        ret = -ESRCH;
                        goto err;
@@ -1282,7 +1291,7 @@ live_engine_reset_workarounds(void *arg)
                igt_spinner_end(&spin);
                igt_spinner_fini(&spin);
 
-               ok = verify_wa_lists(gt, &lists, "after busy reset");
+               ok = verify_wa_lists(gt, lists, "after busy reset");
                if (!ok) {
                        ret = -ESRCH;
                        goto err;
@@ -1294,9 +1303,10 @@ err:
                        break;
        }
 
-       reference_lists_fini(gt, &lists);
+       reference_lists_fini(gt, lists);
        intel_runtime_pm_put(gt->uncore->rpm, wakeref);
        igt_global_reset_unlock(gt);
+       kfree(lists);
 
        igt_flush_test(gt->i915);