drm/amdgpu: remove dead empty checks in ring_mux ib_mark_offset and end_ib
Subsystems (2)
PATCH 1/1 drm/amdgpu: remove dead empty checks in ring_mux ib_mark_offset and end_ib
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.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring_mux.c | 8 -------- 1 file changed, 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring_mux.c +0 -8
@@ -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);
Signature · 1 line
2.34.1
Ping. Christian acked the approach in the inquiry thread, could this be applied?
https://lore.kernel.org/amd-gfx/[email protected]/
Best,
Maoyi