Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp1023944rdf; Sat, 4 Nov 2023 03:59:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHZ3GFh0scyVGhpcVulAKCYO3qvMVNeYFUqYamLF8RGyqe839x+R1URsIHlIsv4272LVJ45 X-Received: by 2002:a92:cd8d:0:b0:357:4a63:2ad2 with SMTP id r13-20020a92cd8d000000b003574a632ad2mr33134006ilb.21.1699095567514; Sat, 04 Nov 2023 03:59:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699095567; cv=none; d=google.com; s=arc-20160816; b=jddfTReZd3DxfLmeZnW12LsZrxxlxgVNLoOsV1sqrNQeDN6WxoD/rYiQapRvCpQAwK hdpRzRSYUZ7itYqcDF6V028ZJgWfHPXhhq1viJqjV0x2GK+e5ZKGG3h0RSvGcNUEGboB jBTTiNYAjVAjwGoDH/utFo/Q82sVhJPXkRmCH9wvuqFbQHPH9Gc6dolGh+1IZqmkgalz uTycizaSlj22EiNreqsm0+6sVJjQFppKhSw6/JwmuWlD4nkAyWJdKW9EzPYq1zD2kTlc wN2L0WzNp+T9pL1Zm17aqiY3YWVtFrNa/o6tB1zXykrcA46Iy3gs+6k1ShR2Om72GzK8 QNZg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TkZaHixUrwPrJIZcMAT2UI1CVMoJazwhG5L/qYNHDpM=; fh=L/x1gaxbgFaXxO89heY0nsloKarclpkg/B6XUTvdMKw=; b=Oo1CfieBfDzkeQ8SdTVTVKSwXGCIxNOhGULx/cMedUgtqO+JuGxKzIGtbmQsgCeNO7 FN6mMgqBIE9DJA2vU4XrRh9D9ZF4x+V10SHRvm3VUeGca0hfIoojOEr3ubyxbbrH8XOs s54+cxiG7pva9qyjCT0t4zaa+eNUftrHagAjFDIbb+MpWSAS/J9Ji7p35tetdhRzkQs5 0iB0hrtN3H6iHknf5Iib4eKb6I8V8/xzye1v88HO159hhUqFsHLkokyjJaLTTCCKTqsc QYjlZ1hnbrfHR1mwf0krHeGB5pfYTl0WhKnyyV5955zisaC+G9V5e85qk1Y2HsNWKmc7 MpfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="OLJZ/NAf"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id i9-20020a17090332c900b001ca335f71bbsi3745534plr.140.2023.11.04.03.59.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 03:59:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="OLJZ/NAf"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 8707B80425AD; Sat, 4 Nov 2023 03:59:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232025AbjKDK7Y (ORCPT + 99 others); Sat, 4 Nov 2023 06:59:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231991AbjKDK7U (ORCPT ); Sat, 4 Nov 2023 06:59:20 -0400 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00EACD48 for ; Sat, 4 Nov 2023 03:59:16 -0700 (PDT) Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2c5b7764016so38768821fa.1 for ; Sat, 04 Nov 2023 03:59:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699095555; x=1699700355; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TkZaHixUrwPrJIZcMAT2UI1CVMoJazwhG5L/qYNHDpM=; b=OLJZ/NAf4ZEf45K0m9be9tlxklipxKiEah3Lfiw9MRb55oJkvQevIb88wp9EAb2egV ZlzaMnhwvzTIl/PpPCD9eNcJAv6QEb0PimPNwsV7wGNPZ+zGz6HqUj5ZaIJdcRDe4U2n n33vMenx3zLynMJvznF38JJXbmc90bRyw4vYBufEza0/Wafj5aMcmYn83AVXJ3QsaUgL D4AUVBUS39tmQZd8mHslkvW5yZNqbsEx2svupRPqvgeMbkJsMI84dp5rAtyr8FkxZDWd mNwb63WHrjHrSpKHSPEWQ4fm07zIGKGIn2XJvmucFkIO7AKhLIyLbYwY24f8af0Bh8RO wQKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699095555; x=1699700355; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TkZaHixUrwPrJIZcMAT2UI1CVMoJazwhG5L/qYNHDpM=; b=BeOKFG0VvOsYjFfzuzoKrthCxSLV9BsY96veJAT++j2ZliGeGskI//Cku9tLxSb90O 7I3Pgm51N3YOePKEMfq5clVJtgAKhpTpnCQzhrAvzXelH8BzD6hZFD8Y2Q/Op3xbtBQF rGkA+saB7YYQJGIr2rfdKQqHn4H6tETqV9zalbWyh7VZQw5x3rrskyVgWcyM6QgUDWDt ZF0v4PyMD/mHxBMRjJSN4RYjg/jQ6dE8DzR0RBm98LorGHIMa2/1yTNvR3oxHxgdCDFA 9BMOPfmOYk9fdTy65dTVZ/3DJE0rBt/QfzzZb5awOEW9+j07IOydmQ7+48IBYlf6Gy0j ITzQ== X-Gm-Message-State: AOJu0Yw6FZvMkBLkVLJaHuiSeFA6wygAa0eOg1W73qmDYQTH/MgYwt2m /vo4kq+iEDKxCqTYb/sVh5evtg== X-Received: by 2002:a2e:7a17:0:b0:2c2:a337:5ea with SMTP id v23-20020a2e7a17000000b002c2a33705eamr19234202ljc.27.1699095555017; Sat, 04 Nov 2023 03:59:15 -0700 (PDT) Received: from vingu-book.. ([2a01:e0a:f:6020:3172:eb13:5bac:126a]) by smtp.gmail.com with ESMTPSA id p6-20020a05600c358600b004053a6b8c41sm5315809wmq.12.2023.11.04.03.59.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 03:59:14 -0700 (PDT) From: Vincent Guittot To: linux@armlinux.org.uk, catalin.marinas@arm.com, will@kernel.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, sudeep.holla@arm.com, gregkh@linuxfoundation.org, rafael@kernel.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, viresh.kumar@linaro.org, lenb@kernel.org, robert.moore@intel.com, lukasz.luba@arm.com, ionela.voinescu@arm.com, pierre.gondois@arm.com, beata.michalska@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org Cc: conor.dooley@microchip.com, suagrfillet@gmail.com, ajones@ventanamicro.com, lftan@kernel.org, Vincent Guittot Subject: [PATCH v5 2/7] cpufreq: Use the fixed and coherent frequency for scaling capacity Date: Sat, 4 Nov 2023 11:59:02 +0100 Message-Id: <20231104105907.1365392-3-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231104105907.1365392-1-vincent.guittot@linaro.org> References: <20231104105907.1365392-1-vincent.guittot@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Sat, 04 Nov 2023 03:59:26 -0700 (PDT) cpuinfo.max_freq can change at runtime because of boost as an example. This implies that the value could be different from the frequency that has been used to compute the capacity of a CPU. The new arch_scale_freq_ref() returns a fixed and coherent frequency that can be used to compute the capacity for a given frequency. Signed-off-by: Vincent Guittot Acked-by: Viresh Kumar Reviewed-by: Lukasz Luba Tested-by: Lukasz Luba Acked-by: Rafael J. Wysocki --- drivers/cpufreq/cpufreq.c | 4 ++-- include/linux/cpufreq.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 60ed89000e82..8c4f9c2f9c44 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -454,7 +454,7 @@ void cpufreq_freq_transition_end(struct cpufreq_policy *policy, arch_set_freq_scale(policy->related_cpus, policy->cur, - policy->cpuinfo.max_freq); + arch_scale_freq_ref(policy->cpu)); spin_lock(&policy->transition_lock); policy->transition_ongoing = false; @@ -2174,7 +2174,7 @@ unsigned int cpufreq_driver_fast_switch(struct cpufreq_policy *policy, policy->cur = freq; arch_set_freq_scale(policy->related_cpus, freq, - policy->cpuinfo.max_freq); + arch_scale_freq_ref(policy->cpu)); cpufreq_stats_record_transition(policy, freq); if (trace_cpu_frequency_enabled()) { diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 71d186d6933a..738dcddf3cfe 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -1211,6 +1211,7 @@ void arch_set_freq_scale(const struct cpumask *cpus, { } #endif + /* the following are really really optional */ extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs; extern struct freq_attr cpufreq_freq_attr_scaling_boost_freqs; -- 2.34.1