From nobody Tue Dec 16 05:40:59 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 110CBC4167B for ; Mon, 11 Dec 2023 10:49:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234446AbjLKKt0 (ORCPT ); Mon, 11 Dec 2023 05:49:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234314AbjLKKtS (ORCPT ); Mon, 11 Dec 2023 05:49:18 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16C51E8 for ; Mon, 11 Dec 2023 02:49:10 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-33334480eb4so4917935f8f.0 for ; Mon, 11 Dec 2023 02:49:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702291749; x=1702896549; 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=+sZ8kiVgSDpOUyXf2RtOeDFCi7Cs5gC6EpwhZGADvk4=; b=Y2IvZdIbPiBXZkxWwgot6ShumU3ahVviMxZcQ/sLAiMQLoYl1vE/rnmINhFD2WeI+T fuIVQhU2jyiVqg+59Bk7OPq8IE6WBqttxv+GF2yA6xdtkJ4r5gUPKCVvob4afXR2rcjw pb1cIt4DDZ/rkvDxr55vxzYBLjum/74UXETMn+PxQzCWtyvQ/qN9HUDC7uMRPktCjR9r otf7jXoORwCfsV7F8Uvoy/EiK3eXpp/aE4jdOtARA+ovCrG1ddSX6n3wI7B8yb+Toptp yVh+obXn7zXXsOupyNKj2TU+YClImb4hGkHOdH6l8qEFNCuqSqXjzqLWEUmER43uziUb nYOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702291749; x=1702896549; 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=+sZ8kiVgSDpOUyXf2RtOeDFCi7Cs5gC6EpwhZGADvk4=; b=J3s5EOp/jGwoRllj09ubyDB5w4zyn1ugpfX9FdB33jlBkBQaVEPDC+mD6g1m0Dt7nL x7rZRIk43c7LF2ijpYK3/W01aEGhyJLLDxfVpJY/uUHbAGcpdq06E/3LLwVB+kJBQ3sh hfEwYPRNd08lAWKGvIHtNIfATA5iOvcORZDU2FLcYn7Gt4lqq+ZT5hRmz4UIdinysYwC KjMZ4fzNXiAFsUmFUYnis7MXeOuuu8mNW9CxPSPXfwc4/Hn+Xw1Tw82x8qDJkHQBPUyS dEyS4FAnubboCx8z3rScdei7ViwNwRwVCTwdOb8XF3w9S2+ohWFeOnqiMTVfa4Mf+YaI SX3A== X-Gm-Message-State: AOJu0YwxrZ62yUeEaPJ0nG49S591u+L7LzS7oLY03KSmDVpxPYlWwLX1 ekQFqb+NQp9z7tTPUlelrTx+ew== X-Google-Smtp-Source: AGHT+IFSoCtcskpBZxIV6K9X1cjaO7KURWoJMi3lTZ9pqegf+liCRlmjJACZcZ0sjG+wrMj3VN7d2w== X-Received: by 2002:a5d:650e:0:b0:332:ffcc:861b with SMTP id x14-20020a5d650e000000b00332ffcc861bmr2109663wru.1.1702291748938; Mon, 11 Dec 2023 02:49:08 -0800 (PST) Received: from vingu-book.. ([2a01:e0a:f:6020:a8d:abc:f0ae:3066]) by smtp.gmail.com with ESMTPSA id e16-20020adffd10000000b003346db01263sm8232579wrr.104.2023.12.11.02.49.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 02:49:08 -0800 (PST) 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, 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, beata.michalska@arm.com, Vincent Guittot Subject: [PATCH v7 6/7] cpufreq/cppc: Set the frequency used for computing the capacity Date: Mon, 11 Dec 2023 11:48:54 +0100 Message-Id: <20231211104855.558096-7-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231211104855.558096-1-vincent.guittot@linaro.org> References: <20231211104855.558096-1-vincent.guittot@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Save the frequency associated to the performance that has been used when initializing the capacity of CPUs. Also, cppc cpufreq driver can register an artificial energy model. In such case, it needs the frequency for this compute capacity. Signed-off-by: Vincent Guittot Acked-by: Sudeep Holla Tested-by: Pierre Gondois Acked-by: Viresh Kumar --- drivers/base/arch_topology.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index e8d1cdf1f761..0a2e43728286 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -349,6 +349,7 @@ bool __init topology_parse_cpu_capacity(struct device_n= ode *cpu_node, int cpu) =20 void topology_init_cpu_capacity_cppc(void) { + u64 capacity, capacity_scale =3D 0; struct cppc_perf_caps perf_caps; int cpu; =20 @@ -365,6 +366,10 @@ void topology_init_cpu_capacity_cppc(void) (perf_caps.highest_perf >=3D perf_caps.nominal_perf) && (perf_caps.highest_perf >=3D perf_caps.lowest_perf)) { raw_capacity[cpu] =3D perf_caps.highest_perf; + capacity_scale =3D max_t(u64, capacity_scale, raw_capacity[cpu]); + + per_cpu(capacity_freq_ref, cpu) =3D cppc_perf_to_khz(&perf_caps, raw_ca= pacity[cpu]); + pr_debug("cpu_capacity: CPU%d cpu_capacity=3D%u (raw).\n", cpu, raw_capacity[cpu]); continue; @@ -375,7 +380,15 @@ void topology_init_cpu_capacity_cppc(void) goto exit; } =20 - topology_normalize_cpu_scale(); + for_each_possible_cpu(cpu) { + capacity =3D raw_capacity[cpu]; + capacity =3D div64_u64(capacity << SCHED_CAPACITY_SHIFT, + capacity_scale); + topology_set_cpu_scale(cpu, capacity); + pr_debug("cpu_capacity: CPU%d cpu_capacity=3D%lu\n", + cpu, topology_get_cpu_scale(cpu)); + } + schedule_work(&update_topology_flags_work); pr_debug("cpu_capacity: cpu_capacity initialization done\n"); =20 --=20 2.34.1