[Intel-gfx] [PATCH i-g-t 2/3] tests/i915: Default fence expiry test
Matthew Auld
matthew.william.auld at gmail.com
Tue Mar 30 12:53:56 UTC 2021
On Thu, 18 Mar 2021 at 16:24, Tvrtko Ursulin
<tvrtko.ursulin at linux.intel.com> wrote:
>
> From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
>
> Basic test to check that default fence expiry works as expected.
>
> Relies on the modparam to run quicker.
>
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> ---
> tests/Makefile.sources | 3 +
> tests/i915/gem_watchdog.c | 376 ++++++++++++++++++++++++++++++++++++++
> tests/meson.build | 1 +
> 3 files changed, 380 insertions(+)
> create mode 100644 tests/i915/gem_watchdog.c
>
> diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> index 4f24fb3a15a5..e992285fedc5 100644
> --- a/tests/Makefile.sources
> +++ b/tests/Makefile.sources
> @@ -463,6 +463,9 @@ gem_userptr_blits_SOURCES = i915/gem_userptr_blits.c
> TESTS_progs += gem_wait
> gem_wait_SOURCES = i915/gem_wait.c
>
> +TESTS_progs += gem_watchdog
> +gem_exec_watchdog_SOURCES = i915/gem_watchdog.c
> +
> TESTS_progs += gem_workarounds
> gem_workarounds_SOURCES = i915/gem_workarounds.c
>
> diff --git a/tests/i915/gem_watchdog.c b/tests/i915/gem_watchdog.c
> new file mode 100644
> index 000000000000..f86d3d4c7437
> --- /dev/null
> +++ b/tests/i915/gem_watchdog.c
> @@ -0,0 +1,376 @@
> +/*
> + * Copyright © 2021 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 "config.h"
> +
> +#include <stdio.h>
> +#include <unistd.h>
> +#include <sched.h>
> +
> +#include "i915/gem.h"
> +#include "igt.h"
> +#include "igt_params.h"
> +#include "sw_sync.h"
> +
> +#define EWATCHDOG EINTR
> +
> +static struct drm_i915_query_engine_info *__engines__;
> +
> +static int __i915_query(int fd, struct drm_i915_query *q)
> +{
> + if (igt_ioctl(fd, DRM_IOCTL_I915_QUERY, q))
> + return -errno;
> + return 0;
> +}
> +
> +static int
> +__i915_query_items(int fd, struct drm_i915_query_item *items, uint32_t n_items)
> +{
> + struct drm_i915_query q = {
> + .num_items = n_items,
> + .items_ptr = to_user_pointer(items),
> + };
> + return __i915_query(fd, &q);
> +}
> +
> +#define i915_query_items(fd, items, n_items) do { \
> + igt_assert_eq(__i915_query_items(fd, items, n_items), 0); \
> + errno = 0; \
> + } while (0)
> +
> +static unsigned int default_timeout_wait_s;
> +static const unsigned int watchdog_us = 500 * 1000;
> +
> +static unsigned int
> +wait_timeout(int i915, igt_spin_t **spin, unsigned int num_engines,
> + unsigned int wait_us, unsigned int expect)
> +{
> + unsigned int count_idle = 0, count_fence = 0, count_started = 0, i;
> + bool started[num_engines];
> +
> + memset(started, 0, sizeof(started));
> +
> + while (count_started < num_engines) {
> + for (i = 0; i < num_engines; i++) {
> + if (started[i])
> + continue;
> +
> + if (igt_spin_has_started(spin[i])) {
> + started[i] = true;
> + count_started++;
> + }
> + }
> + }
for_each {
igt_spin_busywait_until_started(spin[i])
}
Might be slightly simpler?
Reviewed-by: Matthew Auld <matthew.auld at intel.com>
More information about the Intel-gfx
mailing list