Re: [Intel-gfx] [PATCH i-g-t v2] tests/kms_atomic_allow_modeset: Add DRM_MODE_ATOMIC_ALLOW_MODESET test

2017-04-05 Thread Mika Kahola
On Tue, 2017-04-04 at 14:28 +0200, Maarten Lankhorst wrote:
> Hey,
> 
> Op 04-04-17 om 13:59 schreef Mika Kahola:
> > 
> > When doing a full atomic modeset, kernel should fail if the flag
> > DRM_MODE_ATOMIC_ALLOW_MODESET is not set. Let's add this test as
> > part of
> > Intel-GPU-Tools. The test procedure is the following:
> > 
> > - Try to do atomic commit without DRM_MODE_ATOMIC_ALLOW_MODESET
> > flag.
> >   Kernel should reject this request.
> > - Do full modeset
> > - Enable DRM_MODE_ATOMIC_ALLOW_MODESET and try to do atmic commit.
> >   Kernel should now allow atomic modeset.
> > 
> > For: VIZ-6955
> > 
> > Signed-off-by: Mika Kahola 
> > ---
> >  tests/Makefile.sources   |   1 +
> >  tests/kms_atomic_allow_modeset.c | 133
> > +++
> >  2 files changed, 134 insertions(+)
> >  create mode 100644 tests/kms_atomic_allow_modeset.c
> > 
> > diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> > index 45c21a0..d3ee629 100644
> > --- a/tests/Makefile.sources
> > +++ b/tests/Makefile.sources
> > @@ -94,6 +94,7 @@ TESTS_progs_M = \
> >     kms_addfb_basic \
> >     kms_atomic \
> >     kms_atomic_transition \
> > +   kms_atomic_allow_modeset \
> >     kms_busy \
> >     kms_ccs \
> >     kms_chv_cursor_fail \
> > diff --git a/tests/kms_atomic_allow_modeset.c
> > b/tests/kms_atomic_allow_modeset.c
> > new file mode 100644
> > index 000..b4d8c16
> > --- /dev/null
> > +++ b/tests/kms_atomic_allow_modeset.c
> > @@ -0,0 +1,133 @@
> > +/*
> > + * 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"
> > +
> > +IGT_TEST_DESCRIPTION("Test that kernel rejects atomic modeset if
> > ALLOW_MODESET flag is not set");
> > +
> > +static void
> > +test_init(igt_display_t *display, struct igt_fb *fb, igt_output_t
> > *output)
> > +{
> > +   drmModeModeInfo *mode;
> > +   igt_plane_t *primary;
> > +   int id;
> > +
> > +   mode = igt_output_get_mode(output);
> > +
> > +   id = igt_create_pattern_fb(display->drm_fd,
> > +      mode->hdisplay, mode->vdisplay,
> > +      DRM_FORMAT_XRGB,
> > +      LOCAL_I915_FORMAT_MOD_X_TILED,
> > +      fb);
> > +   igt_assert(id);
> > +
> > +   primary = igt_output_get_plane_type(output,
> > DRM_PLANE_TYPE_PRIMARY);
> > +   igt_plane_set_fb(primary, fb);
> > +}
> > +
> > +static void
> > +test_finish(igt_display_t *display, struct igt_fb *fb,
> > igt_output_t *output)
> > +{
> > +   igt_plane_t *primary;
> > +
> > +   primary = igt_output_get_plane_type(output,
> > DRM_PLANE_TYPE_PRIMARY);
> > +
> > +   igt_remove_fb(display->drm_fd, fb);
> > +
> > +   igt_plane_set_fb(primary, NULL);
> > +   igt_output_set_pipe(output, PIPE_ANY);
> > +
> > +   igt_display_commit2(display, COMMIT_ATOMIC);
> > +}
> > +
> > +static void
> > +test_allow_modeset(igt_display_t *display, enum pipe pipe,
> > igt_output_t *output)
> > +{
> > +   struct igt_fb fb;
> > +   int flags = DRM_MODE_ATOMIC_NONBLOCK;
> > +   int ret;
> > +
> > +   igt_output_set_pipe(output, pipe);
> > +
> > +   test_init(display, &fb, output);
> > +
> > +   /*
> > +    * Try to do atomic commit without
> > DRM_MODE_ATOMIC_ALLOW_MODESET flag.
> > +    * Kernel should reject this request.
> > +    */
> > +   ret = igt_display_try_commit_atomic(display, flags, NULL);
> > +   igt_assert_eq(ret, -EINVAL);
> > +
> > +   /* do modeset */
> > +   igt_output_set_pipe(output, pipe);
> > +
> > +   /*
> > +    * Try to do atomic commit with
> > DRM_MODE_ATOMIC_ALLOW_MODESET flag set.
> > +    * The kernel should now accept this request.
> > +    */
> > +   flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
> > +   ret = igt_display_try_commit_atom

Re: [Intel-gfx] [PATCH i-g-t v2] tests/kms_atomic_allow_modeset: Add DRM_MODE_ATOMIC_ALLOW_MODESET test

2017-04-04 Thread Maarten Lankhorst
Hey,

Op 04-04-17 om 13:59 schreef Mika Kahola:
> When doing a full atomic modeset, kernel should fail if the flag
> DRM_MODE_ATOMIC_ALLOW_MODESET is not set. Let's add this test as part of
> Intel-GPU-Tools. The test procedure is the following:
>
> - Try to do atomic commit without DRM_MODE_ATOMIC_ALLOW_MODESET flag.
>   Kernel should reject this request.
> - Do full modeset
> - Enable DRM_MODE_ATOMIC_ALLOW_MODESET and try to do atmic commit.
>   Kernel should now allow atomic modeset.
>
> For: VIZ-6955
>
> Signed-off-by: Mika Kahola 
> ---
>  tests/Makefile.sources   |   1 +
>  tests/kms_atomic_allow_modeset.c | 133 
> +++
>  2 files changed, 134 insertions(+)
>  create mode 100644 tests/kms_atomic_allow_modeset.c
>
> diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> index 45c21a0..d3ee629 100644
> --- a/tests/Makefile.sources
> +++ b/tests/Makefile.sources
> @@ -94,6 +94,7 @@ TESTS_progs_M = \
>   kms_addfb_basic \
>   kms_atomic \
>   kms_atomic_transition \
> + kms_atomic_allow_modeset \
>   kms_busy \
>   kms_ccs \
>   kms_chv_cursor_fail \
> diff --git a/tests/kms_atomic_allow_modeset.c 
> b/tests/kms_atomic_allow_modeset.c
> new file mode 100644
> index 000..b4d8c16
> --- /dev/null
> +++ b/tests/kms_atomic_allow_modeset.c
> @@ -0,0 +1,133 @@
> +/*
> + * 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"
> +
> +IGT_TEST_DESCRIPTION("Test that kernel rejects atomic modeset if 
> ALLOW_MODESET flag is not set");
> +
> +static void
> +test_init(igt_display_t *display, struct igt_fb *fb, igt_output_t *output)
> +{
> + drmModeModeInfo *mode;
> + igt_plane_t *primary;
> + int id;
> +
> + mode = igt_output_get_mode(output);
> +
> + id = igt_create_pattern_fb(display->drm_fd,
> +mode->hdisplay, mode->vdisplay,
> +DRM_FORMAT_XRGB,
> +LOCAL_I915_FORMAT_MOD_X_TILED,
> +fb);
> + igt_assert(id);
> +
> + primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
> + igt_plane_set_fb(primary, fb);
> +}
> +
> +static void
> +test_finish(igt_display_t *display, struct igt_fb *fb, igt_output_t *output)
> +{
> + igt_plane_t *primary;
> +
> + primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
> +
> + igt_remove_fb(display->drm_fd, fb);
> +
> + igt_plane_set_fb(primary, NULL);
> + igt_output_set_pipe(output, PIPE_ANY);
> +
> + igt_display_commit2(display, COMMIT_ATOMIC);
> +}
> +
> +static void
> +test_allow_modeset(igt_display_t *display, enum pipe pipe, igt_output_t 
> *output)
> +{
> + struct igt_fb fb;
> + int flags = DRM_MODE_ATOMIC_NONBLOCK;
> + int ret;
> +
> + igt_output_set_pipe(output, pipe);
> +
> + test_init(display, &fb, output);
> +
> + /*
> +  * Try to do atomic commit without DRM_MODE_ATOMIC_ALLOW_MODESET flag.
> +  * Kernel should reject this request.
> +  */
> + ret = igt_display_try_commit_atomic(display, flags, NULL);
> + igt_assert_eq(ret, -EINVAL);
> +
> + /* do modeset */
> + igt_output_set_pipe(output, pipe);
> +
> + /*
> +  * Try to do atomic commit with DRM_MODE_ATOMIC_ALLOW_MODESET flag set.
> +  * The kernel should now accept this request.
> +  */
> + flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
> + ret = igt_display_try_commit_atomic(display, flags, NULL);
> + igt_assert_eq(ret, 0);
> +
> + test_finish(display, &fb, output);
> +}
> +
> +igt_simple_main
> +{
> + igt_output_t *output;
> + igt_display_t display;
> + drmModeResPtr res;
> + enum pipe pipe;
> +
> + igt_skip_on_simulation();
> +
> + igt_fixture {
> + i

[Intel-gfx] [PATCH i-g-t v2] tests/kms_atomic_allow_modeset: Add DRM_MODE_ATOMIC_ALLOW_MODESET test

2017-04-04 Thread Mika Kahola
When doing a full atomic modeset, kernel should fail if the flag
DRM_MODE_ATOMIC_ALLOW_MODESET is not set. Let's add this test as part of
Intel-GPU-Tools. The test procedure is the following:

- Try to do atomic commit without DRM_MODE_ATOMIC_ALLOW_MODESET flag.
  Kernel should reject this request.
- Do full modeset
- Enable DRM_MODE_ATOMIC_ALLOW_MODESET and try to do atmic commit.
  Kernel should now allow atomic modeset.

For: VIZ-6955

Signed-off-by: Mika Kahola 
---
 tests/Makefile.sources   |   1 +
 tests/kms_atomic_allow_modeset.c | 133 +++
 2 files changed, 134 insertions(+)
 create mode 100644 tests/kms_atomic_allow_modeset.c

diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 45c21a0..d3ee629 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -94,6 +94,7 @@ TESTS_progs_M = \
kms_addfb_basic \
kms_atomic \
kms_atomic_transition \
+   kms_atomic_allow_modeset \
kms_busy \
kms_ccs \
kms_chv_cursor_fail \
diff --git a/tests/kms_atomic_allow_modeset.c b/tests/kms_atomic_allow_modeset.c
new file mode 100644
index 000..b4d8c16
--- /dev/null
+++ b/tests/kms_atomic_allow_modeset.c
@@ -0,0 +1,133 @@
+/*
+ * 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"
+
+IGT_TEST_DESCRIPTION("Test that kernel rejects atomic modeset if ALLOW_MODESET 
flag is not set");
+
+static void
+test_init(igt_display_t *display, struct igt_fb *fb, igt_output_t *output)
+{
+   drmModeModeInfo *mode;
+   igt_plane_t *primary;
+   int id;
+
+   mode = igt_output_get_mode(output);
+
+   id = igt_create_pattern_fb(display->drm_fd,
+  mode->hdisplay, mode->vdisplay,
+  DRM_FORMAT_XRGB,
+  LOCAL_I915_FORMAT_MOD_X_TILED,
+  fb);
+   igt_assert(id);
+
+   primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+   igt_plane_set_fb(primary, fb);
+}
+
+static void
+test_finish(igt_display_t *display, struct igt_fb *fb, igt_output_t *output)
+{
+   igt_plane_t *primary;
+
+   primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+
+   igt_remove_fb(display->drm_fd, fb);
+
+   igt_plane_set_fb(primary, NULL);
+   igt_output_set_pipe(output, PIPE_ANY);
+
+   igt_display_commit2(display, COMMIT_ATOMIC);
+}
+
+static void
+test_allow_modeset(igt_display_t *display, enum pipe pipe, igt_output_t 
*output)
+{
+   struct igt_fb fb;
+   int flags = DRM_MODE_ATOMIC_NONBLOCK;
+   int ret;
+
+   igt_output_set_pipe(output, pipe);
+
+   test_init(display, &fb, output);
+
+   /*
+* Try to do atomic commit without DRM_MODE_ATOMIC_ALLOW_MODESET flag.
+* Kernel should reject this request.
+*/
+   ret = igt_display_try_commit_atomic(display, flags, NULL);
+   igt_assert_eq(ret, -EINVAL);
+
+   /* do modeset */
+   igt_output_set_pipe(output, pipe);
+
+   /*
+* Try to do atomic commit with DRM_MODE_ATOMIC_ALLOW_MODESET flag set.
+* The kernel should now accept this request.
+*/
+   flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
+   ret = igt_display_try_commit_atomic(display, flags, NULL);
+   igt_assert_eq(ret, 0);
+
+   test_finish(display, &fb, output);
+}
+
+igt_simple_main
+{
+   igt_output_t *output;
+   igt_display_t display;
+   drmModeResPtr res;
+   enum pipe pipe;
+
+   igt_skip_on_simulation();
+
+   igt_fixture {
+   int valid_outputs = 0;
+
+   display.drm_fd = drm_open_driver_master(DRIVER_ANY);
+   igt_enable_connectors();
+   kmstest_set_vt_graphics_mode();
+   igt_display_init(&display, display.drm_