[PATCH 01/12] drm/amdgpu: Use memset32 for IB padding
Christian König
christian.koenig at amd.com
Thu Jan 2 13:45:43 UTC 2025
Am 27.12.24 um 12:19 schrieb Tvrtko Ursulin:
> From: Tvrtko Ursulin <tvrtko.ursulin at igalia.com>
>
> Use memset32 instead of open coding it, just because it is
> that bit nicer.
In general looks mostly good, my only concern is that we already had to
switch to memset_io() on some platforms for clearing buffers.
Now an IB should in theory always be in system memory, but it would be
nice to handle that cleanly.
Regards,
Christian.
>
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at igalia.com>
> Cc: Christian König <christian.koenig at amd.com>
> Cc: Sunil Khatri <sunil.khatri at amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
> index a6e28fe3f8d6..a27e32f48f99 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
> @@ -136,8 +136,16 @@ void amdgpu_ring_insert_nop(struct amdgpu_ring *ring, uint32_t count)
> */
> void amdgpu_ring_generic_pad_ib(struct amdgpu_ring *ring, struct amdgpu_ib *ib)
> {
> - while (ib->length_dw & ring->funcs->align_mask)
> - ib->ptr[ib->length_dw++] = ring->funcs->nop;
> + u32 align_mask = ring->funcs->align_mask;
> + u32 count = ib->length_dw & align_mask;
> +
> + if (count) {
> + count = align_mask + 1 - count;
> +
> + memset32(&ib->ptr[ib->length_dw], ring->funcs->nop, count);
> +
> + ib->length_dw += count;
> + }
> }
>
> /**
More information about the amd-gfx
mailing list