From: Robert Foss <robert.foss@collabora.com>
To: Brian Starkey <brian.starkey@arm.com>
Cc: Gustavo Padovan <gustavo.padovan@collabora.com>,
intel-gfx@lists.freedesktop.org,
Gustavo Padovan <gustavo.padovan@collabora.co.uk>,
Tomeu Vizoso <tomeu.vizoso@collabora.com>
Subject: Re: [PATCH i-g-t v4 09/11] tests/kms_atomic_transition: add out_fences tests
Date: Wed, 1 Feb 2017 11:42:24 -0500 [thread overview]
Message-ID: <815b60f3-0dac-067a-e541-0ccdc6cde97b@collabora.com> (raw)
In-Reply-To: <20170201104027.GC17595@e106950-lin.cambridge.arm.com>
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 Padovan <gustavo.padovan@collabora.co.uk>
>> Signed-off-by: Robert Foss <robert.foss@collabora.com>
>> ---
>> 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 = &display->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 <errno.h>
>> +#include <pthread.h>
>> #include <stdbool.h>
>> #include <stdio.h>
>> #include <string.h>
>> @@ -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(&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)
>> +{
>> + if (fencing) {
>> + configure_fencing(display, pipe);
>> + igt_pipe_request_out_fence(&display->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, &argb_fb, &sprite_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) {
>> + wm_setup_plane(display, pipe, iter_max - 1, parms);
>> +
>> + if (fencing)
>> + igt_pipe_request_out_fence(&display->pipes[pipe]);
>> +
>> + ret = igt_display_try_commit_atomic(display,
>> DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
>> + if (ret != -EINVAL || display->pipes[pipe].n_planes < 3)
>> + break;
>> +
>> + ret = 0;
>> + for_each_plane_on_pipe(display, pipe, plane) {
>> + i = plane->index;
>> +
>> + if (plane->type == DRM_PLANE_TYPE_PRIMARY ||
>> + plane->type == DRM_PLANE_TYPE_CURSOR)
>> + continue;
>> +
>> + if (parms[i].width <= 512)
>> + continue;
>> +
>> + parms[i].width /= 2;
>> + ret = 1;
>> + igt_info("Reducing sprite %i to %ux%u\n", i - 1,
>> parms[i].width, parms[i].height);
>> + break;
>> + }
>> +
>> + if (!ret)
>> + igt_skip("Cannot run tests without proper size sprite
>> planes\n");
>> + }
>> +
>> for (i = 0; i < iter_max; i++) {
>> igt_output_set_pipe(output, pipe);
>>
>> wm_setup_plane(display, pipe, i, parms);
>>
>> - igt_display_commit_atomic(display, flags, (void *)(unsigned
>> long)i);
>> + atomic_commit(display, pipe, flags, (void *)(unsigned long)i,
>> fencing);
>> drmHandleEvent(display->drm_fd, &drm_events);
>>
>> if (type == TRANSITION_MODESET_DISABLE) {
>> @@ -320,8 +450,7 @@ run_transition_test(igt_display_t *display, enum
>> pipe pipe, igt_output_t *output
>>
>> wm_setup_plane(display, pipe, 0, parms);
>>
>> - igt_display_commit_atomic(display, flags, (void *)0UL);
>> -
>> + atomic_commit(display, pipe, flags, (void *) 0UL, fencing);
>> drmHandleEvent(display->drm_fd, &drm_events);
>> } else {
>> uint32_t j;
>> @@ -333,20 +462,22 @@ 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);
>>
>> - igt_display_commit_atomic(display, flags, (void
>> *)(unsigned long)j);
>> + atomic_commit(display, pipe, flags, (void *)(unsigned
>> long) j, fencing);
>> drmHandleEvent(display->drm_fd, &drm_events);
>>
>> wm_setup_plane(display, pipe, i, parms);
>> if (type == TRANSITION_MODESET)
>> igt_output_override_mode(output, NULL);
>>
>> - igt_display_commit_atomic(display, flags, (void
>> *)(unsigned long)i);
>> + atomic_commit(display, pipe, flags, (void *)(unsigned
>> long) i, fencing);
>> drmHandleEvent(display->drm_fd, &drm_events);
>> }
>> }
>> }
>>
>> cleanup:
>> + unprepare_fencing(display, pipe);
>> +
>> igt_output_set_pipe(output, PIPE_NONE);
>>
>> for_each_plane_on_pipe(display, pipe, plane)
>> @@ -676,14 +807,26 @@ igt_main
>> for_each_pipe_with_valid_output(&display, pipe, output)
>> run_transition_test(&display, pipe, output,
>> TRANSITION_PLANES, false, false);
>>
>> + igt_subtest("plane-all-transition-fencing")
>> + for_each_pipe_with_valid_output(&display, pipe, output)
>> + run_transition_test(&display, pipe, output,
>> TRANSITION_PLANES, false, true);
>> +
>> igt_subtest("plane-all-transition-nonblocking")
>> for_each_pipe_with_valid_output(&display, pipe, output)
>> run_transition_test(&display, pipe, output,
>> TRANSITION_PLANES, true, false);
>>
>> + igt_subtest("plane-all-transition-nonblocking-fencing")
>> + for_each_pipe_with_valid_output(&display, pipe, output)
>> + run_transition_test(&display, pipe, output,
>> TRANSITION_PLANES, true, true);
>> +
>> igt_subtest("plane-all-modeset-transition")
>> for_each_pipe_with_valid_output(&display, pipe, output)
>> run_transition_test(&display, pipe, output,
>> TRANSITION_MODESET, false, false);
>>
>> + igt_subtest("plane-all-modeset-transition-fencing")
>> + for_each_pipe_with_valid_output(&display, pipe, output)
>> + run_transition_test(&display, pipe, output,
>> TRANSITION_MODESET, false, true);
>> +
>> igt_subtest("plane-toggle-modeset-transition")
>> for_each_pipe_with_valid_output(&display, pipe, output)
>> run_transition_test(&display, pipe, output,
>> TRANSITION_MODESET_DISABLE, false, false);
>> --
>> 2.11.0.453.g787f75f05
>>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2017-02-01 16:42 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-01 1:25 [PATCH i-g-t v4 00/11] tests/kms_atomic_transition add fence testing Robert Foss
2017-02-01 1:25 ` [PATCH i-g-t v4 01/11] tests/kms_atomic_transition: use igt timeout instead of blocking Robert Foss
2017-02-01 1:25 ` [PATCH i-g-t v4 02/11] lib/igt_kms: move igt_kms_get_alt_edid() to the right place Robert Foss
2017-02-01 1:25 ` [PATCH i-g-t v4 03/11] lib/igt_kms: export properties names Robert Foss
2017-02-01 1:25 ` [PATCH i-g-t v4 04/11] tests/kms_atomic: use global atomic properties definitions Robert Foss
2017-02-01 1:25 ` [PATCH i-g-t v4 05/11] lib/igt_kms: Add support for the IN_FENCE_FD property Robert Foss
2017-02-01 10:39 ` Brian Starkey
2017-02-01 16:32 ` Robert Foss
2017-02-01 1:25 ` [PATCH i-g-t v4 06/11] lib/igt_kms: Add support for the OUT_FENCE_PTR property Robert Foss
2017-02-01 10:40 ` Brian Starkey
2017-02-01 16:35 ` Robert Foss
2017-02-01 1:25 ` [PATCH i-g-t v4 07/11] tests/kms_atomic: stress possible fence settings Robert Foss
2017-02-01 1:25 ` [PATCH i-g-t v4 08/11] tests/kms_atomic_transition: add fencing parameter to run_transition_tests Robert Foss
2017-02-01 1:25 ` [PATCH i-g-t v4 09/11] tests/kms_atomic_transition: add out_fences tests Robert Foss
2017-02-01 10:40 ` Brian Starkey
2017-02-01 16:42 ` Robert Foss [this message]
2017-02-01 1:25 ` [PATCH i-g-t v4 10/11] tests/kms_atomic_transition: add in_fences tests Robert Foss
2017-02-01 10:41 ` Brian Starkey
2017-02-01 17:17 ` Robert Foss
2017-02-01 1:25 ` [PATCH i-g-t v4 11/11] lib/igt_kms: Added igt_pipe_get_last_out_fence() Robert Foss
2017-02-01 10:41 ` Brian Starkey
2017-02-01 10:44 ` [PATCH i-g-t v4 00/11] tests/kms_atomic_transition add fence testing Brian Starkey
2017-02-01 18:11 ` Robert Foss
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=815b60f3-0dac-067a-e541-0ccdc6cde97b@collabora.com \
--to=robert.foss@collabora.com \
--cc=brian.starkey@arm.com \
--cc=gustavo.padovan@collabora.co.uk \
--cc=gustavo.padovan@collabora.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=tomeu.vizoso@collabora.com \
/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