From: Maoyi Xie <maoyixie.tju@gmail.com>
To: Alex Deucher <alexander.deucher@amd.com>,
Christian König <christian.koenig@amd.com>
Cc: David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] drm/amdgpu: remove dead empty checks in ring_mux ib_mark_offset and end_ib
Date: Thu, 21 May 2026 21:35:37 +0800 [thread overview]
Message-ID: <20260521133537.3438468-1-maoyixie.tju@gmail.com> (raw)
amdgpu_ring_mux_ib_mark_offset() and amdgpu_ring_mux_end_ib() read
e->list with list_last_entry() and then test the returned pointer
against NULL. list_last_entry() never returns NULL. On an empty
list it returns container_of(&e->list, struct amdgpu_mux_chunk,
entry), which is an aliased pointer derived from the list head.
The "cannot find chunk!" error path is dead code.
These callsites run on the software ring submission path, after
amdgpu_ring_mux_start_ib() has linked a fresh chunk into e->list.
By the IB API contract, mark_offset and end_ib only execute between
start_ib and the chunk's removal in scan_and_remove_signaled_chunk(),
so e->list is non-empty at the read. The defensive check is
misleading and never fires.
Drop the dead block on both sites. The list_last_entry() read stays.
If a future change broke the precondition, callers would crash on
the aliased pointer, which is louder than the current silent error
log and easier to debug.
Suggested-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Maoyi Xie <maoyixie.tju@gmail.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ring_mux.c | 8 --------
1 file changed, 8 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring_mux.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring_mux.c
index 6e64a96fa285..83d62d9f76d4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring_mux.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring_mux.c
@@ -495,10 +495,6 @@ void amdgpu_ring_mux_ib_mark_offset(struct amdgpu_ring_mux *mux,
}
chunk = list_last_entry(&e->list, struct amdgpu_mux_chunk, entry);
- if (!chunk) {
- DRM_ERROR("cannot find chunk!\n");
- return;
- }
switch (type) {
case AMDGPU_MUX_OFFSET_TYPE_CONTROL:
@@ -528,10 +524,6 @@ void amdgpu_ring_mux_end_ib(struct amdgpu_ring_mux *mux, struct amdgpu_ring *rin
}
chunk = list_last_entry(&e->list, struct amdgpu_mux_chunk, entry);
- if (!chunk) {
- DRM_ERROR("cannot find chunk!\n");
- return;
- }
chunk->end = ring->wptr;
chunk->sync_seq = READ_ONCE(ring->fence_drv.sync_seq);
--
2.34.1
next reply other threads:[~2026-05-22 14:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 13:35 Maoyi Xie [this message]
2026-05-25 10:07 ` Claude review: drm/amdgpu: remove dead empty checks in ring_mux ib_mark_offset and end_ib Claude Code Review Bot
2026-05-25 10:07 ` Claude Code Review Bot
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=20260521133537.3438468-1-maoyixie.tju@gmail.com \
--to=maoyixie.tju@gmail.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--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