drm/amdgpu: clean up the count calculation for nop
Subsystems (2)
PATCH 1/1 drm/amdgpu: clean up the count calculation for nop
clean up the calculation for nops count before
commit in the ring.
Signed-off-by Sunil Khatri <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +2 -3
@@ -142,9 +142,8 @@ void amdgpu_ring_commit(struct amdgpu_ring *ring)uint32_t count;/* We pad to match fetch size */ - count = ring->funcs->align_mask +1 - - (ring->wptr & ring->funcs->align_mask); - count %= ring->funcs->align_mask +1 ; + count = ring->funcs->align_mask - + ((ring->wptr + ring->funcs->align_mask) & ring->funcs->align_mask);if (count !=0 ) ring->funcs->insert_nop (ring, count);
Signature · 1 line
2.34.1
Christian König
maintainerAm 31.07.24 um 11:35 schrieb Sunil Khatri:
Quoted 13 lines
clean up the calculation for nops count before
commit in the ring.Signed-off-by Sunil Khatri <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c void amdgpu_ring_commit(struct amdgpu_ring *ring) · line 146
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +2
-3@@ -142,9 +142,8 @@ void amdgpu_ring_commit(struct amdgpu_ring *ring)uint32_t count;/* We pad to match fetch size */ - count = ring->funcs->align_mask +1 - - (ring->wptr & ring->funcs->align_mask); - count %= ring->funcs->align_mask +1 ; + count = ring->funcs->align_mask - + ((ring->wptr + ring->funcs->align_mask) & ring->funcs->align_mask);
I just realized that the old handling was potentially better since it only required a constant addition instead of two with the align_mask.
E.g. "ring->funcs->align_mask + 1 -" looks a bit odd but might be less instructions.
Maybe just review and commit the version from Tvrtko which just replaces the % with an & operation.
Regards,
Christian.
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0
-0if (count !=0 ) ring->funcs->insert_nop (ring, count);