Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t v2 1/3] tests/intel/xe_eu_stall: Close any open EU stall fd before opening a new one
@ 2025-06-16 23:57 Harish Chegondi
  2025-06-16 23:57 ` [PATCH i-g-t v2 2/3] tests/intel/xe_eu_stall: Do not check for presence of data on simulation Harish Chegondi
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Harish Chegondi @ 2025-06-16 23:57 UTC (permalink / raw)
  To: igt-dev; +Cc: Harish Chegondi, Ashutosh Dixit

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@intel.com>
Signed-off-by: Harish Chegondi <harish.chegondi@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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-06-18 18:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-16 23:57 [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
2025-06-16 23:57 ` [PATCH i-g-t v2 2/3] tests/intel/xe_eu_stall: Do not check for presence of data on simulation Harish Chegondi
2025-06-16 23:57 ` [PATCH i-g-t v2 3/3] tests/intel/xe_eu_stall: Use query IOCTL to check for EU stall support Harish Chegondi
2025-06-18 15:53   ` Kolakowski, Jakub1
2025-06-18 18:42     ` Dixit, Ashutosh
2025-06-17  2:19 ` ✓ Xe.CI.BAT: success for series starting with [i-g-t,v2,1/3] tests/intel/xe_eu_stall: Close any open EU stall fd before opening a new one Patchwork
2025-06-17 10:55 ` ✗ Xe.CI.Full: failure " Patchwork
2025-06-17 14:32 ` ✗ i915.CI.BAT: " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox