<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <div class="moz-cite-prefix">On 28-05-2025 00:09,
      <a class="moz-txt-link-abbreviated" href="mailto:sk.anirban@intel.com">sk.anirban@intel.com</a> wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:20250527183957.4137136-1-sk.anirban@intel.com">
      <pre wrap="" class="moz-quote-pre">From: Sk Anirban <a class="moz-txt-link-rfc2396E" href="mailto:sk.anirban@intel.com"><sk.anirban@intel.com></a>

Update the vram-d3cold-threshold test to include validation of
VRAM self-refresh functionality. It introduces checks for VRAM
self-refresh capability and verifies the ModS residency to ensure
accurate self-refresh behavior.
The test now distinguishes between D3Cold and D3Hot states based on
VRAM self-refresh capability.</pre>
    </blockquote>
    <pre wrap="" class="moz-quote-pre"><span style="color: rgb(66, 66, 66); font-family: "Segoe Sans", "Segoe UI", "Segoe UI Web (West European)", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(250, 250, 250); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">You can rephase commit message to<code>,</code>

Update the<span> </span></span><code style="color: rgb(66, 66, 66); font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(250, 250, 250); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">vram-d3cold-threshold</code><span style="color: rgb(66, 66, 66); font-family: "Segoe Sans", "Segoe UI", "Segoe UI Web (West European)", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(250, 250, 250); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"><span> </span>test to include validatation of
VRAM self-refresh (VRSR) functionality, by including checks for VRSR capability and ModS residency.
The test now differentiates between D3Cold and D3Hot states based on VRAM self-refresh capability."</span></pre>
    <blockquote type="cite" cite="mid:20250527183957.4137136-1-sk.anirban@intel.com">
      <pre wrap="" class="moz-quote-pre">

Signed-off-by: Sk Anirban <a class="moz-txt-link-rfc2396E" href="mailto:sk.anirban@intel.com"><sk.anirban@intel.com></a>
---
 tests/intel/xe_pm.c | 51 ++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 50 insertions(+), 1 deletion(-)

diff --git a/tests/intel/xe_pm.c b/tests/intel/xe_pm.c
index 6eb21d5ec..f8074a9c6 100644
--- a/tests/intel/xe_pm.c
+++ b/tests/intel/xe_pm.c
@@ -144,6 +144,29 @@ static void vram_d3cold_threshold_restore(int sig)
        close(fd);
 }
 
+static uint64_t read_mods(device_t device)
+{
+       uint64_t mods_value;
+       char buf[4096];</pre>
    </blockquote>
    we dont need 4K buf here, 256 Bytes should be enough.
    <blockquote type="cite" cite="mid:20250527183957.4137136-1-sk.anirban@intel.com">
      <pre wrap="" class="moz-quote-pre">
+       int dir, ret;
+       char *mods_ptr;
+
+       dir = igt_debugfs_dir(device.fd_xe);
+       igt_assert(dir >= 0);
+</pre>
    </blockquote>
    this extra line space is not necessary
    <blockquote type="cite" cite="mid:20250527183957.4137136-1-sk.anirban@intel.com">
      <pre wrap="" class="moz-quote-pre">
+       ret = igt_debugfs_simple_read(dir, "gtidle/dgfx_pkg_residencies", buf, sizeof(buf));
+       igt_assert_f(ret >= 0, "Debugfs dgfx_pkg_residencies is not present.\n");
+</pre>
    </blockquote>
    this extra line space is not necessary
    <blockquote type="cite" cite="mid:20250527183957.4137136-1-sk.anirban@intel.com">
      <pre wrap="" class="moz-quote-pre">
+       close(dir);
+
+       mods_ptr = strstr(buf, "Package ModS: ");
+</pre>
    </blockquote>
    extra line space not needed here.
    <blockquote type="cite" cite="mid:20250527183957.4137136-1-sk.anirban@intel.com">
      <pre wrap="" class="moz-quote-pre">
+       if (mods_ptr)
+               sscanf(mods_ptr, "Package ModS: %"PRIu64"\n", &mods_value);
+
+       return mods_value;
+}
+
 static bool setup_d3(device_t device, enum igt_acpi_d_state state)
 {
        igt_require_f(igt_has_pci_pm_capability(device.pci_xe),
@@ -561,10 +584,25 @@ static void test_vram_d3cold_threshold(device_t device, int sysfs_fd)
        };
        uint64_t vram_used_mb = 0, vram_total_mb = 0, threshold;
        uint32_t bo, placement;
+       int vrsr_capability = 0;
+       uint64_t mods_value = 0;
+       char buf[4096];</pre>
    </blockquote>
    we dont need 4K buf here, 8 Bytes should be enough.
    <blockquote type="cite" cite="mid:20250527183957.4137136-1-sk.anirban@intel.com">
      <pre wrap="" class="moz-quote-pre">
+       int dir, ret;
        bool active;
        void *map;
        int i;
 
+       dir = igt_debugfs_dir(device.fd_xe);
+       igt_assert(dir >= 0);
+
+       ret = igt_debugfs_simple_read(dir, "vrsr_capable",
+                                     buf, sizeof(buf));
+       igt_assert_f(ret >= 0, "Debugfs vrsr_capable is not present.\n");
+       close(dir);
+
+       if (strstr(buf, "true"))
+               vrsr_capability = 1;
+
        igt_require(xe_has_vram(device.fd_xe));
 
        placement = vram_memory(device.fd_xe, 0);
@@ -595,10 +633,21 @@ static void test_vram_d3cold_threshold(device_t device, int sysfs_fd)
        munmap(map, SIZE);
        set_vram_d3cold_threshold(sysfs_fd, threshold);
 
+       if (vrsr_capability)
+               mods_value = read_mods(device);
+
        /* Setup D3Cold but card should be in D3hot */
        igt_assert(setup_d3(device, IGT_ACPI_D3Cold));
        sleep(1);
-       igt_assert(in_d3(device, IGT_ACPI_D3Hot));
+       if (vrsr_capability) {
+               igt_assert(in_d3(device, IGT_ACPI_D3Cold));
+               mods_value = read_mods(device) - mods_value;
+               igt_assert_f(mods_value > 0,
+                            "Mods residency is inaccurate: %"PRIu64"\n", mods_value);
+       } else {
+               igt_assert(in_d3(device, IGT_ACPI_D3Hot));
+       }
+
        igt_assert(igt_pm_get_acpi_real_d_state(device.pci_root) == IGT_ACPI_D0);
        gem_close(device.fd_xe, bo);
 
</pre>
    </blockquote>
  </body>
</html>