All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH i-g-t 1/3] lib/igt_kms: Drop all stale events on first commit.
Date: Thu,  7 Dec 2017 14:40:25 +0100	[thread overview]
Message-ID: <20171207134027.61108-1-maarten.lankhorst@linux.intel.com> (raw)

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>
---
 lib/igt_kms.c | 39 ++++++++++++++++++++++++++++++++++++++-
 lib/igt_kms.h |  1 +
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 223dbe4ca565..9e14f071ea57 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,36 @@ 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.
+ */
+void igt_display_drop_events(igt_display_t *display)
+{
+	/* 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);
+	}
+}
+
 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 2a480bf39956..342881a69177 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -360,6 +360,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);
+void 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);
-- 
2.15.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

             reply	other threads:[~2017-12-07 13:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-07 13:40 Maarten Lankhorst [this message]
2017-12-07 13:40 ` [PATCH i-g-t 2/3] tests/kms_cursor_legacy: Perform lazy cleanup between tests Maarten Lankhorst
2017-12-22  9:14   ` Mika Kahola
2017-12-22 12:50   ` Mika Kahola
2017-12-07 13:40 ` [PATCH i-g-t 3/3] tests/kms_cursor_legacy: Rework the 2x-*-vs-cursor-* tests Maarten Lankhorst
2017-12-22  8:55   ` Mika Kahola
2018-01-02  8:45     ` Maarten Lankhorst
2017-12-07 15:03 ` [PATCH i-g-t 1/3] lib/igt_kms: Drop all stale events on first commit Chris Wilson
2017-12-07 15:42   ` Maarten Lankhorst
2017-12-07 15:50     ` Chris Wilson
2017-12-07 15:57       ` Maarten Lankhorst
2017-12-07 16:12         ` Chris Wilson
2017-12-19 13:18           ` Chris Wilson
2017-12-07 18:43 ` ✓ Fi.CI.BAT: success for series starting with [1/3] " Patchwork
2017-12-07 22:54 ` ✗ Fi.CI.IGT: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171207134027.61108-1-maarten.lankhorst@linux.intel.com \
    --to=maarten.lankhorst@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.