[PATCH i-g-t 3/8] lib/xe: Move functions from xe_util to xe_gt
Cavitt, Jonathan
jonathan.cavitt at intel.com
Mon Jan 6 22:58:15 UTC 2025
-----Original Message-----
From: igt-dev <igt-dev-bounces at lists.freedesktop.org> On Behalf Of Lucas De Marchi
Sent: Friday, January 3, 2025 11:16 PM
To: igt-dev at lists.freedesktop.org
Cc: De Marchi, Lucas <lucas.demarchi at intel.com>
Subject: [PATCH i-g-t 3/8] lib/xe: Move functions from xe_util to xe_gt
>
> Some functions are clearly gt-related, so move them to xe_gt.
>
> Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
LGTM, though at some point in the future, we should probably take a closer look at
the test files that have been impacted by this change and check if xe_util.h is still a
required includes for them.
Reviewed-by: Jonathan Cavitt <jonathan.cavitt at intel.com>
-Jonathan Cavitt
> ---
> lib/xe/xe_gt.c | 67 ++++++++++++++++++++++++++++++++++
> lib/xe/xe_gt.h | 8 ++++
> lib/xe/xe_util.c | 67 ----------------------------------
> lib/xe/xe_util.h | 7 ----
> tests/intel/xe_drm_fdinfo.c | 2 +
> tests/intel/xe_exec_balancer.c | 1 +
> tests/intel/xe_exec_reset.c | 1 +
> tests/intel/xe_exec_threads.c | 1 +
> tests/intel/xe_gt_freq.c | 1 +
> tests/intel/xe_pm_residency.c | 2 +
> 10 files changed, 83 insertions(+), 74 deletions(-)
>
> diff --git a/lib/xe/xe_gt.c b/lib/xe/xe_gt.c
> index 53554beb0..e1f353b41 100644
> --- a/lib/xe/xe_gt.c
> +++ b/lib/xe/xe_gt.c
> @@ -174,3 +174,70 @@ int xe_gt_stats_get_count(int fd, int gt, const char *stat)
>
> return count;
> }
> +
> +/**
> + * xe_is_gt_in_c6:
> + * @fd: pointer to xe drm fd
> + * @gt: gt number
> + *
> + * Check if GT is in C6 state
> + */
> +bool xe_is_gt_in_c6(int fd, int gt)
> +{
> + char gt_c_state[16];
> + int gt_fd;
> +
> + gt_fd = xe_sysfs_gt_open(fd, gt);
> + igt_assert(gt_fd >= 0);
> + igt_assert(igt_sysfs_scanf(gt_fd, "gtidle/idle_status", "%s", gt_c_state) == 1);
> + close(gt_fd);
> +
> + return strcmp(gt_c_state, "gt-c6") == 0;
> +}
> +
> +/**
> + * xe_gt_fill_engines_by_class:
> + * @fd: pointer to xe drm fd
> + * @gt: gt number
> + * @class: engine class to use to filter engines
> + * @eci: output argument to copy engines to
> + *
> + * Fill out @drm_xe_engine_class_instance with all the engines in @gt that have
> + * a certain @class.
> + *
> + * Return: number of engines that match the gt and clas
> + */
> +int xe_gt_fill_engines_by_class(int fd, int gt, int class,
> + struct drm_xe_engine_class_instance eci[static XE_MAX_ENGINE_INSTANCE])
> +{
> + struct drm_xe_engine_class_instance *hwe;
> + int n = 0;
> +
> + xe_for_each_engine(fd, hwe)
> + if (hwe->engine_class == class && hwe->gt_id == gt)
> + eci[n++] = *hwe;
> +
> + return n;
> +}
> +
> +/**
> + * xe_gt_count_engines_by_class:
> + * @fd: pointer to xe drm fd
> + * @gt: gt number
> + * @class: engine class to use to filter engines
> + *
> + * Count number of engines in @gt that have a certain @class.
> + *
> + * Return: number of engines that match the gt and clas
> + */
> +int xe_gt_count_engines_by_class(int fd, int gt, int class)
> +{
> + struct drm_xe_engine_class_instance *hwe;
> + int n = 0;
> +
> + xe_for_each_engine(fd, hwe)
> + if (hwe->engine_class == class && hwe->gt_id == gt)
> + n++;
> +
> + return n;
> +}
> diff --git a/lib/xe/xe_gt.h b/lib/xe/xe_gt.h
> index 756b5f38e..47569cec3 100644
> --- a/lib/xe/xe_gt.h
> +++ b/lib/xe/xe_gt.h
> @@ -8,6 +8,8 @@
>
> #include "lib/igt_gt.h"
>
> +#include "xe_query.h"
> +
> bool has_xe_gt_reset(int fd);
> void xe_force_gt_reset_all(int fd);
> igt_hang_t xe_hang_ring(int fd, uint64_t ahnd, uint32_t ctx, int ring,
> @@ -15,4 +17,10 @@ igt_hang_t xe_hang_ring(int fd, uint64_t ahnd, uint32_t ctx, int ring,
> void xe_post_hang_ring(int fd, igt_hang_t arg);
> int xe_gt_stats_get_count(int fd, int gt, const char *stat);
>
> +bool xe_is_gt_in_c6(int fd, int gt);
> +
> +int xe_gt_fill_engines_by_class(int fd, int gt, int class,
> + struct drm_xe_engine_class_instance eci[static XE_MAX_ENGINE_INSTANCE]);
> +int xe_gt_count_engines_by_class(int fd, int gt, int class);
> +
> #endif
> diff --git a/lib/xe/xe_util.c b/lib/xe/xe_util.c
> index 9482819c2..f0b6bbb2d 100644
> --- a/lib/xe/xe_util.c
> +++ b/lib/xe/xe_util.c
> @@ -235,70 +235,3 @@ void xe_bind_unbind_async(int xe, uint32_t vm, uint32_t bind_engine,
>
> free(bind_ops);
> }
> -
> -/**
> - * xe_is_gt_in_c6:
> - * @fd: pointer to xe drm fd
> - * @gt: gt number
> - *
> - * Check if GT is in C6 state
> - */
> -bool xe_is_gt_in_c6(int fd, int gt)
> -{
> - char gt_c_state[16];
> - int gt_fd;
> -
> - gt_fd = xe_sysfs_gt_open(fd, gt);
> - igt_assert(gt_fd >= 0);
> - igt_assert(igt_sysfs_scanf(gt_fd, "gtidle/idle_status", "%s", gt_c_state) == 1);
> - close(gt_fd);
> -
> - return strcmp(gt_c_state, "gt-c6") == 0;
> -}
> -
> -/**
> - * xe_gt_fill_engines_by_class:
> - * @fd: pointer to xe drm fd
> - * @gt: gt number
> - * @class: engine class to use to filter engines
> - * @eci: output argument to copy engines to
> - *
> - * Fill out @drm_xe_engine_class_instance with all the engines in @gt that have
> - * a certain @class.
> - *
> - * Return: number of engines that match the gt and clas
> - */
> -int xe_gt_fill_engines_by_class(int fd, int gt, int class,
> - struct drm_xe_engine_class_instance eci[static XE_MAX_ENGINE_INSTANCE])
> -{
> - struct drm_xe_engine_class_instance *hwe;
> - int n = 0;
> -
> - xe_for_each_engine(fd, hwe)
> - if (hwe->engine_class == class && hwe->gt_id == gt)
> - eci[n++] = *hwe;
> -
> - return n;
> -}
> -
> -/**
> - * xe_gt_count_engines_by_class:
> - * @fd: pointer to xe drm fd
> - * @gt: gt number
> - * @class: engine class to use to filter engines
> - *
> - * Count number of engines in @gt that have a certain @class.
> - *
> - * Return: number of engines that match the gt and clas
> - */
> -int xe_gt_count_engines_by_class(int fd, int gt, int class)
> -{
> - struct drm_xe_engine_class_instance *hwe;
> - int n = 0;
> -
> - xe_for_each_engine(fd, hwe)
> - if (hwe->engine_class == class && hwe->gt_id == gt)
> - n++;
> -
> - return n;
> -}
> diff --git a/lib/xe/xe_util.h b/lib/xe/xe_util.h
> index b9fbfc5cd..c544d912f 100644
> --- a/lib/xe/xe_util.h
> +++ b/lib/xe/xe_util.h
> @@ -47,11 +47,4 @@ void xe_bind_unbind_async(int fd, uint32_t vm, uint32_t bind_engine,
> struct igt_list_head *obj_list,
> uint32_t sync_in, uint32_t sync_out);
>
> -bool xe_is_gt_in_c6(int fd, int gt);
> -
> -int xe_gt_fill_engines_by_class(int fd, int gt, int class,
> - struct drm_xe_engine_class_instance eci[static XE_MAX_ENGINE_INSTANCE]);
> -int xe_gt_count_engines_by_class(int fd, int gt, int class);
> -
> -
> #endif /* XE_UTIL_H */
> diff --git a/tests/intel/xe_drm_fdinfo.c b/tests/intel/xe_drm_fdinfo.c
> index 6549629b4..f4264aadb 100644
> --- a/tests/intel/xe_drm_fdinfo.c
> +++ b/tests/intel/xe_drm_fdinfo.c
> @@ -8,7 +8,9 @@
> #include "igt_device.h"
> #include "igt_drm_fdinfo.h"
> #include "lib/igt_syncobj.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"
> diff --git a/tests/intel/xe_exec_balancer.c b/tests/intel/xe_exec_balancer.c
> index 1e552e9ef..f2df5cbec 100644
> --- a/tests/intel/xe_exec_balancer.c
> +++ b/tests/intel/xe_exec_balancer.c
> @@ -19,6 +19,7 @@
> #include "lib/intel_reg.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"
> diff --git a/tests/intel/xe_exec_reset.c b/tests/intel/xe_exec_reset.c
> index a3eaf8bbf..47c7666df 100644
> --- a/tests/intel/xe_exec_reset.c
> +++ b/tests/intel/xe_exec_reset.c
> @@ -21,6 +21,7 @@
>
> #include "xe/xe_ioctl.h"
> #include "xe/xe_query.h"
> +#include "xe/xe_gt.h"
> #include "xe/xe_spin.h"
> #include "xe/xe_util.h"
> #include <string.h>
> diff --git a/tests/intel/xe_exec_threads.c b/tests/intel/xe_exec_threads.c
> index 661117bed..c8fc17366 100644
> --- a/tests/intel/xe_exec_threads.c
> +++ b/tests/intel/xe_exec_threads.c
> @@ -21,6 +21,7 @@
>
> #include "xe/xe_ioctl.h"
> #include "xe/xe_query.h"
> +#include "xe/xe_gt.h"
> #include "xe/xe_spin.h"
> #include "xe/xe_util.h"
> #include <string.h>
> diff --git a/tests/intel/xe_gt_freq.c b/tests/intel/xe_gt_freq.c
> index de4d111ea..5d806cf15 100644
> --- a/tests/intel/xe_gt_freq.c
> +++ b/tests/intel/xe_gt_freq.c
> @@ -17,6 +17,7 @@
> #include "igt_sysfs.h"
>
> #include "xe_drm.h"
> +#include "xe/xe_gt.h"
> #include "xe/xe_ioctl.h"
> #include "xe/xe_spin.h"
> #include "xe/xe_query.h"
> diff --git a/tests/intel/xe_pm_residency.c b/tests/intel/xe_pm_residency.c
> index d4b26b231..18e5cb6c3 100644
> --- a/tests/intel/xe_pm_residency.c
> +++ b/tests/intel/xe_pm_residency.c
> @@ -21,7 +21,9 @@
> #include "igt_sysfs.h"
>
> #include "lib/igt_syncobj.h"
> +
> #include "xe/xe_ioctl.h"
> +#include "xe/xe_gt.h"
> #include "xe/xe_query.h"
> #include "xe/xe_util.h"
>
> --
> 2.47.0
>
>
More information about the igt-dev
mailing list