From patchwork Fri Oct 14 15:13:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Deucher X-Patchwork-Id: 9376939 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D6C88607FD for ; Fri, 14 Oct 2016 15:13:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEB752A6DD for ; Fri, 14 Oct 2016 15:13:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B16322A769; Fri, 14 Oct 2016 15:13:50 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 2C26F2A6DD for ; Fri, 14 Oct 2016 15:13:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1F5A66E119; Fri, 14 Oct 2016 15:13:45 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yw0-x233.google.com (mail-yw0-x233.google.com [IPv6:2607:f8b0:4002:c05::233]) by gabe.freedesktop.org (Postfix) with ESMTPS id DA4736E119 for ; Fri, 14 Oct 2016 15:13:42 +0000 (UTC) Received: by mail-yw0-x233.google.com with SMTP id w3so76330496ywg.1 for ; Fri, 14 Oct 2016 08:13:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=a6sx803nluIOoZiEsJEi6QMuPgoyvL1jrH1Q4qFJIjs=; b=a3q8zqzLgSHeI5QcWPQS07UWLLVRD3h9V3N9gv38BN2G9+211paFeUFc+/LR/84k3Z 2aGV/5hHG03XoC7Cl8mDLswE7c4ygTYUmPYQc7FNiooo0SOjFfI601vtW406LkWAeJk1 Fr81hwVcMPgGvHo7ezQZCiqAs8W1CLvPQq1j1jYaMiC/UneW3FQWJkAr9Z6lS3JSTTFz gM3o0fQPQvLi7zJaxqrZ5JrosMy6OrUH2dOvB5oDFlrpC+xIxzN8/zlTHASPKlUQMkCi z9glgOF5oZmRpEUDo5NGjMaBnOnStFJOKL5ZHOlEpEiyIAyV20ZIVvBu4RQWnS7gxeFE TNJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=a6sx803nluIOoZiEsJEi6QMuPgoyvL1jrH1Q4qFJIjs=; b=Yzs9U4i9w4s8cMf5BAd3h8/1prg2Vj0QhU3CVdOxaDHMDWvkAAkTBqfTIVIe8Eng7h e0yKtFsnq0pDl5mSK674CZprQuXpw63YLbz4y58Bb42SeEQpUoZEI0rbzG0Q5lyro0iB FOIFikBnjaWEt6BDCKiwPhxe/UJaQxSYdAkfKILJj5KdGjOl3z9DOgCKc84v5cutslsB 91OMLkVHhnWWorCdvfKJf4WxOqkLabkIb25YH20/0wtdsOqJI8UQ4j3j0x/jn3aMuOpA Nu+fg6di3eZm30+JkCy1sfBFtkLMJbqNJRBpbV0X2xGDcwLa7vO5DupXOgGA4tHw8qq/ uQHw== X-Gm-Message-State: AA6/9RkQRAL/Wy5jncThSFGCZmt4JjluiOkC7X+SpBsVZMfGqUNAzKLYSXF0iYhCklDtjz21RwSFjkEjTavAqw== X-Received: by 10.129.80.68 with SMTP id e65mr12147497ywb.111.1476458022019; Fri, 14 Oct 2016 08:13:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.37.90.85 with HTTP; Fri, 14 Oct 2016 08:13:41 -0700 (PDT) In-Reply-To: <20161014143250.GA32671@mwanda> References: <20161014143250.GA32671@mwanda> From: Alex Deucher Date: Fri, 14 Oct 2016 11:13:41 -0400 Message-ID: Subject: Re: [bug report] drm/amd/powerplay: implement smu7 hwmgr to manager asics with smu ip version 7. To: Dan Carpenter Cc: Rex Zhu , Maling list - DRI developers X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP On Fri, Oct 14, 2016 at 10:32 AM, Dan Carpenter wrote: > Hello Rex Zhu, > > The patch 599a7e9fe1b6: "drm/amd/powerplay: implement smu7 hwmgr to > manager asics with smu ip version 7." from Sep 9, 2016, leads to the > following static checker warning: > > drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/smu7_hwmgr.c:2125 smu7_patch_limits_vddc() > warn: passing casted pointer '&tab->vddc' to 'smu7_patch_ppt_v0_with_vdd_leakage()' 16 vs 32. > > drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/smu7_hwmgr.c > 2119 static int smu7_patch_limits_vddc(struct pp_hwmgr *hwmgr, > 2120 struct phm_clock_and_voltage_limits *tab) > 2121 { > 2122 struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend); > 2123 > 2124 if (tab) { > 2125 smu7_patch_ppt_v0_with_vdd_leakage(hwmgr, (uint32_t *)&tab->vddc, > 2126 &data->vddc_leakage); > > This call corrupts vddci. > > 2127 smu7_patch_ppt_v0_with_vdd_leakage(hwmgr, (uint32_t *)&tab->vddci, > 2128 &data->vddci_leakage); > > But that's fine since we immediately overwrite it here. But > unfortunately this call corrupt tab->vddgfx. Thanks. Should be fixed in the attached patch. Alex > > 2129 } > 2130 > 2131 return 0; > 2132 } > > regards, > dan carpenter > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel From 2e94250b99ceb556335a34a01ea9d36cd9ce6cec Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Fri, 14 Oct 2016 11:11:06 -0400 Subject: [PATCH] drm/amdgpu/powerplay/smu7: fix static checker warning Casting of voltage values to a larger size results in overwriting adjacent memory in the structure. Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c index 7fba97e..11df7b2 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c @@ -2133,15 +2133,18 @@ static int smu7_patch_acp_vddc(struct pp_hwmgr *hwmgr, } static int smu7_patch_limits_vddc(struct pp_hwmgr *hwmgr, - struct phm_clock_and_voltage_limits *tab) + struct phm_clock_and_voltage_limits *tab) { + uint32_t vddc, vddci; struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend); if (tab) { - smu7_patch_ppt_v0_with_vdd_leakage(hwmgr, (uint32_t *)&tab->vddc, - &data->vddc_leakage); - smu7_patch_ppt_v0_with_vdd_leakage(hwmgr, (uint32_t *)&tab->vddci, - &data->vddci_leakage); + smu7_patch_ppt_v0_with_vdd_leakage(hwmgr, &vddc, + &data->vddc_leakage); + tab->vddc = vddc; + smu7_patch_ppt_v0_with_vdd_leakage(hwmgr, &vddci, + &data->vddci_leakage); + tab->vddci = vddci; } return 0; -- 2.5.5