summaryrefslogtreecommitdiff
path: root/tests/kms_cursor_legacy.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-05-23 21:56:01 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2016-05-23 22:29:04 +0100
commit9579e5447aa304d0b8d36688b8d0da0c97ca284a (patch)
treeb4539164e830ce8989701a1e67c9c4a71f06c7c0 /tests/kms_cursor_legacy.c
parentf68735773c7b6597cf416c89c21e3be38c58f864 (diff)
test: Add legacy cursor stress test
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tests/kms_cursor_legacy.c')
-rw-r--r--tests/kms_cursor_legacy.c109
1 files changed, 109 insertions, 0 deletions
diff --git a/tests/kms_cursor_legacy.c b/tests/kms_cursor_legacy.c
new file mode 100644
index 00000000..75827908
--- /dev/null
+++ b/tests/kms_cursor_legacy.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright © 2013 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+
+#define _GNU_SOURCE
+#include <sched.h>
+
+#include "igt.h"
+
+IGT_TEST_DESCRIPTION("Stress legacy cursor ioctl");
+
+struct data {
+ int fd;
+};
+
+static uint32_t state = 0x12345678;
+
+static uint32_t
+hars_petruska_f54_1_random (void)
+{
+#define rol(x,k) ((x << k) | (x >> (32-k)))
+ return state = (state ^ rol (state, 5) ^ rol (state, 24)) + 0x37798849;
+#undef rol
+}
+
+static void stress(struct data *data, unsigned mode, int timeout)
+{
+ drmModeRes *r;
+ struct drm_mode_cursor arg;
+ int n;
+
+ r = drmModeGetResources(data->fd);
+ igt_assert(r);
+
+ memset(&arg, 0, sizeof(arg));
+ arg.flags = DRM_MODE_CURSOR_BO;
+ arg.crtc_id = 0;
+ arg.width = 64;
+ arg.height = 64;
+ arg.handle = gem_create(data->fd, 4*64*64);
+
+ for (n = 0; n < r->count_crtcs; n++)
+ drmIoctl(data->fd, DRM_IOCTL_MODE_CURSOR, &arg);
+
+ arg.flags = mode;
+ igt_fork(child, sysconf(_SC_NPROCESSORS_ONLN)) {
+ struct sched_param rt = {.sched_priority = 99 };
+ cpu_set_t allowed;
+ unsigned long count = 0;
+
+ sched_setscheduler(getpid(), SCHED_RR, &rt);
+
+ CPU_ZERO(&allowed);
+ CPU_SET(child, &allowed);
+ sched_setaffinity(getpid(), sizeof(cpu_set_t), &allowed);
+
+ igt_until_timeout(timeout) {
+ arg.crtc_id = r->crtcs[hars_petruska_f54_1_random() % r->count_crtcs];
+ do_ioctl(data->fd, DRM_IOCTL_MODE_CURSOR, &arg);
+ count++;
+ }
+
+ igt_info("[%d] count=%lu\n", child, count);
+ }
+ igt_waitchildren();
+
+ gem_close(data->fd, arg.handle);
+ drmModeFreeResources(r);
+}
+
+igt_main
+{
+ struct data data = { .fd = -1 };
+
+ igt_skip_on_simulation();
+
+ igt_fixture {
+ data.fd = drm_open_driver_master(DRIVER_INTEL);
+ kmstest_set_vt_graphics_mode();
+ }
+
+ igt_subtest("stress-bo")
+ stress(&data, DRM_MODE_CURSOR_BO, 20);
+ igt_subtest("stress-move")
+ stress(&data, DRM_MODE_CURSOR_MOVE, 20);
+
+ igt_fixture {
+ }
+}