From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 59C71C021A6 for ; Thu, 13 Feb 2025 02:03:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4165410E363; Thu, 13 Feb 2025 02:03:43 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="AiRQVtFW"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2937210E1C0 for ; Thu, 13 Feb 2025 02:03:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1739412222; x=1770948222; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zzzbWrhKaKcyd+fAYmJDj/E3DM93dO2Zf36YNH6t62E=; b=AiRQVtFW5jsNx2U2qcK899uIrAcf/kI6xaw5NmXOXCicajc2vrtJUBJF HJR8z6pezrDISFgSep2NY4ynxyLIPWsEn5Ea9BKaHemdWuVMOAkv+phyO jVfrU/WKzc8Cmo+rbdybPwEKDATldaLjsC65RhBmGm8yVQmYYnrlRzqIG KfyQhjOW6fGTYaJ1jT6GRkkz0098k0rqFcQ3lLNIcbAOl8Q7pUsLLZx4y CTNGYrG4DtEuuYjHJrbOKRo2ZvEPDFGuNCoEWQGLF7MphYV9yP6zBJ7pM 4XV38RdN2zvumWsxOnCi+vPPrfO7DSvyvf3KQe9PHViaRutfbPYTUAm+l A==; X-CSE-ConnectionGUID: skpy/4JEQ5aK56UW7jIGJw== X-CSE-MsgGUID: ItOaPVISRN+xWWlJt9vcHg== X-IronPort-AV: E=McAfee;i="6700,10204,11343"; a="39329685" X-IronPort-AV: E=Sophos;i="6.13,281,1732608000"; d="scan'208";a="39329685" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2025 18:03:41 -0800 X-CSE-ConnectionGUID: wHPbROicQjmIv/FEXHbnAg== X-CSE-MsgGUID: U4lfzeRfR0KrQJL2zrFYEQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,281,1732608000"; d="scan'208";a="112856260" Received: from szeng-desk.jf.intel.com ([10.165.21.160]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2025 18:03:41 -0800 From: Oak Zeng 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: Wed, 12 Feb 2025 21:19:15 -0500 Message-Id: <20250213021915.264978-4-oak.zeng@intel.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20250213021915.264978-1-oak.zeng@intel.com> References: <20250213021915.264978-1-oak.zeng@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: igt-dev@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development mailing list for IGT GPU Tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" 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 --- tests/intel/xe_exec_fault_mode.c | 65 ++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/tests/intel/xe_exec_fault_mode.c b/tests/intel/xe_exec_fault_mode.c index ae40e099b..ee1cf7491 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,62 @@ #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_destroy_cmdbuf(&cmd_buf); + xe_create_buffer(&dst_buf); + xe_create_cmdbuf(&cmd_buf, insert_store, dst_buf.gpu_addr, 0xc0ffee, eci); + 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 +515,7 @@ igt_main { NULL }, }; int fd; + uint32_t dev_id; igt_fixture { struct timespec tv = {}; @@ -466,6 +524,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 +567,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