[PATCH i-g-t v2 1/3] tests/intel/xe_eu_stall: Close any open EU stall fd before opening a new one
Harish Chegondi
harish.chegondi at intel.com
Mon Jun 16 23:57:07 UTC 2025
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).
v2: 1. Use igt_assert_fd() instead of igt_require_fd() as skips are
not allowed from a child process
2. Close any open stream fd before fork()
3. Rebase
Reviewed-by: Ashutosh Dixit <ashutosh.dixit at intel.com>
Signed-off-by: Harish Chegondi <harish.chegondi at intel.com>
---
tests/intel/xe_eu_stall.c | 38 ++++++++++++++++++++++++++++++--------
1 file changed, 30 insertions(+), 8 deletions(-)
diff --git a/tests/intel/xe_eu_stall.c b/tests/intel/xe_eu_stall.c
index b27f5685e..16428af9b 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_assert_fd(ret);
+
+ return ret;
+}
+
/*
* Verify that tests with invalid arguments fail.
*/
@@ -353,7 +373,11 @@ static inline void disable_paranoid(void)
*/
static void test_non_privileged_access(int drm_fd)
{
- int paranoid, stream_fd;
+ int paranoid;
+
+ /* Close any open stream fd before fork() */
+ if (stream_fd >= 0)
+ eu_stall_close(stream_fd);
paranoid = read_u64_file(OBSERVATION_PARANOID);
@@ -395,9 +419,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 +495,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 +541,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: %" PRIu64 "\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 +614,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