summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2018-09-04 13:43:12 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2018-09-04 15:00:15 +0100
commit93a1b39fcbbe18199165ce6000e26a0c1b082fb3 (patch)
tree5de9067a398fa70230369ac8e23ba5391455a7f3 /tests
parent67fbe2967889484f1248d851c068e1021f2dc332 (diff)
igt/pm_rps: Clear previous high load on high->low transition
Make sure we do flush out the previous spinner and delay signaling transition completion until we do. References: https://bugs.freedesktop.org/show_bug.cgi?id=102250 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Katarzyna Dec <katarzyna.dec@intel.com> Reviewed-by: Katarzyna Dec <katarzyna.dec@intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/pm_rps.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/tests/pm_rps.c b/tests/pm_rps.c
index 84e71fa8..d20cd2d8 100644
--- a/tests/pm_rps.c
+++ b/tests/pm_rps.c
@@ -198,12 +198,17 @@ static void load_helper_signal_handler(int sig)
lh.exit = true;
}
+static void load_helper_sync(void)
+{
+ bool dummy;
+
+ igt_assert_eq(read(lh.link, &dummy, sizeof(dummy)), sizeof(dummy));
+}
+
#define LOAD_HELPER_PAUSE_USEC 500
#define LOAD_HELPER_BO_SIZE (16*1024*1024)
static void load_helper_set_load(enum load load)
{
- bool dummy;
-
igt_assert(lh.igt_proc.running);
if (lh.load == load)
@@ -213,7 +218,7 @@ static void load_helper_set_load(enum load load)
kill(lh.igt_proc.pid, SIGUSR2);
/* wait for load-helper to switch */
- igt_assert_eq(read(lh.link, &dummy, sizeof(dummy)), sizeof(dummy));
+ load_helper_sync();
}
static void load_helper_run(enum load load)
@@ -233,13 +238,14 @@ static void load_helper_run(enum load load)
lh.exit = false;
lh.load = load;
- lh.signal = false;
+ lh.signal = true;
pipe(link);
lh.link = link[1];
igt_fork_helper(&lh.igt_proc) {
igt_spin_t *spin[2] = {};
+ bool prev_load;
uint32_t handle;
signal(SIGUSR1, load_helper_signal_handler);
@@ -247,10 +253,14 @@ static void load_helper_run(enum load load)
igt_debug("Applying %s load...\n", lh.load ? "high" : "low");
+ prev_load = lh.load == HIGH;
spin[0] = __igt_spin_batch_new(drm_fd);
- if (lh.load == HIGH)
+ if (prev_load)
spin[1] = __igt_spin_batch_new(drm_fd);
+ prev_load = !prev_load; /* send the initial signal */
while (!lh.exit) {
+ bool high_load;
+
handle = spin[0]->handle;
igt_spin_batch_end(spin[0]);
while (gem_bo_busy(drm_fd, handle))
@@ -259,13 +269,20 @@ static void load_helper_run(enum load load)
igt_spin_batch_free(drm_fd, spin[0]);
usleep(100);
- spin[0] = spin[1];
- spin[lh.load == HIGH] = __igt_spin_batch_new(drm_fd);
+ high_load = lh.load == HIGH;
+ if (!high_load && spin[1]) {
+ igt_spin_batch_free(drm_fd, spin[1]);
+ spin[1] = NULL;
+ } else {
+ spin[0] = spin[1];
+ }
+ spin[high_load] = __igt_spin_batch_new(drm_fd);
- if (lh.signal) {
+ if (lh.signal && high_load != prev_load) {
write(lh.link, &lh.signal, sizeof(lh.signal));
lh.signal = false;
}
+ prev_load = high_load;
}
handle = spin[0]->handle;
@@ -294,6 +311,9 @@ static void load_helper_run(enum load load)
close(lh.link);
lh.link = link[0];
+
+ /* wait for our helper to complete its first round */
+ load_helper_sync();
}
static void load_helper_stop(void)