Skip to contentSkip to conversation

tests/kms_atomic_abi: Test event ABI corner cases

PATCH In review Mika Kahola 2 participants 2 messages Apr 27, 2017 – May 3, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/kms_atomic_abi: Test event ABI corner cases

Atomic has a few special cases around async commits and event generation that we need to test. This patch addresses these two tests

- kernel rejects events on a disabled pipe
- events on a pipe that is getting enabled/disabled

For: VIZ-6954

---
 tests/Makefile.sources |   1 +
 tests/kms_atomic_abi.c | 201 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 202 insertions(+)
 create mode 100644 tests/kms_atomic_abi.c
tests/Makefile.sources +1 -0
index 2b6e6ee..b4e9897 100644
@@ -121,6 +121,7 @@ TESTS_progs_M = \
 	kms_plane \
 	kms_plane_multiple \
 	kms_plane_lowres \
+	kms_atomic_abi \
 	kms_properties \
 	kms_psr_sink_crc \
 	kms_render \
tests/kms_atomic_abi.c new file +201 -0

201 lines not on this page · raw message

Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

Op 27-04-17 om 14:42 schreef Mika Kahola:

Quoted 65 lines

Atomic has a few special cases around async commits and event generation that we need to test. This patch addresses these two tests

- kernel rejects events on a disabled pipe
- events on a pipe that is getting enabled/disabled

For: VIZ-6954

---
 tests/Makefile.sources |   1 +
 tests/kms_atomic_abi.c | 201 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 202 insertions(+)
 create mode 100644 tests/kms_atomic_abi.c
tests/Makefile.sources +1 -0
index 2b6e6ee..b4e9897 100644
@@ -121,6 +121,7 @@ TESTS_progs_M = \
 	kms_plane \
 	kms_plane_multiple \
 	kms_plane_lowres \
+	kms_atomic_abi \
 	kms_properties \
 	kms_psr_sink_crc \
 	kms_render \
tests/kms_atomic_abi.c new file +32 -0
new file mode 100644
index 0000000..843220b
@@ -0,0 +1,201 @@
+/*
+ * Copyright © 2017 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.
+ *
+ */
+
+#include "igt.h"
+#include <fcntl.h>
+
+IGT_TEST_DESCRIPTION("Test event ABI");
+
+static void
+do_atomic_commit(igt_display_t *display, int expectation)
+{

tests/kms_atomic_abi.c line 42

Quoted 10 lines
tests/kms_atomic_abi.c new file +10 -0
+	char buf[256];
+	struct drm_event *e = (void *)buf;
+	int ret;
+
+	ret = igt_display_try_commit_atomic(display,
+					    DRM_MODE_PAGE_FLIP_EVENT,
+					    NULL);
+	igt_assert_eq(ret, expectation);
+
+	if (expectation == 0) {

I know they're equal, but should be ret == 0 for clarity? :)

Might even be better for readability to remove this function entirely and add a bool to read_pageflip_event whether an event is expected and return error on failure. :)

Quoted 12 lines
tests/kms_atomic_abi.c new file +12 -0
+		igt_set_timeout(1, "Stuck on page flip");
+		ret = read(display->drm_fd, buf, sizeof(buf));
+		igt_assert(ret >= 0);
+
+		igt_reset_timeout();
+		igt_assert_eq(e->type, DRM_EVENT_FLIP_COMPLETE);
+	}
+}
+
+static int
+read_pageflip_event(igt_display_t *display)
+{

tests/kms_atomic_abi.c line 65

Quoted 10 lines
tests/kms_atomic_abi.c new file +10 -0
+	char buf[256];
+	struct drm_event *e = (void *)buf;
+	int ret;
+
+	for (int i = 0; i < 100; i++) {
+		ret = read(display->drm_fd, buf, sizeof(buf));
+
+		if (ret >= 0)
+			break;
+	}

I think just reading 100 times would cause the test to depend on how fast the system is. Might be better to use poll(50ms) + (optional) read() instead? Would also mean the NONBLOCK fudging can be removed. :)

Quoted 23 lines
tests/kms_atomic_abi.c new file +23 -0
+
+	if (ret >= 0)
+		igt_assert_eq(e->type, DRM_EVENT_FLIP_COMPLETE);
+
+	return ret;
+}
+
+static void
+test_init(igt_display_t *display, enum pipe pipe, igt_output_t *output)
+{
+	struct igt_fb fb;
+	drmModeModeInfo *mode;
+	igt_plane_t *primary;
+	int flags = DRM_MODE_ATOMIC_ALLOW_MODESET | DRM_MODE_ATOMIC_NONBLOCK;
+	int ret;
+
+	igt_output_set_pipe(output, pipe);
+
+	primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+
+	mode = igt_output_get_mode(output);
+
+	igt_create_color_fb(display->drm_fd, mode->hdisplay, mode->vdisplay,

tests/kms_atomic_abi.c line 98

Quoted 10 lines
tests/kms_atomic_abi.c new file +10 -0
+			    DRM_FORMAT_XRGB8888,
+			    LOCAL_DRM_FORMAT_MOD_NONE,
+			    0.0f, 0.0f, 1.0f,
+			    &fb);
+
+	igt_plane_set_fb(primary, &fb);
+
+	ret = igt_display_try_commit_atomic(display, flags, NULL);
+	igt_assert_eq(ret, 0);
+}

