From patchwork Mon Jul 8 14:07:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 168651 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp7215983ilk; Mon, 8 Jul 2019 07:08:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqyS0nKPJlbr8o2SGIpuEfVnLEwY1fZF8eoZXz/PNiJXszNRNm4hA99I/3lyaJwp0PljJ+Aa X-Received: by 2002:a17:902:ab83:: with SMTP id f3mr25273070plr.122.1562594906559; Mon, 08 Jul 2019 07:08:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562594906; cv=none; d=google.com; s=arc-20160816; b=mxriU2j25J8fA5AXdRGxSfngFHtDpHaXP7k85/KeSkOAyX7s/xUM3yij2AjH/NSAuG kRPZ21+HQTNliNCC5qm0HUVAiisUi9HsDnmYKBNOC1LjWJ1Wyk+yltdHNqDc4wL/EedK w3PTWgVkkNcE6owdoDlacuQ6ZSjkzxSzKkrW2nSUs2BEH13ZOnIV/ZtRyUao4/fyqeBJ YgqTHeAzag7Mj6UUytBbRlr7cvCpz6MiPpEvNOve5Zu3KtdG7ISkvkyKPRBesuMzcdOp LV2Ta4qPxVbWrfkmgmVodVLdPi4hN/xSclZSsKmtVK+c1xKjF1CnII/RIAjqWFRKg74j NIdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:message-id:date:subject:to:from :delivered-to; bh=FyrbQNzwp9MG7dv3DXlM+kfu0DgSUDtuPtDLTaStA74=; b=in4mrrO5qoKoKzkljjsd5LpU70i9jge1gAZOKMb6LXqREJgcICAA7WeUKqESGa5FXO 9tgHdR2X6KYAD5ckou7C5hbUu5J6W6dnv96lZgaaeGSZkrOhJDEFhIJXqWNmdBy8kLZB NwZuM2qCgS0VU594M+F1D5G3EncsKe+1/KD12xM6D+Tv0ubQsEOXXm1c3emG4IH/CBbU SE00VgavzmsioeXbbj3cg1Eq1OeiCX6yE4XdIEn4kLsqWhVP/lZLOaDPjuRDpeaBPgtG s2Wd2ryr9lWwHZukQ1F1It7rlM4S9e8Oy6/kBwktKWnI6LZma+Xc9WFIygSZJpRIZA9S U1bw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id x185si20721652pfx.243.2019.07.08.07.08.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Jul 2019 07:08:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) 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 8F3EC89D8E; Mon, 8 Jul 2019 14:08:25 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.10]) by gabe.freedesktop.org (Postfix) with ESMTPS id A3A5689D8E for ; Mon, 8 Jul 2019 14:08:23 +0000 (UTC) Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.145]) with ESMTPA (Nemesis) id 1MMoXC-1i375x3FCu-00Ik9A; Mon, 08 Jul 2019 16:08:17 +0200 From: Arnd Bergmann To: Rex Zhu , Evan Quan , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "David (ChunMing) Zhou" , David Airlie , Daniel Vetter Subject: [PATCH 1/2] drm/amd/powerplay: smu_v11_0: fix uninitialized variable use Date: Mon, 8 Jul 2019 16:07:58 +0200 Message-Id: <20190708140816.1334640-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:X3J4e80NQyAuaqivhrauUEXEWU7jDdUAqZMBR/kGPcQ7CYCTHSi CIzF/Hx8mmfKT7DQSNax0/KaUiiTQnuK2hIJxk0dtFaoEHsVLxWeR+yR3fnKIhqt3Dfg4iP PIwtg8WqdZuu0vvm6p03mU3SVAQ/SbVVPQmeuP08r/dD1WfosPTHh5iYGmMh5e0Nlbbcmuq /M8IBS2hCeB21b3CZkm/Q== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:14Ii1zw6QsU=:dUxvAlUg7CH/JD12q86ZkC NPa53AjNYyMTTFb6PHM3SufF/j4+MnmcH24nLk8u0Hgn3Zjyt5+jIgUAsdj/FId5IDMeL/Liv nFyB93a5FGykJUhWnsd4/N7+WiKiZeSeKFiN0Wkl7LFFMw8iFr3+IjVvXXAbkP91ATFF0Ky57 Sjv+FZ05WJjs5A2oHVCsGp27DI94HU4OVvvM06CjWz+uVWaEXCeM6EYs+NNqDfLi75VqEWFdc xJltWBfGrxJgLug9v+coRVT7Min4kP/f1NnvKAuT0TL84cK3VbOCK/N9rwlVCBkSmdQljhiNd nzzBabj5pKnYUSWSsjizgTnUGaI7k8AWxy4JePuE0YNpj0iuFkvGMX/A2alZ/pnDBa36RMNp6 KLTjObokalL6XkDdWgC3m1QyHYwwH/nJke3R/tdvxXI9MeyFxQDjo5Gn/JGtW1TD/3BGVd7Ii p+eI9SipxqKZeL8C23nGph/LlsHXy/jHq+HQ8dwOAwjeVJ3IiDQFvGnkib+FZPah4RGd4gHS6 KetPom7A/2J3Z5F5XDDGeijFvIAYkQYOIBe5/ccHW7XwjieBCWCn0gSq0v8NkVz428AYUCWOP f/IYNPZfMsGCYPZHXFMb2OK+ig0J9/NSkIpixzmkcQY/IB/hpqCDMb2NGE/bJGZyPsIzvHsq2 DwE37KZqnY9akc5gRm42udStAewy3dM3SVFb+Q6RYG6YeSCx/E/OylqA1frsCZe/E1QbFUXJE hMQvYzIH57lCSq586//fOLaruyhv252i6sZ/3g== 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: Chengming Gui , Arnd Bergmann , Kevin Wang , linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, Huang Rui , dri-devel@lists.freedesktop.org, Likun Gao , Hawking Zhang Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" A mistake in the error handling caused an uninitialized variable to be used: drivers/gpu/drm/amd/amdgpu/../powerplay/smu_v11_0.c:1102:10: error: variable 'freq' is used uninitialized whenever '?:' condition is false [-Werror,-Wsometimes-uninitialized] ret = smu_get_current_clk_freq_by_table(smu, clk_id, &freq); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/amd/amdgpu/../powerplay/inc/amdgpu_smu.h:880:3: note: expanded from macro 'smu_get_current_clk_freq_by_table' ((smu)->ppt_funcs->get_current_clk_freq_by_table ? (smu)->ppt_funcs->get_current_clk_freq_by_table((smu), (clk_type), (value)) : 0) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/amd/amdgpu/../powerplay/smu_v11_0.c:1114:2: note: uninitialized use occurs here freq *= 100; ^~~~ drivers/gpu/drm/amd/amdgpu/../powerplay/smu_v11_0.c:1102:10: note: remove the '?:' if its condition is always true ret = smu_get_current_clk_freq_by_table(smu, clk_id, &freq); ^ drivers/gpu/drm/amd/amdgpu/../powerplay/inc/amdgpu_smu.h:880:3: note: expanded from macro 'smu_get_current_clk_freq_by_table' ((smu)->ppt_funcs->get_current_clk_freq_by_table ? (smu)->ppt_funcs->get_current_clk_freq_by_table((smu), (clk_type), (value)) : 0) ^ drivers/gpu/drm/amd/amdgpu/../powerplay/smu_v11_0.c:1095:15: note: initialize the variable 'freq' to silence this warning uint32_t freq; ^ = 0 Bail out of smu_v11_0_get_current_clk_freq() before we get there. Fixes: e36182490dec ("drm/amd/powerplay: fix dpm freq unit error (10KHz -> Mhz)") Signed-off-by: Arnd Bergmann --- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c index c3f9714e9047..bd89a13b6679 100644 --- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c +++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c @@ -1099,9 +1099,11 @@ static int smu_v11_0_get_current_clk_freq(struct smu_context *smu, return -EINVAL; /* if don't has GetDpmClockFreq Message, try get current clock by SmuMetrics_t */ - if (smu_msg_get_index(smu, SMU_MSG_GetDpmClockFreq) == 0) + if (smu_msg_get_index(smu, SMU_MSG_GetDpmClockFreq) == 0) { ret = smu_get_current_clk_freq_by_table(smu, clk_id, &freq); - else { + if (ret) + return ret; + } else { ret = smu_send_smc_msg_with_param(smu, SMU_MSG_GetDpmClockFreq, (smu_clk_get_index(smu, clk_id) << 16)); if (ret) From patchwork Mon Jul 8 14:07:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 168652 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp7216233ilk; Mon, 8 Jul 2019 07:08:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqxnenqMmz+nXXKlWSesmk4dN+K0tImFeyDR1J8iDE+JExlcQm34IerQ2IS2FyZ2+y2VtzIs X-Received: by 2002:a17:902:70cc:: with SMTP id l12mr25305291plt.87.1562594916630; Mon, 08 Jul 2019 07:08:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562594916; cv=none; d=google.com; s=arc-20160816; b=kJhFbps7LsFa1YrdUAoIxpY4AcgilIsAQRHARWA9NyPKxgxJ+tr9jjtJomvPm/uhin Q6+weNTukcbQr97D9WydmSPSSbacyI5WskL903gy5mhEj4mSvX/qUNMFH7gCU+2cUw6N I8F0v0iOb+RWYvHnIC1zVmt6ZHpqhS/kl4335joJue23xQ7IMaCHWIplfW+sj4fCjk0u u7vbG0zilG/5VfM1RdthZXNWqWvV3GKO1iuX/0k1cTh+sM2EMMSIuX1OsLmkepKiTuaz /PFnVAI6wqwU/T/Jd+MO+Fh6a+PEve3wC2KSMePADa1RHJkldI4AgaJp+W8kDgNa+sUN yNbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:delivered-to; bh=Uu+zpL3m00XJ+l6TtCGh/Axl5CwY5ZQpgXPYqPW4ncg=; b=s6JZOqPjp+cDTniTQXKPfUyhmhfiwL6iwxbkI8dtwhiObr2ofwVhw6sE9633FUmaO0 DGnzXlkW1oLG+95JaDY0c+Mdt8b8K/A5lFWDx1bZsF2I6w/xNT4Oau8bvc0lGD2nuqK8 6/BJE7TxkbcisECEz4EovF8H9y04BoqXGuGgLMe7NLRo7q27Hkb+1nHswtmvaUZov5Hr Y35YIxvz/Fi9lt5ZzFkB/hsIIVfE6CVHo3G69g0fXtjpda9hb7rFE9tiJXtK+613WJmm wC5QpMBG/TqFlVpCZtYcld33326+TR/Hejnh3CbctynQFOl/6Q534dHbNRMWkberGwVf 93Cg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id 65si19237734ple.240.2019.07.08.07.08.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Jul 2019 07:08:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) 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 57BB389D81; Mon, 8 Jul 2019 14:08:35 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id BAC9689D81 for ; Mon, 8 Jul 2019 14:08:33 +0000 (UTC) Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.145]) with ESMTPA (Nemesis) id 1M89P3-1ho4wp0FFr-005MGd; Mon, 08 Jul 2019 16:08:28 +0200 From: Arnd Bergmann To: Rex Zhu , Evan Quan , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "David (ChunMing) Zhou" , David Airlie , Daniel Vetter Subject: [PATCH 2/2] drm/amd/powerplay: vega20: fix uninitialized variable use Date: Mon, 8 Jul 2019 16:07:59 +0200 Message-Id: <20190708140816.1334640-2-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190708140816.1334640-1-arnd@arndb.de> References: <20190708140816.1334640-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:NyfhK5Y4jz7Zauo0keyLsO1GaKfDaYS9PZtk4wBhZX4qB8ZPG7o XAcUVBB10BKXLj+ZVSeTI0D/l0efVGJTE5jS5oIEgaFpES91kHGCZp7xFl+VVFnyf2qjvYb 2fB+TOUjE1u/eR4fhGyZ2JdQcYLO2UnbqY0jmhrnxJuGyQOSHKgFFx/hNbUk/9FeK4dtLtA Oxe6uhkvKx0J1PnP+d+xQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:ricJjI9sTU0=:jjXRZ80JOXKSZPGfAGrxJK 5MnloyJFczjlnFDwjZoAv0fwMyEViU4SCNoRSWVfTEh0vtq9rHrXy8+CvjNqjl+T61doObwix m3B5FUdbFLzwvqBot8udnBzZkUd7bTCsEPcWYm4kyB5GZCG9FMddxefo+Be04RtMXrb/Ym2Y+ PKpfcLUjN85jnj5vmcw0EJZ7GHa44LWiwS3HJFinSQZDng4N9nH10YapicmaHhS62nJy+s+R8 bL33CgjW9z0+yon2t3LZe9udh3ZRcKpjSKYOUY55qU8wDLQcW8dK4rqdbwqJ2r2/g6HtEoY/v RuIHTcSjnKd+YeMHG2h2DC/OvaABlVnlTBWcyT3p2vfs+Ow+cEZFJUXVg603RYF4EJ5e/dNeu c71aMaqg57jo/MLiiygnDKvAMvOHL2rEnX9nlZFTc22jLWmgaB52K5De7HPIL8evckboAMlec xMRIyvSKQvWuxoRpvFUzRrcNKdl6qwqnG/O7R1Ul+0sAKP+HKT4mfU5HIisPTI69bLKUUWV2K rd7gHOFQSW0dNEOw/wY4Rq/HDso6zIOiQsKwCDWehWy91e1zYwgmdbsDswzQllLmh9xNuDZ38 uwKA6AIUJQs1k1botxu8ysfXcNj3p9ZyAkUMfBjrPTx05zryPWmzNg/x2c4AcK7T1SIfWj9P9 JO9rk5eSeyYbi5CApjYKkYGASvXiEYCdPTRCIGr8wbUgOFSJTSlqaUqAftcbnNAyP+Zx8cf0w 5bTezfc2UNfDfzWUxTUVcMij5exbEFDN9pIcAg== 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: Chengming Gui , Arnd Bergmann , Kevin Wang , linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, Huang Rui , dri-devel@lists.freedesktop.org, Likun Gao , Hawking Zhang Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" If smu_get_current_rpm() fails, we can't use the output, as that may be uninitialized: drivers/gpu/drm/amd/amdgpu/../powerplay/vega20_ppt.c:3023:8: error: variable 'current_rpm' is used uninitialized whenever '?:' condition is false [-Werror,-Wsometimes-uninitialized] ret = smu_get_current_rpm(smu, ¤t_rpm); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/amd/amdgpu/../powerplay/inc/amdgpu_smu.h:735:3: note: expanded from macro 'smu_get_current_rpm' ((smu)->funcs->get_current_rpm ? (smu)->funcs->get_current_rpm((smu), (speed)) : 0) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/amd/amdgpu/../powerplay/vega20_ppt.c:3024:12: note: uninitialized use occurs here percent = current_rpm * 100 / pptable->FanMaximumRpm; ^~~~~~~~~~~ drivers/gpu/drm/amd/amdgpu/../powerplay/vega20_ppt.c:3023:8: note: remove the '?:' if its condition is always true ret = smu_get_current_rpm(smu, ¤t_rpm); ^ drivers/gpu/drm/amd/amdgpu/../powerplay/inc/amdgpu_smu.h:735:3: note: expanded from macro 'smu_get_current_rpm' ((smu)->funcs->get_current_rpm ? (smu)->funcs->get_current_rpm((smu), (speed)) : 0) ^ drivers/gpu/drm/amd/amdgpu/../powerplay/vega20_ppt.c:3020:22: note: initialize the variable 'current_rpm' to silence this warning uint32_t current_rpm; Propagate the error code in that case. Fixes: ee0db82027ee ("drm/amd/powerplay: move PPTable_t uses into asic level") Signed-off-by: Arnd Bergmann --- drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c index 9ce3f1c8ae0f..20d477f8dc84 100644 --- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c +++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c @@ -3021,10 +3021,13 @@ static int vega20_get_fan_speed_percent(struct smu_context *smu, PPTable_t *pptable = smu->smu_table.driver_pptable; ret = smu_get_current_rpm(smu, ¤t_rpm); + if (ret) + return ret; + percent = current_rpm * 100 / pptable->FanMaximumRpm; *speed = percent > 100 ? 100 : percent; - return ret; + return 0; } static int vega20_get_gpu_power(struct smu_context *smu, uint32_t *value)