Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t v2 0/2] tests/intel/xe_fault_injection: Inject errors during xe_guc_ct_send_recv & xe_guc_mmio_send_recv
@ 2025-01-20  8:34 Satyanarayana K V P
  2025-01-20  8:34 ` [PATCH i-g-t v2 1/2] tests/intel/xe_fault_injection: Inject errors during xe_guc_mmio_send_recv Satyanarayana K V P
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Satyanarayana K V P @ 2025-01-20  8:34 UTC (permalink / raw)
  To: igt-dev
  Cc: Satyanarayana K V P, Matthew Brost, Michał Wajdeczko,
	Francois Dugast

Use the kernel fault injection infrastructure to test error handling of xe
at probe time when executing xe_guc_mmio_send_recv() and at enabling of VFs
stage when executing xe_guc_ct_send_recv().

Error can be injected using:
igt@xe_fault_injection@inject-fault-probe-function-xe_guc_mmio_send_recv
igt@xe_fault_injection@enable-vfs-fail-xe_guc_ct_send_recv

Satyanarayana K V P (2):
  tests/intel/xe_fault_injection: Inject errors during
    xe_guc_mmio_send_recv
  tests/intel/xe_fault_injection: Inject errors during
    xe_guc_ct_send_recv

 tests/intel/xe_fault_injection.c | 65 ++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)

Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Michał Wajdeczko <michal.wajdeczko@intel.com>
Cc: Francois Dugast <francois.dugast@intel.com>
-- 
2.35.3


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH i-g-t v2 1/2] tests/intel/xe_fault_injection: Inject errors during xe_guc_mmio_send_recv
  2025-01-20  8:34 [PATCH i-g-t v2 0/2] tests/intel/xe_fault_injection: Inject errors during xe_guc_ct_send_recv & xe_guc_mmio_send_recv Satyanarayana K V P
@ 2025-01-20  8:34 ` Satyanarayana K V P
  2025-01-20  8:52   ` Francois Dugast
  2025-01-20  8:34 ` [PATCH i-g-t v2 2/2] tests/intel/xe_fault_injection: Inject errors during xe_guc_ct_send_recv Satyanarayana K V P
  2025-01-20 11:47 ` ✗ GitLab.Pipeline: warning for tests/intel/xe_fault_injection: Inject errors during xe_guc_ct_send_recv & xe_guc_mmio_send_recv (rev2) Patchwork
  2 siblings, 1 reply; 7+ messages in thread
From: Satyanarayana K V P @ 2025-01-20  8:34 UTC (permalink / raw)
  To: igt-dev
  Cc: Satyanarayana K V P, Matthew Brost, Michał Wajdeczko,
	Francois Dugast

Use the kernel fault injection infrastructure to test error handling
of xe at probe time when executing xe_guc_mmio_send_recv() so that
more code paths are tested, such as error handling and unwinding.

Error can be injected using:
igt@xe_fault_injection@inject-fault-probe-function-xe_guc_mmio_send_recv

v2: Sorted the entry xe_guc_mmio_send_recv in inject-fault-probe-function-* list

Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Michał Wajdeczko <michal.wajdeczko@intel.com>
Cc: Francois Dugast <francois.dugast@intel.com>
Signed-off-by: Satyanarayana K V P <satyanarayana.k.v.p@intel.com>
---
 tests/intel/xe_fault_injection.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/intel/xe_fault_injection.c b/tests/intel/xe_fault_injection.c
index 7ae941367..3a0e2aa29 100644
--- a/tests/intel/xe_fault_injection.c
+++ b/tests/intel/xe_fault_injection.c
@@ -163,6 +163,7 @@ static void set_retval(const char function_name[], long long retval)
  * @xe_guc_ads_init:		xe_guc_ads_init
  * @xe_guc_ct_init:		xe_guc_ct_init
  * @xe_guc_log_init:		xe_guc_log_init
+ * @xe_guc_mmio_send_recv:     xe_guc_mmio_send_recv
  * @xe_guc_relay_init:		xe_guc_relay_init
  * @xe_pm_init_early:		xe_pm_init_early
  * @xe_sriov_init:		xe_sriov_init
@@ -294,6 +295,7 @@ igt_main
 		{ "xe_guc_ads_init" },
 		{ "xe_guc_ct_init" },
 		{ "xe_guc_log_init" },
+		{ "xe_guc_mmio_send_recv" },
 		{ "xe_guc_relay_init" },
 		{ "xe_pm_init_early" },
 		{ "xe_sriov_init" },
-- 
2.35.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH i-g-t v2 2/2] tests/intel/xe_fault_injection: Inject errors during xe_guc_ct_send_recv
  2025-01-20  8:34 [PATCH i-g-t v2 0/2] tests/intel/xe_fault_injection: Inject errors during xe_guc_ct_send_recv & xe_guc_mmio_send_recv Satyanarayana K V P
  2025-01-20  8:34 ` [PATCH i-g-t v2 1/2] tests/intel/xe_fault_injection: Inject errors during xe_guc_mmio_send_recv Satyanarayana K V P
