<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;" align="Left">
[AMD Official Use Only]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Fixed locally.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Alex</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</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> Lazar, Lijo <Lijo.Lazar@amd.com><br>
<b>Sent:</b> Wednesday, September 22, 2021 3:37 AM<br>
<b>To:</b> Deucher, Alexander <Alexander.Deucher@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Subject:</b> Re: [PATCH 29/66] drm/amdgpu/display/dm: convert to IP version checking</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText"><br>
<br>
On 9/21/2021 11:36 PM, Alex Deucher wrote:<br>
> Use IP versions rather than asic_type to differentiate<br>
> IP version specific features.<br>
> <br>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com><br>
> ---<br>
>   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 194 ++++++++++--------<br>
>   1 file changed, 109 insertions(+), 85 deletions(-)<br>
> <br>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
> index 07adac1a8c42..e189d72f08e9 100644<br>
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
> @@ -1342,16 +1342,23 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)<br>
>        case CHIP_CARRIZO:<br>
>        case CHIP_STONEY:<br>
>        case CHIP_RAVEN:<br>
> -     case CHIP_RENOIR:<br>
> -             init_data.flags.gpu_vm_support = true;<br>
> -             if (ASICREV_IS_GREEN_SARDINE(adev->external_rev_id))<br>
> -                     init_data.flags.disable_dmcu = true;<br>
> -             break;<br>
> -     case CHIP_VANGOGH:<br>
> -     case CHIP_YELLOW_CARP:<br>
>                init_data.flags.gpu_vm_support = true;<br>
>                break;<br>
>        default:<br>
> +             switch (adev->ip_versions[DCE_HWIP]) {<br>
> +             case IP_VERSION(2, 1, 0):<br>
> +                     init_data.flags.gpu_vm_support = true;<br>
> +                     if (ASICREV_IS_GREEN_SARDINE(adev->external_rev_id))<br>
> +                             init_data.flags.disable_dmcu = true;<br>
> +                     break;<br>
> +             case IP_VERSION(3, 0, 1):<br>
> +             case IP_VERSION(3, 1, 2):<br>
> +             case IP_VERSION(3, 1, 3):<br>
> +                     init_data.flags.gpu_vm_support = true;<br>
> +                     break;<br>
> +             default:<br>
> +                     break;<br>
> +             }<br>
>                break;<br>
>        }<br>
>   <br>
> @@ -1442,7 +1449,7 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)<br>
>   #endif<br>
>   <br>
>   #ifdef CONFIG_DRM_AMD_DC_HDCP<br>
> -     if (adev->dm.dc->caps.max_links > 0 && adev->asic_type >= CHIP_RAVEN) {<br>
> +     if (adev->dm.dc->caps.max_links > 0 && adev->family >= AMDGPU_FAMILY_RV) {<br>
>                adev->dm.hdcp_workqueue = hdcp_create_workqueue(adev, &init_params.cp_psp, adev->dm.dc);<br>
>   <br>
>                if (!adev->dm.hdcp_workqueue)<br>
> @@ -1637,15 +1644,6 @@ static int load_dmcu_fw(struct amdgpu_device *adev)<br>
>        case CHIP_VEGA10:<br>
>        case CHIP_VEGA12:<br>
>        case CHIP_VEGA20:<br>
> -     case CHIP_NAVI10:<br>
> -     case CHIP_NAVI14:<br>
> -     case CHIP_RENOIR:<br>
> -     case CHIP_SIENNA_CICHLID:<br>
> -     case CHIP_NAVY_FLOUNDER:<br>
> -     case CHIP_DIMGREY_CAVEFISH:<br>
> -     case CHIP_BEIGE_GOBY:<br>
> -     case CHIP_VANGOGH:<br>
> -     case CHIP_YELLOW_CARP:<br>
>                return 0;<br>
>        case CHIP_NAVI12:<br>
>                fw_name_dmcu = FIRMWARE_NAVI12_DMCU;<br>
> @@ -1659,6 +1657,20 @@ static int load_dmcu_fw(struct amdgpu_device *adev)<br>
>                        return 0;<br>
>                break;<br>
>        default:<br>
> +             switch (adev->ip_versions[DCE_HWIP]) {<br>
> +             case IP_VERSION(2, 0, 2):<br>
> +             case IP_VERSION(2, 0, 0):<br>
> +             case IP_VERSION(2, 1, 0):<br>
> +             case IP_VERSION(3, 0, 0):<br>
> +             case IP_VERSION(3, 0, 2):<br>
> +             case IP_VERSION(3, 0, 3):<br>
> +             case IP_VERSION(3, 0, 1):<br>
> +             case IP_VERSION(3, 1, 2):<br>
> +             case IP_VERSION(3, 1, 3):<br>
> +                     return 0;<br>
> +             default:<br>
> +                     break;<br>
> +             }<br>
>                DRM_ERROR("Unsupported ASIC type: 0x%X\n", adev->asic_type);<br>
>                return -EINVAL;<br>
>        }<br>
> @@ -1737,34 +1749,36 @@ static int dm_dmub_sw_init(struct amdgpu_device *adev)<br>
>        enum dmub_status status;<br>
>        int r;<br>
>   <br>
> -     switch (adev->asic_type) {<br>
> -     case CHIP_RENOIR:<br>
> +     switch (adev->ip_versions[DCE_HWIP]) {<br>
> +     case IP_VERSION(2, 1, 0):<br>
>                dmub_asic = DMUB_ASIC_DCN21;<br>
>                fw_name_dmub = FIRMWARE_RENOIR_DMUB;<br>
>                if (ASICREV_IS_GREEN_SARDINE(adev->external_rev_id))<br>
>                        fw_name_dmub = FIRMWARE_GREEN_SARDINE_DMUB;<br>
>                break;<br>
> -     case CHIP_SIENNA_CICHLID:<br>
> -             dmub_asic = DMUB_ASIC_DCN30;<br>
> -             fw_name_dmub = FIRMWARE_SIENNA_CICHLID_DMUB;<br>
> -             break;<br>
> -     case CHIP_NAVY_FLOUNDER:<br>
> -             dmub_asic = DMUB_ASIC_DCN30;<br>
> -             fw_name_dmub = FIRMWARE_NAVY_FLOUNDER_DMUB;<br>
> +     case IP_VERSION(3, 0, 0):<br>
> +             if (adev->ip_versions[GC_HWIP] == IP_VERSION(10, 3, 0)) {<br>
> +                     dmub_asic = DMUB_ASIC_DCN30;<br>
> +                     fw_name_dmub = FIRMWARE_SIENNA_CICHLID_DMUB;<br>
> +             } else {<br>
> +                     dmub_asic = DMUB_ASIC_DCN30;<br>
> +                     fw_name_dmub = FIRMWARE_NAVY_FLOUNDER_DMUB;<br>
> +             }<br>
>                break;<br>
> -     case CHIP_VANGOGH:<br>
> +     case IP_VERSION(3, 0, 1):<br>
>                dmub_asic = DMUB_ASIC_DCN301;<br>
>                fw_name_dmub = FIRMWARE_VANGOGH_DMUB;<br>
>                break;<br>
> -     case CHIP_DIMGREY_CAVEFISH:<br>
> +     case IP_VERSION(3, 0, 2):<br>
>                dmub_asic = DMUB_ASIC_DCN302;<br>
>                fw_name_dmub = FIRMWARE_DIMGREY_CAVEFISH_DMUB;<br>
>                break;<br>
> -     case CHIP_BEIGE_GOBY:<br>
> +     case IP_VERSION(3, 0, 3):<br>
>                dmub_asic = DMUB_ASIC_DCN303;<br>
>                fw_name_dmub = FIRMWARE_BEIGE_GOBY_DMUB;<br>
>                break;<br>
> -     case CHIP_YELLOW_CARP:<br>
> +     case IP_VERSION(3, 1, 2):<br>
> +     case IP_VERSION(3, 1, 3):<br>
>                dmub_asic = DMUB_ASIC_DCN31;<br>
>                fw_name_dmub = FIRMWARE_YELLOW_CARP_DMUB;<br>
>                break;<br>
> @@ -2063,10 +2077,9 @@ static int amdgpu_dm_smu_write_watermarks_table(struct amdgpu_device *adev)<br>
>         * therefore, this function apply to navi10/12/14 but not Renoir<br>
>         * *<br>
>         */<br>
> -     switch(adev->asic_type) {<br>
> -     case CHIP_NAVI10:<br>
> -     case CHIP_NAVI14:<br>
> -     case CHIP_NAVI12:<br>
> +     switch (adev->ip_versions[DCE_HWIP]) {<br>
> +     case IP_VERSION(2, 0, 2):<br>
> +     case IP_VERSION(2, 0, 0):<br>
>                break;<br>
>        default:<br>
>                return 0;<br>
> @@ -3287,7 +3300,7 @@ static int dce110_register_irq_handlers(struct amdgpu_device *adev)<br>
>        int i;<br>
>        unsigned client_id = AMDGPU_IRQ_CLIENTID_LEGACY;<br>
>   <br>
> -     if (adev->asic_type >= CHIP_VEGA10)<br>
> +     if (adev->family >= AMDGPU_FAMILY_AI)<br>
>                client_id = SOC15_IH_CLIENTID_DCE;<br>
>   <br>
>        int_params.requested_polarity = INTERRUPT_POLARITY_DEFAULT;<br>
> @@ -4072,18 +4085,19 @@ static int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev)<br>
>   <br>
>   #if defined(CONFIG_DRM_AMD_DC_DCN)<br>
>        /* Use Outbox interrupt */<br>
> -     switch (adev->asic_type) {<br>
> -     case CHIP_SIENNA_CICHLID:<br>
> -     case CHIP_NAVY_FLOUNDER:<br>
> -     case CHIP_YELLOW_CARP:<br>
> -     case CHIP_RENOIR:<br>
> +     switch (adev->ip_versions[DCE_HWIP]) {<br>
> +     case IP_VERSION(3, 0, 0):<br>
> +     case IP_VERSION(3, 1, 2):<br>
> +     case IP_VERSION(3, 1, 3):<br>
> +     case IP_VERSION(2, 1, 0):<br>
>                if (register_outbox_irq_handlers(dm->adev)) {<br>
>                        DRM_ERROR("DM: Failed to initialize IRQ\n");<br>
>                        goto fail;<br>
>                }<br>
>                break;<br>
>        default:<br>
> -             DRM_DEBUG_KMS("Unsupported ASIC type for outbox: 0x%X\n", adev->asic_type);<br>
> +             DRM_DEBUG_KMS("Unsupported DCN IP version for outbox: 0x%X\n",<br>
> +                           adev->ip_versions[DCE_HWIP]);<br>
>        }<br>
>   #endif<br>
>   <br>
> @@ -4171,16 +4185,6 @@ static int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev)<br>
>                break;<br>
>   #if defined(CONFIG_DRM_AMD_DC_DCN)<br>
>        case CHIP_RAVEN:<br>
> -     case CHIP_NAVI12:<br>
> -     case CHIP_NAVI10:<br>
> -     case CHIP_NAVI14:<br>
> -     case CHIP_RENOIR:<br>
> -     case CHIP_SIENNA_CICHLID:<br>
> -     case CHIP_NAVY_FLOUNDER:<br>
> -     case CHIP_DIMGREY_CAVEFISH:<br>
> -     case CHIP_BEIGE_GOBY:<br>
> -     case CHIP_VANGOGH:<br>
> -     case CHIP_YELLOW_CARP:<br>
>                if (dcn10_register_irq_handlers(dm->adev)) {<br>
>                        DRM_ERROR("DM: Failed to initialize IRQ\n");<br>
>                        goto fail;<br>
> @@ -4188,6 +4192,26 @@ static int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev)<br>
>                break;<br>
>   #endif<br>
>        default:<br>
> +#if defined(CONFIG_DRM_AMD_DC_DCN)<br>
> +             switch (adev->ip_versions[DCE_HWIP]) {<br>
> +             case IP_VERSION(2, 0, 2):<br>
> +             case IP_VERSION(2, 0, 0):<br>
> +             case IP_VERSION(2, 1, 0):<br>
> +             case IP_VERSION(3, 0, 0):<br>
> +             case IP_VERSION(3, 0, 2):<br>
> +             case IP_VERSION(3, 0, 3):<br>
> +             case IP_VERSION(3, 0, 1):<br>
> +             case IP_VERSION(3, 1, 2):<br>
> +             case IP_VERSION(3, 1, 3):<br>
> +                     if (dcn10_register_irq_handlers(dm->adev)) {<br>
> +                             DRM_ERROR("DM: Failed to initialize IRQ\n");<br>
> +                             goto fail;<br>
> +                     }<br>
> +                     break;<br>
> +             default:<br>
> +                     break;<br>
> +             }<br>
> +#endif<br>
>                DRM_ERROR("Unsupported ASIC type: 0x%X\n", adev->asic_type);<br>
>                goto fail;<br>
>        }<br>
> @@ -4338,38 +4362,43 @@ static int dm_early_init(void *handle)<br>
>                break;<br>
>   #if defined(CONFIG_DRM_AMD_DC_DCN)<br>
>        case CHIP_RAVEN:<br>
> -     case CHIP_RENOIR:<br>
> -     case CHIP_VANGOGH:<br>
> -             adev->mode_info.num_crtc = 4;<br>
> -             adev->mode_info.num_hpd = 4;<br>
> -             adev->mode_info.num_dig = 4;<br>
> -             break;<br>
> -     case CHIP_NAVI10:<br>
> -     case CHIP_NAVI12:<br>
> -     case CHIP_SIENNA_CICHLID:<br>
> -     case CHIP_NAVY_FLOUNDER:<br>
> -             adev->mode_info.num_crtc = 6;<br>
> -             adev->mode_info.num_hpd = 6;<br>
> -             adev->mode_info.num_dig = 6;<br>
> -             break;<br>
> -     case CHIP_YELLOW_CARP:<br>
>                adev->mode_info.num_crtc = 4;<br>
>                adev->mode_info.num_hpd = 4;<br>
>                adev->mode_info.num_dig = 4;<br>
>                break;<br>
> -     case CHIP_NAVI14:<br>
> -     case CHIP_DIMGREY_CAVEFISH:<br>
> -             adev->mode_info.num_crtc = 5;<br>
> -             adev->mode_info.num_hpd = 5;<br>
> -             adev->mode_info.num_dig = 5;<br>
> -             break;<br>
> -     case CHIP_BEIGE_GOBY:<br>
> -             adev->mode_info.num_crtc = 2;<br>
> -             adev->mode_info.num_hpd = 2;<br>
> -             adev->mode_info.num_dig = 2;<br>
> -             break;<br>
>   #endif<br>
>        default:<br>
> +#if defined(CONFIG_DRM_AMD_DC_DCN)<br>
> +             switch (adev->ip_versions[DCE_HWIP]) {<br>
> +             case IP_VERSION(2, 0, 2):<br>
> +             case IP_VERSION(3, 0, 0):<br>
> +                     adev->mode_info.num_crtc = 6;<br>
> +                     adev->mode_info.num_hpd = 6;<br>
> +                     adev->mode_info.num_dig = 6;<br>
> +                     break;<br>
> +             case IP_VERSION(2, 0, 0):<br>
> +             case IP_VERSION(3, 0, 2):<br>
> +                     adev->mode_info.num_crtc = 5;<br>
> +                     adev->mode_info.num_hpd = 5;<br>
> +                     adev->mode_info.num_dig = 5;<br>
> +                     break;<br>
> +             case IP_VERSION(3, 0, 3):<br>
> +                     adev->mode_info.num_crtc = 2;<br>
> +                     adev->mode_info.num_hpd = 2;<br>
> +                     adev->mode_info.num_dig = 2;<br>
> +                     break;<br>
> +             case IP_VERSION(3, 0, 1):<br>
> +             case IP_VERSION(2, 1, 0):<br>
> +             case IP_VERSION(3, 1, 2):<br>
> +             case IP_VERSION(3, 1, 3):<br>
> +                     adev->mode_info.num_crtc = 4;<br>
> +                     adev->mode_info.num_hpd = 4;<br>
> +                     adev->mode_info.num_dig = 4;<br>
> +                     break;<br>
> +             default:<br>
> +                     break;<br>
> +             }<br>
> +#endif<br>
>                DRM_ERROR("Unsupported ASIC type: 0x%X\n", adev->asic_type);<br>
>                return -EINVAL;<br>
>        }<br>
> @@ -4590,12 +4619,7 @@ fill_gfx9_tiling_info_from_device(const struct amdgpu_device *adev,<br>
>        tiling_info->gfx9.num_rb_per_se =<br>
>                adev->gfx.config.gb_addr_config_fields.num_rb_per_se;<br>
>        tiling_info->gfx9.shaderEnable = 1;<br>
> -     if (adev->asic_type == CHIP_SIENNA_CICHLID ||<br>
> -         adev->asic_type == CHIP_NAVY_FLOUNDER ||<br>
> -         adev->asic_type == CHIP_DIMGREY_CAVEFISH ||<br>
> -         adev->asic_type == CHIP_BEIGE_GOBY ||<br>
> -         adev->asic_type == CHIP_YELLOW_CARP ||<br>
> -         adev->asic_type == CHIP_VANGOGH)<br>
> +     if (adev->ip_versions[GC_HWIP] >= IP_VERSION(10, 3, 0))<br>
>                tiling_info->gfx9.num_pkrs = adev->gfx.config.gb_addr_config_fields.num_pkrs;<br>
>   }<br>
>   <br>
> @@ -5036,7 +5060,7 @@ get_plane_modifiers(const struct amdgpu_device *adev, unsigned int plane_type, u<br>
>        case AMDGPU_FAMILY_NV:<br>
>        case AMDGPU_FAMILY_VGH:<br>
>        case AMDGPU_FAMILY_YC:<br>
> -             if (adev->asic_type >= CHIP_SIENNA_CICHLID)<br>
> +             if (adev->ip_versions[GC_HWIP] >= IP_VERSION(10, 3, 0))<br>
>                        add_gfx10_3_modifiers(adev, mods, &size, &capacity);<br>
>                else<br>
>                        add_gfx10_1_modifiers(adev, mods, &size, &capacity);<br>
> @@ -7647,7 +7671,7 @@ static int amdgpu_dm_plane_init(struct amdgpu_display_manager *dm,<br>
>                DRM_MODE_ROTATE_0 | DRM_MODE_ROTATE_90 |<br>
>                DRM_MODE_ROTATE_180 | DRM_MODE_ROTATE_270;<br>
>   <br>
> -     if (dm->adev->asic_type >= CHIP_BONAIRE &&<br>
> +     if (dm->adev->family >= AMDGPU_FAMILY_CI &&<br>
<br>
This doesn't look related.<br>
<br>
Thanks,<br>
Lijo<br>
<br>
>            plane->type != DRM_PLANE_TYPE_CURSOR)<br>
>                drm_plane_create_rotation_property(plane, DRM_MODE_ROTATE_0,<br>
>                                                   supported_rotations);<br>
> <br>
</div>
</span></font></div>
</div>
</body>
</html>