<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:#008000;margin:15pt;" align="Left">
[Public]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Fixed locally.  Thanks!<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:32 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 23/66] drm/amdgpu/amdgpu_smu: 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>
> v2: rebase<br>
> <br>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com><br>
> ---<br>
>   drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 94 +++++++++++++----------<br>
>   1 file changed, 55 insertions(+), 39 deletions(-)<br>
> <br>
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c<br>
> index 04863a797115..5f372d353d9d 100644<br>
> --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c<br>
> +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c<br>
> @@ -455,7 +455,8 @@ static int smu_get_power_num_states(void *handle,<br>
>   <br>
>   bool is_support_sw_smu(struct amdgpu_device *adev)<br>
>   {<br>
> -     if (adev->asic_type >= CHIP_ARCTURUS)<br>
> +     if ((adev->asic_type >= CHIP_ARCTURUS) ||<br>
> +         (adev->ip_versions[MP1_HWIP] >= IP_VERSION(11, 0, 0)))<br>
>                return true;<br>
>   <br>
>        return false;<br>
> @@ -575,43 +576,47 @@ static int smu_set_funcs(struct amdgpu_device *adev)<br>
>        if (adev->pm.pp_feature & PP_OVERDRIVE_MASK)<br>
>                smu->od_enabled = true;<br>
>   <br>
> -     switch (adev->asic_type) {<br>
> -     case CHIP_NAVI10:<br>
> -     case CHIP_NAVI14:<br>
> -     case CHIP_NAVI12:<br>
> +     switch (adev->ip_versions[MP1_HWIP]) {<br>
> +     case IP_VERSION(11, 0, 0):<br>
> +     case IP_VERSION(11, 0, 5):<br>
> +     case IP_VERSION(11, 0, 9):<br>
>                navi10_set_ppt_funcs(smu);<br>
>                break;<br>
> -     case CHIP_ARCTURUS:<br>
> -             adev->pm.pp_feature &= ~PP_GFXOFF_MASK;<br>
> -             arcturus_set_ppt_funcs(smu);<br>
> -             /* OD is not supported on Arcturus */<br>
> -             smu->od_enabled =false;<br>
> -             break;<br>
> -     case CHIP_SIENNA_CICHLID:<br>
> -     case CHIP_NAVY_FLOUNDER:<br>
> -     case CHIP_DIMGREY_CAVEFISH:<br>
> -     case CHIP_BEIGE_GOBY:<br>
> +     case IP_VERSION(11, 0, 7):<br>
> +     case IP_VERSION(11, 0, 11):<br>
> +     case IP_VERSION(11, 0, 12):<br>
> +     case IP_VERSION(11, 0, 13):<br>
>                sienna_cichlid_set_ppt_funcs(smu);<br>
>                break;<br>
> -     case CHIP_ALDEBARAN:<br>
> -             aldebaran_set_ppt_funcs(smu);<br>
> -             /* Enable pp_od_clk_voltage node */<br>
> -             smu->od_enabled = true;<br>
> -             break;<br>
> -     case CHIP_RENOIR:<br>
> +     case IP_VERSION(12, 0, 0):<br>
>                renoir_set_ppt_funcs(smu);<br>
>                break;<br>
> -     case CHIP_VANGOGH:<br>
> +     case IP_VERSION(11, 5, 0):<br>
>                vangogh_set_ppt_funcs(smu);<br>
>                break;<br>
> -     case CHIP_YELLOW_CARP:<br>
> +     case IP_VERSION(13, 0, 1):<br>
>                yellow_carp_set_ppt_funcs(smu);<br>
>                break;<br>
> -     case CHIP_CYAN_SKILLFISH:<br>
> +     case IP_VERSION(11, 0, 8):<br>
>                cyan_skillfish_set_ppt_funcs(smu);<br>
>                break;<br>
>        default:<br>
> -             return -EINVAL;<br>
> +             switch (adev->asic_type) {<br>
> +             case CHIP_ARCTURUS:<br>
> +                     adev->pm.pp_feature &= ~PP_GFXOFF_MASK;<br>
> +                     arcturus_set_ppt_funcs(smu);<br>
> +                     /* OD is not supported on Arcturus */<br>
> +                     smu->od_enabled =false;<br>
> +                     break;<br>
> +             case CHIP_ALDEBARAN:<br>
> +                     aldebaran_set_ppt_funcs(smu);<br>
> +                     /* Enable pp_od_clk_voltage node */<br>
> +                     smu->od_enabled = true;<br>
> +                     break;<br>
> +             default:<br>
> +                     return -EINVAL;<br>
> +             }<br>
> +             break;<br>
>        }<br>
>   <br>
>        return 0;<br>
> @@ -694,7 +699,7 @@ static int smu_late_init(void *handle)<br>
>                return ret;<br>
>        }<br>
>   <br>
> -     if (adev->asic_type == CHIP_YELLOW_CARP)<br>
> +     if (adev->ip_versions[MP1_HWIP] == IP_VERSION(13, 0, 1))<br>
>                return 0;<br>
>   <br>
>        if (!amdgpu_sriov_vf(adev) || smu->od_enabled) {<br>
> @@ -1140,8 +1145,10 @@ static int smu_smc_hw_setup(struct smu_context *smu)<br>
>        if (adev->in_suspend && smu_is_dpm_running(smu)) {<br>
>                dev_info(adev->dev, "dpm has been enabled\n");<br>
>                /* this is needed specifically */<br>
> -             if ((adev->asic_type >= CHIP_SIENNA_CICHLID) &&<br>
> -                 (adev->asic_type <= CHIP_DIMGREY_CAVEFISH))<br>
> +             if ((adev->ip_versions[MP1_HWIP] == IP_VERSION(11, 0, 7)) ||<br>
> +                 (adev->ip_versions[MP1_HWIP] == IP_VERSION(11, 0, 11)) ||<br>
> +                 (adev->ip_versions[MP1_HWIP] == IP_VERSION(11, 5, 0)) ||<br>
> +                 (adev->ip_versions[MP1_HWIP] == IP_VERSION(11, 0, 12)))<br>
<br>
switch...case looks better here<br>
<br>
>                        ret = smu_system_features_control(smu, true);<br>
>                return ret;<br>
>        }<br>
> @@ -1284,7 +1291,7 @@ static int smu_start_smc_engine(struct smu_context *smu)<br>
>        int ret = 0;<br>
>   <br>
>        if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) {<br>
> -             if (adev->asic_type < CHIP_NAVI10) {<br>
> +             if (adev->ip_versions[MP1_HWIP] < IP_VERSION(11, 0, 0)) {<br>
>                        if (smu->ppt_funcs->load_microcode) {<br>
>                                ret = smu->ppt_funcs->load_microcode(smu);<br>
>                                if (ret)<br>
> @@ -1403,8 +1410,14 @@ static int smu_disable_dpms(struct smu_context *smu)<br>
>         *     properly.<br>
>         */<br>
>        if (smu->uploading_custom_pp_table &&<br>
> -         (adev->asic_type >= CHIP_NAVI10) &&<br>
> -         (adev->asic_type <= CHIP_BEIGE_GOBY))<br>
> +         ((adev->ip_versions[MP1_HWIP] == IP_VERSION(11, 0, 0)) ||<br>
> +          (adev->ip_versions[MP1_HWIP] == IP_VERSION(11, 0, 5)) ||<br>
> +          (adev->ip_versions[MP1_HWIP] == IP_VERSION(11, 0, 9)) ||<br>
> +          (adev->ip_versions[MP1_HWIP] == IP_VERSION(11, 0, 7)) ||<br>
> +          (adev->ip_versions[MP1_HWIP] == IP_VERSION(11, 0, 11)) ||<br>
> +          (adev->ip_versions[MP1_HWIP] == IP_VERSION(11, 5, 0)) ||<br>
> +          (adev->ip_versions[MP1_HWIP] == IP_VERSION(11, 0, 12)) ||<br>
> +          (adev->ip_versions[MP1_HWIP] == IP_VERSION(11, 0, 13))))<br>
<br>
Same - switch...case<br>
<br>
>                return smu_disable_all_features_with_exception(smu,<br>
>                                                               true,<br>
>                                                               SMU_FEATURE_COUNT);<br>
> @@ -1413,9 +1426,11 @@ static int smu_disable_dpms(struct smu_context *smu)<br>
>         * For Sienna_Cichlid, PMFW will handle the features disablement properly<br>
>         * on BACO in. Driver involvement is unnecessary.<br>
>         */<br>
> -     if (((adev->asic_type == CHIP_SIENNA_CICHLID) ||<br>
> -          ((adev->asic_type >= CHIP_NAVI10) && (adev->asic_type <= CHIP_NAVI12))) &&<br>
> -          use_baco)<br>
> +     if (((adev->ip_versions[MP1_HWIP] == IP_VERSION(11, 0, 7)) ||<br>
> +          (adev->ip_versions[MP1_HWIP] == IP_VERSION(11, 0, 0)) ||<br>
> +          (adev->ip_versions[MP1_HWIP] == IP_VERSION(11, 0, 5)) ||<br>
> +          (adev->ip_versions[MP1_HWIP] == IP_VERSION(11, 0, 9))) &&<br>
> +         use_baco)<br>
<br>
Here as well.<br>
<br>
Thanks,<br>
Lijo<br>
<br>
>                return smu_disable_all_features_with_exception(smu,<br>
>                                                               true,<br>
>                                                               SMU_FEATURE_BACO_BIT);<br>
> @@ -1436,7 +1451,7 @@ static int smu_disable_dpms(struct smu_context *smu)<br>
>                        dev_err(adev->dev, "Failed to disable smu features.\n");<br>
>        }<br>
>   <br>
> -     if (adev->asic_type >= CHIP_NAVI10 &&<br>
> +     if (adev->ip_versions[MP1_HWIP] >= IP_VERSION(11, 0, 0) &&<br>
>            adev->gfx.rlc.funcs->stop)<br>
>                adev->gfx.rlc.funcs->stop(adev);<br>
>   <br>
> @@ -2229,6 +2244,7 @@ int smu_get_power_limit(void *handle,<br>
>                        enum pp_power_type pp_power_type)<br>
>   {<br>
>        struct smu_context *smu = handle;<br>
> +     struct amdgpu_device *adev = smu->adev;<br>
>        enum smu_ppt_limit_level limit_level;<br>
>        uint32_t limit_type;<br>
>        int ret = 0;<br>
> @@ -2273,10 +2289,10 @@ int smu_get_power_limit(void *handle,<br>
>                switch (limit_level) {<br>
>                case SMU_PPT_LIMIT_CURRENT:<br>
>                        if ((smu->adev->asic_type == CHIP_ALDEBARAN) ||<br>
> -                          (smu->adev->asic_type == CHIP_SIENNA_CICHLID) ||<br>
> -                          (smu->adev->asic_type == CHIP_NAVY_FLOUNDER) ||<br>
> -                          (smu->adev->asic_type == CHIP_DIMGREY_CAVEFISH) ||<br>
> -                          (smu->adev->asic_type == CHIP_BEIGE_GOBY))<br>
> +                          (adev->ip_versions[MP1_HWIP] == IP_VERSION(11, 0, 7)) ||<br>
> +                          (adev->ip_versions[MP1_HWIP] == IP_VERSION(11, 0, 11)) ||<br>
> +                          (adev->ip_versions[MP1_HWIP] == IP_VERSION(11, 0, 12)) ||<br>
> +                          (adev->ip_versions[MP1_HWIP] == IP_VERSION(11, 0, 13)))<br>
>                                ret = smu_get_asic_power_limits(smu,<br>
>                                                                &smu->current_power_limit,<br>
>                                                                NULL,<br>
> <br>
</div>
</span></font></div>
</div>
</body>
</html>