diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2015-04-02 11:37:23 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2015-04-02 11:45:17 +0100 |
commit | 590e47c94fd81a182e24b41a715d84491df8cea8 (patch) | |
tree | fcd98e4cb3abb437a8ceb51765ab72552ca3c63e /tests/kms_vblank.c | |
parent | 992f9f6403b95b9822cb651b38d14a95bebc4e73 (diff) |
igt/kms_vblank: Include a test for comparing blocking drmWaitVblank
The other aspect of the spinlock/interrupt on-off overhead is that when
we wait for vblank it immediately turns off, and then we immediately turn
it back on for the next wait.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tests/kms_vblank.c')
-rw-r--r-- | tests/kms_vblank.c | 55 |
1 files changed, 50 insertions, 5 deletions
diff --git a/tests/kms_vblank.c b/tests/kms_vblank.c index 5a00cccf..03db6fd5 100644 --- a/tests/kms_vblank.c +++ b/tests/kms_vblank.c @@ -67,12 +67,12 @@ static bool crtc0_active(int fd) return drmIoctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl) == 0; } -static void query(int fd, bool busy) +static void vblank_query(int fd, bool busy) { union drm_wait_vblank vbl; struct timespec start, end; unsigned long sq, count = 0; - char buf[4096]; + struct drm_event_vblank buf; memset(&vbl, 0, sizeof(vbl)); @@ -101,7 +101,46 @@ static void query(int fd, bool busy) busy ? "busy" : "idle", elapsed(&start, &end, count)); if (busy) - igt_assert_eq(read(fd, buf, sizeof(buf)), sizeof(buf)); + igt_assert_eq(read(fd, &buf, sizeof(buf)), sizeof(buf)); +} + +static void vblank_wait(int fd, bool busy) +{ + union drm_wait_vblank vbl; + struct timespec start, end; + unsigned long sq, count = 0; + struct drm_event_vblank buf; + + memset(&vbl, 0, sizeof(vbl)); + + if (busy) { + vbl.request.type = DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT; + vbl.request.sequence = 72; + do_or_die(drmIoctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl)); + } + + vbl.request.type = DRM_VBLANK_RELATIVE; + vbl.request.sequence = 0; + do_or_die(drmIoctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl)); + + sq = vbl.reply.sequence; + + clock_gettime(CLOCK_MONOTONIC, &start); + do { + vbl.request.type = DRM_VBLANK_RELATIVE; + vbl.request.sequence = 1; + do_or_die(drmIoctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl)); + count++; + } while ((vbl.reply.sequence - sq) <= 60); + clock_gettime(CLOCK_MONOTONIC, &end); + + igt_info("Time to wait for %ld/%d vblanks (%s): %7.3fµs\n", + count, (int)(vbl.reply.sequence - sq), + busy ? "busy" : "idle", + elapsed(&start, &end, count)); + + if (busy) + igt_assert_eq(read(fd, &buf, sizeof(buf)), sizeof(buf)); } igt_main @@ -116,8 +155,14 @@ igt_main } igt_subtest("query-idle") - query(fd, false); + vblank_query(fd, false); igt_subtest("query-busy") - query(fd, true); + vblank_query(fd, true); + + igt_subtest("wait-idle") + vblank_wait(fd, false); + + igt_subtest("wait-busy") + vblank_wait(fd, true); } |