From: Alex Deucher <alexdeucher@gmail.com>
To: Nathan Chancellor <natechancellor@gmail.com>
Cc: "Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>,
"David (ChunMing) Zhou" <David1.Zhou@amd.com>,
LKML <linux-kernel@vger.kernel.org>,
"Maling list - DRI developers" <dri-devel@lists.freedesktop.org>,
clang-built-linux <clang-built-linux@googlegroups.com>,
"amd-gfx list" <amd-gfx@lists.freedesktop.org>,
"Leo Liu" <leo.liu@amd.com>
Subject: Re: [PATCH] drm/amdgpu: Ensure ret is always initialized when using SOC15_WAIT_ON_RREG
Date: Mon, 25 Nov 2019 09:55:06 -0500 [thread overview]
Message-ID: <CADnq5_OGD5q44nEhHp2+RU3syhO9cUhqfnH34BRJhJrC-b+rLw@mail.gmail.com> (raw)
In-Reply-To: <20191123192336.11678-1-natechancellor@gmail.com>
On Mon, Nov 25, 2019 at 3:07 AM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> 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>
Applied. Thanks!
Alex
> ---
> 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 839f186e1182..19e870c79896 100644
> --- a/drivers/gpu/drm/amd/amdgpu/soc15_common.h
> +++ b/drivers/gpu/drm/amd/amdgpu/soc15_common.h
> @@ -52,6 +52,7 @@
> uint32_t old_ = 0; \
> 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)) { \
> if (old_ != tmp_) { \
> loop = adev->usec_timeout; \
> --
> 2.24.0
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
prev parent reply other threads:[~2019-11-25 14:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-23 19:23 [PATCH] drm/amdgpu: Ensure ret is always initialized when using SOC15_WAIT_ON_RREG Nathan Chancellor
2019-11-25 14:55 ` Alex Deucher [this message]
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=CADnq5_OGD5q44nEhHp2+RU3syhO9cUhqfnH34BRJhJrC-b+rLw@mail.gmail.com \
--to=alexdeucher@gmail.com \
--cc=David1.Zhou@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=clang-built-linux@googlegroups.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=leo.liu@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=natechancellor@gmail.com \
/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).