@ 2025-01-20  8:34 ` Satyanarayana K V P
  2025-01-20 13:41   ` Francois Dugast
  2025-01-20 11:47 ` ✗ GitLab.Pipeline: warning for tests/intel/xe_fault_injection: Inject errors during xe_guc_ct_send_recv & xe_guc_mmio_send_recv (rev2) Patchwork
  2 siblings, 1 reply; 7+ messages in thread
From: Satyanarayana K V P @ 2025-01-20  8:34 UTC (permalink / raw)
  To: igt-dev
  Cc: Satyanarayana K V P, Matthew Brost, Michał Wajdeczko,
	Francois Dugast

Use the kernel fault injection infrastructure to test error handling
of xe at enabling of VFs stage when executing xe_guc_ct_send_recv()
so that more code paths are tested, such as error handling and unwinding.

Error can be injected using:
igt@xe_fault_injection@enable-vfs-fail-xe_guc_ct_send_recv

v2: Updated guc_fail_* to enable_vfs_*
Added igt_skip_on(!igt_sriov_is_pf(fd)) to skip test when run without
enabling sriov.

Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Michał Wajdeczko <michal.wajdeczko@intel.com>
Cc: Francois Dugast <francois.dugast@intel.com>
Signed-off-by: Satyanarayana K V P <satyanarayana.k.v.p@intel.com>
---
 tests/intel/xe_fault_injection.c | 63 ++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/tests/intel/xe_fault_injection.c b/tests/intel/xe_fault_injection.c
index 3a0e2aa29..56616ee17 100644
--- a/tests/intel/xe_fault_injection.c
+++ b/tests/intel/xe_fault_injection.c
@@ -19,12 +19,14 @@
 #include "igt_sysfs.h"
 #include "lib/igt_syncobj.h"
 #include "lib/intel_pat.h"
+#include "lib/igt_sriov_device.h"
 #include "xe/xe_ioctl.h"
 #include "xe/xe_query.h"
 
 #define INJECT_ERRNO	-ENOMEM
 #define BO_ADDR		0x1a0000
 #define BO_SIZE		(1024*1024)
+#define NUM_VFS		1
 
 enum injection_list_action {
 	INJECTION_LIST_ADD,
@@ -281,6 +283,55 @@ vm_bind_fail(int fd, const char function_name[])
 	igt_assert_eq(simple_vm_bind(fd, vm), 0);
 }
 
+static int sriov_enable_vfs(int fd, int num_vfs)
+{
+	int sysfs;
+	bool ret;
+
+	sysfs = igt_sysfs_open(fd);
+	igt_assert_fd(sysfs);
+
+	ret = __igt_sysfs_set_u32(sysfs, "device/sriov_numvfs", num_vfs);
+	close(sysfs);
+
+	return ret;
+}
+
+/**
+ * SUBTEST: guc-fail-%s
+ * Description: inject an error in function %arg[1] used when xe interacts with guc to make it fail
+ * Functionality: fault
+ *
+ * arg[1]:
+ * @xe_guc_ct_send_recv:               xe_guc_ct_send_recv
+ */
+
+static void
+enable_vfs_fail(int fd, int num_vfs, const char function_name[])
+{
+	bool autoprobe_en = 0;
+
+	ignore_faults_in_dmesg(function_name);
+	injection_list_do(INJECTION_LIST_ADD, function_name);
+	set_retval(function_name, INJECT_ERRNO);
+
+	autoprobe_en = igt_sriov_is_driver_autoprobe_enabled(fd);
+
+	if (autoprobe_en)
+		igt_sriov_disable_driver_autoprobe(fd);
+
+	/* igt_sriov_enable_vfs can't be used here as it is causing abort on any error.
+	 * Since error in this test is expected, we have written our own static function here.
+	 */
+	sriov_enable_vfs(fd, num_vfs);
+
+	igt_assert_eq(-errno, INJECT_ERRNO);
+	injection_list_do(INJECTION_LIST_REMOVE, function_name);
+
+	if (autoprobe_en)
+		igt_sriov_enable_driver_autoprobe(fd);
+}
+
 igt_main
 {
 	int fd;
@@ -319,6 +370,10 @@ igt_main
 		{ "xe_vma_ops_alloc" },
 		{ }
 	};
+	const struct section enable_vfs_fail_functions[] = {
+		{ "xe_guc_ct_send_recv" },
+		{ }
+	};
 
 	igt_fixture {
 		igt_require(fail_function_injection_enabled());
@@ -335,6 +390,14 @@ igt_main
 		igt_subtest_f("vm-bind-fail-%s", s->name)
 			vm_bind_fail(fd, s->name);
 
+	for (const struct section *s = enable_vfs_fail_functions; s->name; s++)
+		igt_subtest_f("enable-vfs-fail-%s", s->name) {
+			/* Skip the test if not running with SRIOV 
+			 */
+			igt_skip_on(!igt_sriov_is_pf(fd));
+			enable_vfs_fail(fd, NUM_VFS, s->name);
+		}
+
 	igt_fixture {
 		xe_sysfs_driver_do(fd, pci_slot, XE_SYSFS_DRIVER_UNBIND);
 	}
-- 
2.35.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH i-g-t v2 1/2] tests/intel/xe_fault_injection: Inject errors during xe_guc_mmio_send_recv
  2025-01-20  8:34 ` [PATCH i-g-t v2 1/2] tests/intel/xe_fault_injection: Inject errors during xe_guc_mmio_send_recv Satyanarayana K V P
