From patchwork Mon Jun 17 12:51:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10999223 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 0419814B6 for ; Mon, 17 Jun 2019 12:57:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5EED2870B for ; Mon, 17 Jun 2019 12:57:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E41CB28905; Mon, 17 Jun 2019 12:57:39 +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,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 8B1A72870B for ; Mon, 17 Jun 2019 12:57:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8A37F89070; Mon, 17 Jun 2019 12:57:37 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 308 seconds by postgrey-1.36 at gabe; Mon, 17 Jun 2019 12:57:35 UTC Received: from mout.kundenserver.de (mout.kundenserver.de [217.72.192.75]) by gabe.freedesktop.org (Postfix) with ESMTPS id A81F689070; Mon, 17 Jun 2019 12:57:35 +0000 (UTC) Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.145]) with ESMTPA (Nemesis) id 1MGQax-1hquxU2lVF-00GtQn; Mon, 17 Jun 2019 14:52:21 +0200 From: Arnd Bergmann To: Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "David (ChunMing) Zhou" , David Airlie , Daniel Vetter Subject: [PATCH] drm/amdgpu: fix error handling in df_v3_6_pmc_start Date: Mon, 17 Jun 2019 14:51:45 +0200 Message-Id: <20190617125216.1439481-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:4mjJ8DAUrqD7K3ik9JFh1A+imhzojGmM2U9nkMvmJroglwtNgbR uxEfBJoTHVzu13ZhwrwgrM6e38j8pBnDFOSIiI6NVnDb1AKXjj0XsHb5SZ/o7weXZmpJGRK b4RW1+baqU8jtxvfNE0f+7TvDXfTL6sFCl743HK4GE7P7xPMc6wEvBvoJ20HXf3fpOmJcaw UGpQSQaK/Das93ZAx0ETg== X-UI-Out-Filterresults: notjunk:1;V03:K0:K9o8oUbrj80=:KVjf1d+To1N+ESBrsaWTas lPANsTk1ogkH+SUoe3yMQ/3rmU3trfSDWPT2li66fkaqk+rz2VaLU09xqjZvDi2WGhtK2RQRi XBaMKaNdD0pvGhqmk1YMMnOAjfusIEhlw+iY775Ph44YJw286kN5PGLa/1Fkhrsrm7NuV0z6A NDl5tsEI071b2sh8lzew3is0A0lCbEywEwD2KlSZuUtlqmltCY9TGZneUmbVyEnXUV9u5rIwD pJ0vv6/JX5G5n7hzSYUClrKNIemVZXOKXE05sCVA93QFfqQQHUzUKlTkXkXA0Y60mmay42YNZ Icbljq1BrJGxZ8xa2RLi5KlemvMIWltiRDT/CfmhscV3SIMFPjO+0YDs6A4VbWX3O6NoFVNye 80d/3OFwaOC/ZF5xsv21dRey9hwLCRxjxLoVUL/yg74IXAva2MjDegW4FGvK2r5cTmZJ5zgOq PldhfSOJpF4y1gd/jxnZFY0u+uusG4rG1vnjUzQ5Gr05jZydwgR8JD2jHhaI4EnwW50nGQqNQ GVpTPehCfu8vBkzSFTUM7av5hEYwesSWSO+8s8igoh0uLE9B/R1wAphIRCOH8Ue69iy2xMH5o rlkvmRcK3rBNv2zyTqAjPRQhnLXJAFvMBfSb8QfByMNyfHg/UO0TiJv2FUdd8RTV+RiAnAUkj gWanXI6sXLXbYHDgxi7HjqPR+BZipdQMjR3ZcTnQHD5+6y30ZTv5Hk5SG2x5hiICGAxr7V3IL vfKJjSPVGF+TC5lEPQmQgBPsqLjr2dRoW/4heQ== 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: Jonathan Kim , Arnd Bergmann , linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Colin Ian King , Evan Quan Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP When df_v3_6_pmc_get_ctrl_settings() fails for some reason, we store uninitialized data in a register, as gcc points out: drivers/gpu/drm/amd/amdgpu/df_v3_6.c: In function 'df_v3_6_pmc_start': drivers/gpu/drm/amd/amdgpu/amdgpu.h:1012:29: error: 'lo_val' may be used uninitialized in this function [-Werror=maybe-uninitialized] #define WREG32_PCIE(reg, v) adev->pcie_wreg(adev, (reg), (v)) ^~~~ drivers/gpu/drm/amd/amdgpu/df_v3_6.c:334:39: note: 'lo_val' was declared here uint32_t lo_base_addr, hi_base_addr, lo_val, hi_val; ^~~~~~ Make it return a proper error code that we can catch in the caller. Fixes: 992af942a6cf ("drm/amdgpu: add df perfmon regs and funcs for xgmi") Signed-off-by: Arnd Bergmann --- drivers/gpu/drm/amd/amdgpu/df_v3_6.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/df_v3_6.c b/drivers/gpu/drm/amd/amdgpu/df_v3_6.c index 8c09bf994acd..e079ee066d87 100644 --- a/drivers/gpu/drm/amd/amdgpu/df_v3_6.c +++ b/drivers/gpu/drm/amd/amdgpu/df_v3_6.c @@ -177,7 +177,7 @@ static void df_v3_6_pmc_get_read_settings(struct amdgpu_device *adev, } /* get control counter settings i.e. address and values to set */ -static void df_v3_6_pmc_get_ctrl_settings(struct amdgpu_device *adev, +static int df_v3_6_pmc_get_ctrl_settings(struct amdgpu_device *adev, uint64_t config, uint32_t *lo_base_addr, uint32_t *hi_base_addr, @@ -191,12 +191,12 @@ static void df_v3_6_pmc_get_ctrl_settings(struct amdgpu_device *adev, df_v3_6_pmc_get_addr(adev, config, 1, lo_base_addr, hi_base_addr); if (lo_val == NULL || hi_val == NULL) - return; + return -EINVAL; if ((*lo_base_addr == 0) || (*hi_base_addr == 0)) { DRM_ERROR("DF PMC addressing not retrieved! Lo: %x, Hi: %x", *lo_base_addr, *hi_base_addr); - return; + return -ENXIO; } eventsel = GET_EVENT(config); @@ -211,6 +211,8 @@ static void df_v3_6_pmc_get_ctrl_settings(struct amdgpu_device *adev, es_7_0 = es_13_0 & 0x0FFUL; *lo_val = (es_7_0 & 0xFFUL) | ((unitmask & 0x0FUL) << 8); *hi_val = (es_11_8 | ((es_13_12)<<(29))); + + return 0; } /* assign df performance counters for read */ @@ -345,13 +347,16 @@ static int df_v3_6_add_xgmi_link_cntr(struct amdgpu_device *adev, if (ret || is_assigned) return ret; - df_v3_6_pmc_get_ctrl_settings(adev, + ret = df_v3_6_pmc_get_ctrl_settings(adev, config, &lo_base_addr, &hi_base_addr, &lo_val, &hi_val); + if (ret) + return ret; + WREG32_PCIE(lo_base_addr, lo_val); WREG32_PCIE(hi_base_addr, hi_val);