Am 31.07.24 um 11:35 schrieb Sunil Khatri:
clean up the calculation for nops count before
commit in the ring.
Signed-off-by: Sunil Khatri <sunil.khatri@xxxxxxx>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
index 0d72d2cbb64b..2c8218332c65 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
@@ -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.
if (count != 0)
ring->funcs->insert_nop(ring, count);