From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EB0A340A6B for ; Thu, 6 Aug 2026 04:45:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785991537; cv=none; b=oqwEgSUUd9abhP/7FkILo1YuCXOzMtU4ifxEimkv8iBMGU10jKDWPPxq+LrS7Hi5iPdtTYJvaqPDLZVppFzNskBqSZ+La1983paIob8JLsHGQejlk9qLh3n+dVRemRny3wM/rUNkgIMgR/9F3p0vMhgb9CJuE1qGO2s1Gn3BXhs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785991537; c=relaxed/simple; bh=qps4WXR6Y3kW2L+YWOrgrmtd3I5PsdfE4fmyegP2GcM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BBxa+OFV4TSns8H4P7iffUA8uECVUS6r+UWdwPxI6pjdYo6YAFMtVfDePNXPR5p55sgth5th3n0FT4e1BvzsrgUR/QPvjJ6kGlWny8fhttacVXVH2j7MzhKXG1WTrv0IQghxFyfz+kOskn/8MwA7zJq0BzAjmHqLnUP7juGqZMo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ILDNVWJV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ILDNVWJV" Received: by smtp.kernel.org (Postfix) with ESMTPS id 4AB6DC2BCFA; Thu, 6 Aug 2026 04:45:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1785991537; bh=qps4WXR6Y3kW2L+YWOrgrmtd3I5PsdfE4fmyegP2GcM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=ILDNVWJVxJQfuEPhFup9jfsI2OuGe3FdYZAnlYlNMqBwpr9vVfYYBjNukX2PdB+8n yfT7pnF96Xm001au9PdM9wJaRlJ+a+K4MGlP/ORn6LPkt0JIjOJ+DLnFTfFN6eFyrS TW9y4bFDET4jvR1P6TI4K7NIDOdiof8f0QvPsdkCdi9fUxoPMmPEGQk0EiHSVpXpsu iL/vxEWlL3/e3IWRPN1KjRlcNIWkef1Boc7kWCTdtLqSz3AtzphYpPhzd2z1ZUE8t7 rwlG+WqTiSJ3qzx87IYjFYF6wEkI2lS/FlwBviOXUzG4aBF/jchHkgixbx0o23bELB MRm4ILU951b/g== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37278C56208; Thu, 6 Aug 2026 04:45:37 +0000 (UTC) From: Junrui Luo via B4 Relay Date: Thu, 06 Aug 2026 12:45:26 +0800 Subject: [PATCH 3/3] drm/amdgpu: add the BO-va mapping offset when kmapping an IB Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260806-amdgpu-fixes-v1-3-ce247012d4da@outlook.com> References: <20260806-amdgpu-fixes-v1-0-ce247012d4da@outlook.com> In-Reply-To: <20260806-amdgpu-fixes-v1-0-ce247012d4da@outlook.com> To: Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , David Airlie , Simona Vetter , Jammy Zhou , Madhav Chauhan , Felix Kuehling Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Junrui Luo , Yuhao Jiang X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1861; i=moonafterrain@outlook.com; h=from:subject:message-id; bh=MbTPCxPC+NDqqRce7zTi4D+evqyxLQPMZapIx+qmD0Q=; b=owJ4nJvAy8zAJVb4wiKgu++DA+NptSSGrBLB/DfZi47l17h7SAeu4BEMcj9s2DaB3/PUHs7Qr W735Venv+goZWEQ42KQFVNkOV5w6ZuF7xbdLT5bkmHmsDKBDGHg4hSAiSzNYfjJGLTW9nlC6BXO woRQd5XGF9N/L/TaekN2tl3t8czgJm1nRoYNy5/s/vlEadqbDVUJms8cuoTL51u9k/f/yJS309L u0B8uAHdPSUc= X-Developer-Key: i=moonafterrain@outlook.com; a=openpgp; fpr=C770D2F6384DB42DB44CB46371E838508B8EF040 X-Endpoint-Received: by B4 Relay for moonafterrain@outlook.com/default with auth_id=909 X-Original-From: Junrui Luo Reply-To: moonafterrain@outlook.com From: Junrui Luo 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. Fixes: 4802ce117786 ("drm/amdgpu: fix UVD/VCE VM emulation") Reported-by: Yuhao Jiang Assisted-by: Claude:claude-opus-5 Signed-off-by: Junrui Luo --- 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 9c514cb01096..a72cee871af3 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c @@ -1047,7 +1047,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); -- 2.51.2