Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Pottumuttu, Sai Teja" <sai.teja.pottumuttu@intel.com>
To: <nakshtra.goyal@intel.com>, <igt-dev@lists.freedesktop.org>,
	<ramadevi.gandi@intel.com>
Cc: <francois.dugast@intel.com>, <ashutosh.dixit@intel.com>,
	<umesh.nerlige.ramappa@intel.com>
Subject: Re: [PATCH v5 i-g-t] tests/intel/xe_fault_injection: Inject errors during observation IOCTL
Date: Mon, 24 Mar 2025 14:51:01 +0530	[thread overview]
Message-ID: <8500d363-541a-4706-8040-82860134f333@intel.com> (raw)
In-Reply-To: <20250324090801.3121551-1-nakshtra.goyal@intel.com>

On 24-03-2025 14:38, nakshtra.goyal@intel.com wrote:
> From: Nakshtra Goyal <nakshtra.goyal@intel.com>
> 
> Use the fault injection infrastructure to make targeted internal KMD
> functions fail when executing xe_observation_ioctl()
> so that more code paths are tested, such as error handling and unwinding.
> 
> v1: Adding remove config at end of test , Adding igt_sysfs into igt_assert
> so test fails if sysfs read fails (Sai Teja)
> 
> v2: Run sysfs check before creating config to destroy prev. config if
> present, add one check before creating new config after destroying old
> one (Sai Teja)
> 
> Signed-off-by: Nakshtra Goyal <nakshtra.goyal@intel.com>
> ---
>   tests/intel/xe_fault_injection.c | 62 +++++++++++++++++++++++++++++++-
>   tests/meson.build                |  1 +
>   2 files changed, 62 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/intel/xe_fault_injection.c b/tests/intel/xe_fault_injection.c
> index 5409d19a6..eaf93a0b2 100644
> --- a/tests/intel/xe_fault_injection.c
> +++ b/tests/intel/xe_fault_injection.c
> @@ -20,6 +20,7 @@
>   #include "lib/igt_syncobj.h"
>   #include "lib/intel_pat.h"
>   #include "xe/xe_ioctl.h"
> +#include "xe/xe_oa.h"
>   #include "xe/xe_query.h"
>   
>   #define INJECT_ERRNO	-ENOMEM
> @@ -314,10 +315,57 @@ vm_bind_fail(int fd, const char function_name[])
>   	igt_assert_eq(simple_vm_bind(fd, vm), 0);
>   }
>   
> +/**
> + * SUBTEST: oa-add-config-fail-%s
> + * Description: inject an error in function %arg[1] used in oa add config IOCTL to make it fail
> + * Functionality: fault
> + *
> + * arg[1]:
> + * @xe_oa_alloc_regs:		xe_oa_alloc_regs
> + */
> +static void
> +oa_add_config_fail(int fd, int sysfs, int devid, const char function_name[])
> +{
> +	char path[512];
> +	uint64_t config_id;
> +#define SAMPLE_MUX_REG (intel_graphics_ver(devid) >= IP_VER(20, 0) ?	\
> +			0x13000 /* PES* */ : 0x9888 /* NOA_WRITE */)
> +
> +	uint32_t mux_regs[] = { SAMPLE_MUX_REG, 0x0 };
> +	struct drm_xe_oa_config config;
> +	const char *uuid = "01234567-0123-0123-0123-0123456789ab";
> +
> +	snprintf(path, sizeof(path), "metrics/%s/id", uuid);
> +	/* Destroy previous configuration if present */
> +	if (igt_sysfs_scanf(sysfs, path, "%"PRIu64, &config_id) == 1)
> +		igt_assert_eq(intel_xe_perf_ioctl(fd, DRM_XE_OBSERVATION_OP_REMOVE_CONFIG,
> +							&config_id), 0);
> +
> +	memset(&config, 0, sizeof(config));
> +	memcpy(config.uuid, uuid, sizeof(config.uuid));
> +	config.n_regs = 1;
> +	config.regs_ptr = to_user_pointer(mux_regs);
> +
> +	igt_assert_lt(0, intel_xe_perf_ioctl(fd, DRM_XE_OBSERVATION_OP_ADD_CONFIG, &config));
> +	igt_assert(igt_sysfs_scanf(sysfs, path, "%"PRIu64, &config_id) == 1);

We could have dropped these sysfs reads as we get config_id directly as 
the return value of add config ioctl. But this way is also correct I 
guess, I don't see any harm as such.

