From patchwork Sat Nov 23 19:23:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 11259955 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C9BD7138C for ; Mon, 25 Nov 2019 08:07:57 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B2AB7207FD for ; Mon, 25 Nov 2019 08:07:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B2AB7207FD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6174889458; Mon, 25 Nov 2019 08:07:42 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by gabe.freedesktop.org (Postfix) with ESMTPS id 405416E0E6; Sat, 23 Nov 2019 19:24:18 +0000 (UTC) Received: by mail-ot1-x343.google.com with SMTP id m15so9156688otq.7; Sat, 23 Nov 2019 11:24:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jsgedYWGcDm2gsEfcO7YvCurfXqqqHvXcUgzb0SkXvE=; b=iBVYVWJGHm1oTXRXNMY7fLf7OUWACqJUN1m8b0X7ugmIFiMPwbnK1bUxngyXVIv+xh Sh/BMuOpeFri4rbsp3bXVJQ1PIVpRVj4WIRjRkC5y3kvus62BJMjxuU9KpXOWIVvwFvq NeFfsq12RZYDidbmgNigZmW8goKb1HEng646A+GqZ0k707AZWZk2n11DAH611Kb+PVbj 1cANRdsaS+vmbFXg8HM14Hshqo6V9jWkSqgO/x7bUv7qCqQvbHc1M0wc0D2BgfPQ9eJT zKa1FPD8fyzWKUqhPVnK5cc+pKNj4gKduBZbFzzbH9nkD2aitdcCqoOzAEe07U32+er1 ikSQ== X-Gm-Message-State: APjAAAV0Zs/s/EsUERqCjOvXFUykpPZ0erT4cLLB3gXAtNnl1Za1IFPX yba2O+HgrG5fO3IOZxu4uNU= X-Google-Smtp-Source: APXvYqx1fpWBPu6g4gMwvZ8c8rzxDBf/2LNZhYGwrIsO/l49CfLoBbqhpoW6unLQv+Bq31U044WiOA== X-Received: by 2002:a9d:37cb:: with SMTP id x69mr14555138otb.90.1574537057333; Sat, 23 Nov 2019 11:24:17 -0800 (PST) Received: from localhost.localdomain ([2604:1380:4111:8b00::7]) by smtp.gmail.com with ESMTPSA id i12sm549134ota.10.2019.11.23.11.24.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Nov 2019 11:24:16 -0800 (PST) From: Nathan Chancellor To: Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "David (ChunMing) Zhou" Subject: [PATCH] drm/amdgpu: Ensure ret is always initialized when using SOC15_WAIT_ON_RREG Date: Sat, 23 Nov 2019 12:23:36 -0700 Message-Id: <20191123192336.11678-1-natechancellor@gmail.com> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 X-Patchwork-Bot: notify X-Mailman-Approved-At: Mon, 25 Nov 2019 08:07:41 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jsgedYWGcDm2gsEfcO7YvCurfXqqqHvXcUgzb0SkXvE=; b=DhKMGXayoU1zJxSIN7PkHAQmyyS8DnDHS7/rwmIF0HY9CQKJILJSswS3cBOGUI5NDc 9lhNTEM+kKggalT3TCnneA5sSEwHd64La89Ae5uykGkOwYJE3I7R1TFu6WdeDr1DNMaT fgn+8778RSBtUsx0IKwlxFUbHomEhtxV27VE5J+/MnPm7ydJ+SUiHn+3xpqxSmWvTG1u ONFp8keGdHAQ3U8sUG9c36yNc3uAur0l+tLT3dOPUpGgQbRZRPmWLcmGNARcriPrAh1I 5jQYTtmoVWAqJ5poW41jeLvrqUMxApWUUAJGzUI81gNAUaZQTiKyWv9350ti8vjQaUgv U+jA== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, clang-built-linux@googlegroups.com, amd-gfx@lists.freedesktop.org, Nathan Chancellor , Leo Liu Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 --- 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; \