[PATCH 3/4] drm/amdgpu: move UVD IB test into common code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 13.07.2016 um 22:28 schrieb Alex Deucher:
> On Wed, Jul 13, 2016 at 3:08 PM, Christian König
> <deathsimple at vodafone.de> wrote:
>> From: Christian König <christian.koenig at amd.com>
>>
>> Since we now raise the clocks from emit_fence() we don't need
>> a separate function for each hw generation any more.
>>
>> Signed-off-by: Christian König <christian.koenig at amd.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 37 +++++++++++++++++++++++++++
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h |  1 +
>>   drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c   | 45 +--------------------------------
>>   drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c   | 45 +--------------------------------
>>   drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c   | 37 +--------------------------
>>   5 files changed, 41 insertions(+), 124 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
>> index 078a7e4..69a8400 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
>> @@ -1127,3 +1127,40 @@ void amdgpu_uvd_note_usage(struct amdgpu_device *adev)
>>                  }
>>          }
>>   }
>> +
>> +/**
>> + * amdgpu_uvd_ring_test_ib - test ib execution
>> + *
>> + * @ring: amdgpu_ring pointer
>> + *
>> + * Test if we can successfully execute an IB
>> + */
>> +int amdgpu_uvd_ring_test_ib(struct amdgpu_ring *ring)
>> +{
>> +       struct amdgpu_device *adev = ring->adev;
>> +       struct fence *fence = NULL;
>> +       int r;
>> +
>> +       r = amdgpu_uvd_get_create_msg(ring, 1, NULL);
>> +       if (r) {
>> +               DRM_ERROR("amdgpu: failed to get create msg (%d).\n", r);
>> +               goto error;
>> +       }
>> +
>> +       r = amdgpu_uvd_get_destroy_msg(ring, 1, true, &fence);
>> +       if (r) {
>> +               DRM_ERROR("amdgpu: failed to get destroy ib (%d).\n", r);
>> +               goto error;
>> +       }
>> +
>> +       r = fence_wait(fence, false);
>> +       if (r) {
>> +               DRM_ERROR("amdgpu: fence wait failed (%d).\n", r);
>> +               goto error;
>> +       }
>> +       DRM_INFO("ib test on ring %d succeeded\n",  ring->idx);
>> +error:
>> +       fence_put(fence);
>> +       amdgpu_asic_set_uvd_clocks(adev, 0, 0);
> note_usage either sets the clocks or ungate/enables uvd dpm/etc.
> depending on what the asic supports.  It would probably be better to
> call amdgpu_uvd_idle_work_handler() or something similar here rather
> than manually setting the clocks.

Actually that is an unintentional copy & paste error. I didn't wanted to 
reset the clocks manually here. Thanks for catching this.

Going to send out V2 when I've got a chance to test it with Toms PG patches.

Christian.

>
> Alex
>
>
>> +       return r;
>> +}
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h
>> index 1375b21..03088fe 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h
>> @@ -36,5 +36,6 @@ void amdgpu_uvd_free_handles(struct amdgpu_device *adev,
>>                               struct drm_file *filp);
>>   int amdgpu_uvd_ring_parse_cs(struct amdgpu_cs_parser *parser, uint32_t ib_idx);
>>   void amdgpu_uvd_note_usage(struct amdgpu_device *adev);
>> +int amdgpu_uvd_ring_test_ib(struct amdgpu_ring *ring);
>>
>>   #endif
>> diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c b/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c
>> index a762158..d9bdd39 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c
>> @@ -529,49 +529,6 @@ static void uvd_v4_2_ring_emit_ib(struct amdgpu_ring *ring,
>>   }
>>
>>   /**
>> - * uvd_v4_2_ring_test_ib - test ib execution
>> - *
>> - * @ring: amdgpu_ring pointer
>> - *
>> - * Test if we can successfully execute an IB
>> - */
>> -static int uvd_v4_2_ring_test_ib(struct amdgpu_ring *ring)
>> -{
>> -       struct amdgpu_device *adev = ring->adev;
>> -       struct fence *fence = NULL;
>> -       int r;
>> -
>> -       r = amdgpu_asic_set_uvd_clocks(adev, 53300, 40000);
>> -       if (r) {
>> -               DRM_ERROR("amdgpu: failed to raise UVD clocks (%d).\n", r);
>> -               return r;
>> -       }
>> -
>> -       r = amdgpu_uvd_get_create_msg(ring, 1, NULL);
>> -       if (r) {
>> -               DRM_ERROR("amdgpu: failed to get create msg (%d).\n", r);
>> -               goto error;
>> -       }
>> -
>> -       r = amdgpu_uvd_get_destroy_msg(ring, 1, true, &fence);
>> -       if (r) {
>> -               DRM_ERROR("amdgpu: failed to get destroy ib (%d).\n", r);
>> -               goto error;
>> -       }
>> -
>> -       r = fence_wait(fence, false);
>> -       if (r) {
>> -               DRM_ERROR("amdgpu: fence wait failed (%d).\n", r);
>> -               goto error;
>> -       }
>> -       DRM_INFO("ib test on ring %d succeeded\n",  ring->idx);
>> -error:
>> -       fence_put(fence);
>> -       amdgpu_asic_set_uvd_clocks(adev, 0, 0);
>> -       return r;
>> -}
>> -
>> -/**
>>    * uvd_v4_2_mc_resume - memory controller programming
>>    *
>>    * @adev: amdgpu_device pointer
>> @@ -796,7 +753,7 @@ static const struct amdgpu_ring_funcs uvd_v4_2_ring_funcs = {
>>          .emit_hdp_flush = uvd_v4_2_ring_emit_hdp_flush,
>>          .emit_hdp_invalidate = uvd_v4_2_ring_emit_hdp_invalidate,
>>          .test_ring = uvd_v4_2_ring_test_ring,
>> -       .test_ib = uvd_v4_2_ring_test_ib,
>> +       .test_ib = amdgpu_ring_test_ib,
>>          .insert_nop = amdgpu_ring_insert_nop,
>>          .pad_ib = amdgpu_ring_generic_pad_ib,
>>   };
>> diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c
>> index b45fea9..d3909a7 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c
>> @@ -579,49 +579,6 @@ static void uvd_v5_0_ring_emit_ib(struct amdgpu_ring *ring,
>>          amdgpu_ring_write(ring, ib->length_dw);
>>   }
>>
>> -/**
>> - * uvd_v5_0_ring_test_ib - test ib execution
>> - *
>> - * @ring: amdgpu_ring pointer
>> - *
>> - * Test if we can successfully execute an IB
>> - */
>> -static int uvd_v5_0_ring_test_ib(struct amdgpu_ring *ring)
>> -{
>> -       struct amdgpu_device *adev = ring->adev;
>> -       struct fence *fence = NULL;
>> -       int r;
>> -
>> -       r = amdgpu_asic_set_uvd_clocks(adev, 53300, 40000);
>> -       if (r) {
>> -               DRM_ERROR("amdgpu: failed to raise UVD clocks (%d).\n", r);
>> -               return r;
>> -       }
>> -
>> -       r = amdgpu_uvd_get_create_msg(ring, 1, NULL);
>> -       if (r) {
>> -               DRM_ERROR("amdgpu: failed to get create msg (%d).\n", r);
>> -               goto error;
>> -       }
>> -
>> -       r = amdgpu_uvd_get_destroy_msg(ring, 1, true, &fence);
>> -       if (r) {
>> -               DRM_ERROR("amdgpu: failed to get destroy ib (%d).\n", r);
>> -               goto error;
>> -       }
>> -
>> -       r = fence_wait(fence, false);
>> -       if (r) {
>> -               DRM_ERROR("amdgpu: fence wait failed (%d).\n", r);
>> -               goto error;
>> -       }
>> -       DRM_INFO("ib test on ring %d succeeded\n",  ring->idx);
>> -error:
>> -       fence_put(fence);
>> -       amdgpu_asic_set_uvd_clocks(adev, 0, 0);
>> -       return r;
>> -}
>> -
>>   static bool uvd_v5_0_is_idle(void *handle)
>>   {
>>          struct amdgpu_device *adev = (struct amdgpu_device *)handle;
>> @@ -847,7 +804,7 @@ static const struct amdgpu_ring_funcs uvd_v5_0_ring_funcs = {
>>          .emit_hdp_flush = uvd_v5_0_ring_emit_hdp_flush,
>>          .emit_hdp_invalidate = uvd_v5_0_ring_emit_hdp_invalidate,
>>          .test_ring = uvd_v5_0_ring_test_ring,
>> -       .test_ib = uvd_v5_0_ring_test_ib,
>> +       .test_ib = amdgpu_uvd_ring_test_ib,
>>          .insert_nop = amdgpu_ring_insert_nop,
>>          .pad_ib = amdgpu_ring_generic_pad_ib,
>>   };
>> diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
>> index f643fec2..69439ab 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
>> @@ -682,41 +682,6 @@ static void uvd_v6_0_ring_emit_ib(struct amdgpu_ring *ring,
>>          amdgpu_ring_write(ring, ib->length_dw);
>>   }
>>
>> -/**
>> - * uvd_v6_0_ring_test_ib - test ib execution
>> - *
>> - * @ring: amdgpu_ring pointer
>> - *
>> - * Test if we can successfully execute an IB
>> - */
>> -static int uvd_v6_0_ring_test_ib(struct amdgpu_ring *ring)
>> -{
>> -       struct fence *fence = NULL;
>> -       int r;
>> -
>> -       r = amdgpu_uvd_get_create_msg(ring, 1, NULL);
>> -       if (r) {
>> -               DRM_ERROR("amdgpu: failed to get create msg (%d).\n", r);
>> -               goto error;
>> -       }
>> -
>> -       r = amdgpu_uvd_get_destroy_msg(ring, 1, true, &fence);
>> -       if (r) {
>> -               DRM_ERROR("amdgpu: failed to get destroy ib (%d).\n", r);
>> -               goto error;
>> -       }
>> -
>> -       r = fence_wait(fence, false);
>> -       if (r) {
>> -               DRM_ERROR("amdgpu: fence wait failed (%d).\n", r);
>> -               goto error;
>> -       }
>> -       DRM_INFO("ib test on ring %d succeeded\n",  ring->idx);
>> -error:
>> -       fence_put(fence);
>> -       return r;
>> -}
>> -
>>   static bool uvd_v6_0_is_idle(void *handle)
>>   {
>>          struct amdgpu_device *adev = (struct amdgpu_device *)handle;
>> @@ -963,7 +928,7 @@ static const struct amdgpu_ring_funcs uvd_v6_0_ring_funcs = {
>>          .emit_hdp_flush = uvd_v6_0_ring_emit_hdp_flush,
>>          .emit_hdp_invalidate = uvd_v6_0_ring_emit_hdp_invalidate,
>>          .test_ring = uvd_v6_0_ring_test_ring,
>> -       .test_ib = uvd_v6_0_ring_test_ib,
>> +       .test_ib = amdgpu_uvd_ring_test_ib,
>>          .insert_nop = amdgpu_ring_insert_nop,
>>          .pad_ib = amdgpu_ring_generic_pad_ib,
>>   };
>> --
>> 2.5.0
>>
>> _______________________________________________
>> amd-gfx mailing list
>> amd-gfx at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/amd-gfx



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux