<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Arial;font-size:10pt;color:#0000FF;margin:5pt;font-style:normal;font-weight:normal;text-decoration:none;" align="Left">
[AMD Official Use Only - General]<br>
</p>
<br>
<div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
For jpeg, if the rings actually represent independent JPEG engines, we probably want to expose
<font size="3" face="Times New Roman"><span style="font-size:12pt"><font size="2"><span style="font-size:11pt" class="ContentPasted0">adev->jpeg.num_jpeg_inst</span></font></span></font> *
<font size="3" face="Times New Roman"><span style="font-size:12pt"><font size="2"><span style="font-size:11pt" class="ContentPasted1">adev->jpeg.num_jpeg_rings.</span></font></span></font></div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<font size="3" face="Times New Roman"><span style="font-size:12pt"><font size="2"><span style="font-size:11pt" class="ContentPasted1"><br>
</span></font></span></font></div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<font size="3" face="Times New Roman"><span style="font-size:12pt"><font size="2"><span style="font-size:11pt" class="ContentPasted1">Alex<br>
</span></font></span></font></div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Sundararaju, Sathishkumar <Sathishkumar.Sundararaju@amd.com><br>
<b>Sent:</b> Thursday, September 14, 2023 12:00 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Deucher, Alexander <Alexander.Deucher@amd.com>; Koenig, Christian <Christian.Koenig@amd.com>; Liu, Leo <Leo.Liu@amd.com>; Sundararaju, Sathishkumar <Sathishkumar.Sundararaju@amd.com><br>
<b>Subject:</b> [PATCH] drm/amdgpu: update IP count INFO query</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">update the query to return the number of functional<br>
instances where there is more than an instance of the requested<br>
type and for others continue to return one.<br>
<br>
Signed-off-by: Sathishkumar S <sathishkumar.sundararaju@amd.com><br>
---<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 90 +++++++++++++++++--------<br>
1 file changed, 61 insertions(+), 29 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c<br>
index 3a48bec10aea..9521fa7a1bf9 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c<br>
@@ -200,6 +200,44 @@ int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags)<br>
return r;<br>
}<br>
<br>
+static enum amd_ip_block_type amdgpu_ip_get_block_type(<br>
+ struct amdgpu_device *adev, uint32_t ip)<br>
+{<br>
+ enum amd_ip_block_type type;<br>
+<br>
+ switch (ip) {<br>
+ case AMDGPU_HW_IP_GFX:<br>
+ type = AMD_IP_BLOCK_TYPE_GFX;<br>
+ break;<br>
+ case AMDGPU_HW_IP_COMPUTE:<br>
+ type = AMD_IP_BLOCK_TYPE_GFX;<br>
+ break;<br>
+ case AMDGPU_HW_IP_DMA:<br>
+ type = AMD_IP_BLOCK_TYPE_SDMA;<br>
+ break;<br>
+ case AMDGPU_HW_IP_UVD:<br>
+ case AMDGPU_HW_IP_UVD_ENC:<br>
+ type = AMD_IP_BLOCK_TYPE_UVD;<br>
+ break;<br>
+ case AMDGPU_HW_IP_VCE:<br>
+ type = AMD_IP_BLOCK_TYPE_VCE;<br>
+ break;<br>
+ case AMDGPU_HW_IP_VCN_DEC:<br>
+ case AMDGPU_HW_IP_VCN_ENC:<br>
+ type = AMD_IP_BLOCK_TYPE_VCN;<br>
+ break;<br>
+ case AMDGPU_HW_IP_VCN_JPEG:<br>
+ type = (amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_JPEG)) ?<br>
+ AMD_IP_BLOCK_TYPE_JPEG : AMD_IP_BLOCK_TYPE_VCN;<br>
+ break;<br>
+ default:<br>
+ type = AMD_IP_BLOCK_TYPE_NUM;<br>
+ break;<br>
+ }<br>
+<br>
+ return type;<br>
+}<br>
+<br>
static int amdgpu_firmware_info(struct drm_amdgpu_info_firmware *fw_info,<br>
struct drm_amdgpu_query_fw *query_fw,<br>
struct amdgpu_device *adev)<br>
@@ -592,45 +630,39 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)<br>
}<br>
case AMDGPU_INFO_HW_IP_COUNT: {<br>
enum amd_ip_block_type type;<br>
+ struct amdgpu_ip_block *ip_block = NULL;<br>
uint32_t count = 0;<br>
<br>
- switch (info->query_hw_ip.type) {<br>
- case AMDGPU_HW_IP_GFX:<br>
- type = AMD_IP_BLOCK_TYPE_GFX;<br>
- break;<br>
- case AMDGPU_HW_IP_COMPUTE:<br>
- type = AMD_IP_BLOCK_TYPE_GFX;<br>
- break;<br>
- case AMDGPU_HW_IP_DMA:<br>
- type = AMD_IP_BLOCK_TYPE_SDMA;<br>
- break;<br>
- case AMDGPU_HW_IP_UVD:<br>
- type = AMD_IP_BLOCK_TYPE_UVD;<br>
+ type = amdgpu_ip_get_block_type(adev, info->query_hw_ip.type);<br>
+ ip_block = amdgpu_device_ip_get_ip_block(adev, type);<br>
+ if (!ip_block || !ip_block->status.valid)<br>
+ return -EINVAL;<br>
+<br>
+ switch (type) {<br>
+ case AMD_IP_BLOCK_TYPE_GFX:<br>
+ case AMD_IP_BLOCK_TYPE_VCE:<br>
+ count = 1;<br>
break;<br>
- case AMDGPU_HW_IP_VCE:<br>
- type = AMD_IP_BLOCK_TYPE_VCE;<br>
+ case AMD_IP_BLOCK_TYPE_SDMA:<br>
+ count = adev->sdma.num_instances;<br>
break;<br>
- case AMDGPU_HW_IP_UVD_ENC:<br>
- type = AMD_IP_BLOCK_TYPE_UVD;<br>
+ case AMD_IP_BLOCK_TYPE_JPEG:<br>
+ count = adev->jpeg.num_jpeg_inst;<br>
break;<br>
- case AMDGPU_HW_IP_VCN_DEC:<br>
- case AMDGPU_HW_IP_VCN_ENC:<br>
- type = AMD_IP_BLOCK_TYPE_VCN;<br>
+ case AMD_IP_BLOCK_TYPE_VCN:<br>
+ count = adev->vcn.num_vcn_inst;<br>
break;<br>
- case AMDGPU_HW_IP_VCN_JPEG:<br>
- type = (amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_JPEG)) ?<br>
- AMD_IP_BLOCK_TYPE_JPEG : AMD_IP_BLOCK_TYPE_VCN;<br>
+ case AMD_IP_BLOCK_TYPE_UVD:<br>
+ count = adev->uvd.num_uvd_inst;<br>
break;<br>
+ /* For all other IP block types not listed in the switch statement<br>
+ * the ip status is valid here and the instance count is one.<br>
+ */<br>
default:<br>
- return -EINVAL;<br>
+ count = 1;<br>
+ break;<br>
}<br>
<br>
- for (i = 0; i < adev->num_ip_blocks; i++)<br>
- if (adev->ip_blocks[i].version->type == type &&<br>
- adev->ip_blocks[i].status.valid &&<br>
- count < AMDGPU_HW_IP_INSTANCE_MAX_COUNT)<br>
- count++;<br>
-<br>
return copy_to_user(out, &count, min(size, 4u)) ? -EFAULT : 0;<br>
}<br>
case AMDGPU_INFO_TIMESTAMP:<br>
-- <br>
2.25.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>