From: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
To: igt-dev@lists.freedesktop.org
Cc: Eben Upton <eben@raspberrypi.org>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: [igt-dev] [PATCH i-g-t RFC v2 4/4] tests: Add VC4 load tracker tests
Date: Wed, 6 Feb 2019 16:00:59 +0100 [thread overview]
Message-ID: <20190206150059.24679-5-paul.kocialkowski@bootlin.com> (raw)
In-Reply-To: <20190206150059.24679-1-paul.kocialkowski@bootlin.com>
This introduces new tests for the VC4 load tracking mechanism, that
will attempt to add "as many planes as possibles" in the mode
resolution. The associated sub-tests are the following:
- bandwidth-detection: checks that bandwidth limitation is detected;
- underrun-detection: checks that hardware underruns are detected;
- consistency: checks that bandwidth and underrun reports are consistent;
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
tests/meson.build | 1 +
tests/vc4_load_tracker.c | 254 +++++++++++++++++++++++++++++++++++++++
2 files changed, 255 insertions(+)
create mode 100644 tests/vc4_load_tracker.c
diff --git a/tests/meson.build b/tests/meson.build
index 0f12df26d9fb..beff2568cf78 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -86,6 +86,7 @@ test_progs = [
'vc4_create_bo',
'vc4_dmabuf_poll',
'vc4_label_bo',
+ 'vc4_load_tracker',
'vc4_lookup_fail',
'vc4_purgeable_bo',
'vc4_tiling',
diff --git a/tests/vc4_load_tracker.c b/tests/vc4_load_tracker.c
new file mode 100644
index 000000000000..208279c7ee8f
--- /dev/null
+++ b/tests/vc4_load_tracker.c
@@ -0,0 +1,254 @@
+/*
+ * Copyright © 2018 Bootlin
+ * Copyright © 2018 Broadcom
+ *
+ * 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"
+#include "igt_vc4.h"
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <poll.h>
+#include "vc4_drm.h"
+
+static igt_output_t *select_output(igt_display_t *display)
+{
+ igt_output_t *output;
+ enum pipe pipe;
+
+ for_each_pipe(display, pipe) {
+ for_each_valid_output_on_pipe(display, pipe, output) {
+ drmModeConnector *connector = output->config.connector;
+
+ if (connector->connection != DRM_MODE_CONNECTED)
+ continue;
+
+ igt_output_set_pipe(output, pipe);
+
+ return output;
+ }
+ }
+
+ return NULL;
+}
+
+static void setup_primary_plane(int drm_fd, igt_output_t *output,
+ uint32_t width, uint32_t height,
+ igt_plane_t **plane, struct igt_fb *fb)
+{
+ unsigned int fb_id;
+
+ *plane = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+ igt_assert(*plane);
+
+ fb_id = igt_create_pattern_fb(drm_fd, width, height,
+ DRM_FORMAT_ARGB8888,
+ LOCAL_DRM_FORMAT_MOD_NONE, fb);
+ igt_assert(fb_id > 0);
+
+ igt_plane_set_fb(*plane, fb);
+}
+
+static void setup_overlay_plane(int drm_fd, igt_output_t *output,
+ unsigned int index, uint32_t width,
+ uint32_t height, struct igt_fb *fbs)
+{
+ unsigned int fb_id;
+ struct igt_fb *fb = &fbs[index];
+ igt_plane_t *plane =
+ igt_output_get_plane_type_index(output, DRM_PLANE_TYPE_OVERLAY,
+ index);
+ igt_assert(plane);
+
+ fb_id = igt_create_pattern_fb(drm_fd, width, height,
+ DRM_FORMAT_ARGB8888,
+ LOCAL_DRM_FORMAT_MOD_NONE, fb);
+ igt_assert(fb_id > 0);
+
+ igt_plane_set_fb(plane, fb);
+ igt_plane_set_position(plane, 10 * (index + 1), 10 * (index + 1));
+}
+
+static void cleanup_overlay_plane(int drm_fd, igt_output_t *output,
+ unsigned int index, struct igt_fb *fbs,
+ bool cleanup_fb)
+{
+ struct igt_fb *fb = &fbs[index];
+ igt_plane_t *plane =
+ igt_output_get_plane_type_index(output, DRM_PLANE_TYPE_OVERLAY,
+ index);
+ igt_assert(plane);
+
+ if (cleanup_fb)
+ igt_remove_fb(drm_fd, fb);
+ else
+ igt_plane_set_fb(plane, NULL);
+}
+
+static void load_tracker_test(int drm_fd, igt_display_t *display,
+ bool test_consistency, bool test_bandwidth)
+{
+ igt_output_t *output;
+ drmModeModeInfo *mode;
+ struct igt_fb primary_fb;
+ igt_plane_t *primary_plane;
+ struct igt_fb *overlay_fbs;
+ uint32_t overlay_width, overlay_height;
+ unsigned int overlay_planes_count;
+ unsigned int count;
+ unsigned int index;
+ bool load_tracker_initial = false;
+ bool bandwidth_exceeded = false;
+ bool underrun_detected = false;
+ int underrun_count;
+ int debugfs;
+ int ret;
+
+ debugfs = igt_debugfs_dir(drm_fd);
+ igt_assert(debugfs >= 0);
+
+ underrun_count = igt_vc4_get_underrun_count(debugfs);
+ load_tracker_initial = igt_vc4_get_load_tracker(debugfs);
+
+ output = select_output(display);
+ igt_assert(output);
+
+ igt_debug("Selected connector %s\n",
+ kmstest_connector_type_str(output->config.connector->connector_type));
+
+ mode = igt_output_get_mode(output);
+ igt_assert(mode);
+
+ setup_primary_plane(drm_fd, output, mode->hdisplay, mode->vdisplay,
+ &primary_plane, &primary_fb);
+
+ overlay_planes_count =
+ igt_output_count_plane_type(output, DRM_PLANE_TYPE_OVERLAY);
+
+ overlay_fbs = calloc(sizeof(struct igt_fb), overlay_planes_count);
+
+ overlay_width = mode->hdisplay;
+ overlay_height = mode->vdisplay;
+
+ for (count = 1; count <= overlay_planes_count; count++) {
+ int underrun_update;
+
+ igt_debug("Using %d overlay planes with resolution %dx%d\n",
+ overlay_planes_count, overlay_width, overlay_height);
+
+ for (index = 0; index < count; index++)
+ setup_overlay_plane(drm_fd, output, index,
+ overlay_width, overlay_height,
+ overlay_fbs);
+
+ igt_vc4_set_load_tracker(debugfs, true);
+
+ ret = igt_display_try_commit2(display, COMMIT_ATOMIC);
+ bandwidth_exceeded = (ret < 0 && errno == ENOSPC);
+
+ igt_debug("Bandwidth limitation exeeded: %s\n",
+ bandwidth_exceeded ? "Yes" : "No");
+
+ igt_vc4_set_load_tracker(debugfs, false);
+
+ igt_display_commit2(display, COMMIT_ATOMIC);
+
+ igt_wait_for_vblank(drm_fd, output->pending_pipe);
+
+ underrun_update = igt_vc4_get_underrun_count(debugfs);
+
+ underrun_detected = (underrun_update > underrun_count);
+ underrun_count = underrun_update;
+
+ igt_debug("Underrun detected: %s\n",
+ underrun_detected ? "Yes" : "No");
+
+ if (test_consistency)
+ igt_assert(bandwidth_exceeded == underrun_detected);
+
+ for (index = 0; index < count; index++)
+ cleanup_overlay_plane(drm_fd, output, index,
+ overlay_fbs, false);
+
+ igt_display_commit2(display, COMMIT_ATOMIC);
+
+ for (index = 0; index < count; index++)
+ cleanup_overlay_plane(drm_fd, output, index,
+ overlay_fbs, true);
+
+ if ((test_bandwidth && bandwidth_exceeded) ||
+ (!test_bandwidth && underrun_detected))
+ break;
+ }
+
+ if (test_bandwidth)
+ igt_assert(bandwidth_exceeded);
+ else
+ igt_assert(underrun_detected);
+
+ free(overlay_fbs);
+
+ igt_plane_set_fb(primary_plane, NULL);
+
+ igt_display_commit2(display, COMMIT_ATOMIC);
+
+ igt_remove_fb(drm_fd, &primary_fb);
+
+ igt_vc4_set_load_tracker(debugfs, load_tracker_initial);
+ close(debugfs);
+}
+
+igt_main
+{
+ igt_display_t display;
+ int drm_fd;
+
+ igt_fixture {
+ drm_fd = drm_open_driver(DRIVER_VC4);
+
+ kmstest_set_vt_graphics_mode();
+
+ igt_display_require(&display, drm_fd);
+ igt_require(display.is_atomic);
+ }
+
+ igt_subtest("bandwidth-detection")
+ load_tracker_test(drm_fd, &display, false, true);
+
+ igt_subtest("underrun-detection")
+ load_tracker_test(drm_fd, &display, false, false);
+
+ igt_subtest("consistency")
+ load_tracker_test(drm_fd, &display, true, false);
+
+ igt_fixture {
+ igt_display_fini(&display);
+ kmstest_restore_vt_mode();
+ close(drm_fd);
+ }
+}
--
2.20.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2019-02-06 15:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-06 15:00 [igt-dev] [PATCH i-g-t RFC v2 0/4] VC4 load tracker testing Paul Kocialkowski
2019-02-06 15:00 ` [igt-dev] [PATCH i-g-t RFC v2 1/4] lib/igt_kms: Add helpers to count and iterate planes from pipe Paul Kocialkowski
2019-02-06 15:00 ` [igt-dev] [PATCH i-g-t RFC v2 2/4] lib/igt_kms: Add helpers to count and iterate planes from output Paul Kocialkowski
2019-02-06 15:00 ` [igt-dev] [PATCH i-g-t RFC v2 3/4] lib/igt_vc4: Add helpers for underrun count and load tracker state Paul Kocialkowski
2019-02-06 15:00 ` Paul Kocialkowski [this message]
2019-02-06 16:07 ` [igt-dev] ✓ Fi.CI.BAT: success for VC4 load tracker testing (rev3) Patchwork
2019-02-06 16:59 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
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=20190206150059.24679-5-paul.kocialkowski@bootlin.com \
--to=paul.kocialkowski@bootlin.com \
--cc=eben@raspberrypi.org \
--cc=igt-dev@lists.freedesktop.org \
--cc=thomas.petazzoni@bootlin.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