@ 2025-01-20  8:52   ` Francois Dugast
  0 siblings, 0 replies; 7+ messages in thread
From: Francois Dugast @ 2025-01-20  8:52 UTC (permalink / raw)
  To: Satyanarayana K V P; +Cc: igt-dev, Matthew Brost, Michał Wajdeczko

On Mon, Jan 20, 2025 at 02:04:09PM +0530, Satyanarayana K V P wrote:
> Use the kernel fault injection infrastructure to test error handling
> of xe at probe time when executing xe_guc_mmio_send_recv() so that
> more code paths are tested, such as error handling and unwinding.
> 
> Error can be injected using:
> igt@xe_fault_injection@inject-fault-probe-function-xe_guc_mmio_send_recv
> 
> v2: Sorted the entry xe_guc_mmio_send_recv in inject-fault-probe-function-* list
> 
> Cc: Matthew Brost <matthew.brost@intel.com>
> Cc: Michał Wajdeczko <michal.wajdeczko@intel.com>
> Cc: Francois Dugast <francois.dugast@intel.com>
> Signed-off-by: Satyanarayana K V P <satyanarayana.k.v.p@intel.com>

Reviewed-by: Francois Dugast <francois.dugast@intel.com>

> ---
>  tests/intel/xe_fault_injection.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tests/intel/xe_fault_injection.c b/tests/intel/xe_fault_injection.c
> index 7ae941367..3a0e2aa29 100644
> --- a/tests/intel/xe_fault_injection.c
> +++ b/tests/intel/xe_fault_injection.c
> @@ -163,6 +163,7 @@ static void set_retval(const char function_name[], long long retval)
>   * @xe_guc_ads_init:		xe_guc_ads_init
>   * @xe_guc_ct_init:		xe_guc_ct_init
>   * @xe_guc_log_init:		xe_guc_log_init
> + * @xe_guc_mmio_send_recv:     xe_guc_mmio_send_recv
>   * @xe_guc_relay_init:		xe_guc_relay_init
>   * @xe_pm_init_early:		xe_pm_init_early
>   * @xe_sriov_init:		xe_sriov_init
> @@ -294,6 +295,7 @@ igt_main
>  		{ "xe_guc_ads_init" },
>  		{ "xe_guc_ct_init" },
>  		{ "xe_guc_log_init" },
> +		{ "xe_guc_mmio_send_recv" },
>  		{ "xe_guc_relay_init" },
>  		{ "xe_pm_init_early" },
>  		{ "xe_sriov_init" },
> -- 
> 2.35.3
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* ✗ GitLab.Pipeline: warning for tests/intel/xe_fault_injection: Inject errors during xe_guc_ct_send_recv & xe_guc_mmio_send_recv (rev2)
  2025-01-20  8:34 [PATCH i-g-t v2 0/2] tests/intel/xe_fault_injection: Inject errors during xe_guc_ct_send_recv & xe_guc_mmio_send_recv Satyanarayana K V P
  2025-01-20  8:34 ` [PATCH i-g-t v2 1/2] tests/intel/xe_fault_injection: Inject errors during xe_guc_mmio_send_recv Satyanarayana K V P
  2025-01-20  8:34 ` [PATCH i-g-t v2 2/2] tests/intel/xe_fault_injection: Inject errors during xe_guc_ct_send_recv Satyanarayana K V P
@ 2025-01-20 11:47 ` Patchwork
  2 siblings, 0 replies; 7+ messages in thread
