[igt-dev] [CI 3/5] tests/psr: Move PSR state test functions to lib
Rodrigo Vivi
rodrigo.vivi at intel.com
Mon Jul 16 17:38:43 UTC 2018
On Sat, Jul 14, 2018 at 03:19:13PM -0700, Dhinakaran Pandiyan wrote:
> kms_frontbuffer_tracking and kms_psr test PSR in different ways, let'
> fix that by creating common library functions.
>
> Also, rename wait_psr_entry to psr_wait_entry.
>
> v2: Include the new file in meson.build
>
> Cc: Rodrigo Vivi <rodrigo.vivi at intel.com>
> Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan at intel.com>
maybe we could already move the kms_frontbuffer_tracking to use this
library on the same patch... but anyways it is cleaner this way, so:
Reviewed-by: Rodrigo Vivi <rodrigo.vivi at intel.com>
> ---
> lib/Makefile.sources | 2 ++
> lib/igt_psr.c | 40 ++++++++++++++++++++++++++++++++++++++++
> lib/igt_psr.h | 34 ++++++++++++++++++++++++++++++++++
> lib/meson.build | 1 +
> tests/kms_psr.c | 38 +++++++++++---------------------------
> 5 files changed, 88 insertions(+), 27 deletions(-)
> create mode 100644 lib/igt_psr.c
> create mode 100644 lib/igt_psr.h
>
> diff --git a/lib/Makefile.sources b/lib/Makefile.sources
> index 042c1d3b..14356c94 100644
> --- a/lib/Makefile.sources
> +++ b/lib/Makefile.sources
> @@ -103,6 +103,8 @@ lib_source_list = \
> igt_kmod.h \
> igt_syncobj.c \
> igt_syncobj.h \
> + igt_psr.c \
> + igt_psr.h \
> $(NULL)
>
> .PHONY: version.h.tmp
> diff --git a/lib/igt_psr.c b/lib/igt_psr.c
> new file mode 100644
> index 00000000..c979b0b5
> --- /dev/null
> +++ b/lib/igt_psr.c
> @@ -0,0 +1,40 @@
> +/*
> + * Copyright © 2018 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_psr.h"
> +
> +bool psr_active(int fd, bool check_active)
> +{
> + bool active;
> + char buf[512];
> +
> + igt_debugfs_read(fd, "i915_edp_psr_status", buf);
> + active = strstr(buf, "HW Enabled & Active bit: yes\n") &&
> + (strstr(buf, "SRDENT") || strstr(buf, "SLEEP"));
> + return check_active ? active : !active;
> +}
> +
> +bool psr_wait_entry(int fd)
> +{
> + return igt_wait(psr_active(fd, true), 500, 1);
> +}
> diff --git a/lib/igt_psr.h b/lib/igt_psr.h
> new file mode 100644
> index 00000000..980f85e0
> --- /dev/null
> +++ b/lib/igt_psr.h
> @@ -0,0 +1,34 @@
> +/*
> + * Copyright © 2018 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.
> + */
> +
> +#ifndef IGT_PSR_H
> +#define IGT_PSR_H
> +
> +#include "igt_debugfs.h"
> +#include "igt_core.h"
> +#include "igt_aux.h"
> +
> +bool psr_wait_entry(int fd);
> +bool psr_active(int fd, bool check_active);
> +
> +#endif
> diff --git a/lib/meson.build b/lib/meson.build
> index 939167f9..74a5f61e 100644
> --- a/lib/meson.build
> +++ b/lib/meson.build
> @@ -48,6 +48,7 @@ lib_sources = [
> 'uwildmat/uwildmat.c',
> 'igt_kmod.c',
> 'igt_vc4.c',
> + 'igt_psr.c',
> ]
>
> lib_deps = [
> diff --git a/tests/kms_psr.c b/tests/kms_psr.c
> index ded8346a..1ed1f232 100644
> --- a/tests/kms_psr.c
> +++ b/tests/kms_psr.c
> @@ -24,6 +24,7 @@
>
> #include "igt.h"
> #include "igt_sysfs.h"
> +#include "igt_psr.h"
> #include <errno.h>
> #include <stdbool.h>
> #include <stdio.h>
> @@ -195,23 +196,6 @@ static bool sink_support(data_t *data)
> return strstr(buf, "Sink_Support: yes\n");
> }
>
> -static bool psr_active(int fd, bool check_active)
> -{
> - bool active;
> - char buf[512];
> -
> - igt_debugfs_read(fd, "i915_edp_psr_status", buf);
> -
> - active = strstr(buf, "HW Enabled & Active bit: yes\n") &&
> - (strstr(buf, "SRDENT") || strstr(buf, "SLEEP"));
> - return check_active ? active : !active;
> -}
> -
> -static bool wait_psr_entry(int fd)
> -{
> - return igt_wait((psr_active(fd, true)), 500, 1);
> -}
> -
> static inline void manual(const char *expected)
> {
> igt_debug_manual_check("all", expected);
> @@ -237,7 +221,7 @@ static void run_test(data_t *data)
> manual("screen GREEN");
>
> /* Confirm screen stays Green after PSR got active */
> - igt_assert(wait_psr_entry(data->drm_fd));
> + igt_assert(psr_wait_entry(data->drm_fd));
> manual("screen GREEN");
>
> /* Setting a secondary fb/plane */
> @@ -250,7 +234,7 @@ static void run_test(data_t *data)
> else
> manual("GREEN background with WHITE box");
>
> - igt_assert(wait_psr_entry(data->drm_fd));
> + igt_assert(psr_wait_entry(data->drm_fd));
> switch (data->op) {
> case PAGE_FLIP:
> /* Only in use when testing primary plane */
> @@ -408,13 +392,13 @@ igt_main
>
> igt_subtest("basic") {
> setup_test_plane(&data, DRM_PLANE_TYPE_PRIMARY);
> - igt_assert(wait_psr_entry(data.drm_fd));
> + igt_assert(psr_wait_entry(data.drm_fd));
> test_cleanup(&data);
> }
>
> igt_subtest("no_drrs") {
> setup_test_plane(&data, DRM_PLANE_TYPE_PRIMARY);
> - igt_assert(wait_psr_entry(data.drm_fd));
> + igt_assert(psr_wait_entry(data.drm_fd));
> igt_assert(drrs_disabled(&data));
> test_cleanup(&data);
> }
> @@ -423,7 +407,7 @@ igt_main
> igt_subtest_f("primary_%s", op_str(op)) {
> data.op = op;
> setup_test_plane(&data, DRM_PLANE_TYPE_PRIMARY);
> - igt_assert(wait_psr_entry(data.drm_fd));
> + igt_assert(psr_wait_entry(data.drm_fd));
> run_test(&data);
> test_cleanup(&data);
> }
> @@ -433,7 +417,7 @@ igt_main
> igt_subtest_f("sprite_%s", op_str(op)) {
> data.op = op;
> setup_test_plane(&data, DRM_PLANE_TYPE_OVERLAY);
> - igt_assert(wait_psr_entry(data.drm_fd));
> + igt_assert(psr_wait_entry(data.drm_fd));
> run_test(&data);
> test_cleanup(&data);
> }
> @@ -443,7 +427,7 @@ igt_main
> igt_subtest_f("cursor_%s", op_str(op)) {
> data.op = op;
> setup_test_plane(&data, DRM_PLANE_TYPE_CURSOR);
> - igt_assert(wait_psr_entry(data.drm_fd));
> + igt_assert(psr_wait_entry(data.drm_fd));
> run_test(&data);
> test_cleanup(&data);
> }
> @@ -452,7 +436,7 @@ igt_main
> igt_subtest_f("dpms") {
> data.op = RENDER;
> setup_test_plane(&data, DRM_PLANE_TYPE_PRIMARY);
> - igt_assert(wait_psr_entry(data.drm_fd));
> + igt_assert(psr_wait_entry(data.drm_fd));
> dpms_off_on(&data);
> run_test(&data);
> test_cleanup(&data);
> @@ -461,10 +445,10 @@ igt_main
> igt_subtest_f("suspend") {
> data.op = PLANE_ONOFF;
> setup_test_plane(&data, DRM_PLANE_TYPE_CURSOR);
> - igt_assert(wait_psr_entry(data.drm_fd));
> + igt_assert(psr_wait_entry(data.drm_fd));
> igt_system_suspend_autoresume(SUSPEND_STATE_MEM,
> SUSPEND_TEST_NONE);
> - igt_assert(wait_psr_entry(data.drm_fd));
> + igt_assert(psr_wait_entry(data.drm_fd));
> run_test(&data);
> test_cleanup(&data);
> }
> --
> 2.17.1
>
> _______________________________________________
> igt-dev mailing list
> igt-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev
More information about the igt-dev
mailing list