modeset disable should generate a valid event too, as should modeset enable. Might test those here too? :)

Quoted 25 lines
tests/kms_atomic_abi.c new file +25 -0
+
+static void
+test_disable_pipe(igt_display_t *display, enum pipe pipe, igt_output_t *output)
+{
+	test_init(display, pipe, output);
+
+	igt_output_set_pipe(output, pipe);
+
+	do_atomic_commit(display, 0);
+
+	/* disable pipe */
+	igt_output_set_pipe(output, PIPE_NONE);
+
+	/* try to do atomic commit */
+	do_atomic_commit(display, -EINVAL);
+
+	igt_output_set_pipe(output, PIPE_ANY);
+}
+
+static void
+test_dpms(igt_display_t *display, enum pipe pipe, igt_output_t *output)
+{
+	int ret;
+	int flags = fcntl(display->drm_fd, F_GETFL, 0);
+

tests/kms_atomic_abi.c line 133

Quoted 10 lines
tests/kms_atomic_abi.c new file +10 -0
+	test_init(display, pipe, output);
+
+	igt_output_set_pipe(output, pipe);
+
+	do_atomic_commit(display, 0);
+
+	fcntl(display->drm_fd, F_SETFL, flags | O_NONBLOCK);
+
+	kmstest_set_connector_dpms(display->drm_fd, output->config.connector,
+				   DRM_MODE_DPMS_OFF);

It might be worth adding the pipe active property that's reset to default on each call to igt_output_set_pipe, so the default will be track pipe enabled, but with the option to override to always on or always off.

tests/kms_atomic_abi.c line 143

Quoted 9 lines
tests/kms_atomic_abi.c new file +9 -0
+	/* try to do atomic commit */
+	ret = igt_display_try_commit_atomic(display,
+					    DRM_MODE_PAGE_FLIP_EVENT,
+					    NULL);
+	igt_assert_eq(ret, 0);
+
+	/* with pipe off, we shouldn't receive pageflip event */
+	ret = read_pageflip_event(display);
+	igt_assert_eq(ret, -1);

Either try_commit_atomic fails during DPMS off and we return -EINVAL, or we succeed and get an event here. I'm not sure this test works the way you expect it to. Either way it's likely this test is broken here. :)

Quoted 48 lines
tests/kms_atomic_abi.c new file +48 -0
+
+	fcntl(display->drm_fd, F_SETFL, flags & ~O_NONBLOCK);
+
+	kmstest_set_connector_dpms(display->drm_fd, output->config.connector,
+				   DRM_MODE_DPMS_ON);
+
+	igt_output_set_pipe(output, PIPE_ANY);
+
+	fcntl(display->drm_fd, F_SETFL, flags & ~O_NONBLOCK);
+}
+
+igt_main
+{
+	igt_output_t *output;
+	igt_display_t display;
+	enum pipe pipe;
+	int valid_tests;
+
+	igt_skip_on_simulation();
+
+	igt_fixture {
+		display.drm_fd = drm_open_driver_master(DRIVER_ANY);
+		kmstest_set_vt_graphics_mode();
+		igt_display_init(&display, display.drm_fd);
+		igt_require(display.is_atomic);
+	}
+
+	igt_subtest_f("disabled-pipe") {
+		valid_tests = 0;
+		for_each_pipe_with_valid_output(&display, pipe, output) {
+			test_disable_pipe(&display, pipe, output);
+
+			valid_tests++;
+			break;
+		}
+
+		igt_require_f(valid_tests, "no valid crtc/connector combinations found\n");
+	}
+
+	igt_subtest_f("dpms") {
+		valid_tests = 0;
+		for_each_pipe_with_valid_output(&display, pipe, output) {
+			test_dpms(&display, pipe, output);
+
+			valid_tests++;
+			break;
+		}
+

tests/kms_atomic_abi.c line 201

Quoted 10 lines
tests/kms_atomic_abi.c new file +10 -0
+		igt_require_f(valid_tests, "no valid crtc/connector combinations found\n");
+	}
+
+	igt_fixture {
+		igt_display_fini(&display);
+		close(display.drm_fd);
+	}
+
+	igt_exit();
+}

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx