Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp2899739rdh; Mon, 27 Nov 2023 01:28:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IFh/sBQd0Ycigya8zv7dTjAEqv34ahrl3FW1+iCeHtkbkJxzI8HcCjhWjUS20s4pojbMlyK X-Received: by 2002:a05:6a20:7da0:b0:159:c07d:66f0 with SMTP id v32-20020a056a207da000b00159c07d66f0mr15617151pzj.6.1701077286446; Mon, 27 Nov 2023 01:28:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701077286; cv=none; d=google.com; s=arc-20160816; b=vZdoVCW1wWTQcRcgi2TO9dI0gfXzZjD1nygMXW58p6KTvR8XLVqLJ412OuXqfdWUy2 HiKUA9T24W4NxAlwxTblmg1YNrigH0508KusK/up7Dq0jEVgKfO9ZGRAl24x+z40KiWl BASAfihcVYYTV13G+CHjS2o6aEMdD4ZwgWY0iLhCTcunEFhGhGigIVLsi5d60H6s6He+ JWEvRFpFE0DpBTwfZIl1aSWXCXhlM+IGiEbT4RQxnAixuUZX1sIsYD5tA1oylscPgdJj Kpkb9EfNZ2rfQlV0WbgfuNaMREejpSVKhBao8IHA9jNn6Fy4mOSseqYuty37Pb6D1fPX j59g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=TCUmb6d6nEPm3BC31J59W/dg0d21h9YXirYCVIeEXAU=; fh=wqO7u5A9/rR/UsU8jnk5sOW6o7v6l0E9WElXNJFmDXA=; b=bM1mjBVxaPKCAcmO9NMDcNLpIc1BGZD+O7xaKr+GUduqz52vsENsJZRjvuIvhO/LGt RFnXbJc95hmk4kqeS5sXMdElWNqTHtHnyKUjkfF5cWDjboXr2wwz+CKVkY9RCfkAAzj+ +ZhUlDxt/F6P3n/v0viHGrXSOQqU703pkYAA32eMo4Ik+Jl7ubSLG6RywhI7/kuV47wO HVbwyAYRnb2KRiYVbHOFpxH5HYMGWiXIcyxmztuArC4+XsPYvOHu1ZXWrjmFEG3SM+fs uYQs1sacHplMGEVcQgAh5sYhKHRNxUcejLkUuFzPnRdD857kMOiQtNjWabIeqQH6ANHL 8pqg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id w2-20020a056a0014c200b006b1fb740866si9440689pfu.189.2023.11.27.01.28.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 01:28:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 0A1638054BDE; Mon, 27 Nov 2023 01:28:04 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232721AbjK0J1q (ORCPT + 99 others); Mon, 27 Nov 2023 04:27:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232790AbjK0J1o (ORCPT ); Mon, 27 Nov 2023 04:27:44 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 892EC1A5; Mon, 27 Nov 2023 01:27:50 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BC9AE2F4; Mon, 27 Nov 2023 01:28:37 -0800 (PST) Received: from e129166.arm.com (unknown [10.57.4.90]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0A7E63F6C4; Mon, 27 Nov 2023 01:27:48 -0800 (PST) From: Lukasz Luba To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org Cc: lukasz.luba@arm.com, rafael@kernel.org, stable@vger.kernel.org Subject: [PATCH] powercap: DTPM: Fix unneeded conversion to micro-Watts Date: Mon, 27 Nov 2023 09:28:19 +0000 Message-Id: <20231127092819.2019744-1-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, 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 howler.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 (howler.vger.email [0.0.0.0]); Mon, 27 Nov 2023 01:28:04 -0800 (PST) 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. 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; -- 2.25.1