<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);">
Reviewed-by: Alex Deucher <alexander.deucher@amd.com><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> Quan, Evan <Evan.Quan@amd.com><br>
<b>Sent:</b> Friday, January 28, 2022 2:04 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Deucher, Alexander <Alexander.Deucher@amd.com>; Lazar, Lijo <Lijo.Lazar@amd.com>; Quan, Evan <Evan.Quan@amd.com><br>
<b>Subject:</b> [PATCH V3 4/7] drm/amd/pm: correct the usage for 'supported' member of smu_feature structure</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">The supported features should be retrieved just after EnableAllDpmFeatures message<br>
complete. And the check(whether some dpm feature is supported) is only needed when we<br>
decide to enable or disable it.<br>
<br>
Signed-off-by: Evan Quan <evan.quan@amd.com><br>
Change-Id: I07c9a5ac5290cd0d88a40ce1768d393156419b5a<br>
---<br>
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c             | 11 +++++++++++<br>
 drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c       |  8 ++++----<br>
 .../gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c   | 10 +++++-----<br>
 drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c        |  3 ---<br>
 drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c      |  5 +----<br>
 drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c        |  3 ---<br>
 drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c  |  3 ---<br>
 7 files changed, 21 insertions(+), 22 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 ae48cc5aa567..803068cb5079 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c<br>
@@ -1057,8 +1057,10 @@ static int smu_get_thermal_temperature_range(struct smu_context *smu)<br>
 <br>
 static int smu_smc_hw_setup(struct smu_context *smu)<br>
 {<br>
+       struct smu_feature *feature = &smu->smu_feature;<br>
         struct amdgpu_device *adev = smu->adev;<br>
         uint32_t pcie_gen = 0, pcie_width = 0;<br>
+       uint64_t features_supported;<br>
         int ret = 0;<br>
 <br>
         if (adev->in_suspend && smu_is_dpm_running(smu)) {<br>
@@ -1138,6 +1140,15 @@ static int smu_smc_hw_setup(struct smu_context *smu)<br>
                 return ret;<br>
         }<br>
 <br>
+       ret = smu_feature_get_enabled_mask(smu, &features_supported);<br>
+       if (ret) {<br>
+               dev_err(adev->dev, "Failed to retrieve supported dpm features!\n");<br>
+               return ret;<br>
+       }<br>
+       bitmap_copy(feature->supported,<br>
+                   (unsigned long *)&features_supported,<br>
+                   feature->feature_num);<br>
+<br>
         if (!smu_is_dpm_running(smu))<br>
                 dev_info(adev->dev, "dpm has been disabled\n");<br>
 <br>
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c<br>
index 84cbde3f913d..f55ead5f9aba 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c<br>
@@ -1624,8 +1624,8 @@ static int navi10_display_config_changed(struct smu_context *smu)<br>
         int ret = 0;<br>
 <br>
         if ((smu->watermarks_bitmap & WATERMARKS_EXIST) &&<br>
-           smu_cmn_feature_is_supported(smu, SMU_FEATURE_DPM_DCEFCLK_BIT) &&<br>
-           smu_cmn_feature_is_supported(smu, SMU_FEATURE_DPM_SOCCLK_BIT)) {<br>
+           smu_cmn_feature_is_enabled(smu, SMU_FEATURE_DPM_DCEFCLK_BIT) &&<br>
+           smu_cmn_feature_is_enabled(smu, SMU_FEATURE_DPM_SOCCLK_BIT)) {<br>
                 ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_NumOfDisplays,<br>
                                                   smu->display_config->num_display,<br>
                                                   NULL);<br>
@@ -1860,13 +1860,13 @@ static int navi10_notify_smc_display_config(struct smu_context *smu)<br>
         min_clocks.dcef_clock_in_sr = smu->display_config->min_dcef_deep_sleep_set_clk;<br>
         min_clocks.memory_clock = smu->display_config->min_mem_set_clock;<br>
 <br>
-       if (smu_cmn_feature_is_supported(smu, SMU_FEATURE_DPM_DCEFCLK_BIT)) {<br>
+       if (smu_cmn_feature_is_enabled(smu, SMU_FEATURE_DPM_DCEFCLK_BIT)) {<br>
                 clock_req.clock_type = amd_pp_dcef_clock;<br>
                 clock_req.clock_freq_in_khz = min_clocks.dcef_clock * 10;<br>
 <br>
                 ret = smu_v11_0_display_clock_voltage_request(smu, &clock_req);<br>
                 if (!ret) {<br>
-                       if (smu_cmn_feature_is_supported(smu, SMU_FEATURE_DS_DCEFCLK_BIT)) {<br>
+                       if (smu_cmn_feature_is_enabled(smu, SMU_FEATURE_DS_DCEFCLK_BIT)) {<br>
                                 ret = smu_cmn_send_smc_msg_with_param(smu,<br>
                                                                   SMU_MSG_SetMinDeepSleepDcefclk,<br>
                                                                   min_clocks.dcef_clock_in_sr/100,<br>
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c<br>
index b6759f8b5167..804e1c98238d 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c<br>
@@ -1280,8 +1280,8 @@ static int sienna_cichlid_display_config_changed(struct smu_context *smu)<br>
         int ret = 0;<br>
 <br>
         if ((smu->watermarks_bitmap & WATERMARKS_EXIST) &&<br>
-           smu_cmn_feature_is_supported(smu, SMU_FEATURE_DPM_DCEFCLK_BIT) &&<br>
-           smu_cmn_feature_is_supported(smu, SMU_FEATURE_DPM_SOCCLK_BIT)) {<br>
+           smu_cmn_feature_is_enabled(smu, SMU_FEATURE_DPM_DCEFCLK_BIT) &&<br>
+           smu_cmn_feature_is_enabled(smu, SMU_FEATURE_DPM_SOCCLK_BIT)) {<br>
 #if 0<br>
                 ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_NumOfDisplays,<br>
                                                   smu->display_config->num_display,<br>
@@ -1517,13 +1517,13 @@ static int sienna_cichlid_notify_smc_display_config(struct smu_context *smu)<br>
         min_clocks.dcef_clock_in_sr = smu->display_config->min_dcef_deep_sleep_set_clk;<br>
         min_clocks.memory_clock = smu->display_config->min_mem_set_clock;<br>
 <br>
-       if (smu_cmn_feature_is_supported(smu, SMU_FEATURE_DPM_DCEFCLK_BIT)) {<br>
+       if (smu_cmn_feature_is_enabled(smu, SMU_FEATURE_DPM_DCEFCLK_BIT)) {<br>
                 clock_req.clock_type = amd_pp_dcef_clock;<br>
                 clock_req.clock_freq_in_khz = min_clocks.dcef_clock * 10;<br>
 <br>
                 ret = smu_v11_0_display_clock_voltage_request(smu, &clock_req);<br>
                 if (!ret) {<br>
-                       if (smu_cmn_feature_is_supported(smu, SMU_FEATURE_DS_DCEFCLK_BIT)) {<br>
+                       if (smu_cmn_feature_is_enabled(smu, SMU_FEATURE_DS_DCEFCLK_BIT)) {<br>
                                 ret = smu_cmn_send_smc_msg_with_param(smu,<br>
                                                                   SMU_MSG_SetMinDeepSleepDcefclk,<br>
                                                                   min_clocks.dcef_clock_in_sr/100,<br>
@@ -3785,7 +3785,7 @@ static int sienna_cichlid_gpo_control(struct smu_context *smu,<br>
         int ret = 0;<br>
 <br>
 <br>
-       if (smu_cmn_feature_is_supported(smu, SMU_FEATURE_DPM_GFX_GPO_BIT)) {<br>
+       if (smu_cmn_feature_is_enabled(smu, SMU_FEATURE_DPM_GFX_GPO_BIT)) {<br>
                 ret = smu_cmn_get_smc_version(smu, NULL, &smu_version);<br>
                 if (ret)<br>
                         return ret;<br>
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c<br>
index b34d3a416939..d36b64371492 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c<br>
@@ -808,7 +808,6 @@ int smu_v11_0_system_features_control(struct smu_context *smu,<br>
                 return ret;<br>
 <br>
         bitmap_zero(feature->enabled, feature->feature_num);<br>
-       bitmap_zero(feature->supported, feature->feature_num);<br>
 <br>
         if (en) {<br>
                 ret = smu_cmn_get_enabled_mask(smu, &feature_mask);<br>
@@ -817,8 +816,6 @@ int smu_v11_0_system_features_control(struct smu_context *smu,<br>
 <br>
                 bitmap_copy(feature->enabled, (unsigned long *)&feature_mask,<br>
                             feature->feature_num);<br>
-               bitmap_copy(feature->supported, (unsigned long *)&feature_mask,<br>
-                           feature->feature_num);<br>
         }<br>
 <br>
         return ret;<br>
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c<br>
index 65f30cdafc8f..478151e72889 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c<br>
@@ -1956,7 +1956,6 @@ static int vangogh_system_features_control(struct smu_context *smu, bool en)<br>
                                                       RLC_STATUS_OFF, NULL);<br>
 <br>
         bitmap_zero(feature->enabled, feature->feature_num);<br>
-       bitmap_zero(feature->supported, feature->feature_num);<br>
 <br>
         if (!en)<br>
                 return ret;<br>
@@ -1967,8 +1966,6 @@ static int vangogh_system_features_control(struct smu_context *smu, bool en)<br>
 <br>
         bitmap_copy(feature->enabled, (unsigned long *)&feature_mask,<br>
                     feature->feature_num);<br>
-       bitmap_copy(feature->supported, (unsigned long *)&feature_mask,<br>
-                   feature->feature_num);<br>
 <br>
         return 0;<br>
 }<br>
@@ -1985,7 +1982,7 @@ static int vangogh_post_smu_init(struct smu_context *smu)<br>
                 adev->gfx.config.max_sh_per_se * adev->gfx.config.max_shader_engines;<br>
 <br>
         /* allow message will be sent after enable message on Vangogh*/<br>
-       if (smu_cmn_feature_is_supported(smu, SMU_FEATURE_DPM_GFXCLK_BIT) &&<br>
+       if (smu_cmn_feature_is_enabled(smu, SMU_FEATURE_DPM_GFXCLK_BIT) &&<br>
                         (adev->pg_flags & AMD_PG_SUPPORT_GFX_PG)) {<br>
                 ret = smu_cmn_send_smc_msg(smu, SMU_MSG_EnableGfxOff, NULL);<br>
                 if (ret) {<br>
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c<br>
index 6b77fc4b4698..92b5c1108a2e 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c<br>
@@ -774,7 +774,6 @@ int smu_v13_0_system_features_control(struct smu_context *smu,<br>
                 return ret;<br>
 <br>
         bitmap_zero(feature->enabled, feature->feature_num);<br>
-       bitmap_zero(feature->supported, feature->feature_num);<br>
 <br>
         if (en) {<br>
                 ret = smu_cmn_get_enabled_mask(smu, &feature_mask);<br>
@@ -783,8 +782,6 @@ int smu_v13_0_system_features_control(struct smu_context *smu,<br>
 <br>
                 bitmap_copy(feature->enabled, (unsigned long *)&feature_mask,<br>
                             feature->feature_num);<br>
-               bitmap_copy(feature->supported, (unsigned long *)&feature_mask,<br>
-                           feature->feature_num);<br>
         }<br>
 <br>
         return ret;<br>
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c<br>
index a7aabb8079ed..d89e8a03651b 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c<br>
@@ -204,7 +204,6 @@ static int yellow_carp_system_features_control(struct smu_context *smu, bool en)<br>
                 ret = smu_cmn_send_smc_msg(smu, SMU_MSG_PrepareMp1ForUnload, NULL);<br>
 <br>
         bitmap_zero(feature->enabled, feature->feature_num);<br>
-       bitmap_zero(feature->supported, feature->feature_num);<br>
 <br>
         if (!en)<br>
                 return ret;<br>
@@ -215,8 +214,6 @@ static int yellow_carp_system_features_control(struct smu_context *smu, bool en)<br>
 <br>
         bitmap_copy(feature->enabled, (unsigned long *)&feature_mask,<br>
                     feature->feature_num);<br>
-       bitmap_copy(feature->supported, (unsigned long *)&feature_mask,<br>
-                   feature->feature_num);<br>
 <br>
         return 0;<br>
 }<br>
-- <br>
2.29.0<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>