[PATCH] drm/amdgpu: fix ip count query for xcp partitions

Sundararaju, Sathishkumar sasundar at amd.com
Thu Sep 21 11:54:54 UTC 2023


Please ignore this patch, will send v2 with few corrections.

Regards,

Sathish

On 9/21/2023 1:31 AM, Sathishkumar S wrote:
> fix wrong ip count INFO on spatial partitions. update the query
> to return the instance count corresponding to the partition id.
>
> Signed-off-by: Sathishkumar S <sathishkumar.sundararaju at amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 32 +++++++++++++++++++++++++
>   1 file changed, 32 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index 081bd28e2443..42348f61a5c5 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -639,13 +639,45 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
>   	case AMDGPU_INFO_HW_IP_COUNT: {
>   		enum amd_ip_block_type type;
>   		struct amdgpu_ip_block *ip_block = NULL;
> +		struct amdgpu_xcp *xcp = NULL;
> +		struct amdgpu_fpriv *fpriv = (struct amdgpu_fpriv *) filp->driver_priv;
>   		uint32_t count = 0;
> +		uint32_t inst_mask = 0;
> +		int ret = -EINVAL;
>   
>   		type = amdgpu_ip_get_block_type(adev, info->query_hw_ip.type);
>   		ip_block = amdgpu_device_ip_get_ip_block(adev, type);
>   		if (!ip_block || !ip_block->status.valid)
>   			return -EINVAL;
>   
> +		if (adev->xcp_mgr && adev->xcp_mgr->num_xcps > 0 &&
> +			fpriv->xcp_id >= 0 && fpriv->xcp_id < adev->xcp_mgr->num_xcps) {
> +			xcp = &adev->xcp_mgr->xcp[fpriv->xcp_id];
> +			switch (type) {
> +			case AMD_IP_BLOCK_TYPE_GFX:
> +				ret = amdgpu_xcp_get_inst_details(xcp, AMDGPU_XCP_GFX, &inst_mask);
> +				count = hweight32(inst_mask);
> +				break;
> +			case AMD_IP_BLOCK_TYPE_SDMA:
> +				ret = amdgpu_xcp_get_inst_details(xcp, AMDGPU_XCP_SDMA, &inst_mask);
> +				count = hweight32(inst_mask);
> +				break;
> +			case AMD_IP_BLOCK_TYPE_JPEG:
> +				ret = amdgpu_xcp_get_inst_details(xcp, AMDGPU_XCP_VCN, &inst_mask);
> +				count = hweight32(inst_mask) * adev->jpeg.num_jpeg_rings;
> +				break;
> +			case AMD_IP_BLOCK_TYPE_VCN:
> +				ret = amdgpu_xcp_get_inst_details(xcp, AMDGPU_XCP_VCN, &inst_mask);
> +				count = hweight32(inst_mask);
> +				break;
> +			default:
> +				return -EINVAL;
> +			}
> +			if (ret)
> +				return ret;
> +			return copy_to_user(out, &count, min(size, 4u)) ? -EFAULT : 0;
> +		}
> +
>   		switch (type) {
>   		case AMD_IP_BLOCK_TYPE_GFX:
>   		case AMD_IP_BLOCK_TYPE_VCE:


More information about the amd-gfx mailing list