Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
To: igt-dev@lists.freedesktop.org, Ashutosh Dixit <ashutosh.dixit@intel.com>
Subject: [PATCH i-g-t] tests/intel/xe_oa: Call get_stream_status only on EIO
Date: Wed, 16 Apr 2025 16:12:02 -0700	[thread overview]
Message-ID: <20250416231203.13916-1-umesh.nerlige.ramappa@intel.com> (raw)

Turns out that get_stream_status resets errno and anything that checks
errno afterwards fails. This resulted in a bunch of test failures. Fix
it by calling get_stream_status only if errno is EIO and also save and
restore errno within get_stream_status.

Closes: https://gitlab.freedesktop.org/drm/xe/kernel/issues/4804
Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
---
 tests/intel/xe_oa.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/tests/intel/xe_oa.c b/tests/intel/xe_oa.c
index 1fc8bfaafee2..360dd8ba00d9 100644
--- a/tests/intel/xe_oa.c
+++ b/tests/intel/xe_oa.c
@@ -380,9 +380,11 @@ static void set_fd_flags(int fd, int flags)
 static u32 get_stream_status(int fd)
 {
 	struct drm_xe_oa_stream_status status;
+	int _e = errno;
 
 	do_ioctl(fd, DRM_XE_OBSERVATION_IOCTL_STATUS, &status);
 	igt_debug("oa status %llx\n", status.oa_status);
+	errno = _e; 
 
 	return status.oa_status;
 }
@@ -2294,7 +2296,8 @@ static void test_polling_small_buf(void)
 	errno = 0;
 	ret = read(stream_fd, buf, sizeof(buf));
 	igt_assert_eq(ret, -1);
-	get_stream_status(stream_fd);
+	if (errno == EIO)
+		get_stream_status(stream_fd);
 	igt_assert_eq(errno, ENOSPC);
 
 	/* Poll with 0 timeout and expect POLLIN flag to be set */
@@ -2569,7 +2572,8 @@ test_enable_disable(const struct drm_xe_engine_class_instance *hwe)
 	errno = 0;
 	ret = read(stream_fd, buf, sizeof(buf));
 	igt_assert_eq(ret, -1);
-	get_stream_status(stream_fd);
+	if (errno == EIO)
+		get_stream_status(stream_fd);
 	igt_assert_eq(errno, EINVAL);
 
 	do_ioctl(stream_fd, DRM_XE_OBSERVATION_IOCTL_ENABLE, 0);
@@ -2586,7 +2590,8 @@ test_enable_disable(const struct drm_xe_engine_class_instance *hwe)
 	/* Ensure num_reports can be read */
 	while ((ret = read(stream_fd, buf, sizeof(buf))) < 0 && errno == EINTR)
 		;
-	get_stream_status(stream_fd);
+	if (errno == EIO)
+		get_stream_status(stream_fd);
 	igt_assert_eq(ret, sizeof(buf));
 
 	__perf_close(stream_fd);
@@ -2730,7 +2735,8 @@ test_non_sampling_read_error(void)
 
 	ret = read(stream_fd, buf, sizeof(buf));
 	igt_assert_eq(ret, -1);
-	get_stream_status(stream_fd);
+	if (errno == EIO)
+		get_stream_status(stream_fd);
 	igt_assert_eq(errno, EINVAL);
 
 	__perf_close(stream_fd);
@@ -2772,7 +2778,8 @@ test_disabled_read_error(void)
 
 	ret = read(stream_fd, buf, sizeof(buf));
 	igt_assert_eq(ret, -1);
-	get_stream_status(stream_fd);
+	if (errno == EIO)
+		get_stream_status(stream_fd);
 	igt_assert_eq(errno, EINVAL);
 
 	__perf_close(stream_fd);
@@ -2791,7 +2798,8 @@ test_disabled_read_error(void)
 
 	ret = read(stream_fd, buf, sizeof(buf));
 	igt_assert_eq(ret, -1);
-	get_stream_status(stream_fd);
+	if (errno == EIO)
+		get_stream_status(stream_fd);
 	igt_assert_eq(errno, EINVAL);
 
 	do_ioctl(stream_fd, DRM_XE_OBSERVATION_IOCTL_ENABLE, 0);
-- 
2.45.2


             reply	other threads:[~2025-04-16 23:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-16 23:12 Umesh Nerlige Ramappa [this message]
2025-04-16 23:16 ` [PATCH i-g-t] tests/intel/xe_oa: Call get_stream_status only on EIO Dixit, Ashutosh
2025-04-17 19:00   ` Umesh Nerlige Ramappa
2025-04-17 19:16     ` Dixit, Ashutosh
2025-04-17  1:15 ` ✓ Xe.CI.BAT: success for " Patchwork
2025-04-17  1:22 ` ✓ i915.CI.BAT: " Patchwork
2025-04-17 14:10 ` ✗ i915.CI.Full: failure " Patchwork
2025-04-17 15:15 ` ✗ Xe.CI.Full: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250416231203.13916-1-umesh.nerlige.ramappa@intel.com \
    --to=umesh.nerlige.ramappa@intel.com \
    --cc=ashutosh.dixit@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox