Avoid having to test for spin[0] existing by starting the load-loop with it allocated. v2: Preallocate the spin[1] as well for high load. References: https://bugs.freedesktop.org/show_bug.cgi?id=104060 Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> --- tests/pm_rps.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/tests/pm_rps.c b/tests/pm_rps.c index 57633c547..6148f5532 100644 --- a/tests/pm_rps.c +++ b/tests/pm_rps.c @@ -191,6 +191,7 @@ static void load_helper_signal_handler(int sig) if (sig == SIGUSR2) { lh.load = !lh.load; igt_debug("Switching background load to %s\n", lh.load ? "high" : "low"); + usleep(200); /* wait for a spin-batch cycle */ } else lh.exit = true; } @@ -231,24 +232,26 @@ static void load_helper_run(enum load load) igt_debug("Applying %s load...\n", lh.load ? "high" : "low"); + spin[0] = igt_spin_batch_new(drm_fd, 0, 0, 0); + if (lh.load == HIGH) + spin[1] = __igt_spin_batch_new(drm_fd, 0, 0, 0); while (!lh.exit) { - if (spin[0]) { - handle = spin[0]->handle; - igt_spin_batch_end(spin[0]); - while (gem_bo_busy(drm_fd, handle)) - usleep(100); - igt_spin_batch_free(drm_fd, spin[0]); + handle = spin[0]->handle; + igt_spin_batch_end(spin[0]); + while (gem_bo_busy(drm_fd, handle)) usleep(100); - } + + igt_spin_batch_free(drm_fd, spin[0]); + usleep(100); + spin[0] = spin[1]; spin[lh.load == HIGH] = - igt_spin_batch_new(drm_fd, 0, 0, 0); + __igt_spin_batch_new(drm_fd, 0, 0, 0); } - if (spin[0]) { - handle = spin[0]->handle; - igt_spin_batch_end(spin[0]); - } + handle = spin[0]->handle; + igt_spin_batch_end(spin[0]); + if (spin[1]) { handle = spin[1]->handle; igt_spin_batch_end(spin[1]); -- 2.15.1 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx