[PATCH 2/2] drm/amdgpu: Add helper function to get sdma index

Alex Deucher alexdeucher at gmail.com
Thu Nov 1 14:43:52 UTC 2018


On Thu, Nov 1, 2018 at 1:59 AM Rex Zhu <Rex.Zhu at amd.com> wrote:
>
> Get the sdma index from ring
>
> v2: refine function name
>
> Signed-off-by: Rex Zhu <Rex.Zhu at amd.com>

Series is:
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c | 16 ++++++++++++++++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h |  1 +
>  2 files changed, 17 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
> index c912230..115bb0c 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
> @@ -40,3 +40,19 @@ struct amdgpu_sdma_instance *amdgpu_sdma_get_instance_from_ring(struct amdgpu_ri
>
>         return NULL;
>  }
> +
> +int amdgpu_sdma_get_index_from_ring(struct amdgpu_ring *ring, uint32_t *index)
> +{
> +       struct amdgpu_device *adev = ring->adev;
> +       int i;
> +
> +       for (i = 0; i < adev->sdma.num_instances; i++) {
> +               if (ring == &adev->sdma.instance[i].ring ||
> +                       ring == &adev->sdma.instance[i].page) {
> +                       *index = i;
> +                       return 0;
> +               }
> +       }
> +
> +       return -EINVAL;
> +}
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h
> index 664f549..16b1a6a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h
> @@ -95,5 +95,6 @@ struct amdgpu_buffer_funcs {
>
>  struct amdgpu_sdma_instance *
>  amdgpu_sdma_get_instance_from_ring(struct amdgpu_ring *ring);
> +int amdgpu_sdma_get_index_from_ring(struct amdgpu_ring *ring, uint32_t *index);
>
>  #endif
> --
> 1.9.1
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx


More information about the amd-gfx mailing list