Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3876742rdh; Tue, 28 Nov 2023 06:17:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IE9AHVDJeWyEMNJtgZZEvFJsup1nui1F2MkEZ55XYOF6RfXhUQUkaf/AfqEDxMeyAMqk6l8 X-Received: by 2002:a17:90b:4a90:b0:280:3cc4:f052 with SMTP id lp16-20020a17090b4a9000b002803cc4f052mr15053161pjb.17.1701181077101; Tue, 28 Nov 2023 06:17:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701181077; cv=none; d=google.com; s=arc-20160816; b=evhfQnrq+PUaEvHYLCAWI+I6daNKX7kJhhQnGudMs0m3fab6vqv8twmswY8JZIjQJ6 +dMw7P5Er2YHIcbwQWXC/Tzwb09JLfOcq25nOuuyqzc2FWw4JBh96w//VZPVFuuVWlG5 FO742zXQUl+wyqIbpKEDoq1ALztGuO/4MGcAMtNgbebVcnoy8MjUhcVf02AYr3HEaO0f mGf7mTMJkeBY6hf8u2F1uIo+ltQElswNpjJFUcTeNghYotFx0sjr3Xag+MYj9tvLutSd YF2sF+/94hdSA2z2EPZy4C6c/HaSx2JfKDxf7NZC9Cm9aepY0yu/piHIOaGm+VViSatG 5sLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=aF6ztooXqvf/8XtRGikrHTo9OtN5bNyDe+pZBn8FJNM=; fh=IXI57RYZJ5ML2GINoWb2R70DHYEZScdvccJy15A0qMs=; b=Ck+pIdHwwQw25lJ8ZT3ebS+mxWxQP/8W5SCNclaUyokXXchYEmEBTiTefalDtSRhTF aPAFru48oKP0sRfXg/0EV16wCY7aLftI2F+LV3M5eJX5Dz6v9y90+qw70cZ51GP30KyT hmtSlHP83BMOl3yURgI5mkibtIF975Gtt0m/9rJ6eP/yn61vxLgLdWKxZHxyu37uqycj lWBwwfljeeuSz5ZrsMJ20nJoaa2vknKq4/P6rzi2wCj8UBOHzu7qiswuDTlAY/c4fxyH Y/SzJxX+9n23v4v5LK8S+HvIRsQJdU2dIo3BaMCsXxTsM1crrwvVzsYXXbTDyXVcjfmg QESw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id n4-20020a17090a9f0400b0027686905e79si12755728pjp.146.2023.11.28.06.17.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 06:17:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id B49898056A06; Tue, 28 Nov 2023 06:17:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346149AbjK1ORa convert rfc822-to-8bit (ORCPT + 99 others); Tue, 28 Nov 2023 09:17:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346077AbjK1OR1 (ORCPT ); Tue, 28 Nov 2023 09:17:27 -0500 Received: from mail-oa1-f43.google.com (mail-oa1-f43.google.com [209.85.160.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 250CBD53; Tue, 28 Nov 2023 06:17:33 -0800 (PST) Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-1fa364b147dso354175fac.1; Tue, 28 Nov 2023 06:17:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701181052; x=1701785852; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IRGoQyo/qsOxZBEdcNrITTBVpKcTeeXC0RVRkpQMWcc=; b=DX+GzVg7G4cnUNM6VX53uBl46XooZGjkdqyEFVM6x9GIohl4sWNz9rDwHDpO++MStb npOwsQcRk+5rYVIL4oFdV6kRkTSNaKKGxJMLJo93k37K5Li4rvEU2r05pXl8jyxkHXmF YZ7oRzO4G1VXaXYrbknZsWtDeAzUlytaeVihNm+EtPXEp1HH9v8kRsl+FNW1rr0F9IXY r37Zz1D+PsGtYaHrvVBy2BW65mMdcS7/+U5Iwj1dr7r5+xoNw1HJ/700pLKiqRZQcY7v VZ5YONfrcUnOZNYBRSROdJDTNNQqFIBTdnhFvzO4GG/pdifP3rDbFqGZx1S552UOtSq8 vqZw== X-Gm-Message-State: AOJu0YzS77xrEHkXWPGZidDFYIqxyJjSXnW0+vX89+eKe2OmuqpEoo20 XJMynQnmpcJUmZMqVvfAIfUlzV5ZX1fJ9s5Op6Smz+Rw X-Received: by 2002:a05:6870:d0a:b0:1f9:5346:2121 with SMTP id mk10-20020a0568700d0a00b001f953462121mr16981047oab.4.1701181052390; Tue, 28 Nov 2023 06:17:32 -0800 (PST) MIME-Version: 1.0 References: <20231127092819.2019744-1-lukasz.luba@arm.com> In-Reply-To: <20231127092819.2019744-1-lukasz.luba@arm.com> From: "Rafael J. Wysocki" Date: Tue, 28 Nov 2023 15:17:21 +0100 Message-ID: Subject: Re: [PATCH] powercap: DTPM: Fix unneeded conversion to micro-Watts To: Lukasz Luba Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, rafael@kernel.org, stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 28 Nov 2023 06:17:51 -0800 (PST) On Mon, Nov 27, 2023 at 10:27 AM Lukasz Luba wrote: > > The Power values coming from the Energy Model are already in uW. > The PowerCap and DTPM framework operate on uW, thus all places should > just use the values from EM. Fix the code which left and still does > the unneeded conversion. > > Fixes: ae6ccaa65038 (PM: EM: convert power field to micro-Watts precision and align drivers) > Cc: # v5.19+ > Signed-off-by: Lukasz Luba > --- > Hi Daniel, > > I have found an issue due to the uW in the EM. My apologies for that. No need to apologize, you are making the code better. > I have check those with the Rockpi dev board with your DTPM module there. > BTW, if you like to check the DTPM_devfreq there, you can apply that > patch. It should create EM for your GPU there and setup DTPM GPU: > https://lore.kernel.org/all/20231127081511.1911706-1-lukasz.luba@arm.com/ > > Regards, > Lukasz > > > drivers/powercap/dtpm_cpu.c | 6 +----- > drivers/powercap/dtpm_devfreq.c | 11 +++-------- > 2 files changed, 4 insertions(+), 13 deletions(-) > > diff --git a/drivers/powercap/dtpm_cpu.c b/drivers/powercap/dtpm_cpu.c > index 2ff7717530bf..8a2f18fa3faf 100644 > --- a/drivers/powercap/dtpm_cpu.c > +++ b/drivers/powercap/dtpm_cpu.c > @@ -24,7 +24,6 @@ > #include > #include > #include > -#include > > struct dtpm_cpu { > struct dtpm dtpm; > @@ -104,8 +103,7 @@ static u64 get_pd_power_uw(struct dtpm *dtpm) > if (pd->table[i].frequency < freq) > continue; > > - return scale_pd_power_uw(pd_mask, pd->table[i].power * > - MICROWATT_PER_MILLIWATT); > + return scale_pd_power_uw(pd_mask, pd->table[i].power); > } > > return 0; > @@ -122,11 +120,9 @@ static int update_pd_power_uw(struct dtpm *dtpm) > nr_cpus = cpumask_weight(&cpus); > > dtpm->power_min = em->table[0].power; > - dtpm->power_min *= MICROWATT_PER_MILLIWATT; > dtpm->power_min *= nr_cpus; > > dtpm->power_max = em->table[em->nr_perf_states - 1].power; > - dtpm->power_max *= MICROWATT_PER_MILLIWATT; > dtpm->power_max *= nr_cpus; > > return 0; > diff --git a/drivers/powercap/dtpm_devfreq.c b/drivers/powercap/dtpm_devfreq.c > index 91276761a31d..612c3b59dd5b 100644 > --- a/drivers/powercap/dtpm_devfreq.c > +++ b/drivers/powercap/dtpm_devfreq.c > @@ -39,10 +39,8 @@ static int update_pd_power_uw(struct dtpm *dtpm) > struct em_perf_domain *pd = em_pd_get(dev); > > dtpm->power_min = pd->table[0].power; > - dtpm->power_min *= MICROWATT_PER_MILLIWATT; > > dtpm->power_max = pd->table[pd->nr_perf_states - 1].power; > - dtpm->power_max *= MICROWATT_PER_MILLIWATT; > > return 0; > } > @@ -54,13 +52,10 @@ static u64 set_pd_power_limit(struct dtpm *dtpm, u64 power_limit) > struct device *dev = devfreq->dev.parent; > struct em_perf_domain *pd = em_pd_get(dev); > unsigned long freq; > - u64 power; > int i; > > for (i = 0; i < pd->nr_perf_states; i++) { > - > - power = pd->table[i].power * MICROWATT_PER_MILLIWATT; > - if (power > power_limit) > + if (pd->table[i].power > power_limit) > break; > } > > @@ -68,7 +63,7 @@ static u64 set_pd_power_limit(struct dtpm *dtpm, u64 power_limit) > > dev_pm_qos_update_request(&dtpm_devfreq->qos_req, freq); > > - power_limit = pd->table[i - 1].power * MICROWATT_PER_MILLIWATT; > + power_limit = pd->table[i - 1].power; > > return power_limit; > } > @@ -110,7 +105,7 @@ static u64 get_pd_power_uw(struct dtpm *dtpm) > if (pd->table[i].frequency < freq) > continue; > > - power = pd->table[i].power * MICROWATT_PER_MILLIWATT; > + power = pd->table[i].power; > power *= status.busy_time; > power >>= 10; > > -- Applied as 6.7-rc material, thanks!