From: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxxx> With the end goal being using the number of rings for exposing capacity in fdinfo, and the observation that the number could be used elsewhere in the driver, lets cache it during the driver init phase. We count the number of created scheduler instances for user visible hw ip block types, which correspond with the number of user visible rings. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxxx> --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index f87d53e183c3..4f394602bbd8 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -964,6 +964,7 @@ struct amdgpu_device { /* rings */ u64 fence_context; unsigned num_rings; + unsigned num_ip_rings[AMDGPU_HW_IP_NUM]; struct amdgpu_ring *rings[AMDGPU_MAX_RINGS]; struct dma_fence __rcu *gang_submit; bool ib_pool_ready; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 861ccff78af9..e421f352d77e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -2756,6 +2756,20 @@ static int amdgpu_device_init_schedulers(struct amdgpu_device *adev) ring->name); return r; } + + BUILD_BUG_ON(AMDGPU_RING_TYPE_GFX != AMDGPU_HW_IP_GFX); + BUILD_BUG_ON(AMDGPU_RING_TYPE_COMPUTE != AMDGPU_HW_IP_COMPUTE); + BUILD_BUG_ON(AMDGPU_RING_TYPE_SDMA != AMDGPU_HW_IP_DMA); + BUILD_BUG_ON(AMDGPU_RING_TYPE_UVD != AMDGPU_HW_IP_UVD); + BUILD_BUG_ON(AMDGPU_RING_TYPE_VCE != AMDGPU_HW_IP_VCE); + BUILD_BUG_ON(AMDGPU_RING_TYPE_UVD_ENC != AMDGPU_HW_IP_UVD_ENC); + BUILD_BUG_ON(AMDGPU_RING_TYPE_VCN_DEC != AMDGPU_HW_IP_VCN_DEC); + BUILD_BUG_ON(AMDGPU_RING_TYPE_VCN_ENC != AMDGPU_HW_IP_VCN_ENC); + BUILD_BUG_ON(AMDGPU_RING_TYPE_VCN_JPEG != AMDGPU_HW_IP_VCN_JPEG); + BUILD_BUG_ON(AMDGPU_RING_TYPE_VPE != AMDGPU_HW_IP_VPE); + + if (ring->funcs->type < ARRAY_SIZE(adev->num_ip_rings)) + adev->num_ip_rings[ring->funcs->type]++; } amdgpu_xcp_update_partition_sched_list(adev); -- 2.44.0