From: Anshuman Gupta <anshuman.gupta@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Subject: [PATCH i-g-t v6 3/4] tests/xe_pm: Add d3-mmap IGT test
Date: Wed, 24 Jan 2024 17:20:18 +0530 [thread overview]
Message-ID: <20240124115019.2067089-4-anshuman.gupta@intel.com> (raw)
In-Reply-To: <20240124115019.2067089-1-anshuman.gupta@intel.com>
Adding a test to validate mmap memory mappings along with runtime
suspend and resume for both xe device and it's pci parent bridge
in device hierarchy.
v2:
- Use 0xc00fee pattern. [Rodrigo]
- Test the pagefault case on read and write the mapping. [Rodrigo]
v3:
- Cosmetic comment. [Kamil]
- Use MAGIC macro for 0xc0ffe and 0xdeadbeef. [Kamil]
- Fix xe_bo_create() with respect to Xe uapi.
- Set auto_suspend delay to 1000ms and restore it.
v4:
- Set autosuspend delay to 1 sec for entire test. [Badal]
v5:
- Use DPMS on/off.
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Badal Nilawar <badal.nilawar@intel.com>
---
tests/intel/xe_pm.c | 101 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 101 insertions(+)
diff --git a/tests/intel/xe_pm.c b/tests/intel/xe_pm.c
index f793fd24e..395f5cc21 100644
--- a/tests/intel/xe_pm.c
+++ b/tests/intel/xe_pm.c
@@ -30,6 +30,8 @@
#define NO_RPM -1
#define SIZE (4096 * 1024)
+#define MAGIC_1 0xc0ffee
+#define MAGIC_2 0xdeadbeef
typedef struct {
int fd_xe;
@@ -476,6 +478,79 @@ static void test_vram_d3cold_threshold(device_t device, int sysfs_fd)
igt_assert(in_d3(device, IGT_ACPI_D3Cold));
}
+/**
+ * SUBTEST: d3-mmap-%s
+ * Description:
+ * Validate mmap memory mapping with d3 state, for %arg[1] region,
+ * if supported by device.
+ * arg[1]:
+ *
+ * @vram: vram region
+ * @system: system region
+ *
+ * Functionality: pm-d3
+ * Run type: FULL
+ */
+static void test_mmap(device_t device, uint32_t placement, uint32_t flags)
+{
+ size_t bo_size = 8192;
+ uint32_t *map = NULL;
+ uint32_t bo;
+ int i;
+
+ igt_require_f(placement, "Device doesn't support such memory region\n");
+
+ bo_size = ALIGN(bo_size, xe_get_default_alignment(device.fd_xe));
+
+ bo = xe_bo_create(device.fd_xe, 0, bo_size, placement, flags);
+ map = xe_bo_map(device.fd_xe, bo, bo_size);
+ igt_assert(map);
+ memset(map, 0, bo_size);
+
+ fw_handle = igt_debugfs_open(device.fd_xe, "forcewake_all", O_RDONLY);
+
+ igt_assert(fw_handle >= 0);
+ igt_assert(igt_get_runtime_pm_status() == IGT_RUNTIME_PM_STATUS_ACTIVE);
+
+ for (i = 0; i < bo_size / sizeof(*map); i++)
+ map[i] = MAGIC_1;
+
+ for (i = 0; i < bo_size / sizeof(*map); i++)
+ igt_assert(map[i] == MAGIC_1);
+
+ /* Runtime suspend and validate the pattern and changed the pattern */
+ close(fw_handle);
+ igt_assert(igt_wait_for_pm_status(IGT_RUNTIME_PM_STATUS_SUSPENDED));
+
+ for (i = 0; i < bo_size / sizeof(*map); i++)
+ igt_assert(map[i] == MAGIC_1);
+
+ /* dgfx page-fault on mmaping should wake the gpu */
+ if (xe_has_vram(device.fd_xe))
+ igt_assert(igt_get_runtime_pm_status() == IGT_RUNTIME_PM_STATUS_ACTIVE);
+
+ igt_assert(igt_wait_for_pm_status(IGT_RUNTIME_PM_STATUS_SUSPENDED));
+
+ for (i = 0; i < bo_size / sizeof(*map); i++)
+ map[i] = MAGIC_2;
+
+ if (xe_has_vram(device.fd_xe))
+ igt_assert(igt_get_runtime_pm_status() == IGT_RUNTIME_PM_STATUS_ACTIVE);
+
+ igt_assert(igt_wait_for_pm_status(IGT_RUNTIME_PM_STATUS_SUSPENDED));
+
+ /* Runtime resume and check the pattern */
+ fw_handle = igt_debugfs_open(device.fd_xe, "forcewake_all", O_RDONLY);
+ igt_assert(fw_handle >= 0);
+ igt_assert(igt_get_runtime_pm_status() == IGT_RUNTIME_PM_STATUS_ACTIVE);
+ for (i = 0; i < bo_size / sizeof(*map); i++)
+ igt_assert(map[i] == MAGIC_2);
+
+ igt_assert(munmap(map, bo_size) == 0);
+ gem_close(device.fd_xe, bo);
+ close(fw_handle);
+}
+
igt_main
{
struct drm_xe_engine_class_instance *hwe;
@@ -591,6 +666,32 @@ igt_main
igt_install_exit_handler(vram_d3cold_threshold_restore);
test_vram_d3cold_threshold(device, sysfs_fd);
}
+
+ igt_describe("Validate mmap memory mappings with system region,"
+ "when device along with parent bridge in d3");
+ igt_subtest("d3-mmap-system") {
+ test_mmap(device, system_memory(device.fd_xe), 0);
+ }
+
+ igt_describe("Validate mmap memory mappings with vram region,"
+ "when device along with parent bridge in d3");
+ igt_subtest("d3-mmap-vram") {
+ int delay_ms;
+
+ if (device.pci_root != device.pci_xe) {
+ igt_pm_enable_pci_card_runtime_pm(device.pci_root, NULL);
+ igt_pm_set_d3cold_allowed(device.pci_slot_name, 1);
+ }
+
+ delay_ms = igt_pm_get_autosuspend_delay(device.pci_xe);
+
+ /* Give some auto suspend delay to validate rpm active during page fault */
+ igt_pm_set_autosuspend_delay(device.pci_xe, 1000);
+ dpms_on_off(device, DRM_MODE_DPMS_OFF);
+ test_mmap(device, vram_memory(device.fd_xe, 0), DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM);
+ dpms_on_off(device, DRM_MODE_DPMS_ON);
+ igt_pm_set_autosuspend_delay(device.pci_xe, delay_ms);
+ }
}
igt_fixture {
--
2.25.1
next prev parent reply other threads:[~2024-01-24 11:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-24 11:50 [PATCH i-g-t v6 0/4] Add d3 mmap test Anshuman Gupta
2024-01-24 11:50 ` [PATCH i-g-t v6 1/4] test/xe_pm: Add exit handler to close fw handle Anshuman Gupta
2024-01-24 11:50 ` [PATCH i-g-t v6 2/4] lib/igt_pm: Add helper to get/set auto_suspenddelay_ms Anshuman Gupta
2024-01-24 13:32 ` Kamil Konieczny
2024-01-24 11:50 ` Anshuman Gupta [this message]
2024-01-24 11:50 ` [PATCH i-g-t v6 4/4] HAX: Add d3-mmap to xe-fast-feedback Anshuman Gupta
2024-01-24 13:39 ` Kamil Konieczny
2024-01-25 9:32 ` Gupta, Anshuman
2024-01-25 13:41 ` Kamil Konieczny
2024-01-24 12:43 ` ✓ CI.xeBAT: success for Add d3 mmap test (rev5) Patchwork
2024-01-24 12:49 ` ✗ Fi.CI.BAT: 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=20240124115019.2067089-4-anshuman.gupta@intel.com \
--to=anshuman.gupta@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=rodrigo.vivi@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