Skip to contentSkip to conversation

drm/amd/pm: fix the uninitialized scalar variable warning

PATCH In review Jesse Zhang 2 participants 2 messages Apr 29, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 3/3 drm/amd/pm: fix the uninitialized scalar variable warning

Fix warning for using uninitialized values sclk_mask, mck_mask and soc_mask.
v2: Init the variables in the renoir_get_profiling_clk_mask(Tim Huang)

---
 drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c +4 -0
index 8908bbb3ff1f..546a2268823a 100644
@@ -253,6 +253,10 @@ static int renoir_get_profiling_clk_mask(struct smu_context *smu,
 					 uint32_t *mclk_mask,
 					 uint32_t *soc_mask)
 {
+	*sclk_mask = 0;
+	/* mclk levels are in reverse order */
+	*mclk_maks = NUM_MEMCLK_DPM_LEVELS - 1;
+	*sock_mask = 0;
 
 	if (level == AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK) {
 		if (sclk_mask)
Signature · 1 line
2.25.1
#1 lore raw

[AMD Official Use Only - General]

Quoted 24 lines

-----Original Message-----
From: Jesse Zhang <[email protected]>
Sent: Monday, April 29, 2024 10:10 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Huang, Tim <[email protected]>; Zhang, Jesse(Jie) <[email protected]>; Zhang, Jesse(Jie) <[email protected]>
Subject: [PATCH 3/3 V2] drm/amd/pm: fix the uninitialized scalar variable warning

Fix warning for using uninitialized values sclk_mask, mck_mask and soc_mask.
v2: Init the variables in the renoir_get_profiling_clk_mask(Tim Huang)

---
 drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c +0 -0
index 8908bbb3ff1f..546a2268823a 100644

drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c static int renoir_get_profiling_clk_mask(struct · line 261

Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c +4 -0
@@ -253,6 +253,10 @@ static int renoir_get_profiling_clk_mask(struct
 smu_context *smu,
                                       uint32_t *mclk_mask,
                                       uint32_t *soc_mask)
 {
+     *sclk_mask = 0;
+     /* mclk levels are in reverse order */
+     *mclk_maks = NUM_MEMCLK_DPM_LEVELS - 1;
+     *sock_mask = 0;
 

This is risky because the function may be called with an empty parameter pointer, like in the renoir_get_dpm_ultimate_freq. Besides, for some profile mode, like the AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK, the default mask for sclk_mask and soc_mask maybe not 0. IIRC, the smu13 use the default UMD_PSTATE frequency. Not sure whether Renoir apply this as well.

Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c +0 -0
      if (level == AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK) {

if (sclk_mask)
--
2.25.1