From: Gustavo Padovan <gustavo@padovan.org>
To: intel-gfx@lists.freedesktop.org
Cc: Gustavo Padovan <gustavo.padovan@collabora.co.uk>,
dri-devel@lists.freedesktop.org
Subject: [PATCH 11/12] tests/kms_atomic_transition: add in_fences tests
Date: Mon, 14 Nov 2016 18:59:25 +0900 [thread overview]
Message-ID: <1479117566-17709-14-git-send-email-gustavo@padovan.org> (raw)
In-Reply-To: <1479117566-17709-1-git-send-email-gustavo@padovan.org>
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
tests/kms_atomic_transition.c | 92 ++++++++++++++++++++++++++++++++++++++-----
1 file changed, 82 insertions(+), 10 deletions(-)
diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c
index 507f526..54fc9da 100644
--- a/tests/kms_atomic_transition.c
+++ b/tests/kms_atomic_transition.c
@@ -23,7 +23,9 @@
#include "igt.h"
#include "drmtest.h"
+#include "sw_sync.h"
#include <errno.h>
+#include <pthread.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
@@ -111,6 +113,78 @@ enum transition_type {
TRANSITION_MODESET_DISABLE,
};
+int timeline[IGT_MAX_PLANES];
+pthread_t thread[IGT_MAX_PLANES];
+int seqno[IGT_MAX_PLANES];
+
+static void prepare_fencing(igt_display_t *display, enum pipe pipe)
+{
+ igt_plane_t *plane;
+
+ for_each_plane_on_pipe(display, pipe, plane)
+ timeline[plane->index] = sw_sync_timeline_create();
+}
+
+static void unprepare_fencing(igt_display_t *display, enum pipe pipe)
+{
+ igt_plane_t *plane;
+
+ for_each_plane_on_pipe(display, pipe, plane)
+ close(timeline[plane->index]);
+}
+
+static void *fence_inc_thread(void *arg)
+{
+ int t = *((int *) arg);
+
+ pthread_detach(pthread_self());
+
+ usleep(5000);
+ sw_sync_timeline_inc(t, 1);
+ return NULL;
+}
+
+static void configure_fencing(igt_display_t *display, enum pipe pipe)
+{
+ igt_plane_t *plane;
+ int i, fd, ret;
+
+ for_each_plane_on_pipe(display, pipe, plane) {
+
+ if (!plane->fb)
+ continue;
+
+ i = plane->index;
+
+ seqno[i]++;
+ fd = sw_sync_fence_create(timeline[i], seqno[i]);
+ igt_plane_set_fence_fd(plane, fd);
+ ret = pthread_create(&thread[i], NULL, fence_inc_thread, &timeline[i]);
+ igt_assert_eq(ret, 0);
+ }
+}
+
+static void clear_fencing(igt_display_t *display, enum pipe pipe)
+{
+ igt_plane_t *plane;
+
+ for_each_plane_on_pipe(display, pipe, plane)
+ igt_plane_set_fence_fd(plane, -1);
+}
+
+static void atomic_commit(igt_display_t *display, enum pipe pipe, unsigned int flags, void *data, bool fencing, int *out_fence)
+{
+ if (fencing) {
+ configure_fencing(display, pipe);
+ igt_pipe_set_out_fence_ptr(&display->pipes[pipe], out_fence);
+ }
+
+ igt_display_commit_atomic(display, flags, data);
+
+ if (fencing)
+ clear_fencing(display, pipe);
+}
+
/*
* 1. Set primary plane to a known fb.
* 2. Make sure getcrtc returns the correct fb id.
@@ -134,6 +208,9 @@ run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t *output
unsigned flags = DRM_MODE_PAGE_FLIP_EVENT;
int out_fence, ret;
+ if (fencing)
+ prepare_fencing(display, pipe);
+
if (nonblocking)
flags |= DRM_MODE_ATOMIC_NONBLOCK;
@@ -233,10 +310,8 @@ run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t *output
wm_setup_plane(display, pipe, i, parms);
- if (fencing)
- igt_pipe_set_out_fence_ptr(&display->pipes[pipe], &out_fence);
+ atomic_commit(display, pipe, flags, (void *)(unsigned long)i, fencing, &out_fence);
- igt_display_commit_atomic(display, flags, (void *)(unsigned long)i);
drmHandleEvent(display->drm_fd, &drm_events);
if (type == TRANSITION_MODESET_DISABLE) {
@@ -260,19 +335,14 @@ run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t *output
if (type == TRANSITION_MODESET)
igt_output_override_mode(output, &override_mode);
- if (fencing)
- igt_pipe_set_out_fence_ptr(&display->pipes[pipe], &out_fence);
-
- igt_display_commit_atomic(display, flags, (void *)(unsigned long)j);
+ atomic_commit(display, pipe, flags, (void *)(unsigned long)i, fencing, &out_fence);
drmHandleEvent(display->drm_fd, &drm_events);
wm_setup_plane(display, pipe, i, parms);
if (type == TRANSITION_MODESET)
igt_output_override_mode(output, NULL);
- if (fencing)
- igt_pipe_set_out_fence_ptr(&display->pipes[pipe], &out_fence);
-
+ atomic_commit(display, pipe, flags, (void *)(unsigned long)i, fencing, &out_fence);
igt_display_commit_atomic(display, flags, (void *)(unsigned long)i);
drmHandleEvent(display->drm_fd, &drm_events);
}
@@ -280,6 +350,8 @@ run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t *output
}
cleanup:
+ unprepare_fencing(display, pipe);
+
igt_output_set_pipe(output, PIPE_NONE);
for_each_plane_on_pipe(display, pipe, plane)
--
2.5.5
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2016-11-14 9:59 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-14 9:59 [PATCH 00/12] kms tests for the DRM fences interfaces Gustavo Padovan
2016-11-14 9:59 ` [PATCH i-g-t 1/2] lib/drmtest: Fix igt_skip message Gustavo Padovan
2016-11-14 9:59 ` [PATCH 01/12] tests/kms_atomic_transition: use select + read instead of blocking read Gustavo Padovan
2016-11-15 7:57 ` Daniel Vetter
2016-11-14 9:59 ` [PATCH i-g-t 2/2] lib/drmtest: add virtio_gpu support Gustavo Padovan
2016-11-14 9:59 ` [PATCH 02/12] tests/kms_atomic_transition: don't assume max pipes Gustavo Padovan
2016-11-15 8:01 ` [Intel-gfx] " Daniel Vetter
2016-11-15 13:25 ` Tomeu Vizoso
2016-11-15 15:30 ` [Intel-gfx] " Robert Foss
2016-11-14 9:59 ` [PATCH 03/12] lib/igt_kms: move igt_kms_get_alt_edid() to the right place Gustavo Padovan
2016-11-14 9:59 ` [PATCH 04/12] lib/igt_kms: export properties names Gustavo Padovan
2016-11-15 8:34 ` [Intel-gfx] " Daniel Vetter
2016-11-14 9:59 ` [PATCH 05/12] tests/kms_atomic: use global atomic properties definitions Gustavo Padovan
2016-11-14 9:59 ` [PATCH 06/12] lib/igt_kms: Add support for the IN_FENCE_FD property Gustavo Padovan
2016-11-22 11:41 ` Brian Starkey
2016-11-14 9:59 ` [PATCH 07/12] lib/igt_kms: Add support for the OUT_FENCE_PTR property Gustavo Padovan
2016-11-22 10:53 ` [Intel-gfx] " Brian Starkey
2016-11-22 11:06 ` Chris Wilson
2016-11-22 11:54 ` Brian Starkey
2016-11-22 12:10 ` [Intel-gfx] " Chris Wilson
2016-11-22 12:37 ` Brian Starkey
2016-11-22 13:12 ` Daniel Vetter
2016-11-22 13:50 ` Brian Starkey
2016-11-22 13:56 ` Daniel Vetter
2016-11-22 14:06 ` Brian Starkey
2016-11-14 9:59 ` [PATCH 08/12] tests/kms_atomic: stress possible fence settings Gustavo Padovan
2016-11-15 8:39 ` Daniel Vetter
2016-11-14 9:59 ` [PATCH 09/12] tests/kms_atomic_transition: add fencing parameter to run_transition_tests Gustavo Padovan
2016-11-14 9:59 ` [PATCH 10/12] tests/kms_atomic_transition: add out_fences tests Gustavo Padovan
2016-11-14 9:59 ` Gustavo Padovan [this message]
2016-11-14 9:59 ` [PATCH 12/12] tests/kms_atomic_transition: set out_fence for all crtcs Gustavo Padovan
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=1479117566-17709-14-git-send-email-gustavo@padovan.org \
--to=gustavo@padovan.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gustavo.padovan@collabora.co.uk \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).