Re: [Intel-gfx] [PATCH i-g-t v4 09/11] tests/kms_atomic_transition: add out_fences tests
On 2017-02-01 05:40 AM, Brian Starkey wrote: On Tue, Jan 31, 2017 at 08:25:18PM -0500, Robert Foss wrote: Signed-off-by: Gustavo PadovanSigned-off-by: Robert Foss --- lib/igt_kms.c | 16 + tests/kms_atomic_transition.c | 153 -- 2 files changed, 164 insertions(+), 5 deletions(-) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 7bf3fa3a..64f8b337 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -53,6 +53,7 @@ #include "intel_chipset.h" #include "igt_debugfs.h" #include "igt_sysfs.h" +#include "sw_sync.h" /** * SECTION:igt_kms @@ -2470,6 +2471,21 @@ static int igt_atomic_commit(igt_display_t *display, uint32_t flags, void *user_ } ret = drmModeAtomicCommit(display->drm_fd, req, flags, user_data); +if (!ret) { + +for_each_pipe(display, pipe) { +igt_pipe_t *pipe_obj = >pipes[pipe]; + +if (pipe_obj->out_fence_fd == -1) +continue; + +igt_assert(pipe_obj->out_fence_fd >= 0); +ret = sync_fence_wait(pipe_obj->out_fence_fd, 1000); +igt_assert(ret == 0); +close(pipe_obj->out_fence_fd); Setting it to -1 after closing seems like a good idea. Also see my comment on patch 11 about interactions with get_last_out_fence. -Brian Ack, fixed in v5. Rob. +} +} + drmModeAtomicFree(req); return ret; diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c index 72429759..4b1278a4 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 +#include #include #include #include @@ -253,6 +255,94 @@ retry: sprite_width, sprite_height, alpha); } +int *timeline; +pthread_t *thread; +int *seqno; + +static void prepare_fencing(igt_display_t *display, enum pipe pipe) +{ +igt_plane_t *plane; +int n_planes; + +igt_require_sw_sync(); + +n_planes = display->pipes[pipe].n_planes; +timeline = calloc(sizeof(*timeline), n_planes); +igt_assert_f(timeline != NULL, "Failed to allocate memory for timelines\n"); +thread = calloc(sizeof(*thread), n_planes); +igt_assert_f(thread != NULL, "Failed to allocate memory for thread\n"); +seqno = calloc(sizeof(*seqno), n_planes); +igt_assert_f(seqno != NULL, "Failed to allocate memory for seqno\n"); + +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]); + +free(timeline); +free(thread); +free(seqno); +} + +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_timeline_create_fence(timeline[i], seqno[i]); +igt_plane_set_fence_fd(plane, fd); +close(fd); +ret = pthread_create([i], NULL, fence_inc_thread, [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) +{ +if (fencing) { +configure_fencing(display, pipe); +igt_pipe_request_out_fence(>pipes[pipe]); +} + +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. @@ -273,6 +363,10 @@ run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t *output struct plane_parms parms[display->pipes[pipe].n_planes]; bool skip_test = false; unsigned flags = DRM_MODE_PAGE_FLIP_EVENT; +int ret; + +if (fencing) +prepare_fencing(display, pipe); if (nonblocking) flags |= DRM_MODE_ATOMIC_NONBLOCK; @@ -307,12 +401,48 @@ run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t *output setup_parms(display, pipe, mode, _fb, _fb, parms); +/* + * In some configurations the tests may not run to completion with all + * sprite planes lit up at 4k resolution, try decreasing width/size of secondary + * planes to fix this + */ +while (1) { +
Re: [Intel-gfx] [PATCH i-g-t v4 09/11] tests/kms_atomic_transition: add out_fences tests
On Tue, Jan 31, 2017 at 08:25:18PM -0500, Robert Foss wrote: Signed-off-by: Gustavo PadovanSigned-off-by: Robert Foss --- lib/igt_kms.c | 16 + tests/kms_atomic_transition.c | 153 -- 2 files changed, 164 insertions(+), 5 deletions(-) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 7bf3fa3a..64f8b337 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -53,6 +53,7 @@ #include "intel_chipset.h" #include "igt_debugfs.h" #include "igt_sysfs.h" +#include "sw_sync.h" /** * SECTION:igt_kms @@ -2470,6 +2471,21 @@ static int igt_atomic_commit(igt_display_t *display, uint32_t flags, void *user_ } ret = drmModeAtomicCommit(display->drm_fd, req, flags, user_data); + if (!ret) { + + for_each_pipe(display, pipe) { + igt_pipe_t *pipe_obj = >pipes[pipe]; + + if (pipe_obj->out_fence_fd == -1) + continue; + + igt_assert(pipe_obj->out_fence_fd >= 0); + ret = sync_fence_wait(pipe_obj->out_fence_fd, 1000); + igt_assert(ret == 0); + close(pipe_obj->out_fence_fd); Setting it to -1 after closing seems like a good idea. Also see my comment on patch 11 about interactions with get_last_out_fence. -Brian + } + } + drmModeAtomicFree(req); return ret; diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c index 72429759..4b1278a4 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 +#include #include #include #include @@ -253,6 +255,94 @@ retry: sprite_width, sprite_height, alpha); } +int *timeline; +pthread_t *thread; +int *seqno; + +static void prepare_fencing(igt_display_t *display, enum pipe pipe) +{ + igt_plane_t *plane; + int n_planes; + + igt_require_sw_sync(); + + n_planes = display->pipes[pipe].n_planes; + timeline = calloc(sizeof(*timeline), n_planes); + igt_assert_f(timeline != NULL, "Failed to allocate memory for timelines\n"); + thread = calloc(sizeof(*thread), n_planes); + igt_assert_f(thread != NULL, "Failed to allocate memory for thread\n"); + seqno = calloc(sizeof(*seqno), n_planes); + igt_assert_f(seqno != NULL, "Failed to allocate memory for seqno\n"); + + 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]); + + free(timeline); + free(thread); + free(seqno); +} + +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_timeline_create_fence(timeline[i], seqno[i]); + igt_plane_set_fence_fd(plane, fd); + close(fd); + ret = pthread_create([i], NULL, fence_inc_thread, [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) +{ + if (fencing) { + configure_fencing(display, pipe); + igt_pipe_request_out_fence(>pipes[pipe]); + } + + 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. @@ -273,6 +363,10 @@ run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t *output struct plane_parms parms[display->pipes[pipe].n_planes]; bool skip_test = false; unsigned flags = DRM_MODE_PAGE_FLIP_EVENT; + int ret; + + if (fencing) + prepare_fencing(display, pipe); if (nonblocking) flags |= DRM_MODE_ATOMIC_NONBLOCK; @@ -307,12 +401,48 @@ run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t *output
[Intel-gfx] [PATCH i-g-t v4 09/11] tests/kms_atomic_transition: add out_fences tests
Signed-off-by: Gustavo PadovanSigned-off-by: Robert Foss --- lib/igt_kms.c | 16 + tests/kms_atomic_transition.c | 153 -- 2 files changed, 164 insertions(+), 5 deletions(-) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 7bf3fa3a..64f8b337 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -53,6 +53,7 @@ #include "intel_chipset.h" #include "igt_debugfs.h" #include "igt_sysfs.h" +#include "sw_sync.h" /** * SECTION:igt_kms @@ -2470,6 +2471,21 @@ static int igt_atomic_commit(igt_display_t *display, uint32_t flags, void *user_ } ret = drmModeAtomicCommit(display->drm_fd, req, flags, user_data); + if (!ret) { + + for_each_pipe(display, pipe) { + igt_pipe_t *pipe_obj = >pipes[pipe]; + + if (pipe_obj->out_fence_fd == -1) + continue; + + igt_assert(pipe_obj->out_fence_fd >= 0); + ret = sync_fence_wait(pipe_obj->out_fence_fd, 1000); + igt_assert(ret == 0); + close(pipe_obj->out_fence_fd); + } + } + drmModeAtomicFree(req); return ret; diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c index 72429759..4b1278a4 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 +#include #include #include #include @@ -253,6 +255,94 @@ retry: sprite_width, sprite_height, alpha); } +int *timeline; +pthread_t *thread; +int *seqno; + +static void prepare_fencing(igt_display_t *display, enum pipe pipe) +{ + igt_plane_t *plane; + int n_planes; + + igt_require_sw_sync(); + + n_planes = display->pipes[pipe].n_planes; + timeline = calloc(sizeof(*timeline), n_planes); + igt_assert_f(timeline != NULL, "Failed to allocate memory for timelines\n"); + thread = calloc(sizeof(*thread), n_planes); + igt_assert_f(thread != NULL, "Failed to allocate memory for thread\n"); + seqno = calloc(sizeof(*seqno), n_planes); + igt_assert_f(seqno != NULL, "Failed to allocate memory for seqno\n"); + + 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]); + + free(timeline); + free(thread); + free(seqno); +} + +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_timeline_create_fence(timeline[i], seqno[i]); + igt_plane_set_fence_fd(plane, fd); + close(fd); + ret = pthread_create([i], NULL, fence_inc_thread, [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) +{ + if (fencing) { + configure_fencing(display, pipe); + igt_pipe_request_out_fence(>pipes[pipe]); + } + + 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. @@ -273,6 +363,10 @@ run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t *output struct plane_parms parms[display->pipes[pipe].n_planes]; bool skip_test = false; unsigned flags = DRM_MODE_PAGE_FLIP_EVENT; + int ret; + + if (fencing) + prepare_fencing(display, pipe); if (nonblocking) flags |= DRM_MODE_ATOMIC_NONBLOCK; @@ -307,12 +401,48 @@ run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t *output setup_parms(display, pipe, mode, _fb, _fb, parms); + /* +* In some configurations the tests may not run to completion with all +* sprite planes lit up at 4k