From patchwork Wed Mar 20 00:58:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 10861031 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 74C4A14DE for ; Wed, 20 Mar 2019 08:33:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5CE5E29AA3 for ; Wed, 20 Mar 2019 08:33:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5163829AA6; Wed, 20 Mar 2019 08:33:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F099F29AA3 for ; Wed, 20 Mar 2019 08:33:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F1AF389C98; Wed, 20 Mar 2019 08:33:02 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by gabe.freedesktop.org (Postfix) with ESMTPS id 437CD89BDB; Wed, 20 Mar 2019 01:00:04 +0000 (UTC) Received: by mail-ed1-x544.google.com with SMTP id j89so496562edb.9; Tue, 19 Mar 2019 18:00:04 -0700 (PDT) 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=pOVvWiIbvkv3BPkmEu5aKRdzm0rTvaqyGu0VcKq2UcI=; b=Ym/7pIAz5LeGDMbqsEqGtjxKg4+HCNqollj+SF1+t0T+UJkTXQpRQS5rDHEEWFF5vP MUDneAlPB7FRiqv3p1PEWcAhoT2bjBp3eK3iQefzqcYghqmXc082Cm412tAq9kpcbwUa ziDvQkkv+eQWpXbGIRVyFfNVc9OEbqYn93Zyi1MK+fzCcmIEhbONw8pwc7/H4yl2e6ZF 32Uv7jwNdDppTtScLAD+KH2jDUMjdAhSL5Wkzv3FW99TFOF6KxjYzltbqPFRhrELkU/f kBQZlpc6H8Wnmb1DyeYCY7FqMoSh8jte/GGsD0QUk6hy5bWd7ESZYmvkXG6O/0sCsV/+ f+TA== X-Gm-Message-State: APjAAAUsWyrHinve1xSG5Lr0vOB47+BvK1V+nlI53RR4fsoJA3u5jbG+ 9t6btxTLhvKLFjcgQlUkQko= X-Google-Smtp-Source: APXvYqw+0mNOdD9OpPVjAEqf4P5SvmzDL0Bd5kC8hWfVjlV0PafbkpAPkpVICZ6XFMVW7UdFkIIxww== X-Received: by 2002:aa7:d406:: with SMTP id z6mr929570edq.197.1553043602763; Tue, 19 Mar 2019 18:00:02 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f9:2a:1fae::2]) by smtp.gmail.com with ESMTPSA id g2sm163296edi.76.2019.03.19.18.00.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Mar 2019 18:00:02 -0700 (PDT) From: Nathan Chancellor To: Rex Zhu , Evan Quan , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "David (ChunMing) Zhou" Subject: [PATCH] drm/amd/powerplay: Zero initialize num_of_levels in vega20_set_single_dpm_table Date: Tue, 19 Mar 2019 17:58:42 -0700 Message-Id: <20190320005842.25383-1-natechancellor@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-Patchwork-Bot: notify X-Mailman-Approved-At: Wed, 20 Mar 2019 08:32:28 +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=pOVvWiIbvkv3BPkmEu5aKRdzm0rTvaqyGu0VcKq2UcI=; b=cEYYZsCyS1qFITS10aeYQGv12nLdcVypBSXszAFRudBZcrngMqMKv88nZjzsRdTopO 3kaGYJ5FEZua+pkofNmRA9Fb8hJ0DbU7T5M5626ypc6Np2H+phLAu0JPh24b8CSLOHIl +5JqIL2SqlFEp3PhTiNcKwabQuUc8oYMpe0bfKjH1++6wNyztD7oI5qDo+7BdAhIZ0iN BZ40JQJGho8f9NVLq/KqoQ2UXSUiAkPO1KQwGoSUIzzHdN8spzsKBFtMZ65OrBhgVNGO GihfLC1vWn+e8vNM5KeLsQPLZnjXya5rs2gHf79o66Elny61l4wd+xhDxkEneuhsuDRN er9A== 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: Nick Desaulniers , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, clang-built-linux@googlegroups.com, amd-gfx@lists.freedesktop.org, Nathan Chancellor Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Nick Desaulniers --- 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 7e9e8ad9a300..41e6f49c9cb6 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,