From: Patchwork @ 2025-01-20 11:47 UTC (permalink / raw)
  To: Satyanarayana K V P; +Cc: igt-dev

== Series Details ==

Series: tests/intel/xe_fault_injection: Inject errors during xe_guc_ct_send_recv & xe_guc_mmio_send_recv (rev2)
URL   : https://patchwork.freedesktop.org/series/142999/
State : warning

== Summary ==

Pipeline status: FAILED.

see https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/pipelines/1348708 for the overview.

build:tests-debian-meson has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/69618899):
  ninja: build stopped: subcommand failed.
  ninja: Entering directory `build'
  [1/857] Generating version.h with a custom command.
  [2/8] Linking target runner/runner_test.
  [3/8] Linking target assembler/intel-gen4asm.
  [4/8] Generating i915_tests.html with a custom command.
  [5/8] Generating kms_tests.html with a custom command.
  [6/8] Generating xe_tests.rst with a custom command.
  FAILED: docs/testplan/xe_tests.rst 
  /builds/gfx-ci/igt-ci-tags/scripts/igt_doc.py --config /builds/gfx-ci/igt-ci-tags/tests/intel/xe_test_config.json --rest docs/testplan/xe_tests.rst --check-testlist --igt-build-path /builds/gfx-ci/igt-ci-tags/build
  ERROR: Missing documentation for igt@xe_fault_injection@enable-vfs-fail-xe_guc_ct_send_recv
  ERROR: Unneeded documentation for igt@xe_fault_injection@guc-fail-xe_guc_ct_send_recv
  Please refer: docs/test_documentation.md for more details
  ninja: build stopped: subcommand failed.
  section_end:1737373453:step_script
  section_start:1737373453:cleanup_file_variables
  Cleaning up project directory and file based variables
  section_end:1737373454:cleanup_file_variables
  ERROR: Job failed: exit code 1
  

build:tests-fedora has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/69618894):
  ninja: build stopped: subcommand failed.
  ninja: Entering directory `build'
  [1/859] Generating version.h with a custom command.
  [2/7] Linking target runner/runner_test.
  [3/7] Generating intel-ci-tests with a custom command.
  [4/7] Generating i915_tests.html with a custom command.
  [5/7] Generating kms_tests.html with a custom command.
  [6/7] Generating xe_tests.rst with a custom command.
  FAILED: docs/testplan/xe_tests.rst 
  /builds/gfx-ci/igt-ci-tags/scripts/igt_doc.py --config /builds/gfx-ci/igt-ci-tags/tests/intel/xe_test_config.json --rest docs/testplan/xe_tests.rst --check-testlist --igt-build-path /builds/gfx-ci/igt-ci-tags/build
  ERROR: Missing documentation for igt@xe_fault_injection@enable-vfs-fail-xe_guc_ct_send_recv
  ERROR: Unneeded documentation for igt@xe_fault_injection@guc-fail-xe_guc_ct_send_recv
  Please refer: docs/test_documentation.md for more details
  ninja: build stopped: subcommand failed.
  section_end:1737373454:step_script
  section_start:1737373454:cleanup_file_variables
  Cleaning up project directory and file based variables
  section_end:1737373454:cleanup_file_variables
  ERROR: Job failed: exit code 1
  

build:tests-fedora-clang has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/69618898):
  [1933/1936] Generating intel-ci-tests with a custom command.
  ninja: build stopped: subcommand failed.
  ninja: Entering directory `build'
  [1/859] Generating version.h with a custom command.
  [2/6] Generating kms_tests.html with a custom command.
  [3/6] Generating intel-ci-tests with a custom command.
  [4/6] Generating i915_tests.html with a custom command.
  [5/6] Generating xe_tests.rst with a custom command.
  FAILED: docs/testplan/xe_tests.rst 
  /builds/gfx-ci/igt-ci-tags/scripts/igt_doc.py --config /builds/gfx-ci/igt-ci-tags/tests/intel/xe_test_config.json --rest docs/testplan/xe_tests.rst --check-testlist --igt-build-path /builds/gfx-ci/igt-ci-tags/build
  ERROR: Missing documentation for igt@xe_fault_injection@enable-vfs-fail-xe_guc_ct_send_recv
  ERROR: Unneeded documentation for igt@xe_fault_injection@guc-fail-xe_guc_ct_send_recv
  Please refer: docs/test_documentation.md for more details
  ninja: build stopped: subcommand failed.
  section_end:1737373481:step_script
  section_start:1737373481:cleanup_file_variables
  Cleaning up project directory and file based variables
  section_end:1737373482:cleanup_file_variables
  ERROR: Job failed: exit code 1
  

build:tests-fedora-no-libdrm-nouveau has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/69618897):
  [1760/1764] Compiling C object 'runner/527aa9f@@runner_test@exe/runner_tests.c.o'.
  ninja: build stopped: subcommand failed.
  ninja: Entering directory `build'
  [1/807] Generating version.h with a custom command.
  [2/7] Linking target runner/runner_test.
  [3/7] Generating i915_tests.html with a custom command.
  [4/7] Generating kms_tests.html with a custom command.
  [5/7] Generating xe_tests.rst with a custom command.
  FAILED: docs/testplan/xe_tests.rst 
  /builds/gfx-ci/igt-ci-tags/scripts/igt_doc.py --config /builds/gfx-ci/igt-ci-tags/tests/intel/xe_test_config.json --rest docs/testplan/xe_tests.rst --check-testlist --igt-build-path /builds/gfx-ci/igt-ci-tags/build
  ERROR: Missing documentation for igt@xe_fault_injection@enable-vfs-fail-xe_guc_ct_send_recv
  ERROR: Unneeded documentation for igt@xe_fault_injection@guc-fail-xe_guc_ct_send_recv
  Please refer: docs/test_documentation.md for more details
  ninja: build stopped: subcommand failed.
  section_end:1737373424:step_script
  section_start:1737373424:cleanup_file_variables
  Cleaning up project directory and file based variables
  section_end:1737373426:cleanup_file_variables
  ERROR: Job failed: exit code 1
  

