<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 class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Series is:</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Acked-by: Alex Deucher <alexander.deucher@amd.com></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> Ma, Jun <Jun.Ma2@amd.com><br>
<b>Sent:</b> Monday, April 29, 2024 3:58 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Feng, Kenneth <Kenneth.Feng@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>; Wang, Yang(Kevin) <KevinYang.Wang@amd.com>; Koenig, Christian <Christian.Koenig@amd.com>; Ma, Jun <Jun.Ma2@amd.com><br>
<b>Subject:</b> [PATCH v2 2/2] drm/amdgpu/pm: Fix uninitialized variable warning</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Check return value of smum_send_msg_to_smc to fix<br>
uninitialized variable varning<br>
<br>
Signed-off-by: Ma Jun <Jun.Ma2@amd.com><br>
---<br>
.../drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c | 21 +++++++++++++----<br>
.../drm/amd/pm/powerplay/hwmgr/vega12_hwmgr.c | 20 ++++++++++++----<br>
.../drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c | 23 ++++++++++++++-----<br>
3 files changed, 48 insertions(+), 16 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c<br>
index 38d5605117ff..a8c732e07006 100644<br>
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c<br>
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c<br>
@@ -1558,7 +1558,10 @@ static int smu10_set_fine_grain_clk_vol(struct pp_hwmgr *hwmgr,<br>
}<br>
<br>
if (input[0] == 0) {<br>
- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMinGfxclkFrequency, &min_freq);<br>
+ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMinGfxclkFrequency, &min_freq);<br>
+ if (ret)<br>
+ return ret;<br>
+<br>
if (input[1] < min_freq) {<br>
pr_err("Fine grain setting minimum sclk (%ld) MHz is less than the minimum allowed (%d) MHz\n",<br>
input[1], min_freq);<br>
@@ -1566,7 +1569,10 @@ static int smu10_set_fine_grain_clk_vol(struct pp_hwmgr *hwmgr,<br>
}<br>
smu10_data->gfx_actual_soft_min_freq = input[1];<br>
} else if (input[0] == 1) {<br>
- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMaxGfxclkFrequency, &max_freq);<br>
+ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMaxGfxclkFrequency, &max_freq);<br>
+ if (ret)<br>
+ return ret;<br>
+<br>
if (input[1] > max_freq) {<br>
pr_err("Fine grain setting maximum sclk (%ld) MHz is greater than the maximum allowed (%d) MHz\n",<br>
input[1], max_freq);<br>
@@ -1581,10 +1587,15 @@ static int smu10_set_fine_grain_clk_vol(struct pp_hwmgr *hwmgr,<br>
pr_err("Input parameter number not correct\n");<br>
return -EINVAL;<br>
}<br>
- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMinGfxclkFrequency, &min_freq);<br>
- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMaxGfxclkFrequency, &max_freq);<br>
-<br>
+ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMinGfxclkFrequency, &min_freq);<br>
+ if (ret)<br>
+ return ret;<br>
smu10_data->gfx_actual_soft_min_freq = min_freq;<br>
+<br>
+ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMaxGfxclkFrequency, &max_freq);<br>
+ if (ret)<br>
+ return ret;<br>
+<br>
smu10_data->gfx_actual_soft_max_freq = max_freq;<br>
} else if (type == PP_OD_COMMIT_DPM_TABLE) {<br>
if (size != 0) {<br>
diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_hwmgr.c<br>
index c223e3a6bfca..10fd4e9f016c 100644<br>
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_hwmgr.c<br>
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_hwmgr.c<br>
@@ -293,12 +293,12 @@ static int vega12_set_features_platform_caps(struct pp_hwmgr *hwmgr)<br>
return 0;<br>
}<br>
<br>
-static void vega12_init_dpm_defaults(struct pp_hwmgr *hwmgr)<br>
+static int vega12_init_dpm_defaults(struct pp_hwmgr *hwmgr)<br>
{<br>
struct vega12_hwmgr *data = (struct vega12_hwmgr *)(hwmgr->backend);<br>
struct amdgpu_device *adev = hwmgr->adev;<br>
uint32_t top32, bottom32;<br>
- int i;<br>
+ int i, ret;<br>
<br>
data->smu_features[GNLD_DPM_PREFETCHER].smu_feature_id =<br>
FEATURE_DPM_PREFETCHER_BIT;<br>
@@ -364,10 +364,16 @@ static void vega12_init_dpm_defaults(struct pp_hwmgr *hwmgr)<br>
}<br>
<br>
/* Get the SN to turn into a Unique ID */<br>
- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_ReadSerialNumTop32, &top32);<br>
- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_ReadSerialNumBottom32, &bottom32);<br>
+ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_ReadSerialNumTop32, &top32);<br>
+ if (ret)<br>
+ return ret;<br>
+ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_ReadSerialNumBottom32, &bottom32);<br>
+ if (ret)<br>
+ return ret;<br>
<br>
adev->unique_id = ((uint64_t)bottom32 << 32) | top32;<br>
+<br>
+ return 0;<br>
}<br>
<br>
static int vega12_set_private_data_based_on_pptable(struct pp_hwmgr *hwmgr)<br>
@@ -410,7 +416,11 @@ static int vega12_hwmgr_backend_init(struct pp_hwmgr *hwmgr)<br>
<br>
vega12_set_features_platform_caps(hwmgr);<br>
<br>
- vega12_init_dpm_defaults(hwmgr);<br>
+ result = vega12_init_dpm_defaults(hwmgr);<br>
+ if (result) {<br>
+ pr_err("%s failed\n", __func__);<br>
+ return result;<br>
+ }<br>
<br>
/* Parse pptable data read from VBIOS */<br>
vega12_set_private_data_based_on_pptable(hwmgr);<br>
diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c<br>
index f9efb0bad807..bf1b829f9d68 100644<br>
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c<br>
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c<br>
@@ -328,12 +328,12 @@ static int vega20_set_features_platform_caps(struct pp_hwmgr *hwmgr)<br>
return 0;<br>
}<br>
<br>
-static void vega20_init_dpm_defaults(struct pp_hwmgr *hwmgr)<br>
+static int vega20_init_dpm_defaults(struct pp_hwmgr *hwmgr)<br>
{<br>
struct vega20_hwmgr *data = (struct vega20_hwmgr *)(hwmgr->backend);<br>
struct amdgpu_device *adev = hwmgr->adev;<br>
uint32_t top32, bottom32;<br>
- int i;<br>
+ int i, ret;<br>
<br>
data->smu_features[GNLD_DPM_PREFETCHER].smu_feature_id =<br>
FEATURE_DPM_PREFETCHER_BIT;<br>
@@ -404,10 +404,17 @@ static void vega20_init_dpm_defaults(struct pp_hwmgr *hwmgr)<br>
}<br>
<br>
/* Get the SN to turn into a Unique ID */<br>
- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_ReadSerialNumTop32, &top32);<br>
- smum_send_msg_to_smc(hwmgr, PPSMC_MSG_ReadSerialNumBottom32, &bottom32);<br>
+ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_ReadSerialNumTop32, &top32);<br>
+ if (ret)<br>
+ return ret;<br>
+<br>
+ ret = smum_send_msg_to_smc(hwmgr, PPSMC_MSG_ReadSerialNumBottom32, &bottom32);<br>
+ if (ret)<br>
+ return ret;<br>
<br>
adev->unique_id = ((uint64_t)bottom32 << 32) | top32;<br>
+<br>
+ return 0;<br>
}<br>
<br>
static int vega20_set_private_data_based_on_pptable(struct pp_hwmgr *hwmgr)<br>
@@ -427,6 +434,7 @@ static int vega20_hwmgr_backend_init(struct pp_hwmgr *hwmgr)<br>
{<br>
struct vega20_hwmgr *data;<br>
struct amdgpu_device *adev = hwmgr->adev;<br>
+ int result;<br>
<br>
data = kzalloc(sizeof(struct vega20_hwmgr), GFP_KERNEL);<br>
if (data == NULL)<br>
@@ -452,8 +460,11 @@ static int vega20_hwmgr_backend_init(struct pp_hwmgr *hwmgr)<br>
<br>
vega20_set_features_platform_caps(hwmgr);<br>
<br>
- vega20_init_dpm_defaults(hwmgr);<br>
-<br>
+ result = vega20_init_dpm_defaults(hwmgr);<br>
+ if (result) {<br>
+ pr_err("%s failed\n", __func__);<br>
+ return result;<br>
+ }<br>
/* Parse pptable data read from VBIOS */<br>
vega20_set_private_data_based_on_pptable(hwmgr);<br>
<br>
-- <br>
2.34.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>