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 CF81FCA0FF0 for ; Tue, 26 Aug 2025 20:18:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8A36610E662; Tue, 26 Aug 2025 20:18:36 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="DPBhntHL"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) by gabe.freedesktop.org (Postfix) with ESMTPS id E5F2A10E132 for ; Tue, 26 Aug 2025 20:18:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1756239513; x=1787775513; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ok5E8nZKQWszjvUTaU9vQ+ubiopVLe6xH5tCJ5RTtV0=; b=DPBhntHL69xOFrM/SPAwN3AYaACYQD7Z4Q8zd5Ovtc4G6lMQJeCGkcI/ fCeQJkRN1Py5HlvPwOooJQdEENTP1r4t+WQiFhIiyIHHjeXOuvrwfZ5Gq gTE/Q0i7IlHb/cRrxe+extIWGnsqjH+LUVngbYapoGplUTny7GHr06rUs EnPeELsbuz9nOLniNIa+8GMu08K71hMjB1ps5005vBPu9TIkmxp5pGj3A 1NQvf8GKADI+hLBheyIIgxc20LcnIPvPnmziHa9ah3ZhuewtlSyXAaQKi JPWRDsbCTQKeVURC33ujqSOMOVn/s/dZOp9gW/cLuSY5yzmgItSdEbs6V w==; X-CSE-ConnectionGUID: ihu5M3BpSwq9hbYvWdqPwg== X-CSE-MsgGUID: jeTk1iW6Rb6LeWHn8zkvjg== X-IronPort-AV: E=McAfee;i="6800,10657,11534"; a="46068143" X-IronPort-AV: E=Sophos;i="6.18,214,1751266800"; d="scan'208";a="46068143" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2025 13:18:32 -0700 X-CSE-ConnectionGUID: FeQtJNZOT92GfzLSHJgduQ== X-CSE-MsgGUID: ScVK1bfoQTGKhEYPuJly9Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.18,214,1751266800"; d="scan'208";a="168907883" Received: from dut4086lnl.fm.intel.com ([10.105.10.138]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2025 13:18:32 -0700 From: Jonathan Cavitt To: igt-dev@lists.freedesktop.org Cc: saurabhg.gupta@intel.com, alex.zuo@intel.com, jonathan.cavitt@intel.com, john.c.harrison@intel.com, matthew.brost@intel.com Subject: [PATCH v2 4/4] tests/intel/xe_vm: Move vm fault tests from xe_fault_injection to xe_vm Date: Tue, 26 Aug 2025 20:18:29 +0000 Message-ID: <20250826201829.190241-10-jonathan.cavitt@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250826201829.190241-6-jonathan.cavitt@intel.com> References: <20250826201829.190241-6-jonathan.cavitt@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" Move the fault injection tests that exercise the xe vm ioctl from the xe_fault_injection test suite to the xe_vm test suite. Signed-off-by: Jonathan Cavitt --- tests/intel/xe_fault_injection.c | 121 --------------------------- tests/intel/xe_vm.c | 138 +++++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+), 121 deletions(-) diff --git a/tests/intel/xe_fault_injection.c b/tests/intel/xe_fault_injection.c index 92b09cbb90..06b7bcab3d 100644 --- a/tests/intel/xe_fault_injection.c +++ b/tests/intel/xe_fault_injection.c @@ -172,104 +172,6 @@ exec_queue_create_fail(int fd, struct drm_xe_engine_class_instance *instance, xe_exec_queue_destroy(fd, exec_queue_id); } -static int -simple_vm_create(int fd, unsigned int flags) -{ - struct drm_xe_vm_create create = { - .flags = flags, - }; - - return igt_ioctl(fd, DRM_IOCTL_XE_VM_CREATE, &create); -} - -/** - * SUBTEST: vm-create-fail-%s - * Description: inject an error in function %arg[1] used in vm create IOCTL to make it fail - * Functionality: fault - * - * arg[1]: - * @xe_exec_queue_create_bind: xe_exec_queue_create_bind - * @xe_pt_create: xe_pt_create - * @xe_vm_create_scratch: xe_vm_create_scratch - */ -static void -vm_create_fail(int fd, const char pci_slot[], - const char function_name[], unsigned int flags) -{ - igt_assert_eq(simple_vm_create(fd, flags), 0); - - injection_ignore_dmesg_errors_from_dut(pci_slot); - injection_list_add(function_name); - injection_set_retval(function_name, INJECT_ERRNO); - igt_assert(simple_vm_create(fd, flags) != 0); - injection_list_remove(function_name); - - igt_assert_eq(simple_vm_create(fd, flags), 0); -} - -static int -simple_vm_bind(int fd, uint32_t vm) -{ - struct { - uint32_t batch[16]; - uint64_t pad; - uint32_t data; - } *data; - struct drm_xe_sync syncobj = { - .type = DRM_XE_SYNC_TYPE_SYNCOBJ, - .flags = DRM_XE_SYNC_FLAG_SIGNAL, - .handle = syncobj_create(fd, 0), - }; - struct drm_xe_vm_bind bind = { - .vm_id = vm, - .num_binds = 1, - .bind.obj = 0, - .bind.range = BO_SIZE, - .bind.addr = BO_ADDR, - .bind.op = DRM_XE_VM_BIND_OP_MAP_USERPTR, - .bind.pat_index = intel_get_pat_idx_wb(fd), - .bind.flags = 0, - .num_syncs = 1, - .syncs = (uintptr_t)&syncobj, - .exec_queue_id = 0, - }; - - data = aligned_alloc(xe_get_default_alignment(fd), BO_SIZE); - bind.bind.obj_offset = to_user_pointer(data); - - return igt_ioctl(fd, DRM_IOCTL_XE_VM_BIND, &bind); -} - -/** - * SUBTEST: vm-bind-fail-%s - * Description: inject an error in function %arg[1] used in vm bind IOCTL - * to make it fail - * Functionality: fault - * - * arg[1]: - * @vm_bind_ioctl_ops_create: vm_bind_ioctl_ops_create - * @vm_bind_ioctl_ops_execute: vm_bind_ioctl_ops_execute - * @xe_pt_update_ops_prepare: xe_pt_update_ops_prepare - * @xe_pt_update_ops_run: xe_pt_update_ops_run - * @xe_vma_ops_alloc: xe_vma_ops_alloc - * @xe_sync_entry_parse: xe_sync_entry_parse - */ -static void -vm_bind_fail(int fd, const char pci_slot[], const char function_name[]) -{ - uint32_t vm = xe_vm_create(fd, 0, 0); - - igt_assert_eq(simple_vm_bind(fd, vm), 0); - - injection_ignore_dmesg_errors_from_dut(pci_slot); - injection_list_add(function_name); - injection_set_retval(function_name, INJECT_ERRNO); - igt_assert(simple_vm_bind(fd, vm) != 0); - injection_list_remove(function_name); - - igt_assert_eq(simple_vm_bind(fd, vm), 0); -} - static int opt_handler(int opt, int opt_index, void *data) { int in_param; @@ -325,21 +227,6 @@ igt_main_args("I:", NULL, help_str, opt_handler, NULL) { "xe_wopcm_init", 0, true }, { } }; - const struct section vm_create_fail_functions[] = { - { "xe_exec_queue_create_bind", 0 }, - { "xe_pt_create", 0 }, - { "xe_vm_create_scratch", DRM_XE_VM_CREATE_FLAG_SCRATCH_PAGE }, - { } - }; - const struct section vm_bind_fail_functions[] = { - { "vm_bind_ioctl_ops_create" }, - { "vm_bind_ioctl_ops_execute" }, - { "xe_pt_update_ops_prepare" }, - { "xe_pt_update_ops_run" }, - { "xe_vma_ops_alloc" }, - { "xe_sync_entry_parse" }, - { } - }; const struct section exec_queue_create_fail_functions[] = { { "xe_exec_queue_create", 0 }, @@ -369,14 +256,6 @@ igt_main_args("I:", NULL, help_str, opt_handler, NULL) is_vf_device = intel_is_vf_device(fd); } - for (const struct section *s = vm_create_fail_functions; s->name; s++) - igt_subtest_f("vm-create-fail-%s", s->name) - vm_create_fail(fd, pci_slot, s->name, s->flags); - - for (const struct section *s = vm_bind_fail_functions; s->name; s++) - igt_subtest_f("vm-bind-fail-%s", s->name) - vm_bind_fail(fd, pci_slot, s->name); - for (const struct section *s = exec_queue_create_fail_functions; s->name; s++) igt_subtest_f("exec-queue-create-fail-%s", s->name) xe_for_each_engine(fd, hwe) diff --git a/tests/intel/xe_vm.c b/tests/intel/xe_vm.c index 6bef25851e..2af77350ff 100644 --- a/tests/intel/xe_vm.c +++ b/tests/intel/xe_vm.c @@ -11,6 +11,7 @@ */ #include "igt.h" +#include "igt_device.h" #include "intel_pat.h" #include "lib/igt_syncobj.h" #include "lib/intel_reg.h" @@ -2465,10 +2466,109 @@ static void test_oom(int fd) } } +static int +simple_vm_create(int fd, unsigned int flags) +{ + struct drm_xe_vm_create create = { + .flags = flags, + }; + + return igt_ioctl(fd, DRM_IOCTL_XE_VM_CREATE, &create); +} + +/** + * SUBTEST: vm-create-fail-%s + * Description: inject an error in function %arg[1] used in vm create IOCTL to make it fail + * Functionality: fault + * + * arg[1]: + * @xe_exec_queue_create_bind: xe_exec_queue_create_bind + * @xe_pt_create: xe_pt_create + * @xe_vm_create_scratch: xe_vm_create_scratch + */ +static void +vm_create_fail(int fd, const char pci_slot[], + const char function_name[], unsigned int flags) +{ + igt_assert_eq(simple_vm_create(fd, flags), 0); + + injection_ignore_dmesg_errors_from_dut(pci_slot); + injection_list_add(function_name); + injection_set_retval(function_name, -ENOMEM); + igt_assert(simple_vm_create(fd, flags) != 0); + injection_list_remove(function_name); + + igt_assert_eq(simple_vm_create(fd, flags), 0); +} + +static int +simple_vm_bind(int fd, uint32_t vm) +{ + struct { + uint32_t batch[16]; + uint64_t pad; + uint32_t data; + } *data; + struct drm_xe_sync syncobj = { + .type = DRM_XE_SYNC_TYPE_SYNCOBJ, + .flags = DRM_XE_SYNC_FLAG_SIGNAL, + .handle = syncobj_create(fd, 0), + }; + struct drm_xe_vm_bind bind = { + .vm_id = vm, + .num_binds = 1, + .bind.obj = 0, + .bind.range = BO_SIZE, + .bind.addr = 0x1a0000, + .bind.op = DRM_XE_VM_BIND_OP_MAP_USERPTR, + .bind.pat_index = intel_get_pat_idx_wb(fd), + .bind.flags = 0, + .num_syncs = 1, + .syncs = (uintptr_t)&syncobj, + .exec_queue_id = 0, + }; + + data = aligned_alloc(xe_get_default_alignment(fd), BO_SIZE); + bind.bind.obj_offset = to_user_pointer(data); + + return igt_ioctl(fd, DRM_IOCTL_XE_VM_BIND, &bind); +} + +/** + * SUBTEST: vm-bind-fail-%s + * Description: inject an error in function %arg[1] used in vm bind IOCTL + * to make it fail + * Functionality: fault + * + * arg[1]: + * @vm_bind_ioctl_ops_create: vm_bind_ioctl_ops_create + * @vm_bind_ioctl_ops_execute: vm_bind_ioctl_ops_execute + * @xe_pt_update_ops_prepare: xe_pt_update_ops_prepare + * @xe_pt_update_ops_run: xe_pt_update_ops_run + * @xe_vma_ops_alloc: xe_vma_ops_alloc + * @xe_sync_entry_parse: xe_sync_entry_parse + */ +static void +vm_bind_fail(int fd, const char pci_slot[], const char function_name[]) +{ + uint32_t vm = xe_vm_create(fd, 0, 0); + + igt_assert_eq(simple_vm_bind(fd, vm), 0); + + injection_ignore_dmesg_errors_from_dut(pci_slot); + injection_list_add(function_name); + injection_set_retval(function_name, -ENOMEM); + igt_assert(simple_vm_bind(fd, vm) != 0); + injection_list_remove(function_name); + + igt_assert_eq(simple_vm_bind(fd, vm), 0); +} + igt_main { struct drm_xe_engine_class_instance *hwe, *hwe_non_copy = NULL; uint64_t bind_size; + char pci_slot[NAME_MAX]; int fd; const struct section { const char *name; @@ -2583,6 +2683,27 @@ igt_main "xe_pt_update_ops_run", }; + const struct fault_section { + const char *name; + unsigned int flags; + bool pf_only; + } vm_create_fail_functions[] = { + { "xe_exec_queue_create_bind", 0 }, + { "xe_pt_create", 0 }, + { "xe_vm_create_scratch", DRM_XE_VM_CREATE_FLAG_SCRATCH_PAGE }, + { } + }; + + const struct fault_section vm_bind_fail_functions[] = { + { "vm_bind_ioctl_ops_create" }, + { "vm_bind_ioctl_ops_execute" }, + { "xe_pt_update_ops_prepare" }, + { "xe_pt_update_ops_run" }, + { "xe_vma_ops_alloc" }, + { "xe_sync_entry_parse" }, + { } + }; + igt_fixture { fd = drm_open_driver(DRIVER_XE); @@ -2883,6 +3004,23 @@ igt_main test_oom(fd); } + igt_subtest_group { + igt_fixture { + igt_require(fail_function_injection_enabled()); + injection_setup_fault(&default_fault_params); + injection_exit_handler(); + igt_device_get_pci_slot_name(fd, pci_slot); + } + + for (const struct fault_section *s = vm_create_fail_functions; s->name; s++) + igt_subtest_f("vm-create-fail-%s", s->name) + vm_create_fail(fd, pci_slot, s->name, s->flags); + + for (const struct fault_section *s = vm_bind_fail_functions; s->name; s++) + igt_subtest_f("vm-bind-fail-%s", s->name) + vm_bind_fail(fd, pci_slot, s->name); + } + igt_fixture drm_close_driver(fd); } -- 2.43.0