> +	igt_assert_eq(intel_xe_perf_ioctl(fd, DRM_XE_OBSERVATION_OP_REMOVE_CONFIG, &config_id), 0);
> +
> +	ignore_faults_in_dmesg(function_name);
> +	injection_list_do(INJECTION_LIST_ADD, function_name);
> +	set_retval(function_name, INJECT_ERRNO);
> +	igt_assert_lt(intel_xe_perf_ioctl(fd, DRM_XE_OBSERVATION_OP_ADD_CONFIG, &config), 0);

I still think that it would be better to do an assert_eq to INJECT_ERRNO 
here. But then looking at other fault injection tests, it doesn't seem 
to be very important.

So, LGTM

Reviewed-by: Sai Teja Pottumuttu <sai.teja.pottumuttu@intel.com>

> +	injection_list_do(INJECTION_LIST_REMOVE, function_name);
> +
> +	igt_assert_lt(0, intel_xe_perf_ioctl(fd, DRM_XE_OBSERVATION_OP_ADD_CONFIG, &config));
> +	igt_assert(igt_sysfs_scanf(sysfs, path, "%"PRIu64, &config_id) == 1);
> +	igt_assert_eq(intel_xe_perf_ioctl(fd, DRM_XE_OBSERVATION_OP_REMOVE_CONFIG, &config_id), 0);
> +}
> +
>   igt_main
>   {
> -	int fd;
> +	int fd, sysfs;
>   	struct drm_xe_engine_class_instance *hwe;
> +	static uint32_t devid;
>   	char pci_slot[NAME_MAX];
>   	const struct section {
>   		const char *name;
> @@ -366,9 +414,16 @@ igt_main
>   		{ }
>   	};
>   
> +	const struct section oa_add_config_fail_functions[] = {
> +		{ "xe_oa_alloc_regs"},
> +		{ }
> +	};
> +
>   	igt_fixture {
>   		igt_require(fail_function_injection_enabled());
>   		fd = drm_open_driver(DRIVER_XE);
> +		devid = intel_get_drm_devid(fd);
> +		sysfs = igt_sysfs_open(fd);
>   		igt_device_get_pci_slot_name(fd, pci_slot);
>   		setup_injection_fault();
>   	}
> @@ -393,6 +448,10 @@ igt_main
>   				if (hwe->engine_class == DRM_XE_ENGINE_CLASS_VM_BIND)
>   					exec_queue_create_fail(fd, hwe, s->name, s->flags);
>   
> +	for (const struct section *s = oa_add_config_fail_functions; s->name; s++)
> +		igt_subtest_f("oa-add-config-fail-%s", s->name)
> +			oa_add_config_fail(fd, sysfs, devid, s->name);
> +
>   	igt_fixture {
>   		xe_sysfs_driver_do(fd, pci_slot, XE_SYSFS_DRIVER_UNBIND);
>   	}
> @@ -402,6 +461,7 @@ igt_main
>   			inject_fault_probe(fd, pci_slot, s->name);
>   
>   	igt_fixture {
> +		close(sysfs);
>   		drm_close_driver(fd);
>   		xe_sysfs_driver_do(fd, pci_slot, XE_SYSFS_DRIVER_BIND);
>   	}
> diff --git a/tests/meson.build b/tests/meson.build
> index 2f5406523..c4a9093c4 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -401,6 +401,7 @@ extra_dependencies = {
>   	'perf_pmu':  [ lib_igt_perf ],
>   	'sw_sync': [ libatomic ],
>   	'xe_oa': [ lib_igt_xe_oa ],
> +	'xe_fault_injection': [ lib_igt_xe_oa ],
>   }
>   
>   test_executables = []

  reply	other threads:[~2025-03-24  9:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-24  9:08 [PATCH v5 i-g-t] tests/intel/xe_fault_injection: Inject errors during observation IOCTL nakshtra.goyal
2025-03-24  9:21 ` Pottumuttu, Sai Teja [this message]
2025-03-25  9:09   ` Francois Dugast
2025-03-24 21:09 ` ✓ Xe.CI.BAT: success for tests/intel/xe_fault_injection: Inject errors during observation IOCTL (rev5) Patchwork
2025-03-24 21:26 ` ✓ i915.CI.BAT: " Patchwork
2025-03-24 23:29 ` ✗ Xe.CI.Full: failure " Patchwork
2025-03-26 11:19   ` Goyal, Nakshtra
2025-03-25  2:23 ` ✗ i915.CI.Full: " 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=8500d363-541a-4706-8040-82860134f333@intel.com \
    --to=sai.teja.pottumuttu@intel.com \
    --cc=ashutosh.dixit@intel.com \
    --cc=francois.dugast@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=nakshtra.goyal@intel.com \
    --cc=ramadevi.gandi@intel.com \
    --cc=umesh.nerlige.ramappa@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