* [PATCH v7 i-g-t 2/4] kms_writeback: Add initial writeback tests
@ 2019-10-22 0:59 ` Brian Starkey
0 siblings, 0 replies; 7+ messages in thread
From: Brian Starkey @ 2019-10-22 0:59 UTC (permalink / raw)
To: Simon Ser, Brian Starkey, Liviu Dudau, Petri Latvala,
Arkadiusz Hiler, Daniel Vetter
Cc: igt-dev, intel-gfx, nd
[-- Attachment #1.1: Type: text/plain, Size: 11404 bytes --]
Add tests for the WRITEBACK_PIXEL_FORMATS, WRITEBACK_OUT_FENCE_PTR and
WRITEBACK_FB_ID properties on writeback connectors, ensuring their
behaviour is correct.
V6: Simon Ser
- Add igt documentation with igt_describe and IGT_TEST_DESCRIPTION
- Drop kmstest_force_connector with FORCE_CONNECTOR_ON in
kms_writeback_get_output since userspace won't do this operation
- Add an igt_debug statement in case we don't use writeback output
- Drop flags parameter from do_writeback_test
- Remove do_writeback_test "igt_assert(*out_fence_ptr == -1)" after
igt_display_try_commit_atomic
- Rename writeback_fb_id to writeback_test_fb
- Rework writeback_test_fb for checking buffer
- Move some tests from invalid_out_fence to writeback_test_fb
- Replace ret != 0 checking by ret == -EINVAL after invoke
do_writeback_test
- Assert on igt_output_get_plane_type()
- Replace igt_fb_mod_to_tiling to DRM_FORMAT_MOD_LINEAR
- Rename tests
- Replace int ret by unsigned int fd_id when calling igt_create_fb
Signed-off-by: Brian Starkey <brian.starkey@arm.com>
[rebased and updated do_writeback_test() function to address feedback]
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
[rebased and updated the patch to address feedback]
Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
---
tests/Makefile.sources | 1 +
tests/kms_writeback.c | 290 +++++++++++++++++++++++++++++++++++++++++
tests/meson.build | 1 +
3 files changed, 292 insertions(+)
create mode 100644 tests/kms_writeback.c
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 343be050..331270ae 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -81,6 +81,7 @@ TESTS_progs = \
kms_universal_plane \
kms_vblank \
kms_vrr \
+ kms_writeback \
meta_test \
perf \
perf_pmu \
diff --git a/tests/kms_writeback.c b/tests/kms_writeback.c
new file mode 100644
index 00000000..a373ec4d
--- /dev/null
+++ b/tests/kms_writeback.c
@@ -0,0 +1,290 @@
+/*
+ * (C) COPYRIGHT 2017 ARM Limited. All rights reserved.
+ *
+ * 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 <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "igt.h"
+#include "igt_core.h"
+#include "igt_fb.h"
+
+IGT_TEST_DESCRIPTION("Exercise writeback feature.");
+
+static drmModePropertyBlobRes *get_writeback_formats_blob(igt_output_t *output)
+{
+ drmModePropertyBlobRes *blob = NULL;
+ uint64_t blob_id;
+ int ret;
+
+ ret = kmstest_get_property(output->display->drm_fd,
+ output->config.connector->connector_id,
+ DRM_MODE_OBJECT_CONNECTOR,
+ igt_connector_prop_names[IGT_CONNECTOR_WRITEBACK_PIXEL_FORMATS],
+ NULL, &blob_id, NULL);
+ if (ret)
+ blob = drmModeGetPropertyBlob(output->display->drm_fd, blob_id);
+
+ igt_assert(blob);
+
+ return blob;
+}
+
+static bool check_writeback_config(igt_display_t *display, igt_output_t *output)
+{
+ igt_fb_t input_fb, output_fb;
+ igt_plane_t *plane;
+ uint32_t writeback_format = DRM_FORMAT_XRGB8888;
+ int width, height, ret;
+ unsigned int fb_id;
+ drmModeModeInfo override_mode = {
+ .clock = 25175,
+ .hdisplay = 640,
+ .hsync_start = 656,
+ .hsync_end = 752,
+ .htotal = 800,
+ .hskew = 0,
+ .vdisplay = 480,
+ .vsync_start = 490,
+ .vsync_end = 492,
+ .vtotal = 525,
+ .vscan = 0,
+ .vrefresh = 60,
+ .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
+ .name = {"640x480-60"},
+ };
+ igt_output_override_mode(output, &override_mode);
+
+ width = override_mode.hdisplay;
+ height = override_mode.vdisplay;
+
+ fb_id = igt_create_fb(display->drm_fd, width, height, DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_LINEAR, &input_fb);
+ igt_assert(fb_id >= 0);
+
+ fb_id = igt_create_fb(display->drm_fd, width, height, writeback_format, DRM_FORMAT_MOD_LINEAR, &output_fb);
+ igt_assert(fb_id >= 0);
+
+ plane = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+ igt_plane_set_fb(plane, &input_fb);
+ igt_output_set_writeback_fb(output, &output_fb);
+
+ ret = igt_display_try_commit_atomic(display, DRM_MODE_ATOMIC_TEST_ONLY |
+ DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
+ igt_plane_set_fb(plane, NULL);
+ igt_remove_fb(display->drm_fd, &input_fb);
+ igt_remove_fb(display->drm_fd, &output_fb);
+
+ return !ret;
+}
+
+static igt_output_t *kms_writeback_get_output(igt_display_t *display)
+{
+ int i;
+
+ for (i = 0; i < display->n_outputs; i++) {
+ igt_output_t *output = &display->outputs[i];
+ int j;
+
+ if (output->config.connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK)
+ continue;
+
+ for (j = 0; j < igt_display_get_n_pipes(display); j++) {
+ igt_output_set_pipe(output, j);
+
+ if (check_writeback_config(display, output)) {
+ igt_debug("Using connector %u:%s on pipe %d\n",
+ output->config.connector->connector_id,
+ output->name, j);
+ return output;
+ }
+ }
+
+ /* Restore any connectors we don't use, so we don't trip on them later */
+ kmstest_force_connector(display->drm_fd, output->config.connector, FORCE_CONNECTOR_UNSPECIFIED);
+ }
+
+ igt_debug("The device does not enable writeback\n");
+
+ return NULL;
+}
+
+static void check_writeback_fb_id(igt_output_t *output)
+{
+ uint64_t check_fb_id;
+
+ check_fb_id = igt_output_get_prop(output, IGT_CONNECTOR_WRITEBACK_FB_ID);
+ igt_assert(check_fb_id == 0);
+}
+
+static int do_writeback_test(igt_output_t *output, uint32_t fb_id,
+ int32_t *out_fence_ptr, bool ptr_valid)
+{
+ int ret;
+ int flags = DRM_MODE_ATOMIC_ALLOW_MODESET;
+ igt_display_t *display = output->display;
+ struct kmstest_connector_config *config = &output->config;
+
+ igt_output_set_prop_value(output, IGT_CONNECTOR_CRTC_ID, config->crtc->crtc_id);
+ igt_output_set_prop_value(output, IGT_CONNECTOR_WRITEBACK_FB_ID, fb_id);
+ igt_output_set_prop_value(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR, (uint64_t)out_fence_ptr);
+
+ if (ptr_valid)
+ *out_fence_ptr = 0;
+
+ ret = igt_display_try_commit_atomic(display, flags, NULL);
+
+ /* WRITEBACK_FB_ID must always read as zero */
+ check_writeback_fb_id(output);
+
+ return ret;
+}
+
+static void invalid_output_fence(igt_output_t *output, igt_fb_t *valid_fb)
+{
+ int ret;
+
+ ret = do_writeback_test(output, valid_fb->fb_id, (int32_t *)0x8, false);
+ igt_assert(ret == -EFAULT);
+}
+
+static void writeback_test_fb(igt_output_t *output, igt_fb_t *valid_fb, igt_fb_t *invalid_fb)
+{
+
+ int ret;
+ int32_t out_fence;
+
+ /* Valid output buffer */
+ ret = do_writeback_test(output, valid_fb->fb_id, NULL, false);
+ igt_assert(ret == 0);
+
+ /* Invalid object for WRITEBACK_FB_ID */
+ ret = do_writeback_test(output, output->id, NULL, false);
+ igt_assert(ret == -EINVAL);
+
+ /* Zero WRITEBACK_FB_ID */
+ ret = do_writeback_test(output, 0, NULL, false);
+ igt_assert(ret == 0);
+
+ /* No output buffer, but the WRITEBACK_OUT_FENCE_PTR set. */
+ ret = do_writeback_test(output, 0, &out_fence, true);
+ igt_assert(ret == -EINVAL);
+
+ /* Invalid output buffer. */
+ ret = do_writeback_test(output, invalid_fb->fb_id, &out_fence, true);
+ igt_assert(ret == -EINVAL);
+}
+
+igt_main
+{
+ igt_display_t display;
+ igt_output_t *output;
+ igt_plane_t *plane;
+ igt_fb_t input_fb;
+ drmModeModeInfo mode;
+ unsigned int fb_id;
+
+ memset(&display, 0, sizeof(display));
+
+ igt_fixture {
+ display.drm_fd = drm_open_driver_master(DRIVER_ANY);
+ igt_display_require(&display, display.drm_fd);
+
+ kmstest_set_vt_graphics_mode();
+
+ igt_display_require(&display, display.drm_fd);
+
+ igt_require(display.is_atomic);
+
+ output = kms_writeback_get_output(&display);
+ igt_require(output);
+
+ if (output->use_override_mode)
+ memcpy(&mode, &output->override_mode, sizeof(mode));
+ else
+ memcpy(&mode, &output->config.default_mode, sizeof(mode));
+
+ plane = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+ igt_assert(plane);
+
+ fb_id = igt_create_fb(display.drm_fd, mode.hdisplay,
+ mode.vdisplay,
+ DRM_FORMAT_XRGB8888,
+ DRM_FORMAT_MOD_LINEAR,
+ &input_fb);
+ igt_assert(fb_id >= 0);
+ igt_plane_set_fb(plane, &input_fb);
+ }
+
+ igt_describe("Check writeback formats");
+ igt_subtest("pixel-formats") {
+ drmModePropertyBlobRes *formats_blob = get_writeback_formats_blob(output);
+ const char *valid_chars = "0123456 ABCGNRUVXY";
+ unsigned int i;
+ char *c;
+
+ /*
+ * We don't have a comprehensive list of formats, so just check
+ * that the blob length is sensible and that it doesn't contain
+ * any outlandish characters
+ */
+ igt_assert(!(formats_blob->length % 4));
+ c = formats_blob->data;
+ for (i = 0; i < formats_blob->length; i++)
+ igt_assert_f(strchr(valid_chars, c[i]),
+ "Unexpected character %c\n", c[i]);
+ }
+
+ igt_describe("This test validates if the writeback core identify an "
+ "invalid output");
+ igt_subtest("invalid-output-fb") {
+ invalid_output_fence(output, &input_fb);
+ }
+
+ igt_describe("Test writeback with valid and invalid framebuffer");
+ igt_subtest("writeback-test-framebuffer") {
+ igt_fb_t output_fb, invalid_fb;
+ fb_id = igt_create_fb(display.drm_fd, mode.hdisplay,
+ mode.vdisplay, DRM_FORMAT_XRGB8888,
+ DRM_FORMAT_MOD_LINEAR, &output_fb);
+ igt_require(fb_id > 0);
+
+ fb_id = igt_create_fb(display.drm_fd, mode.hdisplay / 2,
+ mode.vdisplay / 2,
+ DRM_FORMAT_XRGB8888,
+ DRM_FORMAT_MOD_LINEAR,
+ &invalid_fb);
+ igt_require(fb_id > 0);
+
+ writeback_test_fb(output, &output_fb, &invalid_fb);
+
+ igt_remove_fb(display.drm_fd, &output_fb);
+ igt_remove_fb(display.drm_fd, &invalid_fb);
+ }
+
+ igt_fixture {
+ igt_remove_fb(display.drm_fd, &input_fb);
+ igt_display_fini(&display);
+ }
+}
diff --git a/tests/meson.build b/tests/meson.build
index 7e3f9e0a..af601725 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -66,6 +66,7 @@ test_progs = [
'kms_universal_plane',
'kms_vblank',
'kms_vrr',
+ 'kms_writeback',
'meta_test',
'panfrost_get_param',
'panfrost_gem_new',
--
2.23.0
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
[-- Attachment #2: Type: text/plain, Size: 159 bytes --]
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [igt-dev] [PATCH v7 i-g-t 2/4] kms_writeback: Add initial writeback tests
@ 2019-10-22 0:59 ` Brian Starkey
0 siblings, 0 replies; 7+ messages in thread
From: Brian Starkey @ 2019-10-22 0:59 UTC (permalink / raw)
To: Simon Ser, Brian Starkey, Liviu Dudau, Petri Latvala,
Arkadiusz Hiler, Daniel Vetter
Cc: igt-dev, intel-gfx, nd
[-- Attachment #1.1: Type: text/plain, Size: 11404 bytes --]
Add tests for the WRITEBACK_PIXEL_FORMATS, WRITEBACK_OUT_FENCE_PTR and
WRITEBACK_FB_ID properties on writeback connectors, ensuring their
behaviour is correct.
V6: Simon Ser
- Add igt documentation with igt_describe and IGT_TEST_DESCRIPTION
- Drop kmstest_force_connector with FORCE_CONNECTOR_ON in
kms_writeback_get_output since userspace won't do this operation
- Add an igt_debug statement in case we don't use writeback output
- Drop flags parameter from do_writeback_test
- Remove do_writeback_test "igt_assert(*out_fence_ptr == -1)" after
igt_display_try_commit_atomic
- Rename writeback_fb_id to writeback_test_fb
- Rework writeback_test_fb for checking buffer
- Move some tests from invalid_out_fence to writeback_test_fb
- Replace ret != 0 checking by ret == -EINVAL after invoke
do_writeback_test
- Assert on igt_output_get_plane_type()
- Replace igt_fb_mod_to_tiling to DRM_FORMAT_MOD_LINEAR
- Rename tests
- Replace int ret by unsigned int fd_id when calling igt_create_fb
Signed-off-by: Brian Starkey <brian.starkey@arm.com>
[rebased and updated do_writeback_test() function to address feedback]
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
[rebased and updated the patch to address feedback]
Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
---
tests/Makefile.sources | 1 +
tests/kms_writeback.c | 290 +++++++++++++++++++++++++++++++++++++++++
tests/meson.build | 1 +
3 files changed, 292 insertions(+)
create mode 100644 tests/kms_writeback.c
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 343be050..331270ae 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -81,6 +81,7 @@ TESTS_progs = \
kms_universal_plane \
kms_vblank \
kms_vrr \
+ kms_writeback \
meta_test \
perf \
perf_pmu \
diff --git a/tests/kms_writeback.c b/tests/kms_writeback.c
new file mode 100644
index 00000000..a373ec4d
--- /dev/null
+++ b/tests/kms_writeback.c
@@ -0,0 +1,290 @@
+/*
+ * (C) COPYRIGHT 2017 ARM Limited. All rights reserved.
+ *
+ * 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 <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "igt.h"
+#include "igt_core.h"
+#include "igt_fb.h"
+
+IGT_TEST_DESCRIPTION("Exercise writeback feature.");
+
+static drmModePropertyBlobRes *get_writeback_formats_blob(igt_output_t *output)
+{
+ drmModePropertyBlobRes *blob = NULL;
+ uint64_t blob_id;
+ int ret;
+
+ ret = kmstest_get_property(output->display->drm_fd,
+ output->config.connector->connector_id,
+ DRM_MODE_OBJECT_CONNECTOR,
+ igt_connector_prop_names[IGT_CONNECTOR_WRITEBACK_PIXEL_FORMATS],
+ NULL, &blob_id, NULL);
+ if (ret)
+ blob = drmModeGetPropertyBlob(output->display->drm_fd, blob_id);
+
+ igt_assert(blob);
+
+ return blob;
+}
+
+static bool check_writeback_config(igt_display_t *display, igt_output_t *output)
+{
+ igt_fb_t input_fb, output_fb;
+ igt_plane_t *plane;
+ uint32_t writeback_format = DRM_FORMAT_XRGB8888;
+ int width, height, ret;
+ unsigned int fb_id;
+ drmModeModeInfo override_mode = {
+ .clock = 25175,
+ .hdisplay = 640,
+ .hsync_start = 656,
+ .hsync_end = 752,
+ .htotal = 800,
+ .hskew = 0,
+ .vdisplay = 480,
+ .vsync_start = 490,
+ .vsync_end = 492,
+ .vtotal = 525,
+ .vscan = 0,
+ .vrefresh = 60,
+ .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
+ .name = {"640x480-60"},
+ };
+ igt_output_override_mode(output, &override_mode);
+
+ width = override_mode.hdisplay;
+ height = override_mode.vdisplay;
+
+ fb_id = igt_create_fb(display->drm_fd, width, height, DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_LINEAR, &input_fb);
+ igt_assert(fb_id >= 0);
+
+ fb_id = igt_create_fb(display->drm_fd, width, height, writeback_format, DRM_FORMAT_MOD_LINEAR, &output_fb);
+ igt_assert(fb_id >= 0);
+
+ plane = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+ igt_plane_set_fb(plane, &input_fb);
+ igt_output_set_writeback_fb(output, &output_fb);
+
+ ret = igt_display_try_commit_atomic(display, DRM_MODE_ATOMIC_TEST_ONLY |
+ DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
+ igt_plane_set_fb(plane, NULL);
+ igt_remove_fb(display->drm_fd, &input_fb);
+ igt_remove_fb(display->drm_fd, &output_fb);
+
+ return !ret;
+}
+
+static igt_output_t *kms_writeback_get_output(igt_display_t *display)
+{
+ int i;
+
+ for (i = 0; i < display->n_outputs; i++) {
+ igt_output_t *output = &display->outputs[i];
+ int j;
+
+ if (output->config.connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK)
+ continue;
+
+ for (j = 0; j < igt_display_get_n_pipes(display); j++) {
+ igt_output_set_pipe(output, j);
+
+ if (check_writeback_config(display, output)) {
+ igt_debug("Using connector %u:%s on pipe %d\n",
+ output->config.connector->connector_id,
+ output->name, j);
+ return output;
+ }
+ }
+
+ /* Restore any connectors we don't use, so we don't trip on them later */
+ kmstest_force_connector(display->drm_fd, output->config.connector, FORCE_CONNECTOR_UNSPECIFIED);
+ }
+
+ igt_debug("The device does not enable writeback\n");
+
+ return NULL;
+}
+
+static void check_writeback_fb_id(igt_output_t *output)
+{
+ uint64_t check_fb_id;
+
+ check_fb_id = igt_output_get_prop(output, IGT_CONNECTOR_WRITEBACK_FB_ID);
+ igt_assert(check_fb_id == 0);
+}
+
+static int do_writeback_test(igt_output_t *output, uint32_t fb_id,
+ int32_t *out_fence_ptr, bool ptr_valid)
+{
+ int ret;
+ int flags = DRM_MODE_ATOMIC_ALLOW_MODESET;
+ igt_display_t *display = output->display;
+ struct kmstest_connector_config *config = &output->config;
+
+ igt_output_set_prop_value(output, IGT_CONNECTOR_CRTC_ID, config->crtc->crtc_id);
+ igt_output_set_prop_value(output, IGT_CONNECTOR_WRITEBACK_FB_ID, fb_id);
+ igt_output_set_prop_value(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR, (uint64_t)out_fence_ptr);
+
+ if (ptr_valid)
+ *out_fence_ptr = 0;
+
+ ret = igt_display_try_commit_atomic(display, flags, NULL);
+
+ /* WRITEBACK_FB_ID must always read as zero */
+ check_writeback_fb_id(output);
+
+ return ret;
+}
+
+static void invalid_output_fence(igt_output_t *output, igt_fb_t *valid_fb)
+{
+ int ret;
+
+ ret = do_writeback_test(output, valid_fb->fb_id, (int32_t *)0x8, false);
+ igt_assert(ret == -EFAULT);
+}
+
+static void writeback_test_fb(igt_output_t *output, igt_fb_t *valid_fb, igt_fb_t *invalid_fb)
+{
+
+ int ret;
+ int32_t out_fence;
+
+ /* Valid output buffer */
+ ret = do_writeback_test(output, valid_fb->fb_id, NULL, false);
+ igt_assert(ret == 0);
+
+ /* Invalid object for WRITEBACK_FB_ID */
+ ret = do_writeback_test(output, output->id, NULL, false);
+ igt_assert(ret == -EINVAL);
+
+ /* Zero WRITEBACK_FB_ID */
+ ret = do_writeback_test(output, 0, NULL, false);
+ igt_assert(ret == 0);
+
+ /* No output buffer, but the WRITEBACK_OUT_FENCE_PTR set. */
+ ret = do_writeback_test(output, 0, &out_fence, true);
+ igt_assert(ret == -EINVAL);
+
+ /* Invalid output buffer. */
+ ret = do_writeback_test(output, invalid_fb->fb_id, &out_fence, true);
+ igt_assert(ret == -EINVAL);
+}
+
+igt_main
+{
+ igt_display_t display;
+ igt_output_t *output;
+ igt_plane_t *plane;
+ igt_fb_t input_fb;
+ drmModeModeInfo mode;
+ unsigned int fb_id;
+
+ memset(&display, 0, sizeof(display));
+
+ igt_fixture {
+ display.drm_fd = drm_open_driver_master(DRIVER_ANY);
+ igt_display_require(&display, display.drm_fd);
+
+ kmstest_set_vt_graphics_mode();
+
+ igt_display_require(&display, display.drm_fd);
+
+ igt_require(display.is_atomic);
+
+ output = kms_writeback_get_output(&display);
+ igt_require(output);
+
+ if (output->use_override_mode)
+ memcpy(&mode, &output->override_mode, sizeof(mode));
+ else
+ memcpy(&mode, &output->config.default_mode, sizeof(mode));
+
+ plane = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+ igt_assert(plane);
+
+ fb_id = igt_create_fb(display.drm_fd, mode.hdisplay,
+ mode.vdisplay,
+ DRM_FORMAT_XRGB8888,
+ DRM_FORMAT_MOD_LINEAR,
+ &input_fb);
+ igt_assert(fb_id >= 0);
+ igt_plane_set_fb(plane, &input_fb);
+ }
+
+ igt_describe("Check writeback formats");
+ igt_subtest("pixel-formats") {
+ drmModePropertyBlobRes *formats_blob = get_writeback_formats_blob(output);
+ const char *valid_chars = "0123456 ABCGNRUVXY";
+ unsigned int i;
+ char *c;
+
+ /*
+ * We don't have a comprehensive list of formats, so just check
+ * that the blob length is sensible and that it doesn't contain
+ * any outlandish characters
+ */
+ igt_assert(!(formats_blob->length % 4));
+ c = formats_blob->data;
+ for (i = 0; i < formats_blob->length; i++)
+ igt_assert_f(strchr(valid_chars, c[i]),
+ "Unexpected character %c\n", c[i]);
+ }
+
+ igt_describe("This test validates if the writeback core identify an "
+ "invalid output");
+ igt_subtest("invalid-output-fb") {
+ invalid_output_fence(output, &input_fb);
+ }
+
+ igt_describe("Test writeback with valid and invalid framebuffer");
+ igt_subtest("writeback-test-framebuffer") {
+ igt_fb_t output_fb, invalid_fb;
+ fb_id = igt_create_fb(display.drm_fd, mode.hdisplay,
+ mode.vdisplay, DRM_FORMAT_XRGB8888,
+ DRM_FORMAT_MOD_LINEAR, &output_fb);
+ igt_require(fb_id > 0);
+
+ fb_id = igt_create_fb(display.drm_fd, mode.hdisplay / 2,
+ mode.vdisplay / 2,
+ DRM_FORMAT_XRGB8888,
+ DRM_FORMAT_MOD_LINEAR,
+ &invalid_fb);
+ igt_require(fb_id > 0);
+
+ writeback_test_fb(output, &output_fb, &invalid_fb);
+
+ igt_remove_fb(display.drm_fd, &output_fb);
+ igt_remove_fb(display.drm_fd, &invalid_fb);
+ }
+
+ igt_fixture {
+ igt_remove_fb(display.drm_fd, &input_fb);
+ igt_display_fini(&display);
+ }
+}
diff --git a/tests/meson.build b/tests/meson.build
index 7e3f9e0a..af601725 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -66,6 +66,7 @@ test_progs = [
'kms_universal_plane',
'kms_vblank',
'kms_vrr',
+ 'kms_writeback',
'meta_test',
'panfrost_get_param',
'panfrost_gem_new',
--
2.23.0
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
[-- Attachment #2: Type: text/plain, Size: 153 bytes --]
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Intel-gfx] [PATCH v7 i-g-t 2/4] kms_writeback: Add initial writeback tests
2019-10-22 0:59 ` [igt-dev] " Brian Starkey
(?)
@ 2020-04-15 9:46 ` Maxime Ripard
2020-04-15 9:49 ` Simon Ser
-1 siblings, 1 reply; 7+ messages in thread
From: Maxime Ripard @ 2020-04-15 9:46 UTC (permalink / raw)
To: Brian Starkey; +Cc: Simon Ser, intel-gfx, igt-dev, nd
[-- Attachment #1.1: Type: text/plain, Size: 7486 bytes --]
On Mon, Oct 21, 2019 at 09:59:17PM -0300, Brian Starkey wrote:
> Add tests for the WRITEBACK_PIXEL_FORMATS, WRITEBACK_OUT_FENCE_PTR and
> WRITEBACK_FB_ID properties on writeback connectors, ensuring their
> behaviour is correct.
>
> V6: Simon Ser
> - Add igt documentation with igt_describe and IGT_TEST_DESCRIPTION
> - Drop kmstest_force_connector with FORCE_CONNECTOR_ON in
> kms_writeback_get_output since userspace won't do this operation
> - Add an igt_debug statement in case we don't use writeback output
> - Drop flags parameter from do_writeback_test
> - Remove do_writeback_test "igt_assert(*out_fence_ptr == -1)" after
> igt_display_try_commit_atomic
> - Rename writeback_fb_id to writeback_test_fb
> - Rework writeback_test_fb for checking buffer
> - Move some tests from invalid_out_fence to writeback_test_fb
> - Replace ret != 0 checking by ret == -EINVAL after invoke
> do_writeback_test
> - Assert on igt_output_get_plane_type()
> - Replace igt_fb_mod_to_tiling to DRM_FORMAT_MOD_LINEAR
> - Rename tests
> - Replace int ret by unsigned int fd_id when calling igt_create_fb
>
> Signed-off-by: Brian Starkey <brian.starkey@arm.com>
> [rebased and updated do_writeback_test() function to address feedback]
> Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
> [rebased and updated the patch to address feedback]
> Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
> ---
> tests/Makefile.sources | 1 +
> tests/kms_writeback.c | 290 +++++++++++++++++++++++++++++++++++++++++
> tests/meson.build | 1 +
> 3 files changed, 292 insertions(+)
> create mode 100644 tests/kms_writeback.c
>
> diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> index 343be050..331270ae 100644
> --- a/tests/Makefile.sources
> +++ b/tests/Makefile.sources
> @@ -81,6 +81,7 @@ TESTS_progs = \
> kms_universal_plane \
> kms_vblank \
> kms_vrr \
> + kms_writeback \
> meta_test \
> perf \
> perf_pmu \
> diff --git a/tests/kms_writeback.c b/tests/kms_writeback.c
> new file mode 100644
> index 00000000..a373ec4d
> --- /dev/null
> +++ b/tests/kms_writeback.c
> @@ -0,0 +1,290 @@
> +/*
> + * (C) COPYRIGHT 2017 ARM Limited. All rights reserved.
> + *
> + * 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 <errno.h>
> +#include <stdbool.h>
> +#include <stdio.h>
> +#include <string.h>
> +
> +#include "igt.h"
> +#include "igt_core.h"
> +#include "igt_fb.h"
> +
> +IGT_TEST_DESCRIPTION("Exercise writeback feature.");
> +
> +static drmModePropertyBlobRes *get_writeback_formats_blob(igt_output_t *output)
> +{
> + drmModePropertyBlobRes *blob = NULL;
> + uint64_t blob_id;
> + int ret;
> +
> + ret = kmstest_get_property(output->display->drm_fd,
> + output->config.connector->connector_id,
> + DRM_MODE_OBJECT_CONNECTOR,
> + igt_connector_prop_names[IGT_CONNECTOR_WRITEBACK_PIXEL_FORMATS],
> + NULL, &blob_id, NULL);
> + if (ret)
> + blob = drmModeGetPropertyBlob(output->display->drm_fd, blob_id);
> +
> + igt_assert(blob);
> +
> + return blob;
> +}
> +
> +static bool check_writeback_config(igt_display_t *display, igt_output_t *output)
> +{
> + igt_fb_t input_fb, output_fb;
> + igt_plane_t *plane;
> + uint32_t writeback_format = DRM_FORMAT_XRGB8888;
> + int width, height, ret;
> + unsigned int fb_id;
> + drmModeModeInfo override_mode = {
> + .clock = 25175,
> + .hdisplay = 640,
> + .hsync_start = 656,
> + .hsync_end = 752,
> + .htotal = 800,
> + .hskew = 0,
> + .vdisplay = 480,
> + .vsync_start = 490,
> + .vsync_end = 492,
> + .vtotal = 525,
> + .vscan = 0,
> + .vrefresh = 60,
> + .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
> + .name = {"640x480-60"},
> + };
> + igt_output_override_mode(output, &override_mode);
> +
> + width = override_mode.hdisplay;
> + height = override_mode.vdisplay;
> +
> + fb_id = igt_create_fb(display->drm_fd, width, height, DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_LINEAR, &input_fb);
> + igt_assert(fb_id >= 0);
> +
> + fb_id = igt_create_fb(display->drm_fd, width, height, writeback_format, DRM_FORMAT_MOD_LINEAR, &output_fb);
> + igt_assert(fb_id >= 0);
> +
> + plane = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
> + igt_plane_set_fb(plane, &input_fb);
> + igt_output_set_writeback_fb(output, &output_fb);
> +
> + ret = igt_display_try_commit_atomic(display, DRM_MODE_ATOMIC_TEST_ONLY |
> + DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
> + igt_plane_set_fb(plane, NULL);
> + igt_remove_fb(display->drm_fd, &input_fb);
> + igt_remove_fb(display->drm_fd, &output_fb);
> +
> + return !ret;
> +}
> +
> +static igt_output_t *kms_writeback_get_output(igt_display_t *display)
> +{
> + int i;
> +
> + for (i = 0; i < display->n_outputs; i++) {
> + igt_output_t *output = &display->outputs[i];
> + int j;
> +
> + if (output->config.connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK)
> + continue;
> +
> + for (j = 0; j < igt_display_get_n_pipes(display); j++) {
> + igt_output_set_pipe(output, j);
> +
> + if (check_writeback_config(display, output)) {
> + igt_debug("Using connector %u:%s on pipe %d\n",
> + output->config.connector->connector_id,
> + output->name, j);
> + return output;
> + }
> + }
> +
> + /* Restore any connectors we don't use, so we don't trip on them later */
> + kmstest_force_connector(display->drm_fd, output->config.connector, FORCE_CONNECTOR_UNSPECIFIED);
> + }
> +
> + igt_debug("The device does not enable writeback\n");
> +
> + return NULL;
> +}
> +
> +static void check_writeback_fb_id(igt_output_t *output)
> +{
> + uint64_t check_fb_id;
> +
> + check_fb_id = igt_output_get_prop(output, IGT_CONNECTOR_WRITEBACK_FB_ID);
> + igt_assert(check_fb_id == 0);
> +}
> +
> +static int do_writeback_test(igt_output_t *output, uint32_t fb_id,
> + int32_t *out_fence_ptr, bool ptr_valid)
> +{
> + int ret;
> + int flags = DRM_MODE_ATOMIC_ALLOW_MODESET;
> + igt_display_t *display = output->display;
> + struct kmstest_connector_config *config = &output->config;
> +
> + igt_output_set_prop_value(output, IGT_CONNECTOR_CRTC_ID, config->crtc->crtc_id);
> + igt_output_set_prop_value(output, IGT_CONNECTOR_WRITEBACK_FB_ID, fb_id);
> + igt_output_set_prop_value(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR, (uint64_t)out_fence_ptr);
On ARM (32bits), this cast creates a compilation error since the
pointer size isn't an uint64_t.
Maxime
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Intel-gfx] [PATCH v7 i-g-t 2/4] kms_writeback: Add initial writeback tests
2020-04-15 9:46 ` [Intel-gfx] " Maxime Ripard
@ 2020-04-15 9:49 ` Simon Ser
2020-04-15 10:06 ` Maxime Ripard
0 siblings, 1 reply; 7+ messages in thread
From: Simon Ser @ 2020-04-15 9:49 UTC (permalink / raw)
To: Maxime Ripard; +Cc: Brian Starkey, intel-gfx, igt-dev, nd
> > + igt_output_set_prop_value(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR, (uint64_t)out_fence_ptr);
>
> On ARM (32bits), this cast creates a compilation error since the
> pointer size isn't an uint64_t.
Does casting to uintptr_t before uint64_t fix it?
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Intel-gfx] [PATCH v7 i-g-t 2/4] kms_writeback: Add initial writeback tests
2020-04-15 9:49 ` Simon Ser
@ 2020-04-15 10:06 ` Maxime Ripard
2020-04-15 10:08 ` [igt-dev] " Petri Latvala
0 siblings, 1 reply; 7+ messages in thread
From: Maxime Ripard @ 2020-04-15 10:06 UTC (permalink / raw)
To: Simon Ser; +Cc: Brian Starkey, intel-gfx, igt-dev, nd
[-- Attachment #1.1: Type: text/plain, Size: 391 bytes --]
On Wed, Apr 15, 2020 at 09:49:46AM +0000, Simon Ser wrote:
> > > + igt_output_set_prop_value(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR, (uint64_t)out_fence_ptr);
> >
> > On ARM (32bits), this cast creates a compilation error since the
> > pointer size isn't an uint64_t.
>
> Does casting to uintptr_t before uint64_t fix it?
It does yep. Casting to uintptr_t alone also works
Maxime
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Intel-gfx] [PATCH v7 i-g-t 2/4] kms_writeback: Add initial writeback tests
2020-04-15 10:06 ` Maxime Ripard
@ 2020-04-15 10:08 ` Petri Latvala
0 siblings, 0 replies; 7+ messages in thread
From: Petri Latvala @ 2020-04-15 10:08 UTC (permalink / raw)
To: Maxime Ripard; +Cc: Brian Starkey, Simon Ser, intel-gfx, igt-dev, nd
On Wed, Apr 15, 2020 at 12:06:18PM +0200, Maxime Ripard wrote:
> On Wed, Apr 15, 2020 at 09:49:46AM +0000, Simon Ser wrote:
> > > > + igt_output_set_prop_value(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR, (uint64_t)out_fence_ptr);
> > >
> > > On ARM (32bits), this cast creates a compilation error since the
> > > pointer size isn't an uint64_t.
> >
> > Does casting to uintptr_t before uint64_t fix it?
>
> It does yep. Casting to uintptr_t alone also works
to_user_pointer(out_fence_ptr)
--
Petri Latvala
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [igt-dev] [Intel-gfx] [PATCH v7 i-g-t 2/4] kms_writeback: Add initial writeback tests
@ 2020-04-15 10:08 ` Petri Latvala
0 siblings, 0 replies; 7+ messages in thread
From: Petri Latvala @ 2020-04-15 10:08 UTC (permalink / raw)
To: Maxime Ripard
Cc: Simon Ser, intel-gfx, Liviu Dudau, igt-dev, Daniel Vetter, nd,
Brian Starkey
On Wed, Apr 15, 2020 at 12:06:18PM +0200, Maxime Ripard wrote:
> On Wed, Apr 15, 2020 at 09:49:46AM +0000, Simon Ser wrote:
> > > > + igt_output_set_prop_value(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR, (uint64_t)out_fence_ptr);
> > >
> > > On ARM (32bits), this cast creates a compilation error since the
> > > pointer size isn't an uint64_t.
> >
> > Does casting to uintptr_t before uint64_t fix it?
>
> It does yep. Casting to uintptr_t alone also works
to_user_pointer(out_fence_ptr)
--
Petri Latvala
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-04-15 13:32 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-22 0:59 [PATCH v7 i-g-t 2/4] kms_writeback: Add initial writeback tests Brian Starkey
2019-10-22 0:59 ` [igt-dev] " Brian Starkey
2020-04-15 9:46 ` [Intel-gfx] " Maxime Ripard
2020-04-15 9:49 ` Simon Ser
2020-04-15 10:06 ` Maxime Ripard
2020-04-15 10:08 ` Petri Latvala
2020-04-15 10:08 ` [igt-dev] " Petri Latvala
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.