From patchwork Mon Oct 9 10:36:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 13413363 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 61886E95A96 for ; Mon, 9 Oct 2023 10:37:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=SA9E5KD12wm8FlBqAbP7MPubvT6zThgzruAGIUQ4bDs=; b=V/yskLJTLxjoNb ERPlVH9k+iveh887OcO+zgh9XHXXQQR+xMo1mz66Qp01J9W62teXgmqnLa/K//5WnDXgN7oH6tZdc i/tr05Od3QoDNR9WijfOxIxIhEHJqL0wwZx/SI3zaotTJ0YhW6o2WzD4RQ72tbMklUKkJn9AT7nSb K0i9lsq8S0XLXhqnPRu+ujWWHnriM18ysMtbCRjcnZMtbW0vxxSx2ci46gidl0whypJLq7vfxaId0 UGWpCvXxRtxqXPZz43/6ITZvkOyobNXcdIxBEHct0Tz7gfhqj8EN418f/dGJnQdbRmVJ33IX0J9Yn GBsELZBNvZi1EEcS5c8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qpnd0-00AFhM-0T; Mon, 09 Oct 2023 10:36:46 +0000 Received: from mail-wr1-f41.google.com ([209.85.221.41]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qpncs-00AFWO-00 for linux-arm-kernel@lists.infradead.org; Mon, 09 Oct 2023 10:36:40 +0000 Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-3248ac76acbso3945328f8f.1 for ; Mon, 09 Oct 2023 03:36:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696847793; x=1697452593; darn=lists.infradead.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=zLqmJToKVvGx3RPF93C/D7OTDNmDiwUSULcdREcteNg=; b=U3GFykntT8dYxu8c/TtyuMsy/LZvSJrC5I2gXEOhpOPJ9p9chQEHVf1yC8Hp2/l+Ud SmvZs2gfCGVpreKLXm/UkGPEjVt+h2EpG6GbLz7UsFyaH17RzGzSpaV8yIbdlMX00VM9 mwhRkMLKupFZ8112V0f5/kEDzBrI0it/tj/QT19bEQ37VMLEGu/dPg3G0n/OH0lBIOMT y2XYK1h1VEDmcZJaQWu8jx2vIw8SQHWLazISJJuS4nDfcd2kEj5D07/Y3oGQMpBrbzs+ VHBM7zGo08FoUvtwm+BKo1hZF8YT8uLarAjZlF+rm/3bjml0CrWBnhMM0LgAEjldeM+3 NWAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696847793; x=1697452593; 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=zLqmJToKVvGx3RPF93C/D7OTDNmDiwUSULcdREcteNg=; b=Kpke7w2OAWAModmfjrBNHH0qACueRmx4Md6Wni2K3OVlRZgIb/zLaldkxIyUUC0C24 LoLoD1swtioauyaGyrnBuwf1Bt4Bpo55kAmvHz4KCzLKrpYBypQfZL3Usc9Mi2kwL8mk fD5vn4y7x8URcAUnG/Qz4fUuvO/fn+Dv3joxTrDhxNETfyD/kIYtR8YGfggTS//vT/Gz d1trFfM99Tq6jv6VnrJyBjRpsc8PVzxr+lD8GBIKLHy+TUzZNZ+EkpVeVbOu5ZZ6+jNC yLawpK1T/MbliEXfUTa2z+1MSGkQ6E1LF+IBrBxJe97ofr4xnhHdcfcaLq+VUil4PyGy 63oA== X-Gm-Message-State: AOJu0YzAI7CCtVzGMuIM/mnjiLrlPq4dbh606+pnzwQ+ebkxTqPIDrb4 iz8vl/yvBbhUIJeSmTCvHHfkpw== X-Google-Smtp-Source: AGHT+IE1c9bbdHMwBLMomM9sWbKgUcq5hfVG4KlvDcosRRJkN4Ti2TteiXopQtpHeenYl1QcJ2PxJw== X-Received: by 2002:a5d:614b:0:b0:31c:8c93:61e3 with SMTP id y11-20020a5d614b000000b0031c8c9361e3mr12270603wrt.60.1696847793608; Mon, 09 Oct 2023 03:36:33 -0700 (PDT) Received: from vingu-book.. ([2a01:e0a:f:6020:53f1:24bc:5e47:821d]) by smtp.gmail.com with ESMTPSA id f16-20020adfdb50000000b0031ff89af0e4sm9226722wrj.99.2023.10.09.03.36.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 03:36:33 -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, 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 Cc: conor.dooley@microchip.com, suagrfillet@gmail.com, ajones@ventanamicro.com, lftan@kernel.org, Vincent Guittot Subject: [PATCH v2 6/6] cpufreq/cppc: set the frequency used for capacity computation Date: Mon, 9 Oct 2023 12:36:21 +0200 Message-Id: <20231009103621.374412-7-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231009103621.374412-1-vincent.guittot@linaro.org> References: <20231009103621.374412-1-vincent.guittot@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231009_033638_091728_44222556 X-CRM114-Status: GOOD ( 12.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org cppc cpufreq driver can register an artificial energy model. In such case, it also have to register the frequency that is used to define the CPU capacity Signed-off-by: Vincent Guittot --- drivers/cpufreq/cppc_cpufreq.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c index fe08ca419b3d..24c6ba349f01 100644 --- a/drivers/cpufreq/cppc_cpufreq.c +++ b/drivers/cpufreq/cppc_cpufreq.c @@ -636,6 +636,21 @@ static int populate_efficiency_class(void) return 0; } + +static void cppc_cpufreq_set_capacity_ref_freq(struct cpufreq_policy *policy) +{ + struct cppc_perf_caps *perf_caps; + struct cppc_cpudata *cpu_data; + unsigned int ref_freq; + + cpu_data = policy->driver_data; + perf_caps = &cpu_data->perf_caps; + + ref_freq = cppc_cpufreq_perf_to_khz(cpu_data, perf_caps->highest_perf); + + per_cpu(capacity_ref_freq, policy->cpu) = ref_freq; +} + static void cppc_cpufreq_register_em(struct cpufreq_policy *policy) { struct cppc_cpudata *cpu_data; @@ -643,6 +658,9 @@ static void cppc_cpufreq_register_em(struct cpufreq_policy *policy) EM_ADV_DATA_CB(cppc_get_cpu_power, cppc_get_cpu_cost); cpu_data = policy->driver_data; + + cppc_cpufreq_set_capacity_ref_freq(policy); + em_dev_register_perf_domain(get_cpu_device(policy->cpu), get_perf_level_count(policy), &em_cb, cpu_data->shared_cpu_map, 0);