From: "Nilawar, Badal" <badal.nilawar@intel.com>
To: Riana Tauro <riana.tauro@intel.com>, <igt-dev@lists.freedesktop.org>
Subject: Re: [igt-dev] [PATCH i-g-t v4 1/3] tests/xe: Add basic idle residency test
Date: Fri, 14 Jul 2023 15:52:31 +0530 [thread overview]
Message-ID: <c5e10faf-3495-c7b5-4a1e-1118b2eb73c1@intel.com> (raw)
In-Reply-To: <20230714094121.1446298-2-riana.tauro@intel.com>
On 14-07-2023 15:11, Riana Tauro wrote:
> This test validates idle residency measured over a time interval
> is within the tolerance.
>
> Patch for gtidle properties
> https://patchwork.freedesktop.org/series/119262/
>
> v2:
> - rename file to xe_pm_residency
> - add kernel patch in commit message (Kamil)
>
> v3:
> - add igt test description (Anshuman)
>
> v4:
> - fix cosmetic review comments
> - replace assert with igt_assert_f (Anshuman)
>
> v5:
> - use tile sysfs library functions
>
> v6:
> - fix cosmetic review comments (Badal)
>
> Signed-off-by: Riana Tauro <riana.tauro@intel.com>
> Reviewed-by: Anshuman Gupta <anshuman.gupta@intel.com>
Acked-by: Badal Nilawar <badal.nilawar@intel.com>
> ---
> tests/meson.build | 1 +
> tests/xe/xe_pm_residency.c | 113 +++++++++++++++++++++++++++++++++++++
> 2 files changed, 114 insertions(+)
> create mode 100644 tests/xe/xe_pm_residency.c
>
> diff --git a/tests/meson.build b/tests/meson.build
> index 3eddb2fb4..944a0941f 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -287,6 +287,7 @@ xe_progs = [
> 'xe_module_load',
> 'xe_noexec_ping_pong',
> 'xe_pm',
> + 'xe_pm_residency',
> 'xe_prime_self_import',
> 'xe_query',
> 'xe_sysfs_tile',
> diff --git a/tests/xe/xe_pm_residency.c b/tests/xe/xe_pm_residency.c
> new file mode 100644
> index 000000000..4fd374933
> --- /dev/null
> +++ b/tests/xe/xe_pm_residency.c
> @@ -0,0 +1,113 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright © 2023 Intel Corporation
> + */
> +
> +/**
> + * TEST: Test gtidle properties
> + * Category: Software building block
> + * Sub-category: Power Management
> + * Functionality: GT C States
> + * Test category: functionality test
> + */
> +
> +#include "igt.h"
> +#include "igt_sysfs.h"
> +
> +#include "xe/xe_query.h"
> +
> +#define SLEEP_DURATION 3000 /* in milliseconds */
> +
> +const double tolerance = 0.1;
> +
> +#define assert_within_epsilon(x, ref, tol) \
> + igt_assert_f((double)(x) <= (1.0 + (tol)) * (double)(ref) && \
> + (double)(x) >= (1.0 - (tol)) * (double)(ref), \
> + "'%s' != '%s' (%f not within +%.1f%%/-%.1f%% tolerance of %f)\n",\
> + #x, #ref, (double)(x), \
> + (tol) * 100.0, (tol) * 100.0, \
> + (double)(ref))
> +
> +IGT_TEST_DESCRIPTION("Tests for gtidle properties");
> +
> +static unsigned int measured_usleep(unsigned int usec)
> +{
> + struct timespec ts = { };
> + unsigned int slept;
> +
> + slept = igt_nsec_elapsed(&ts);
> + igt_assert(slept == 0);
> + do {
> + usleep(usec - slept);
> + slept = igt_nsec_elapsed(&ts) / 1000;
> + } while (slept < usec);
> +
> + return igt_nsec_elapsed(&ts) / 1000;
> +}
> +
> +static bool is_gt_in_c6(int fd, int gt)
> +{
> + char gt_c_state[16];
> + int gt_fd;
> +
> + gt_fd = xe_sysfs_gt_open(fd, gt);
> + igt_assert(gt_fd >= 0);
> + igt_assert(igt_sysfs_scanf(gt_fd, "gtidle/idle_status", "%s", gt_c_state) == 1);
> + close(gt_fd);
> +
> + return strcmp(gt_c_state, "gt-c6") == 0;
> +}
> +
> +static unsigned long read_idle_residency(int fd, int gt)
> +{
> + unsigned long residency = 0;
> + int gt_fd;
> +
> + gt_fd = xe_sysfs_gt_open(fd, gt);
> + igt_assert(gt_fd >= 0);
> + igt_assert(igt_sysfs_scanf(gt_fd, "gtidle/idle_residency_ms", "%lu", &residency) == 1);
> + close(gt_fd);
> +
> + return residency;
> +}
> +
> +/**
> + * SUBTEST: idle-residency
> + * Description: basic residency test to validate idle residency
> + * measured over a time interval is within the tolerance
> + * Run type: FULL
> + */
> +static void test_idle_residency(int fd, int gt)
> +{
> + unsigned long elapsed_ms, residency_start, residency_end;
> +
> + igt_assert_f(igt_wait(is_gt_in_c6(fd, gt), 1000, 1), "GT not in C6\n");
> +
> + residency_start = read_idle_residency(fd, gt);
> + elapsed_ms = measured_usleep(SLEEP_DURATION * 1000) / 1000;
> + residency_end = read_idle_residency(fd, gt);
> +
> + igt_info("Measured %lums of idle residency in %lums\n",
> + residency_end - residency_start, elapsed_ms);
> +
> + assert_within_epsilon(residency_end - residency_start, elapsed_ms, tolerance);
> +}
> +
> +igt_main
> +{
> + int fd, gt;
> +
> + igt_fixture {
> + fd = drm_open_driver(DRIVER_XE);
> + igt_require(!IS_PONTEVECCHIO(xe_dev_id(fd)));
> + }
> +
> + igt_describe("Validate idle residency measured over a time interval is within the tolerance");
> + igt_subtest("idle-residency")
> + xe_for_each_gt(fd, gt)
> + test_idle_residency(fd, gt);
> +
> + igt_fixture {
> + close(fd);
> + }
> +}
next prev parent reply other threads:[~2023-07-14 10:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-14 9:41 [igt-dev] [PATCH i-g-t v4 0/3] Test for gtidle properties Riana Tauro
2023-07-14 9:41 ` [igt-dev] [PATCH i-g-t v4 1/3] tests/xe: Add basic idle residency test Riana Tauro
2023-07-14 10:22 ` Nilawar, Badal [this message]
2023-07-14 9:41 ` [igt-dev] [PATCH i-g-t v4 2/3] tests/xe: Validate GT is in C6 on idle Riana Tauro
2023-07-14 10:21 ` Nilawar, Badal
2023-07-14 9:41 ` [igt-dev] [PATCH i-g-t v4 3/3] xe-fast-feedback.testlist: Add gt-c6-on-idle to BAT Riana Tauro
2023-07-14 11:10 ` Gupta, Anshuman
2023-07-14 11:28 ` Nilawar, Badal
2023-07-14 12:03 ` Gupta, Anshuman
2023-07-14 10:19 ` [igt-dev] ○ CI.xeBAT: info for Test for gtidle properties (rev5) Patchwork
2023-07-14 10:19 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2023-07-14 12:11 ` [igt-dev] ✗ Fi.CI.IGT: failure " 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=c5e10faf-3495-c7b5-4a1e-1118b2eb73c1@intel.com \
--to=badal.nilawar@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=riana.tauro@intel.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