[PATCH] drm/amdgpu/{uvd,vcn}: fetch ring's read_ptr after alloc

S, Shirish sshankar at amd.com
Wed Jun 5 01:35:19 UTC 2019


Hi Alex,

On 6/4/2019 9:43 PM, Alex Deucher wrote:
> On Tue, Jun 4, 2019 at 12:07 PM S, Shirish <Shirish.S at amd.com> wrote:
>> [What]
>> readptr read always returns zero, since most likely
>> UVD block is either power or clock gated.
>>
>> [How]
>> fetch rptr after amdgpu_ring_alloc() which informs
>> the power management code that the block is about to be
>> used and hence the gating is turned off.
>>
>> Signed-off-by: Louis Li <Ching-shih.Li at amd.com>
>> Signed-off-by: Shirish S <shirish.s at amd.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 4 +++-
>>   drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c   | 5 ++++-
>>   drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c   | 5 ++++-
> What about uvd 4.2, 5.0 and VCE 2.0, 3.0, 4.0?
amdgpu_vce_ring_test_ring() is the common function for VCE 2.0, 3.0 & 4.0
and patch that fixes it, is already reviewed.

UVD 4.2 & 5.0  use mmUVD_CONTEXT_ID instead of readptr,
so i beleive this fix is not applicable for them.
Regards,
Shirish S
>
> Alex
>
>>   3 files changed, 11 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
>> index 118451f..d786098 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
>> @@ -468,7 +468,7 @@ int amdgpu_vcn_dec_ring_test_ib(struct amdgpu_ring *ring, long timeout)
>>   int amdgpu_vcn_enc_ring_test_ring(struct amdgpu_ring *ring)
>>   {
>>          struct amdgpu_device *adev = ring->adev;
>> -       uint32_t rptr = amdgpu_ring_get_rptr(ring);
>> +       uint32_t rptr;
>>          unsigned i;
>>          int r;
>>
>> @@ -476,6 +476,8 @@ int amdgpu_vcn_enc_ring_test_ring(struct amdgpu_ring *ring)
>>          if (r)
>>                  return r;
>>
>> +       rptr = amdgpu_ring_get_rptr(ring);
>> +
>>          amdgpu_ring_write(ring, VCN_ENC_CMD_END);
>>          amdgpu_ring_commit(ring);
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
>> index c61a314..16682b7 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
>> @@ -170,13 +170,16 @@ static void uvd_v6_0_enc_ring_set_wptr(struct amdgpu_ring *ring)
>>   static int uvd_v6_0_enc_ring_test_ring(struct amdgpu_ring *ring)
>>   {
>>          struct amdgpu_device *adev = ring->adev;
>> -       uint32_t rptr = amdgpu_ring_get_rptr(ring);
>> +       uint32_t rptr;
>>          unsigned i;
>>          int r;
>>
>>          r = amdgpu_ring_alloc(ring, 16);
>>          if (r)
>>                  return r;
>> +
>> +       rptr = amdgpu_ring_get_rptr(ring);
>> +
>>          amdgpu_ring_write(ring, HEVC_ENC_CMD_END);
>>          amdgpu_ring_commit(ring);
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
>> index cdb96d4..74811b2 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
>> @@ -175,7 +175,7 @@ static void uvd_v7_0_enc_ring_set_wptr(struct amdgpu_ring *ring)
>>   static int uvd_v7_0_enc_ring_test_ring(struct amdgpu_ring *ring)
>>   {
>>          struct amdgpu_device *adev = ring->adev;
>> -       uint32_t rptr = amdgpu_ring_get_rptr(ring);
>> +       uint32_t rptr;
>>          unsigned i;
>>          int r;
>>
>> @@ -185,6 +185,9 @@ static int uvd_v7_0_enc_ring_test_ring(struct amdgpu_ring *ring)
>>          r = amdgpu_ring_alloc(ring, 16);
>>          if (r)
>>                  return r;
>> +
>> +       rptr = amdgpu_ring_get_rptr(ring);
>> +
>>          amdgpu_ring_write(ring, HEVC_ENC_CMD_END);
>>          amdgpu_ring_commit(ring);
>>
>> --
>> 2.7.4
>>
>> _______________________________________________
>> amd-gfx mailing list
>> amd-gfx at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/amd-gfx

-- 
Regards,
Shirish S



More information about the amd-gfx mailing list