From: Ray Wu <ray.wu@amd.com>
To: <igt-dev@lists.freedesktop.org>
Cc: <jani.nikula@linux.intel.com>, <kamil.konieczny@linux.intel.com>,
<alex.hung@amd.com>, <sunpeng.li@amd.com>,
<chiahsuan.chung@amd.com>, Ray Wu <ray.wu@amd.com>
Subject: [PATCH i-g-t v2 1/6] tests/amdgpu/amd_replay: Read DPCD at the target offset
Date: Mon, 16 Nov 2026 10:24:42 +0800 [thread overview]
Message-ID: <20261116022447.3981877-2-ray.wu@amd.com> (raw)
In-Reply-To: <20261116022447.3981877-1-ray.wu@amd.com>
A short read in dpcd_read_byte() returns a byte from the wrong offset.
Use pread() at the target offset, and drop the double close of dir_fd.
Signed-off-by: Ray Wu <ray.wu@amd.com>
---
tests/amdgpu/amd_replay.c | 23 ++++-------------------
1 file changed, 4 insertions(+), 19 deletions(-)
diff --git a/tests/amdgpu/amd_replay.c b/tests/amdgpu/amd_replay.c
index 775bed190..4640eb804 100644
--- a/tests/amdgpu/amd_replay.c
+++ b/tests/amdgpu/amd_replay.c
@@ -159,7 +159,6 @@ static bool dpcd_read_byte(int drm_fd,
{
DIR *dir;
int dir_fd;
- uint8_t buf[16] = {0};
*val = 0;
dir_fd = igt_connector_sysfs_open(drm_fd, connector);
@@ -171,7 +170,7 @@ static bool dpcd_read_byte(int drm_fd,
for (;;) {
struct dirent *ent;
char path[5 + sizeof(ent->d_name)];
- int fd, ret, i, j, k;
+ int fd, ret;
ent = readdir(dir);
if (!ent)
@@ -185,31 +184,17 @@ static bool dpcd_read_byte(int drm_fd,
fd = open(path, O_RDONLY);
igt_assert(fd >= 0);
- k = (addr / 16) + 1;
- j = addr % 16;
-
- /* read 16 bytes each loop */
- for (i = 0; i < k; i++) {
- ret = read(fd, buf, sizeof(buf));
- if (ret < 0)
- break;
- if (ret != sizeof(buf))
- break;
- }
+ ret = pread(fd, val, 1, addr);
close(fd);
+ /* closedir() also closes dir_fd */
closedir(dir);
- close(dir_fd);
-
- if (ret > 0)
- *val = buf[j];
- return (ret > 0);
+ return (ret == 1);
}
closedir(dir);
- close(dir_fd);
igt_skip("Missing /dev/drm_dp_aux*, check DRM_DISPLAY_DP_AUX_CHARDEV in kernel config\n");
--
2.43.0
next prev parent reply other threads:[~2026-11-16 2:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 2:24 [PATCH i-g-t v2 0/6] tests/amdgpu/amd_replay: Fix state and sink status checks Ray Wu
2026-11-16 2:24 ` Ray Wu [this message]
2026-11-16 2:24 ` [PATCH i-g-t v2 2/6] tests/amdgpu/amd_replay: Fix test_mode checks Ray Wu
2026-11-16 2:24 ` [PATCH i-g-t v2 3/6] tests/amdgpu/amd_replay: Fix inverted Replay state range checks Ray Wu
2026-11-16 2:24 ` [PATCH i-g-t v2 4/6] tests/amdgpu/amd_replay: Require REPLAY_STATE_3 after settle Ray Wu
2026-11-16 2:24 ` [PATCH i-g-t v2 5/6] tests/amdgpu/amd_replay: Fail on page flip errors Ray Wu
2026-11-16 2:24 ` [PATCH i-g-t v2 6/6] tests/amdgpu/amd_replay: Check sink Replay error status Ray Wu
2026-11-16 3:25 ` ✓ Xe.CI.BAT: success for tests/amdgpu/amd_replay: Fix state and sink status checks (rev2) Patchwork
2026-11-16 3:45 ` ✗ i915.CI.BAT: failure " Patchwork
2026-11-16 5:28 ` ✗ 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=20261116022447.3981877-2-ray.wu@amd.com \
--to=ray.wu@amd.com \
--cc=alex.hung@amd.com \
--cc=chiahsuan.chung@amd.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=kamil.konieczny@linux.intel.com \
--cc=sunpeng.li@amd.com \
/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