aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
diff options
context:
space:
mode:
authorArindam Nath <arindam.nath@amd.com>2016-12-12 04:59:33 -0500
committerAlex Deucher <alexander.deucher@amd.com>2017-01-27 11:12:38 -0500
commit44879b6261530b14be339958a0f34805a8fa739a (patch)
tree9452b3a156aab983db2917e960debd88e288318d /drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
parent0ef5b226c472ca6048cce315b20d1d462f23b589 (diff)
drm/amd/amdgpu: get maximum and used UVD handles (v4)
Change History -------------- v4: Changes suggested by Emil, Christian - return -ENODATA for asics with unlimited sessions v3: changes suggested by Christian - Add a check for UVD IP block using AMDGPU_HW_IP_UVD query type. - Add a check for asic_type to be less than CHIP_POLARIS10 since starting Polaris, we support unlimited UVD instances. - Add kerneldoc style comment for amdgpu_uvd_used_handles(). v2: as suggested by Christian - Add a new query AMDGPU_INFO_NUM_HANDLES - Create a helper function to return the number of currently used UVD handles. - Modify the logic to count the number of used UVD handles since handles can be freed in non-linear fashion. v1: - User might want to query the maximum number of UVD instances supported by firmware. In addition to that, if there are multiple applications using UVD handles at the same time, he might also want to query the currently used number of handles. For this we add two variables max_handles and used_handles inside drm_amdgpu_info_hw_ip. So now an application (or libdrm) can use AMDGPU_INFO IOCTL with AMDGPU_INFO_HW_IP_INFO query type to get these values. Signed-off-by: Arindam Nath <arindam.nath@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
index 1d564beb0fde..326b7f5a79ff 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
@@ -1178,3 +1178,28 @@ int amdgpu_uvd_ring_test_ib(struct amdgpu_ring *ring, long timeout)
1178error: 1178error:
1179 return r; 1179 return r;
1180} 1180}
1181
1182/**
1183 * amdgpu_uvd_used_handles - returns used UVD handles
1184 *
1185 * @adev: amdgpu_device pointer
1186 *
1187 * Returns the number of UVD handles in use
1188 */
1189uint32_t amdgpu_uvd_used_handles(struct amdgpu_device *adev)
1190{
1191 unsigned i;
1192 uint32_t used_handles = 0;
1193
1194 for (i = 0; i < adev->uvd.max_handles; ++i) {
1195 /*
1196 * Handles can be freed in any order, and not
1197 * necessarily linear. So we need to count
1198 * all non-zero handles.
1199 */
1200 if (atomic_read(&adev->uvd.handles[i]))
1201 used_handles++;
1202 }
1203
1204 return used_handles;
1205}