aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/linux-yocto-4.19.8/1659-drm-amd-powerplay-Zero-initialize-num_of_levels-in-v.patch
diff options
context:
space:
mode:
Diffstat (limited to 'common/recipes-kernel/linux/linux-yocto-4.19.8/1659-drm-amd-powerplay-Zero-initialize-num_of_levels-in-v.patch')
-rw-r--r--common/recipes-kernel/linux/linux-yocto-4.19.8/1659-drm-amd-powerplay-Zero-initialize-num_of_levels-in-v.patch67
1 files changed, 67 insertions, 0 deletions
diff --git a/common/recipes-kernel/linux/linux-yocto-4.19.8/1659-drm-amd-powerplay-Zero-initialize-num_of_levels-in-v.patch b/common/recipes-kernel/linux/linux-yocto-4.19.8/1659-drm-amd-powerplay-Zero-initialize-num_of_levels-in-v.patch
new file mode 100644
index 00000000..f75ca4f0
--- /dev/null
+++ b/common/recipes-kernel/linux/linux-yocto-4.19.8/1659-drm-amd-powerplay-Zero-initialize-num_of_levels-in-v.patch
@@ -0,0 +1,67 @@
+From e9bc7091b5cf10a59998a4b13cd34841cd105ec4 Mon Sep 17 00:00:00 2001
+From: Nathan Chancellor <natechancellor@gmail.com>
+Date: Tue, 19 Mar 2019 17:58:42 -0700
+Subject: [PATCH 1659/2940] drm/amd/powerplay: Zero initialize num_of_levels in
+ vega20_set_single_dpm_table
+
+When building with -Wsometimes-uninitialized, Clang warns:
+
+drivers/gpu/drm/amd/amdgpu/../powerplay/vega20_ppt.c:456:2: warning:
+variable 'num_of_levels' is used uninitialized whenever '?:' condition
+is false [-Wsometimes-uninitialized]
+ smu_read_smc_arg(smu, &num_of_levels);
+ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+drivers/gpu/drm/amd/amdgpu/../powerplay/inc/amdgpu_smu.h:608:3: note:
+expanded from macro 'smu_read_smc_arg'
+ ((smu)->funcs->read_smc_arg? (smu)->funcs->read_smc_arg((smu), (arg)) : 0)
+ ^~~~~~~~~~~~~~~~~~~~~~~~~~
+drivers/gpu/drm/amd/amdgpu/../powerplay/vega20_ppt.c:457:7: note:
+uninitialized use occurs here
+ if (!num_of_levels) {
+ ^~~~~~~~~~~~~
+drivers/gpu/drm/amd/amdgpu/../powerplay/vega20_ppt.c:456:2: note: remove
+the '?:' if its condition is always true
+ smu_read_smc_arg(smu, &num_of_levels);
+ ^
+drivers/gpu/drm/amd/amdgpu/../powerplay/inc/amdgpu_smu.h:608:3: note:
+expanded from macro 'smu_read_smc_arg'
+ ((smu)->funcs->read_smc_arg? (smu)->funcs->read_smc_arg((smu), (arg)) : 0)
+ ^
+drivers/gpu/drm/amd/amdgpu/../powerplay/vega20_ppt.c:446:27: note:
+initialize the variable 'num_of_levels' to silence this warning
+ uint32_t i, num_of_levels, clk;
+ ^
+ = 0
+1 warning generated.
+
+The if statement it mentions as potentially problematic is currently
+always true because the read_smc_arg callback is assigned at the
+bottom of this file but Clang can't tell that. If the callback were
+ever to disappear, num_of_levels would never be initialized. Just
+zero initialize it to ensure that the intent behind this code
+remains the same.
+
+Fixes: 870b996f955f ("drm/amd/powerplay: set defalut dpm table for smu")
+Link: https://github.com/ClangBuiltLinux/linux/issues/425
+Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+---
+ drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
+index 5b4adf901fae..5297b23ebcd1 100644
+--- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
++++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
+@@ -443,7 +443,7 @@ vega20_set_single_dpm_table(struct smu_context *smu,
+ PPCLK_e clk_id)
+ {
+ int ret = 0;
+- uint32_t i, num_of_levels, clk;
++ uint32_t i, num_of_levels = 0, clk;
+
+ ret = smu_send_smc_msg_with_param(smu,
+ SMU_MSG_GetDpmFreqByIndex,
+--
+2.17.1
+