[PATCH i-g-t 1/3] tests/intel/xe_eu_stall: Close any open EU stall fd before opening a new one
Dixit, Ashutosh
ashutosh.dixit at intel.com
Wed Jun 4 23:53:14 UTC 2025
On Tue, 03 Jun 2025 16:57:34 -0700, Harish Chegondi wrote:
>
> asserts in a sub-test can prevent closing an EU stall fd and the next
> subtest may fail with EBUSY if it tries to open another EU stall fd
> as there can only be one EU stall stream open at a time. Any open fds
> are automatically closed at the end of a test (last sub-test).
>
> Cc: Ashutosh Dixit <ashutosh.dixit at intel.com>
> Signed-off-by: Harish Chegondi <harish.chegondi at intel.com>
So -EBUSY errors are gone with this patch, correct? So this is:
Reviewed-by: Ashutosh Dixit <ashutosh.dixit at intel.com>
> ---
> tests/intel/xe_eu_stall.c | 34 ++++++++++++++++++++++++++--------
> 1 file changed, 26 insertions(+), 8 deletions(-)
>
> diff --git a/tests/intel/xe_eu_stall.c b/tests/intel/xe_eu_stall.c
> index 411c30871..1499ec4b4 100644
> --- a/tests/intel/xe_eu_stall.c
> +++ b/tests/intel/xe_eu_stall.c
> @@ -69,6 +69,7 @@ static uint8_t p_gt_id;
> static uint32_t p_rate;
> static uint32_t p_user = DEFAULT_USER_BUF_SIZE;
> static uint32_t p_num_reports = DEFAULT_NUM_REPORTS;
> +static int stream_fd = -1;
>
> static volatile bool child_is_running = true;
>
> @@ -302,6 +303,25 @@ static void set_fd_flags(int fd, int flags)
> igt_assert_eq(0, fcntl(fd, F_SETFL, old | flags));
> }
>
> +static void eu_stall_close(int fd)
> +{
> + close(fd);
> + stream_fd = -1;
> +}
> +
> +static int eu_stall_open(int drm_fd, struct xe_eu_stall_open_prop *props)
> +{
> + int ret;
> +
> + if (stream_fd >= 0)
> + eu_stall_close(stream_fd);
> +
> + ret = xe_eu_stall_ioctl(drm_fd, DRM_XE_OBSERVATION_OP_STREAM_OPEN, props);
> + igt_require_fd(ret);
> +
> + return ret;
> +}
> +
> /*
> * Verify that tests with invalid arguments fail.
> */
> @@ -353,7 +373,7 @@ static inline void disable_paranoid(void)
> */
> static void test_non_privileged_access(int drm_fd)
> {
> - int paranoid, stream_fd;
> + int paranoid;
>
> paranoid = read_u64_file(OBSERVATION_PARANOID);
>
> @@ -395,9 +415,8 @@ static void test_non_privileged_access(int drm_fd)
>
> igt_drop_root();
>
> - stream_fd = xe_eu_stall_ioctl(drm_fd, DRM_XE_OBSERVATION_OP_STREAM_OPEN, &props);
> - igt_require_fd(stream_fd);
> - close(stream_fd);
> + stream_fd = eu_stall_open(drm_fd, &props);
> + eu_stall_close(stream_fd);
> }
>
> igt_waitchildren();
> @@ -472,7 +491,7 @@ static void test_eustall(int drm_fd, uint32_t devid, bool blocking_read, int ite
> uint32_t num_samples, num_drops;
> struct igt_helper_process work_load = {};
> struct sigaction sa = { 0 };
> - int ret, flags, stream_fd;
> + int ret, flags;
> uint64_t total_size;
> uint8_t *buf;
>
> @@ -518,8 +537,7 @@ static void test_eustall(int drm_fd, uint32_t devid, bool blocking_read, int ite
> properties[3] = query_eu_stall_data->sampling_rates[0];
> igt_info("Sampling Rate: %lu\n", properties[3]);
>
> - stream_fd = xe_eu_stall_ioctl(drm_fd, DRM_XE_OBSERVATION_OP_STREAM_OPEN, &props);
> - igt_require_fd(stream_fd);
> + stream_fd = eu_stall_open(drm_fd, &props);
>
> if (!blocking_read)
> flags = O_CLOEXEC | O_NONBLOCK;
> @@ -592,7 +610,7 @@ enable:
> if (--iter)
> goto enable;
>
> - close(stream_fd);
> + eu_stall_close(stream_fd);
> free(buf);
> }
>
> --
> 2.48.1
>
More information about the igt-dev
mailing list