From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Francois Dugast <francois.dugast@intel.com>
Cc: <igt-dev@lists.freedesktop.org>
Subject: Re: [PATCH i-g-t 5/5] tests/intel/xe_fault_injection: Inject errors during vm bind IOCTL
Date: Fri, 8 Nov 2024 15:10:49 -0500 [thread overview]
Message-ID: <Zy5wSaUzcYgCHb4W@intel.com> (raw)
In-Reply-To: <20241108160021.1202234-6-francois.dugast@intel.com>
On Fri, Nov 08, 2024 at 04:59:33PM +0100, Francois Dugast wrote:
> Use the fault injection infrastructure to make targeted internal KMD
> functions fail when executing xe_vm_bind_ioctl() so that more
> code paths are tested, such as error handling and unwinding.
>
> Signed-off-by: Francois Dugast <francois.dugast@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
> tests/intel/xe_fault_injection.c | 72 +++++++++++++++++++++++++++++++-
> 1 file changed, 71 insertions(+), 1 deletion(-)
>
> diff --git a/tests/intel/xe_fault_injection.c b/tests/intel/xe_fault_injection.c
> index eb80f6af8..43d3a2da0 100644
> --- a/tests/intel/xe_fault_injection.c
> +++ b/tests/intel/xe_fault_injection.c
> @@ -17,10 +17,13 @@
> #include "igt_device.h"
> #include "igt_kmod.h"
> #include "igt_sysfs.h"
> +#include "lib/igt_syncobj.h"
> #include "xe/xe_ioctl.h"
> #include "xe/xe_query.h"
>
> -#define INJECT_ERRNO -ENOMEM
> +#define INJECT_ERRNO -ENOMEM
> +#define BO_ADDR 0x1a0000
> +#define BO_SIZE (1024*1024)
>
> enum injection_list_action {
> INJECTION_LIST_ADD,
> @@ -189,6 +192,63 @@ vm_create_fail(int fd, const char function_name[], unsigned int flags)
> 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.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]:
> + * @xe_vma_ops_alloc: xe_vma_ops_alloc
> + * @vm_bind_ioctl_ops_execute: vm_bind_ioctl_ops_execute
> + * @vm_bind_ioctl_ops_create: vm_bind_ioctl_ops_create
> + */
> +static void
> +vm_bind_fail(int fd, const char function_name[])
> +{
> + uint32_t vm = xe_vm_create(fd, 0, 0);
> +
> + igt_assert_eq(simple_vm_bind(fd, vm), 0);
> +
> + injection_list_do(INJECTION_LIST_ADD, function_name);
> + set_retval(function_name, INJECT_ERRNO);
> + igt_assert(simple_vm_bind(fd, vm) != 0);
> + injection_list_do(INJECTION_LIST_REMOVE, function_name);
> +
> + igt_assert_eq(simple_vm_bind(fd, vm), 0);
> +}
> +
> igt_main
> {
> int fd;
> @@ -218,6 +278,12 @@ igt_main
> { "xe_vm_create_scratch", DRM_XE_VM_CREATE_FLAG_SCRATCH_PAGE },
> { }
> };
> + const struct section vm_bind_fail_functions[] = {
> + { "xe_vma_ops_alloc" },
> + { "vm_bind_ioctl_ops_create" },
> + { "vm_bind_ioctl_ops_execute" },
> + { }
> + };
>
> igt_fixture {
> igt_require(fail_function_injection_enabled());
> @@ -230,6 +296,10 @@ igt_main
> igt_subtest_f("vm-create-fail-%s", s->name)
> vm_create_fail(fd, 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, s->name);
> +
> igt_fixture {
> xe_sysfs_driver_do(fd, pci_slot, XE_SYSFS_DRIVER_UNBIND);
> }
> --
> 2.43.0
>
next prev parent reply other threads:[~2024-11-08 20:10 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-08 15:59 [PATCH i-g-t 0/5] xe_fault_injection improvements Francois Dugast
2024-11-08 15:59 ` [PATCH i-g-t 1/5] tests/intel/xe_fault_injection: Use a static list of functions Francois Dugast
2024-11-08 19:09 ` Rodrigo Vivi
2024-11-08 15:59 ` [PATCH i-g-t 2/5] lib/igt_sysfs: Add igt_sysfs_{get,set}_s32 Francois Dugast
2024-11-08 15:59 ` [PATCH i-g-t 3/5] tests/intel/xe_fault_injection: Use igt_sysfs helpers Francois Dugast
2024-11-08 19:18 ` Rodrigo Vivi
2024-11-08 15:59 ` [PATCH i-g-t 4/5] tests/intel/xe_fault_injection: Inject errors during vm create IOCTL Francois Dugast
2024-11-08 20:10 ` Rodrigo Vivi
2024-11-08 15:59 ` [PATCH i-g-t 5/5] tests/intel/xe_fault_injection: Inject errors during vm bind IOCTL Francois Dugast
2024-11-08 20:10 ` Rodrigo Vivi [this message]
2024-11-08 17:09 ` ✗ Fi.CI.BAT: failure for xe_fault_injection improvements (rev2) Patchwork
2024-11-08 17:14 ` ✗ CI.xeBAT: " Patchwork
2024-11-09 19:11 ` ✗ CI.xeFULL: " 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=Zy5wSaUzcYgCHb4W@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=francois.dugast@intel.com \
--cc=igt-dev@lists.freedesktop.org \
/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