Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp623921pxj; Thu, 10 Jun 2021 08:48:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuYQEsbv97d+JVtE2sJ2ClhKC/pxEHX5mS+81RlcA2b2+D2Mp/RbI42rly16LQhPUuw140 X-Received: by 2002:a17:906:914f:: with SMTP id y15mr253922ejw.354.1623340131705; Thu, 10 Jun 2021 08:48:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623340131; cv=none; d=google.com; s=arc-20160816; b=gGnp8ziE+e950jri19EEi3ejE2KSCSjJs1Gc1ZHajJCrY4Hnsvpabf8MD7nQkkSra5 55xGKVudhWCRUP/cWol1e5dJlg32Y8xr+055S+G3jP0g/e41Wdzrj88DVCCYlvuKxwZC xFXA/ZXPbldcw8cf4ITFu/f44ubthGKiqc8d5JptpNLUrOECZAkuFDIcqHcjEsd63ml0 hIN8r69qFqYon+PumLWoEYtFcK/YElW3bEwY+ERwKmBi8rqDHmhArGETNhVZPiaAHefH QHVeVwIsqlKU/HmDg9Wp5gHldusDv/2h+GPnmzQSGrOG+j8TnPUAcFwFZzayM95NhoPY yi8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=bIkOC7ijnAkY9Mv5y+9kSysZ6u0yFrSnVrFQUWyVl0k=; b=LfOMJromqlfzb/JQgReHNpRFUeSMXbsyXGe6JEQSLbKDqRdp8XBLxwD8Q5UnY0DJxn yD4HbfxA24fbRTzAbiBKDwUjBoQdGjSDP6Dms2CwHcVscAmA0V5aaWta9Sa3HK02hNmM +JAwjrgFbgg8RmaeQjdpPbCHJgf3zim/Htz3xW2m7/Jz6B/4b59TAGP2u72CIKEhiNAM OaiuEydjv2pqIa8voqGotHEbXO/w7e+JmxgIwsvKoMqB/7xv/CkZSyWYYKspuvn4LAMI B2Ca0X4KHPc6MyhMsXOfmzEdpekCXWlQeyfxiGAVwBZ2ZZ2+MVEypm3LEJHiDKhuvRD5 LmGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="PoYNHPf/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nc38si3231933ejc.36.2021.06.10.08.48.28; Thu, 10 Jun 2021 08:48:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="PoYNHPf/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231822AbhFJPr7 (ORCPT + 99 others); Thu, 10 Jun 2021 11:47:59 -0400 Received: from mail-oi1-f174.google.com ([209.85.167.174]:43598 "EHLO mail-oi1-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231789AbhFJPrF (ORCPT ); Thu, 10 Jun 2021 11:47:05 -0400 Received: by mail-oi1-f174.google.com with SMTP id x196so2566613oif.10 for ; Thu, 10 Jun 2021 08:44:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bIkOC7ijnAkY9Mv5y+9kSysZ6u0yFrSnVrFQUWyVl0k=; b=PoYNHPf/2yuR5K/nzjrK6zwk0D4OD9xdvf7Py80pXwPb5pQTwpnWUb/UmeC49+VD9k 8jyk2PS5KwoZXvKxZcIf5lnopBxandWalBuxXJ3JuiC/vRN5aQK7PwfM9B0dU/ZkaYQo NTgcCS4uI9If9wkCr73EkhnJBZLYw3l+WKS2bfJuoHdpbAysYLLZqMThyvijKJt39uRC KLemQgY0EXkvGHgxIyxalj5XyyKC8JCd+i62eoHNmvjOiA9e/9w/9/5ZtxXqISusrwdv 8TMSzD9kESyYjbGqEBnskid1PlTrV8tvsFGCvHS+lVMm/HoDBWGeBcqQ6TwAqRwnwnq2 FQdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bIkOC7ijnAkY9Mv5y+9kSysZ6u0yFrSnVrFQUWyVl0k=; b=fEBorsa4TpC1I2c8hvV8cE84kcR7hzYBogPVIGCCUoH/EFxde+jo0IlwRfFwF2ZTV9 0JMR/Yi4IpoRXBOYv3IluDY+pEC0hPj0bnArdz+ILMg3wraD1RseRhEimp2xaZzDWrXe xEIZuBfAOQWBVvHcB0qQ5VtJGhRZf5zoOhMv1z3rHeQMImJdO6Nc6sg3gWm1LV8TkjmN RoCbIOwiserkOrny4uDkQTQu4qHLsUx1En1Idqf+qBVEkrS3RVVkK30pJl5U3Q+ew4gZ 7sIeOB5MV6lhWk7qbWND5JQZItfd6tVcPKVOT2SZXha8pAfKFPuproWcvR1M1F4ZPIXZ y7UA== X-Gm-Message-State: AOAM533MeuGj+LjnZfckM0XHCKUNx28YV3azCsOMEBaOhSUo62vfnu1U zWmOxPrD3vZx+mqokbuCtxB23elp9L1980AfWs80Lw== X-Received: by 2002:a54:408b:: with SMTP id i11mr3984419oii.132.1623339832419; Thu, 10 Jun 2021 08:43:52 -0700 (PDT) MIME-Version: 1.0 References: <548dd463-3942-00a1-85c3-232897dea1a3@canonical.com> <162332615476.15946.17135355064135638083@jlahtine-mobl.ger.corp.intel.com> In-Reply-To: <162332615476.15946.17135355064135638083@jlahtine-mobl.ger.corp.intel.com> From: Jesse Barnes Date: Thu, 10 Jun 2021 08:43:40 -0700 Message-ID: Subject: Re: Computation of return value being discarded in get_cpu_power() in drivers/platform/x86/intel_ips.c To: Joonas Lahtinen Cc: Hans de Goede , Colin Ian King , Jani Nikula , Mark Gross , Rodrigo Vivi , platform-driver-x86@vger.kernel.org, intel-gfx@lists.freedesktop.org, "dri-devel@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Arg html email sorry. Resending plain text: It may be ok to drop this driver entirely now too; I doubt anyone is relying on GPU turbo in Ironlake for anything critical anymore. That would allow for some simplifications in i915 too if it's still supported. On Thu, Jun 10, 2021 at 4:56 AM Joonas Lahtinen wrote: > > (Address for Hans was corrupt in previous message, which confused my mail > client. Sorry for duplicate message, the other is without From: field). > > + Jesse > > Quoting Colin Ian King (2021-06-09 14:50:07) > > Hi, > > > > I was reviewing some old unassigned variable warnings from static > > analysis by Coverity and found an issue introduced with the following > > commit: > > > > commit aa7ffc01d254c91a36bf854d57a14049c6134c72 > > Author: Jesse Barnes > > Date: Fri May 14 15:41:14 2010 -0700 > > > > x86 platform driver: intelligent power sharing driver > > > > The analysis is as follows: > > > > drivers/platform/x86/intel_ips.c > > > > 871 static u32 get_cpu_power(struct ips_driver *ips, u32 *last, int period) > > 872 { > > 873 u32 val; > > 874 u32 ret; > > 875 > > 876 /* > > 877 * CEC is in joules/65535. Take difference over time to > > 878 * get watts. > > 879 */ > > 880 val = thm_readl(THM_CEC); > > 881 > > 882 /* period is in ms and we want mW */ > > 883 ret = (((val - *last) * 1000) / period); > > > > Unused value (UNUSED_VALUE) > > assigned_value: Assigning value from ret * 1000U / 65535U to ret here, > > but that stored value is not used. > > > > 884 ret = (ret * 1000) / 65535; > > 885 *last = val; > > 886 > > 887 return 0; > > 888 } > > > > I'm really not sure why ret is being calculated on lines 883,884 and not > > being used. Should that be *last = ret on line 885? Looks suspect anyhow. > > According to git blame code seems to have been disabled intentionally by the > following commit: > > commit 96f3823f537088c13735cfdfbf284436c802352a > Author: Jesse Barnes > Date: Tue Oct 5 14:50:59 2010 -0400 > > [PATCH 2/2] IPS driver: disable CPU turbo > > The undocumented interface we're using for reading CPU power seems to be > overreporting power. Until we figure out how to correct it, disable CPU > turbo and power reporting to be safe. This will keep the CPU within default > limits and still allow us to increase GPU frequency as needed. > > Maybe wrap the code after thm_readl() in #if 0 in case somebody ends up > wanting to fix it? Or eliminate completely. > > In theory the thm_readl() may affect the system behavior so would not > remove that for extra paranoia. > > Regards, Joonas > > > Colin > > > >