OSDN Git Service

drm/amdgpu: Add helper function to get sdma index
authorRex Zhu <Rex.Zhu@amd.com>
Wed, 31 Oct 2018 11:49:27 +0000 (19:49 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 5 Nov 2018 20:49:38 +0000 (15:49 -0500)
Get the sdma index from ring

v2: refine function name

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Flora Cui <flora.cui@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.h

index c912230..115bb0c 100644 (file)
@@ -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;
+}
index 664f549..16b1a6a 100644 (file)
@@ -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