From: Oak Zeng <oak.zeng@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Thomas.Hellstrom@linux.intel.com, matthew.brost@intel.com
Subject: [i-g-t 4/4] tests/intel/xe_exec_fault_mode: Test scratch page under fault mode
Date: Thu, 13 Feb 2025 17:27:05 -0500 [thread overview]
Message-ID: <20250213222705.275364-4-oak.zeng@intel.com> (raw)
In-Reply-To: <20250213222705.275364-1-oak.zeng@intel.com>
On certain HW (such as lunarlake and battlemage), driver now allows
scratch page be enabled under fault mode. Test this functionality
Signed-off-by: Oak Zeng <oak.zeng@intel.com>
---
tests/intel/xe_exec_fault_mode.c | 63 ++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
diff --git a/tests/intel/xe_exec_fault_mode.c b/tests/intel/xe_exec_fault_mode.c
index ae40e099b..f787660ae 100644
--- a/tests/intel/xe_exec_fault_mode.c
+++ b/tests/intel/xe_exec_fault_mode.c
@@ -17,6 +17,7 @@
#include "igt.h"
#include "lib/igt_syncobj.h"
#include "lib/intel_reg.h"
+#include "lib/xe/xe_util.h"
#include "xe_drm.h"
#include "xe/xe_ioctl.h"
@@ -36,6 +37,60 @@
#define INVALID_VA (0x1 << 8)
#define ENABLE_SCRATCH (0x1 << 9)
+
+/**
+ * SUBTEST: scratch-fault
+ * Description: Test scratch page functionality
+ * Test category: functionality test
+ */
+static void test_scratch(int fd, struct drm_xe_engine_class_instance *eci)
+{
+ size_t bb_size = xe_bb_size(fd, PAGE_ALIGN_UFENCE);
+ uint32_t vm;
+
+ struct xe_buffer dst_buf = {
+ .fd = fd,
+ .size = bb_size,
+ .gpu_addr = 0x1a0000,
+ .placement = vram_if_possible(fd, eci->gt_id),
+ .flag = DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM,
+ };
+
+ struct xe_buffer cmd_buf = {
+ .fd = fd,
+ .size = bb_size,
+ .gpu_addr = 0x10a0000,
+ .placement = vram_if_possible(fd, eci->gt_id),
+ .flag = DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM,
+ };
+
+ vm = xe_vm_create(fd, DRM_XE_VM_CREATE_FLAG_LR_MODE |
+ DRM_XE_VM_CREATE_FLAG_SCRATCH_PAGE |
+ DRM_XE_VM_CREATE_FLAG_FAULT_MODE, 0);
+
+ dst_buf.vm = vm;
+ cmd_buf.vm = vm;
+ /* Submit a command to write 0x1a0000
+ * Since 0x1a0000 is mapped scratch page, cmd execution should still
+ * be successful. Write is either be dropped by HW (NULL PTE case) or
+ * written to scratch page.
+ */
+ xe_create_cmdbuf(&cmd_buf, insert_store, dst_buf.gpu_addr, 0xc0ffee, eci);
+ xe_submit_cmd(&cmd_buf);
+
+ /* Create a buffer object, vm_bind it to 0x1a0000, then re-submit
+ * the command buffer. This should write to the buffer object.
+ * Check the buffer object to see if the write was successful.
+ */
+ xe_create_buffer(&dst_buf);
+ xe_submit_cmd(&cmd_buf);
+ igt_assert_eq(*(uint64_t *)dst_buf.cpu_addr, 0xc0ffee);
+
+ xe_destroy_cmdbuf(&cmd_buf);
+ xe_destroy_buffer(&dst_buf);
+ xe_vm_destroy(fd, vm);
+}
+
/**
* SUBTEST: invalid-va
* Description: Access invalid va and check for EIO through user fence.
@@ -458,6 +513,7 @@ igt_main
{ NULL },
};
int fd;
+ uint32_t dev_id;
igt_fixture {
struct timespec tv = {};
@@ -466,6 +522,7 @@ igt_main
int timeout = igt_run_in_simulation() ? 20 : 2;
fd = drm_open_driver(DRIVER_XE);
+ dev_id = intel_get_drm_devid(fd);
do {
if (ret)
usleep(5000);
@@ -508,6 +565,12 @@ igt_main
xe_for_each_engine(fd, hwe)
test_exec(fd, hwe, 1, 1, ENABLE_SCRATCH | INVALID_VA);
+ igt_subtest("scratch-fault") {
+ igt_skip_on(!IS_LUNARLAKE(dev_id) && !IS_BATTLEMAGE(dev_id));
+ xe_for_each_engine(fd, hwe)
+ test_scratch(fd, hwe);
+ }
+
igt_fixture {
drm_close_driver(fd);
}
--
2.26.3
next prev parent reply other threads:[~2025-02-13 22:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-13 22:27 [i-g-t 1/4] lib/xe: Fix a comment error Oak Zeng
2025-02-13 22:27 ` [i-g-t 2/4] lib/xe/xe_util: Introduce helper functions Oak Zeng
2025-02-14 11:35 ` Kamil Konieczny
2025-02-13 22:27 ` [i-g-t 3/4] tests/intel/xe_vm: Exclude invalid_flags tests from LNL and BMG Oak Zeng
2025-02-13 22:27 ` Oak Zeng [this message]
2025-02-13 22:28 ` ✗ GitLab.Pipeline: warning for series starting with [i-g-t,1/4] lib/xe: Fix a comment error Patchwork
2025-02-13 22:42 ` ✓ Xe.CI.BAT: success " Patchwork
2025-02-13 22:58 ` ✓ i915.CI.BAT: " Patchwork
2025-02-14 4:15 ` ✗ i915.CI.Full: failure " Patchwork
2025-02-14 17:42 ` ✗ Xe.CI.Full: " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2025-02-13 15:40 [i-g-t 1/4] " Oak Zeng
2025-02-13 15:40 ` [i-g-t 4/4] tests/intel/xe_exec_fault_mode: Test scratch page under fault mode Oak Zeng
2025-02-13 2:19 [i-g-t 1/4] lib/xe: Fix a comment error Oak Zeng
2025-02-13 2:19 ` [i-g-t 4/4] tests/intel/xe_exec_fault_mode: Test scratch page under fault mode Oak Zeng
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=20250213222705.275364-4-oak.zeng@intel.com \
--to=oak.zeng@intel.com \
--cc=Thomas.Hellstrom@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=matthew.brost@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