dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Sasha Levin <sashal@kernel.org>,
	dri-devel@lists.freedesktop.org,
	clang-built-linux@googlegroups.com,
	amd-gfx@lists.freedesktop.org,
	Alex Deucher <alexander.deucher@amd.com>,
	Nathan Chancellor <natechancellor@gmail.com>
Subject: [PATCH AUTOSEL 4.19 075/252] drm/amdgpu: Ensure ret is always initialized when using SOC15_WAIT_ON_RREG
Date: Fri, 14 Feb 2020 11:08:50 -0500	[thread overview]
Message-ID: <20200214161147.15842-75-sashal@kernel.org> (raw)
In-Reply-To: <20200214161147.15842-1-sashal@kernel.org>

From: Nathan Chancellor <natechancellor@gmail.com>

[ Upstream commit a63141e31764f8daf3f29e8e2d450dcf9199d1c8 ]

Commit b0f3cd3191cd ("drm/amdgpu: remove unnecessary JPEG2.0 code from
VCN2.0") introduced a new clang warning in the vcn_v2_0_stop function:

../drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c:1082:2: warning: variable 'r'
is used uninitialized whenever 'while' loop exits because its condition
is false [-Wsometimes-uninitialized]
        SOC15_WAIT_ON_RREG(VCN, 0, mmUVD_STATUS, UVD_STATUS__IDLE, 0x7, r);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/amd/amdgpu/../amdgpu/soc15_common.h:55:10: note:
expanded from macro 'SOC15_WAIT_ON_RREG'
                while ((tmp_ & (mask)) != (expected_value)) {   \
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c:1083:6: note: uninitialized use
occurs here
        if (r)
            ^
../drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c:1082:2: note: remove the
condition if it is always true
        SOC15_WAIT_ON_RREG(VCN, 0, mmUVD_STATUS, UVD_STATUS__IDLE, 0x7, r);
        ^
../drivers/gpu/drm/amd/amdgpu/../amdgpu/soc15_common.h:55:10: note:
expanded from macro 'SOC15_WAIT_ON_RREG'
                while ((tmp_ & (mask)) != (expected_value)) {   \
                       ^
../drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c:1072:7: note: initialize the
variable 'r' to silence this warning
        int r;
             ^
              = 0
1 warning generated.

To prevent warnings like this from happening in the future, make the
SOC15_WAIT_ON_RREG macro initialize its ret variable before the while
loop that can time out. This macro's return value is always checked so
it should set ret in both the success and fail path.

Link: https://github.com/ClangBuiltLinux/linux/issues/776
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/gpu/drm/amd/amdgpu/soc15_common.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/soc15_common.h b/drivers/gpu/drm/amd/amdgpu/soc15_common.h
index 0942f492d2e19..9d444f7fdfcdd 100644
--- a/drivers/gpu/drm/amd/amdgpu/soc15_common.h
+++ b/drivers/gpu/drm/amd/amdgpu/soc15_common.h
@@ -51,6 +51,7 @@
 	do {							\
 		uint32_t tmp_ = RREG32(adev->reg_offset[ip##_HWIP][inst][reg##_BASE_IDX] + reg); \
 		uint32_t loop = adev->usec_timeout;		\
+		ret = 0;					\
 		while ((tmp_ & (mask)) != (expected_value)) {	\
 			udelay(2);				\
 			tmp_ = RREG32(adev->reg_offset[ip##_HWIP][inst][reg##_BASE_IDX] + reg); \
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2020-02-14 16:13 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-14 16:07 [PATCH AUTOSEL 4.19 001/252] drm/amdgpu: remove set but not used variable 'mc_shared_chmap' from 'gfx_v6_0.c' and 'gfx_v7_0.c' Sasha Levin
2020-02-14 16:07 ` [PATCH AUTOSEL 4.19 002/252] drm/gma500: Fixup fbdev stolen size usage evaluation Sasha Levin
2020-02-14 16:07 ` [PATCH AUTOSEL 4.19 014/252] pxa168fb: Fix the function used to release some memory in an error handling path Sasha Levin
2020-02-14 16:08 ` [PATCH AUTOSEL 4.19 049/252] drm/amd/display: Retrain dongles when SINK_COUNT becomes non-zero Sasha Levin
2020-02-14 16:08 ` [PATCH AUTOSEL 4.19 054/252] drm/amdgpu: remove 4 set but not used variable in amdgpu_atombios_get_connector_info_from_object_table Sasha Levin
2020-02-14 16:08 ` [PATCH AUTOSEL 4.19 055/252] drm/amdgpu: remove set but not used variable 'dig_connector' Sasha Levin
2020-02-14 16:08 ` [PATCH AUTOSEL 4.19 056/252] drm/amdgpu: remove set but not used variable 'dig' Sasha Levin
2020-02-14 16:08 ` [PATCH AUTOSEL 4.19 057/252] drm/amdgpu: remove always false comparison in 'amdgpu_atombios_i2c_process_i2c_ch' Sasha Levin
2020-02-14 16:08 ` [PATCH AUTOSEL 4.19 058/252] drm/amdgpu: remove set but not used variable 'mc_shared_chmap' Sasha Levin
2020-02-14 16:08 ` [PATCH AUTOSEL 4.19 059/252] drm/amd/powerplay: remove set but not used variable 'threshold', 'state' Sasha Levin
2020-02-14 16:08 ` [PATCH AUTOSEL 4.19 060/252] drm/amdgpu: remove set but not used variable 'amdgpu_connector' Sasha Levin
2020-02-14 16:08 ` [PATCH AUTOSEL 4.19 061/252] drm/amdgpu: remove set but not used variable 'invalid' Sasha Levin
2020-02-14 16:08 ` [PATCH AUTOSEL 4.19 062/252] drm/amd/powerplay: remove set but not used variable 'us_mvdd' Sasha Levin
2020-02-14 16:08 ` [PATCH AUTOSEL 4.19 063/252] drm/gma500: remove set but not used variable 'htotal' Sasha Levin
2020-02-14 16:08 ` [PATCH AUTOSEL 4.19 064/252] drm/gma500: remove set but not used variable 'error' Sasha Levin
2020-02-14 16:08 ` [PATCH AUTOSEL 4.19 065/252] drm/gma500: remove set but not used variable 'is_hdmi', 'is_crt' Sasha Levin
2020-02-14 16:08 ` [PATCH AUTOSEL 4.19 066/252] drm/gma500: remove set but not used variable 'channel_eq' Sasha Levin
2020-02-14 16:08 ` [PATCH AUTOSEL 4.19 067/252] drm/amd/display: remove set but not used variable 'bp' in bios_parser2.c Sasha Levin
2020-02-14 16:08 ` [PATCH AUTOSEL 4.19 068/252] drm/amd/display: remove set but not used variable 'bp' in bios_parser.c Sasha Levin
2020-02-14 16:08 ` [PATCH AUTOSEL 4.19 069/252] drm/radeon: remove set but not used variable 'size', 'relocs_chunk' Sasha Levin
2020-02-14 16:08 ` [PATCH AUTOSEL 4.19 070/252] drm/radeon: remove set but not used variable 'backbias_response_time' Sasha Levin
2020-02-14 16:08 ` [PATCH AUTOSEL 4.19 071/252] drm/radeon: remove set but not used variable 'dig_connector' Sasha Levin
2020-02-14 16:08 ` [PATCH AUTOSEL 4.19 072/252] drm/radeon: remove set but not used variable 'radeon_connector' Sasha Levin
2020-02-14 16:08 ` [PATCH AUTOSEL 4.19 073/252] drm/radeon: remove set but not used variable 'blocks' Sasha Levin
2020-02-14 16:08 ` [PATCH AUTOSEL 4.19 074/252] drm/radeon: remove set but not used variable 'tv_pll_cntl1' Sasha Levin
2020-02-14 16:08 ` Sasha Levin [this message]
2020-02-14 16:09 ` [PATCH AUTOSEL 4.19 113/252] drm/mediatek: handle events when enabling/disabling crtc Sasha Levin
2020-02-14 16:09 ` [PATCH AUTOSEL 4.19 135/252] drm: remove the newline for CRC source name Sasha Levin
2020-02-14 16:09 ` [PATCH AUTOSEL 4.19 136/252] drm/gma500: remove set but not used variables 'hist_reg' Sasha Levin
2020-02-14 16:10 ` [PATCH AUTOSEL 4.19 168/252] drm/nouveau/secboot/gm20b: initialize pointer in gm20b_secboot_new() Sasha Levin
2020-02-14 16:10 ` [PATCH AUTOSEL 4.19 169/252] drm/nouveau/gr/gk20a, gm200-: add terminators to method lists read from fw Sasha Levin
2020-02-14 16:10 ` [PATCH AUTOSEL 4.19 170/252] drm/nouveau: Fix copy-paste error in nouveau_fence_wait_uevent_handler Sasha Levin
2020-02-14 16:10 ` [PATCH AUTOSEL 4.19 171/252] drm/nouveau/drm/ttm: Remove set but not used variable 'mem' Sasha Levin
2020-02-14 16:10 ` [PATCH AUTOSEL 4.19 172/252] drm/nouveau/fault/gv100-: fix memory leak on module unload Sasha Levin
2020-02-14 16:10 ` [PATCH AUTOSEL 4.19 173/252] drm/vmwgfx: prevent memory leak in vmw_cmdbuf_res_add Sasha Levin
2020-02-14 16:10 ` [PATCH AUTOSEL 4.19 182/252] drm/amd/display: fixup DML dependencies Sasha Levin
2020-02-14 16:11 ` [PATCH AUTOSEL 4.19 208/252] drm/nouveau/mmu: fix comptag memory leak Sasha Levin
2020-02-14 16:11 ` [PATCH AUTOSEL 4.19 232/252] drm/nouveau/disp/nv50-: prevent oops when no channel method map provided Sasha Levin
2020-02-14 16:11 ` [PATCH AUTOSEL 4.19 236/252] radeon: insert 10ms sleep in dce5_crtc_load_lut Sasha Levin
2020-02-14 16:11 ` [PATCH AUTOSEL 4.19 245/252] drm/amdgpu/smu10: fix smu10_get_clock_by_type_with_latency Sasha Levin
2020-02-14 16:11 ` [PATCH AUTOSEL 4.19 246/252] drm/amdgpu/smu10: fix smu10_get_clock_by_type_with_voltage Sasha Levin
2020-02-14 16:49   ` Alex Deucher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200214161147.15842-75-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=clang-built-linux@googlegroups.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=natechancellor@gmail.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).