[PATCH i-g-t v2 1/3] lib/xe_gt: Move reset related function to xe_gt.c

Kamil Konieczny kamil.konieczny at linux.intel.com
Mon Jun 2 15:07:48 UTC 2025


Hi Michal,
On 2025-05-29 at 15:11:27 +0200, Michal Wajdeczko wrote:
> Those helper functions are per GT and related query function is
> already there. While around add simple documentation.
> 
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko at intel.com>

Reviewed-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>

> ---
> v2: update also tests/intel/xe_eudebug_online.c (CI)
> ---
>  lib/xe/xe_gt.c                  | 39 +++++++++++++++++++++++++++++++++
>  lib/xe/xe_gt.h                  |  3 +++
>  lib/xe/xe_ioctl.c               | 23 -------------------
>  lib/xe/xe_ioctl.h               |  2 --
>  lib/xe/xe_legacy.c              |  1 +
>  tests/intel/xe_eudebug_online.c |  1 +
>  tests/intel/xe_wedged.c         |  1 +
>  7 files changed, 45 insertions(+), 25 deletions(-)
> 
> diff --git a/lib/xe/xe_gt.c b/lib/xe/xe_gt.c
> index a1e080b88..8bceca10d 100644
> --- a/lib/xe/xe_gt.c
> +++ b/lib/xe/xe_gt.c
> @@ -57,6 +57,45 @@ bool has_xe_gt_reset(int fd)
>  	return 1;
>  }
>  
> +static void xe_force_gt_reset(int fd, int gt, bool sync)
> +{
> +	char reset_string[128];
> +	struct stat st;
> +
> +	igt_assert_eq(fstat(fd, &st), 0);
> +
> +	snprintf(reset_string, sizeof(reset_string),
> +		 "cat /sys/kernel/debug/dri/%d/gt%d/force_reset%s",
> +		 minor(st.st_rdev), gt, sync ? "_sync" : "");
> +	system(reset_string);
> +}
> +
> +/**
> + * xe_force_gt_reset_async:
> + * @fd: the Xe DRM file descriptor
> + * @gt: the GT identifier
> + *
> + * This function forces a reset on the selected GT.
> + * It does not wait for the reset completion.
> + */
> +void xe_force_gt_reset_async(int fd, int gt)
> +{
> +	xe_force_gt_reset(fd, gt, false);
> +}
> +
> +/**
> + * xe_force_gt_reset_async:
> + * @fd: the Xe DRM file descriptor
> + * @gt: the GT identifier
> + *
> + * This function forces a reset on the selected GT.
> + * It will wait until the reset completes.
> + */
> +void xe_force_gt_reset_sync(int fd, int gt)
> +{
> +	xe_force_gt_reset(fd, gt, true);
> +}
> +
>  /**
>   * xe_force_gt_reset_all:
>   *
> diff --git a/lib/xe/xe_gt.h b/lib/xe/xe_gt.h
> index 06a59281c..93525ea35 100644
> --- a/lib/xe/xe_gt.h
> +++ b/lib/xe/xe_gt.h
> @@ -12,6 +12,9 @@
>  
>  bool has_xe_gt_reset(int fd);
>  void xe_force_gt_reset_all(int fd);
> +void xe_force_gt_reset_async(int fd, int gt);
> +void xe_force_gt_reset_sync(int fd, int gt);
> +
>  igt_hang_t xe_hang_ring(int fd, uint64_t ahnd, uint32_t ctx, int ring,
>  				unsigned int flags);
>  void xe_post_hang_ring(int fd, igt_hang_t arg);
> diff --git a/lib/xe/xe_ioctl.c b/lib/xe/xe_ioctl.c
> index 53a53cd0d..1e95af409 100644
> --- a/lib/xe/xe_ioctl.c
> +++ b/lib/xe/xe_ioctl.c
> @@ -585,26 +585,3 @@ int64_t xe_wait_ufence(int fd, uint64_t *addr, uint64_t value,
>  	igt_assert_eq(__xe_wait_ufence(fd, addr, value, exec_queue, &timeout), 0);
>  	return timeout;
>  }
> -
> -static void xe_force_gt_reset(int fd, int gt, bool sync)
> -{
> -	char reset_string[128];
> -	struct stat st;
> -
> -	igt_assert_eq(fstat(fd, &st), 0);
> -
> -	snprintf(reset_string, sizeof(reset_string),
> -		 "cat /sys/kernel/debug/dri/%d/gt%d/force_reset%s",
> -		 minor(st.st_rdev), gt, sync ? "_sync" : "");
> -	system(reset_string);
> -}
> -
> -void xe_force_gt_reset_async(int fd, int gt)
> -{
> -	xe_force_gt_reset(fd, gt, false);
> -}
> -
> -void xe_force_gt_reset_sync(int fd, int gt)
> -{
> -	xe_force_gt_reset(fd, gt, true);
> -}
> diff --git a/lib/xe/xe_ioctl.h b/lib/xe/xe_ioctl.h
> index 522094ae2..6302d1a7d 100644
> --- a/lib/xe/xe_ioctl.h
> +++ b/lib/xe/xe_ioctl.h
> @@ -99,7 +99,5 @@ int __xe_wait_ufence(int fd, uint64_t *addr, uint64_t value,
>  		     uint32_t exec_queue, int64_t *timeout);
>  int64_t xe_wait_ufence(int fd, uint64_t *addr, uint64_t value,
>  		       uint32_t exec_queue, int64_t timeout);
> -void xe_force_gt_reset_async(int fd, int gt);
> -void xe_force_gt_reset_sync(int fd, int gt);
>  
>  #endif /* XE_IOCTL_H */
> diff --git a/lib/xe/xe_legacy.c b/lib/xe/xe_legacy.c
> index a3ff5da03..6570cf1e6 100644
> --- a/lib/xe/xe_legacy.c
> +++ b/lib/xe/xe_legacy.c
> @@ -5,6 +5,7 @@
>  
>  #include "lib/igt_syncobj.h"
>  #include "linux_scaffold.h"
> +#include "xe/xe_gt.h"
>  #include "xe/xe_ioctl.h"
>  #include "xe/xe_legacy.h"
>  #include "xe/xe_spin.h"
> diff --git a/tests/intel/xe_eudebug_online.c b/tests/intel/xe_eudebug_online.c
> index 1f72e3e44..535f00818 100644
> --- a/tests/intel/xe_eudebug_online.c
> +++ b/tests/intel/xe_eudebug_online.c
> @@ -13,6 +13,7 @@
>   */
>  
>  #include "xe/xe_eudebug.h"
> +#include "xe/xe_gt.h"
>  #include "xe/xe_ioctl.h"
>  #include "xe/xe_query.h"
>  #include "igt.h"
> diff --git a/tests/intel/xe_wedged.c b/tests/intel/xe_wedged.c
> index 1d2c510b7..7fc7ca9eb 100644
> --- a/tests/intel/xe_wedged.c
> +++ b/tests/intel/xe_wedged.c
> @@ -22,6 +22,7 @@
>  #include "igt_sysfs.h"
>  
>  #include "xe_drm.h"
> +#include "xe/xe_gt.h"
>  #include "xe/xe_ioctl.h"
>  #include "xe/xe_query.h"
>  #include "xe/xe_spin.h"
> -- 
> 2.47.1
> 


More information about the igt-dev mailing list