Skip to content

Commit

Permalink
drm/amdgpu: Add helper function to get sdma index
Browse files Browse the repository at this point in the history
Get the sdma index from ring

v2: refine function name

Reviewed-by: Alex Deucher <[email protected]>
Reviewed-by: Flora Cui <[email protected]>
Signed-off-by: Rex Zhu <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
  • Loading branch information
Rex Zhu authored and alexdeucher committed Nov 5, 2018
1 parent ccf191f commit f6cffc0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f6cffc0

Please sign in to comment.