Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Riana Tauro <riana.tauro@intel.com>
To: "Nilawar, Badal" <badal.nilawar@intel.com>,
	<igt-dev@lists.freedesktop.org>
Subject: Re: [igt-dev] [PATCH i-g-t] tests/xe: Add basic idle residency test
Date: Thu, 15 Jun 2023 13:27:45 +0530	[thread overview]
Message-ID: <ddb5f33b-d01a-6fed-935d-543546d39bd7@intel.com> (raw)
In-Reply-To: <55ad1a6f-b49f-9899-c1fe-728ee014eaa6@intel.com>



On 6/14/2023 9:28 PM, Nilawar, Badal wrote:
> Hi Riana,
> 
> On 09-06-2023 15:14, Riana Tauro wrote:
>> The test reads idle residency within a time interval and
>> checks if its within the tolerance
>>
>> Currently the test checks RC6 Residency
>>
>> Signed-off-by: Riana Tauro <riana.tauro@intel.com>
>> ---
>>   tests/meson.build     |   1 +
>>   tests/xe/xe_gt_idle.c | 117 ++++++++++++++++++++++++++++++++++++++++++
>>   2 files changed, 118 insertions(+)
>>   create mode 100644 tests/xe/xe_gt_idle.c
>>
>> diff --git a/tests/meson.build b/tests/meson.build
>> index c15eb3a08..10273ebf5 100644
>> --- a/tests/meson.build
>> +++ b/tests/meson.build
>> @@ -254,6 +254,7 @@ xe_progs = [
>>       'xe_exec_fault_mode',
>>       'xe_exec_reset',
>>       'xe_exec_threads',
>> +    'xe_gt_idle',
>>       'xe_gpgpu_fill',
>>       'xe_guc_pc',
>>       'xe_huc_copy',
>> diff --git a/tests/xe/xe_gt_idle.c b/tests/xe/xe_gt_idle.c
>> new file mode 100644
>> index 000000000..3a1090ffd
>> --- /dev/null
>> +++ b/tests/xe/xe_gt_idle.c
>> @@ -0,0 +1,117 @@
>> +// SPDX-License-Identifier: MIT
>> +/*
>> + * Copyright © 2023 Intel Corporation
>> + */
>> +
>> +/**
>> + * TEST: Test gtidle properties
>> + * Category: Software building block
>> + * Sub-category: Power Management
>> + * Functionality: RC6
>> + * Test category: functionality test
>> + */
>> +
>> +#include <limits.h>
>> +
>> +#include "igt.h"
>> +#include "igt_sysfs.h"
>> +
>> +#include "xe/xe_query.h"
>> +
>> +#define SLEEP_DURATION 3 /* in seconds */
>> +
>> +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))
>> +
>> +static bool in_rc6(int sysfs, int gt)
>> +{
>> +    char path[PATH_MAX];
>> +    char rc[8];
>> +
>> +    sprintf(path, "device/gt%d/gtidle/idle_status", gt);
>> +    if (igt_sysfs_scanf(sysfs, path, "%s", rc) < 0)
>> +        return false;
>> +
>> +    return strcmp(rc, "rc6") == 0;
>> +}
> This function is also defined in xe_guc_pc.c. So how about making this 
> function as library function may be under new file lib/xe/xe_pm.c.
Hi Badal

Intention is to move all the rc tests in guc_pc to this file
Would this be needed by any other tests?

Thanks
Riana
> 
> Regards,
> Badal
>> +
>> +static bool is_rc_dir(int sysfs, int gt)
>> +{
>> +    char path[PATH_MAX], name[NAME_MAX];
>> +    char rc[8];
>> +
>> +    sprintf(path, "device/gt%d/gtidle/name", gt);
>> +    if (igt_sysfs_scanf(sysfs, path, "%s", rc) < 0)
>> +        return false;
>> +
>> +    sprintf(name, "gt%d-rc", gt);
>> +    return strcmp(rc, name) == 0;
>> +}
>> +
>> +static unsigned long read_idle_residency(int sysfs, int gt)
>> +{
>> +    unsigned long residency;
>> +    char path[PATH_MAX];
>> +
>> +    residency = 0;
>> +    sprintf(path, "device/gt%d/gtidle/idle_residency_ms", gt);
>> +    igt_assert(igt_sysfs_scanf(sysfs, path, "%lu", &residency) == 1);
>> +    return residency;
>> +}
>> +
>> +/**
>> + * SUBTEST: idle-residency
>> + * Description: basic residency test to check idle residency
>> + *         within a time interval
>> + * Run type: FULL
>> + */
>> +static void test_idle(int sysfs, int gt)
>> +{
>> +    struct timespec tv;
>> +    unsigned long elapsed_ms, residency_start, residency_end;
>> +
>> +    assert(is_rc_dir(sysfs, gt));
>> +    assert(igt_wait(in_rc6(sysfs, gt), 1000, 1));
>> +
>> +    igt_gettime(&tv);
>> +    residency_start = read_idle_residency(sysfs, gt);
>> +    sleep(SLEEP_DURATION);
>> +    residency_end = read_idle_residency(sysfs, gt);
>> +    elapsed_ms = igt_nsec_elapsed(&tv) / 1000000;
>> +
>> +    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;
>> +    static int sysfs = -1;
>> +
>> +    igt_fixture {
>> +        fd = drm_open_driver(DRIVER_XE);
>> +
>> +        xe_device_get(fd);
>> +        sysfs = igt_sysfs_open(fd);
>> +        igt_assert(sysfs != -1);
>> +    }
>> +
>> +    igt_subtest("idle-residency")
>> +        xe_for_each_gt(fd, gt)
>> +            test_idle(sysfs, gt);
>> +
>> +    igt_fixture {
>> +        close(sysfs);
>> +        xe_device_put(fd);
>> +        close(fd);
>> +    }
>> +}

  reply	other threads:[~2023-06-15  7:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-09  9:44 [igt-dev] [PATCH i-g-t] tests/xe: Add basic idle residency test Riana Tauro
2023-06-09 17:33 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2023-06-10 23:43 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2023-06-12 13:29 ` [igt-dev] [PATCH i-g-t] " Kamil Konieczny
2023-06-13  9:47   ` Riana Tauro
2023-06-14 13:27     ` Kamil Konieczny
2023-06-21  4:31       ` Riana Tauro
2023-06-14 15:58 ` Nilawar, Badal
2023-06-15  7:57   ` Riana Tauro [this message]
2023-06-15 11:33     ` Nilawar, Badal

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=ddb5f33b-d01a-6fed-935d-543546d39bd7@intel.com \
    --to=riana.tauro@intel.com \
    --cc=badal.nilawar@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /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