diff options
author | Maarten Lankhorst <maarten.lankhorst@linux.intel.com> | 2017-12-07 09:21:36 +0100 |
---|---|---|
committer | Maarten Lankhorst <maarten.lankhorst@linux.intel.com> | 2018-01-02 09:38:45 +0100 |
commit | 98c64b33a7935fb334c73bb0fc9e76f416b81069 (patch) | |
tree | 89cc360dfe3a59d5bde4b43fbfcd372a15f4c0d3 | |
parent | 4cd4cc4873fc1c916b6bf7b058b12294e16dfd98 (diff) |
lib/igt_kms: Drop all stale events on first commit.
I've been trying to make kms_cursor_legacy work when subtests fail.
Other subtests will start failing too because of expired events or
stale pipe crc. The latter can be resolved in the test, but the former
could affect other tests
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
[mlankhorst: Change return status to int, so callers can see how many events are swallowed.]
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | lib/igt_kms.c | 46 | ||||
-rw-r--r-- | lib/igt_kms.h | 1 |
2 files changed, 46 insertions, 1 deletions
diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 1242324e..ec3b7167 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -2943,7 +2943,10 @@ display_commit_changed(igt_display_t *display, enum igt_commit_style s) output->changed &= 1 << IGT_CONNECTOR_CRTC_ID; } - display->first_commit = false; + if (display->first_commit) { + igt_display_drop_events(display); + display->first_commit = false; + } } /* @@ -3024,6 +3027,10 @@ int igt_display_try_commit_atomic(igt_display_t *display, uint32_t flags, void * if (ret || (flags & DRM_MODE_ATOMIC_TEST_ONLY)) return ret; + if (display->first_commit) + igt_fail_on_f(flags & (DRM_MODE_PAGE_FLIP_EVENT | DRM_MODE_ATOMIC_NONBLOCK), + "First commit has to drop all stale events\n"); + display_commit_changed(display, COMMIT_ATOMIC); igt_debug_wait_for_keypress("modeset"); @@ -3121,6 +3128,43 @@ int igt_display_commit(igt_display_t *display) return igt_display_commit2(display, COMMIT_LEGACY); } +/** + * igt_display_drop_events: + * @display: DRM device handle + * + * Nonblockingly reads all current events and drops them, for highest + * reliablility, call igt_display_commit2() first to flush all outstanding + * events. + * + * This will be called on the first commit after igt_display_reset() too, + * to make sure any stale events are flushed. + * + * Returns: Number of dropped events. + */ +int igt_display_drop_events(igt_display_t *display) +{ + int ret = 0; + + /* Clear all events from drm fd. */ + struct pollfd pfd = { + .fd = display->drm_fd, + .events = POLLIN + }; + + while (poll(&pfd, 1, 0) > 0) { + struct drm_event ev; + char buf[128]; + + read(display->drm_fd, &ev, sizeof(ev)); + igt_info("Dropping event type %u length %u\n", ev.type, ev.length); + igt_assert(ev.length <= sizeof(buf)); + read(display->drm_fd, buf, ev.length); + ret++; + } + + return ret; +} + const char *igt_output_name(igt_output_t *output) { return output->name; diff --git a/lib/igt_kms.h b/lib/igt_kms.h index cfe646ae..7b1ae8b5 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -365,6 +365,7 @@ int igt_display_commit(igt_display_t *display); int igt_display_try_commit_atomic(igt_display_t *display, uint32_t flags, void *user_data); void igt_display_commit_atomic(igt_display_t *display, uint32_t flags, void *user_data); int igt_display_try_commit2(igt_display_t *display, enum igt_commit_style s); +int igt_display_drop_events(igt_display_t *display); int igt_display_get_n_pipes(igt_display_t *display); void igt_display_require_output(igt_display_t *display); void igt_display_require_output_on_pipe(igt_display_t *display, enum pipe pipe); |