[PATCH 2/3] radeon: Fix VCE ring test for Big-Endian systems

Oded Gabbay oded.gabbay at gmail.com
Mon Dec 7 09:49:12 PST 2015


On Mon, Dec 7, 2015 at 9:51 AM, Michel Dänzer <michel at daenzer.net> wrote:
> On 05.12.2015 06:09, Oded Gabbay wrote:
>> This patch fixes the VCE ring test when running on Big-Endian machines.
>> Every write to the ring needs to be translated to little-endian.
>>
>> Signed-off-by: Oded Gabbay <oded.gabbay at gmail.com>
>> Cc: stable at vger.kernel.org
>> ---
>>  drivers/gpu/drm/radeon/radeon_vce.c | 32 ++++++++++++++++----------------
>>  1 file changed, 16 insertions(+), 16 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/radeon/radeon_vce.c b/drivers/gpu/drm/radeon/radeon_vce.c
>> index 574f62b..86f57e4 100644
>> --- a/drivers/gpu/drm/radeon/radeon_vce.c
>> +++ b/drivers/gpu/drm/radeon/radeon_vce.c
>> @@ -699,12 +699,12 @@ bool radeon_vce_semaphore_emit(struct radeon_device *rdev,
>>  {
>>       uint64_t addr = semaphore->gpu_addr;
>>
>> -     radeon_ring_write(ring, VCE_CMD_SEMAPHORE);
>> -     radeon_ring_write(ring, (addr >> 3) & 0x000FFFFF);
>> -     radeon_ring_write(ring, (addr >> 23) & 0x000FFFFF);
>> -     radeon_ring_write(ring, 0x01003000 | (emit_wait ? 1 : 0));
>> +     radeon_ring_write(ring, cpu_to_le32(VCE_CMD_SEMAPHORE));
>> +     radeon_ring_write(ring, cpu_to_le32((addr >> 3) & 0x000FFFFF));
>> +     radeon_ring_write(ring, cpu_to_le32((addr >> 23) & 0x000FFFFF));
>> +     radeon_ring_write(ring, cpu_to_le32(0x01003000 | (emit_wait ? 1 : 0)));
>>       if (!emit_wait)
>> -             radeon_ring_write(ring, VCE_CMD_END);
>> +             radeon_ring_write(ring, cpu_to_le32(VCE_CMD_END));
>>
>>       return true;
>>  }
>> @@ -719,10 +719,10 @@ bool radeon_vce_semaphore_emit(struct radeon_device *rdev,
>>  void radeon_vce_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib)
>>  {
>>       struct radeon_ring *ring = &rdev->ring[ib->ring];
>> -     radeon_ring_write(ring, VCE_CMD_IB);
>> -     radeon_ring_write(ring, ib->gpu_addr);
>> -     radeon_ring_write(ring, upper_32_bits(ib->gpu_addr));
>> -     radeon_ring_write(ring, ib->length_dw);
>> +     radeon_ring_write(ring, cpu_to_le32(VCE_CMD_IB));
>> +     radeon_ring_write(ring, cpu_to_le32(ib->gpu_addr));
>> +     radeon_ring_write(ring, cpu_to_le32(upper_32_bits(ib->gpu_addr)));
>> +     radeon_ring_write(ring, cpu_to_le32(ib->length_dw));
>>  }
>>
>>  /**
>> @@ -738,12 +738,12 @@ void radeon_vce_fence_emit(struct radeon_device *rdev,
>>       struct radeon_ring *ring = &rdev->ring[fence->ring];
>>       uint64_t addr = rdev->fence_drv[fence->ring].gpu_addr;
>>
>> -     radeon_ring_write(ring, VCE_CMD_FENCE);
>> -     radeon_ring_write(ring, addr);
>> -     radeon_ring_write(ring, upper_32_bits(addr));
>> -     radeon_ring_write(ring, fence->seq);
>> -     radeon_ring_write(ring, VCE_CMD_TRAP);
>> -     radeon_ring_write(ring, VCE_CMD_END);
>> +     radeon_ring_write(ring, cpu_to_le32(VCE_CMD_FENCE));
>> +     radeon_ring_write(ring, cpu_to_le32(addr));
>> +     radeon_ring_write(ring, cpu_to_le32(upper_32_bits(addr)));
>> +     radeon_ring_write(ring, cpu_to_le32(fence->seq));
>> +     radeon_ring_write(ring, cpu_to_le32(VCE_CMD_TRAP));
>> +     radeon_ring_write(ring, cpu_to_le32(VCE_CMD_END));
>>  }
>>
>>  /**
>> @@ -765,7 +765,7 @@ int radeon_vce_ring_test(struct radeon_device *rdev, struct radeon_ring *ring)
>>                         ring->idx, r);
>>               return r;
>>       }
>> -     radeon_ring_write(ring, VCE_CMD_END);
>> +     radeon_ring_write(ring, cpu_to_le32(VCE_CMD_END));
>>       radeon_ring_unlock_commit(rdev, ring, false);
>>
>>       for (i = 0; i < rdev->usec_timeout; i++) {
>>
>
> A new helper function such as
>
> static inline void radeon_ring_write_le(struct radeon_ring *ring, uint32_t v)
> {
>         radeon_ring_write(ring, cpu_to_le32(v));
> }
>
> might be nice for this.
>
>
> --
> Earthling Michel Dänzer               |               http://www.amd.com
> Libre software enthusiast             |             Mesa and X developer

IMHO, I don't think this gives any benefit.
You would just need to replace every:

radeon_ring_write(ring, cpu_to_le32(SOME_DEFINE));

with

radeon_ring_write_le(ring, SOME_DEFINE);

So no reduce in code size. Also, if you change it in my code, I think
you need to change it in the entire driver for consistency.

What's even more important, is that when I look at the above, it seems
to me this change even makes the code *less* clear as you now need to
go into radeon_ring_write_le  to actually understand how the value is
written.

       Oded


More information about the dri-devel mailing list