build:tests-fedora-no-libunwind has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/69618895):
  [1932/1936] Compiling C object 'runner/527aa9f@@runner_test@exe/runner_tests.c.o'.
  ninja: build stopped: subcommand failed.
  ninja: Entering directory `build'
  [1/859] Generating version.h with a custom command.
  [2/7] Linking target runner/runner_test.
  [3/7] Generating i915_tests.html with a custom command.
  [4/7] Generating intel-ci-tests with a custom command.
  [5/7] Generating xe_tests.rst with a custom command.
  FAILED: docs/testplan/xe_tests.rst 
  /builds/gfx-ci/igt-ci-tags/scripts/igt_doc.py --config /builds/gfx-ci/igt-ci-tags/tests/intel/xe_test_config.json --rest docs/testplan/xe_tests.rst --check-testlist --igt-build-path /builds/gfx-ci/igt-ci-tags/build
  ERROR: Missing documentation for igt@xe_fault_injection@enable-vfs-fail-xe_guc_ct_send_recv
  ERROR: Unneeded documentation for igt@xe_fault_injection@guc-fail-xe_guc_ct_send_recv
  Please refer: docs/test_documentation.md for more details
  ninja: build stopped: subcommand failed.
  section_end:1737373423:step_script
  section_start:1737373423:cleanup_file_variables
  Cleaning up project directory and file based variables
  section_end:1737373424:cleanup_file_variables
  ERROR: Job failed: exit code 1
  

build:tests-fedora-oldest-meson has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/69618896):
  [1933/1936] Generating intel-ci-tests with a custom command.
  ninja: build stopped: subcommand failed.
  ninja: Entering directory `build'
  [1/859] Generating version.h with a custom command.
  [2/6] Generating intel-ci-tests with a custom command.
  [3/6] Generating i915_tests.html with a custom command.
  [4/6] Generating kms_tests.html with a custom command.
  [5/6] Generating xe_tests.rst with a custom command.
  FAILED: docs/testplan/xe_tests.rst 
  /builds/gfx-ci/igt-ci-tags/scripts/igt_doc.py --config /builds/gfx-ci/igt-ci-tags/tests/intel/xe_test_config.json --rest docs/testplan/xe_tests.rst --check-testlist --igt-build-path /builds/gfx-ci/igt-ci-tags/build
  ERROR: Missing documentation for igt@xe_fault_injection@enable-vfs-fail-xe_guc_ct_send_recv
  ERROR: Unneeded documentation for igt@xe_fault_injection@guc-fail-xe_guc_ct_send_recv
  Please refer: docs/test_documentation.md for more details
  ninja: build stopped: subcommand failed.
  section_end:1737373427:step_script
  section_start:1737373427:cleanup_file_variables
  Cleaning up project directory and file based variables
  section_end:1737373428:cleanup_file_variables
  ERROR: Job failed: exit code 1

== Logs ==

For more details see: https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/pipelines/1348708

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH i-g-t v2 2/2] tests/intel/xe_fault_injection: Inject errors during xe_guc_ct_send_recv
  2025-01-20  8:34 ` [PATCH i-g-t v2 2/2] tests/intel/xe_fault_injection: Inject errors during xe_guc_ct_send_recv Satyanarayana K V P
@ 2025-01-20 13:41   ` Francois Dugast
  2025-01-20 13:43     ` K V P, Satyanarayana
  0 siblings, 1 reply; 7+ messages in thread
From: Francois Dugast @ 2025-01-20 13:41 UTC (permalink / raw)
  To: Satyanarayana K V P; +Cc: igt-dev, Matthew Brost, Michał Wajdeczko

On Mon, Jan 20, 2025 at 02:04:10PM +0530, Satyanarayana K V P wrote:
> Use the kernel fault injection infrastructure to test error handling
> of xe at enabling of VFs stage when executing xe_guc_ct_send_recv()
> so that more code paths are tested, such as error handling and unwinding.
> 
> Error can be injected using:
> igt@xe_fault_injection@enable-vfs-fail-xe_guc_ct_send_recv
> 
> v2: Updated guc_fail_* to enable_vfs_*
> Added igt_skip_on(!igt_sriov_is_pf(fd)) to skip test when run without
> enabling sriov.
> 
> Cc: Matthew Brost <matthew.brost@intel.com>
> Cc: Michał Wajdeczko <michal.wajdeczko@intel.com>
> Cc: Francois Dugast <francois.dugast@intel.com>
> Signed-off-by: Satyanarayana K V P <satyanarayana.k.v.p@intel.com>
> ---
>  tests/intel/xe_fault_injection.c | 63 ++++++++++++++++++++++++++++++++
>  1 file changed, 63 insertions(+)
> 
> diff --git a/tests/intel/xe_fault_injection.c b/tests/intel/xe_fault_injection.c
> index 3a0e2aa29..56616ee17 100644
> --- a/tests/intel/xe_fault_injection.c
> +++ b/tests/intel/xe_fault_injection.c
> @@ -19,12 +19,14 @@
>  #include "igt_sysfs.h"
>  #include "lib/igt_syncobj.h"
>  #include "lib/intel_pat.h"
> +#include "lib/igt_sriov_device.h"
>  #include "xe/xe_ioctl.h"
>  #include "xe/xe_query.h"
>  
>  #define INJECT_ERRNO	-ENOMEM
>  #define BO_ADDR		0x1a0000
>  #define BO_SIZE		(1024*1024)
> +#define NUM_VFS		1
>  
>  enum injection_list_action {
>  	INJECTION_LIST_ADD,
> @@ -281,6 +283,55 @@ vm_bind_fail(int fd, const char function_name[])
>  	igt_assert_eq(simple_vm_bind(fd, vm), 0);
>  }
>  
> +static int sriov_enable_vfs(int fd, int num_vfs)
> +{
> +	int sysfs;
> +	bool ret;
> +
> +	sysfs = igt_sysfs_open(fd);
> +	igt_assert_fd(sysfs);
> +
> +	ret = __igt_sysfs_set_u32(sysfs, "device/sriov_numvfs", num_vfs);
> +	close(sysfs);
> +
> +	return ret;
> +}
> +
> +/**
> + * SUBTEST: guc-fail-%s

Hi,

The test name must be updated in the documentation as well:

    ERROR: Missing documentation for igt@xe_fault_injection@enable-vfs-fail-xe_guc_ct_send_recv
    ERROR: Unneeded documentation for igt@xe_fault_injection@guc-fail-xe_guc_ct_send_recv

> + * Description: inject an error in function %arg[1] used when xe interacts with guc to make it fail
> + * Functionality: fault
> + *
> + * arg[1]:
> + * @xe_guc_ct_send_recv:               xe_guc_ct_send_recv
> + */
> +
> +static void
> +enable_vfs_fail(int fd, int num_vfs, const char function_name[])
> +{
> +	bool autoprobe_en = 0;
> +
> +	ignore_faults_in_dmesg(function_name);
> +	injection_list_do(INJECTION_LIST_ADD, function_name);
> +	set_retval(function_name, INJECT_ERRNO);
> +
> +	autoprobe_en = igt_sriov_is_driver_autoprobe_enabled(fd);
> +
> +	if (autoprobe_en)
> +		igt_sriov_disable_driver_autoprobe(fd);
> +
> +	/* igt_sriov_enable_vfs can't be used here as it is causing abort on any error.
> +	 * Since error in this test is expected, we have written our own static function here.
> +	 */
> +	sriov_enable_vfs(fd, num_vfs);
> +
> +	igt_assert_eq(-errno, INJECT_ERRNO);
> +	injection_list_do(INJECTION_LIST_REMOVE, function_name);
> +
> +	if (autoprobe_en)
> +		igt_sriov_enable_driver_autoprobe(fd);
> +}
> +
>  igt_main
>  {
>  	int fd;
> @@ -319,6 +370,10 @@ igt_main
>  		{ "xe_vma_ops_alloc" },
>  		{ }
>  	};
> +	const struct section enable_vfs_fail_functions[] = {
> +		{ "xe_guc_ct_send_recv" },
> +		{ }
> +	};
>  
>  	igt_fixture {
>  		igt_require(fail_function_injection_enabled());
> @@ -335,6 +390,14 @@ igt_main
>  		igt_subtest_f("vm-bind-fail-%s", s->name)
>  			vm_bind_fail(fd, s->name);
>  
> +	for (const struct section *s = enable_vfs_fail_functions; s->name; s++)
> +		igt_subtest_f("enable-vfs-fail-%s", s->name) {
> +			/* Skip the test if not running with SRIOV 
> +			 */

Is there an accidental newline between the extra white space after "SRIOV"
and "*/" on a new line?

> +			igt_skip_on(!igt_sriov_is_pf(fd));
> +			enable_vfs_fail(fd, NUM_VFS, s->name);
> +		}
> +
>  	igt_fixture {
>  		xe_sysfs_driver_do(fd, pci_slot, XE_SYSFS_DRIVER_UNBIND);
>  	}
> -- 
> 2.35.3
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH i-g-t v2 2/2] tests/intel/xe_fault_injection: Inject errors during xe_guc_ct_send_recv
  2025-01-20 13:41   ` Francois Dugast
@ 2025-01-20 13:43     ` K V P, Satyanarayana
  0 siblings, 0 replies; 7+ messages in thread
From: K V P, Satyanarayana @ 2025-01-20 13:43 UTC (permalink / raw)
  To: Dugast, Francois
  Cc: igt-dev@lists.freedesktop.org, Brost, Matthew, Wajdeczko, Michal,
	K V P, Satyanarayana

> -----Original Message-----
> From: Dugast, Francois <francois.dugast@intel.com>
> Sent: Monday, January 20, 2025 7:11 PM
> To: K V P, Satyanarayana <satyanarayana.k.v.p@intel.com>
> Cc: igt-dev@lists.freedesktop.org; Brost, Matthew
> <matthew.brost@intel.com>; Wajdeczko, Michal
> <Michal.Wajdeczko@intel.com>
> Subject: Re: [PATCH i-g-t v2 2/2] tests/intel/xe_fault_injection: Inject errors
> during xe_guc_ct_send_recv
> 
> On Mon, Jan 20, 2025 at 02:04:10PM +0530, Satyanarayana K V P wrote:
> > Use the kernel fault injection infrastructure to test error handling
> > of xe at enabling of VFs stage when executing xe_guc_ct_send_recv()
> > so that more code paths are tested, such as error handling and unwinding.
> >
> > Error can be injected using:
> > igt@xe_fault_injection@enable-vfs-fail-xe_guc_ct_send_recv
> >
> > v2: Updated guc_fail_* to enable_vfs_*
> > Added igt_skip_on(!igt_sriov_is_pf(fd)) to skip test when run without
> > enabling sriov.
> >
> > Cc: Matthew Brost <matthew.brost@intel.com>
> > Cc: Michał Wajdeczko <michal.wajdeczko@intel.com>
> > Cc: Francois Dugast <francois.dugast@intel.com>
> > Signed-off-by: Satyanarayana K V P <satyanarayana.k.v.p@intel.com>
> > ---
> >  tests/intel/xe_fault_injection.c | 63
> ++++++++++++++++++++++++++++++++
> >  1 file changed, 63 insertions(+)
> >
> > diff --git a/tests/intel/xe_fault_injection.c b/tests/intel/xe_fault_injection.c
> > index 3a0e2aa29..56616ee17 100644
> > --- a/tests/intel/xe_fault_injection.c
> > +++ b/tests/intel/xe_fault_injection.c
> > @@ -19,12 +19,14 @@
> >  #include "igt_sysfs.h"
> >  #include "lib/igt_syncobj.h"
> >  #include "lib/intel_pat.h"
> > +#include "lib/igt_sriov_device.h"
> >  #include "xe/xe_ioctl.h"
> >  #include "xe/xe_query.h"
> >
> >  #define INJECT_ERRNO	-ENOMEM
> >  #define BO_ADDR		0x1a0000
> >  #define BO_SIZE		(1024*1024)
> > +#define NUM_VFS		1
> >
> >  enum injection_list_action {
> >  	INJECTION_LIST_ADD,
> > @@ -281,6 +283,55 @@ vm_bind_fail(int fd, const char function_name[])
> >  	igt_assert_eq(simple_vm_bind(fd, vm), 0);
> >  }
> >
> > +static int sriov_enable_vfs(int fd, int num_vfs)
> > +{
> > +	int sysfs;
> > +	bool ret;
> > +
> > +	sysfs = igt_sysfs_open(fd);
> > +	igt_assert_fd(sysfs);
> > +
> > +	ret = __igt_sysfs_set_u32(sysfs, "device/sriov_numvfs", num_vfs);
> > +	close(sysfs);
> > +
> > +	return ret;
> > +}
> > +
> > +/**
> > + * SUBTEST: guc-fail-%s
> 
> Hi,
> 
> The test name must be updated in the documentation as well:
> 
>     ERROR: Missing documentation for igt@xe_fault_injection@enable-vfs-fail-
> xe_guc_ct_send_recv
>     ERROR: Unneeded documentation for igt@xe_fault_injection@guc-fail-
> xe_guc_ct_send_recv
> 
Updated and pushed V3 patch.
> > + * Description: inject an error in function %arg[1] used when xe interacts
> with guc to make it fail
> > + * Functionality: fault
> > + *
> > + * arg[1]:
> > + * @xe_guc_ct_send_recv:               xe_guc_ct_send_recv
> > + */
> > +
> > +static void
> > +enable_vfs_fail(int fd, int num_vfs, const char function_name[])
> > +{
> > +	bool autoprobe_en = 0;
> > +
> > +	ignore_faults_in_dmesg(function_name);
> > +	injection_list_do(INJECTION_LIST_ADD, function_name);
> > +	set_retval(function_name, INJECT_ERRNO);
> > +
> > +	autoprobe_en = igt_sriov_is_driver_autoprobe_enabled(fd);
> > +
> > +	if (autoprobe_en)
> > +		igt_sriov_disable_driver_autoprobe(fd);
> > +
> > +	/* igt_sriov_enable_vfs can't be used here as it is causing abort on any
> error.
> > +	 * Since error in this test is expected, we have written our own static
> function here.
> > +	 */
> > +	sriov_enable_vfs(fd, num_vfs);
> > +
> > +	igt_assert_eq(-errno, INJECT_ERRNO);
> > +	injection_list_do(INJECTION_LIST_REMOVE, function_name);
> > +
> > +	if (autoprobe_en)
> > +		igt_sriov_enable_driver_autoprobe(fd);
> > +}
> > +
> >  igt_main
> >  {
> >  	int fd;
> > @@ -319,6 +370,10 @@ igt_main
> >  		{ "xe_vma_ops_alloc" },
> >  		{ }
> >  	};
> > +	const struct section enable_vfs_fail_functions[] = {
> > +		{ "xe_guc_ct_send_recv" },
> > +		{ }
> > +	};
> >
> >  	igt_fixture {
> >  		igt_require(fail_function_injection_enabled());
> > @@ -335,6 +390,14 @@ igt_main
> >  		igt_subtest_f("vm-bind-fail-%s", s->name)
> >  			vm_bind_fail(fd, s->name);
> >
> > +	for (const struct section *s = enable_vfs_fail_functions; s->name; s++)
> > +		igt_subtest_f("enable-vfs-fail-%s", s->name) {
> > +			/* Skip the test if not running with SRIOV
> > +			 */
> 
> Is there an accidental newline between the extra white space after "SRIOV"
> and "*/" on a new line?
> 
Was just trying to follow syntax guidelines. Intentionally added */ in the new line.
> > +			igt_skip_on(!igt_sriov_is_pf(fd));
> > +			enable_vfs_fail(fd, NUM_VFS, s->name);
> > +		}
> > +
> >  	igt_fixture {
> >  		xe_sysfs_driver_do(fd, pci_slot, XE_SYSFS_DRIVER_UNBIND);
> >  	}
> > --
> > 2.35.3
> >

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-01-20 13:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-20  8:34 [PATCH i-g-t v2 0/2] tests/intel/xe_fault_injection: Inject errors during xe_guc_ct_send_recv & xe_guc_mmio_send_recv Satyanarayana K V P
2025-01-20  8:34 ` [PATCH i-g-t v2 1/2] tests/intel/xe_fault_injection: Inject errors during xe_guc_mmio_send_recv Satyanarayana K V P
2025-01-20  8:52   ` Francois Dugast
2025-01-20  8:34 ` [PATCH i-g-t v2 2/2] tests/intel/xe_fault_injection: Inject errors during xe_guc_ct_send_recv Satyanarayana K V P
2025-01-20 13:41   ` Francois Dugast
2025-01-20 13:43     ` K V P, Satyanarayana
2025-01-20 11:47 ` ✗ GitLab.Pipeline: warning for tests/intel/xe_fault_injection: Inject errors during xe_guc_ct_send_recv & xe_guc_mmio_send_recv (rev2) Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox