Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
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 1/5] tests/intel/xe_fault_injection: Use a static list of functions
Date: Fri, 8 Nov 2024 14:09:48 -0500	[thread overview]
Message-ID: <Zy5h_NzkIGBjyYmP@intel.com> (raw)
In-Reply-To: <20241108160021.1202234-2-francois.dugast@intel.com>

On Fri, Nov 08, 2024 at 04:59:29PM +0100, Francois Dugast wrote:
> Until now the list of error injectable functions was determined at
> runtime by reading debugfs. This was convenient as a new function
> added in KMD would automatically be tested in a separate test. This
> worked well as long as all error injectable functions were meant to
> only be tested during probe time, which is a specific scenario. As we
> want to use error injection in other situations, we will not be able
> to automatically determine if this is a case for probe time, so we
> need to make it explicit.

oh, that's sad as it was really convenient...

> 
> Signed-off-by: Francois Dugast <francois.dugast@intel.com>
> ---
>  tests/intel/xe_fault_injection.c | 72 ++++++++++++++++++--------------
>  1 file changed, 41 insertions(+), 31 deletions(-)
> 
> diff --git a/tests/intel/xe_fault_injection.c b/tests/intel/xe_fault_injection.c
> index d1c8b2530..891b4d70b 100644
> --- a/tests/intel/xe_fault_injection.c
> +++ b/tests/intel/xe_fault_injection.c
> @@ -11,8 +11,6 @@
>   * Test category: fault injection
>   */
>  
> -#include <regex.h>
> -
>  #include "igt.h"
>  #include "igt_device.h"
>  #include "igt_kmod.h"
> @@ -22,7 +20,6 @@
>  #define PATH_FUNCTIONS_INJECTABLE	"/sys/kernel/debug/fail_function/injectable"
>  #define PATH_FUNCTIONS_INJECT		"/sys/kernel/debug/fail_function/inject"
>  #define PATH_FUNCTIONS_RETVAL		"/sys/kernel/debug/fail_function/%s/retval"
> -#define REGEX_XE_FUNCTIONS		"^(.+)\\[xe\\]"
>  #define INJECT_ERRNO			-ENOMEM
>  
>  enum injection_list_action {
> @@ -45,7 +42,7 @@ static bool function_error_injection_enabled(void)
>  	return false;
>  }
>  
> -static void injection_list_do(enum injection_list_action action, char function_name[])
> +static void injection_list_do(enum injection_list_action action, const char function_name[])
>  {
>  	FILE *file_inject;
>  
> @@ -114,7 +111,7 @@ static void cleanup_injection_fault(void)
>  	fclose(file);
>  }
>  
> -static void set_retval(char function_name[], long long retval)
> +static void set_retval(const char function_name[], long long retval)
>  {
>  	FILE *file_retval;
>  	char file_path[MAX_LINE_SIZE];
> @@ -129,12 +126,27 @@ static void set_retval(char function_name[], long long retval)
>  }
>  
>  /**
> - * SUBTEST: inject-fault-probe
> - * Description: inject an error in the injectable function then reprobe driver
> + * SUBTEST: inject-fault-probe-function-%s
> + * Description: inject an error in the injectable function %arg[1] then reprobe driver
>   * Functionality: fault
> + *
> + * arg[1]:
> + * @wait_for_lmem_ready:	wait_for_lmem_ready
> + * @xe_device_create:		xe_device_create
> + * @xe_ggtt_init_early:		xe_ggtt_init_early
> + * @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_pm_init_early:		xe_pm_init_early
> + * @xe_tile_init_early:		xe_tile_init_early
> + * @xe_uc_fw_init:		xe_uc_fw_init
> + * @xe_wa_init:			xe_wa_init
> + * @xe_wopcm_init:		xe_wopcm_init
> + * @xe_guc_relay_init:		xe_guc_relay_init
> + * @xe_sriov_init:		xe_sriov_init

why not alphabetical order?
I almost missed the guc_relay because it was not along with the other guc entires...

>   */
>  static void
> -inject_fault_try_bind(int fd, char pci_slot[], char function_name[])
> +inject_fault_probe(int fd, char pci_slot[], const char function_name[])
>  {
>  	igt_info("Injecting error \"%s\" (%d) in function \"%s\"\n",
>  		 strerror(-INJECT_ERRNO), INJECT_ERRNO, function_name);
> @@ -149,41 +161,39 @@ inject_fault_try_bind(int fd, char pci_slot[], char function_name[])
>  igt_main
>  {
>  	int fd;
> -	FILE *file_injectable;
> -	char line[MAX_LINE_SIZE];
> -	char function_name[64];
>  	char pci_slot[MAX_LINE_SIZE];
> -	regex_t regex;
> -	regmatch_t pmatch[2];
> +	const struct section {
> +		const char *name;
> +	} probe_function_sections[] = {
> +		{ "wait_for_lmem_ready" },
> +		{ "xe_device_create" },
> +		{ "xe_ggtt_init_early" },
> +		{ "xe_guc_ads_init" },
> +		{ "xe_guc_ct_init" },
> +		{ "xe_guc_log_init" },
> +		{ "xe_pm_init_early" },
> +		{ "xe_tile_init_early" },
> +		{ "xe_uc_fw_init" },
> +		{ "xe_wa_init" },
> +		{ "xe_wopcm_init" },
> +		{ "xe_guc_relay_init" },
> +		{ "xe_sriov_init" },

same comment on the alphabetical sort

but up to you. The content is correct:

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>


> +		{ }
> +	};
>  
>  	igt_fixture {
>  		igt_require(function_error_injection_enabled());
>  		fd = drm_open_driver(DRIVER_XE);
>  		igt_device_get_pci_slot_name(fd, pci_slot);
>  		setup_injection_fault();
> -		file_injectable = fopen(PATH_FUNCTIONS_INJECTABLE, "r");
> -		igt_assert(file_injectable);
>  		xe_sysfs_driver_do(fd, pci_slot, XE_SYSFS_DRIVER_UNBIND);
> -		igt_assert_eq(regcomp(&regex, REGEX_XE_FUNCTIONS, REG_EXTENDED), 0);
>  	}
>  
> -	/*
> -	 * Iterate over each error injectable function of the xe module
> -	 */
> -	igt_subtest_with_dynamic("inject-fault-probe") {
> -		while ((fgets(line, MAX_LINE_SIZE, file_injectable)) != NULL) {
> -			if (regexec(&regex, line, 2, pmatch, 0) == 0) {
> -				strcpy(function_name, line);
> -				function_name[pmatch[1].rm_eo - 1] = '\0';
> -				igt_dynamic_f("function-%s", function_name)
> -					inject_fault_try_bind(fd, pci_slot, function_name);
> -			}
> -		}
> -	}
> +	for (const struct section *s = probe_function_sections; s->name; s++)
> +		igt_subtest_f("inject-fault-probe-function-%s", s->name)
> +			inject_fault_probe(fd, pci_slot, s->name);
>  
>  	igt_fixture {
> -		regfree(&regex);
> -		fclose(file_injectable);
>  		cleanup_injection_fault();
>  		drm_close_driver(fd);
>  		xe_sysfs_driver_do(fd, pci_slot, XE_SYSFS_DRIVER_BIND);
> -- 
> 2.43.0
> 

  reply	other threads:[~2024-11-08 19:09 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 [this message]
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
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=Zy5h_NzkIGBjyYmP@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