From: Junrui Luo via B4 Relay <devnull+moonafterrain.outlook.com@kernel.org>
To: "Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Jammy Zhou" <Jammy.Zhou@amd.com>,
"Madhav Chauhan" <madhav.chauhan@amd.com>,
"Felix Kuehling" <Felix.Kuehling@amd.com>
Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, Yuhao Jiang <danisjiang@gmail.com>,
Junrui Luo <moonafterrain@outlook.com>
Subject: [PATCH v2] drm/amdgpu: add the BO-va mapping offset when kmapping an IB
Date: Sat, 08 Aug 2026 18:07:26 +0800 [thread overview]
Message-ID: <20260808-amdgpu-fixes-v2-1-36d66398601f@outlook.com> (raw)
From: Junrui Luo <moonafterrain@outlook.com>
amdgpu_cs_patch_ibs() derives the CPU-side view of a UVD/VCE/VCN
indirect buffer from the BO returned by amdgpu_cs_find_mapping():
r = amdgpu_bo_kmap(aobj, (void **)&kptr);
kptr += va_start - (m->start * AMDGPU_GPU_PAGE_SIZE);
amdgpu_bo_kmap() returns the start of the BO, so only the displacement
of va_start inside the mapping is added. The page tables, however, are
programmed from mapping->offset (see amdgpu_vm_bo_update()), which
records the offset_in_bo the client passed to AMDGPU_GEM_VA. The GPU
therefore resolves va_start to BO byte
m->offset + (va_start - m->start * AMDGPU_GPU_PAGE_SIZE)
while the kernel inspects the byte m->offset lower. Whenever an IB is
submitted through a mapping created with a non-zero offset_in_bo, the
two views disagree.
Add the missing term so the kmapped pointer describes the same bytes the
page tables do.
Every other CPU-side consumer of amdgpu_cs_find_mapping() omits
mapping->offset in the same way.
Reported-by: Yuhao Jiang <danisjiang@gmail.com>
Assisted-by: Claude:claude-opus-5
Signed-off-by: Junrui Luo <moonafterrain@outlook.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
---
Changes in v2:
- Drop the Fixes tag.
- Pick up Christian's Reviewed-by.
- Resend standalone.
- Link to v1: https://lore.kernel.org/r/20260806-amdgpu-fixes-v1-3-ce247012d4da@outlook.com
---
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index 5445f75741b5..17fe6d56e020 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -1043,7 +1043,7 @@ static int amdgpu_cs_patch_ibs(struct amdgpu_cs_parser *p,
if (r)
return r;
- kptr += va_start - (m->start * AMDGPU_GPU_PAGE_SIZE);
+ kptr += m->offset + va_start - (m->start * AMDGPU_GPU_PAGE_SIZE);
if (ring->funcs->parse_cs) {
memcpy(ib->ptr, kptr, ib->length_dw * 4);
---
base-commit: 075b74841bd0065a3bda3440873c747938e69b68
change-id: 20260808-amdgpu-fixes-9ca10fa07e10
Best regards,
--
Junrui Luo <moonafterrain@outlook.com>
reply other threads:[~2026-08-08 10:07 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260808-amdgpu-fixes-v2-1-36d66398601f@outlook.com \
--to=devnull+moonafterrain.outlook.com@kernel.org \
--cc=Felix.Kuehling@amd.com \
--cc=Jammy.Zhou@amd.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=danisjiang@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=madhav.chauhan@amd.com \
--cc=moonafterrain@outlook.com \
--cc=simona@ffwll.ch \
/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
all inboxes | Powered by JetHome®