Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4494123rdh; Wed, 29 Nov 2023 03:09:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IE23W/Sao8t5IsmZn6rPyU+EHlCRC6ZFoTSkmKHN+g4K9tsc4v6kcTnu8ualzpTZxDPoHPh X-Received: by 2002:a17:903:11c8:b0:1cf:5760:43f9 with SMTP id q8-20020a17090311c800b001cf576043f9mr19984182plh.64.1701256146222; Wed, 29 Nov 2023 03:09:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701256146; cv=none; d=google.com; s=arc-20160816; b=j2Nw7RcmOpCDwjvICyZKnEhr0nOhgE94cGUiD9vO2R+9gEZCeXKPAckWTH8uWxy/lG t9UbAw3TmQ/qMeRJE/90fWuYYNSs4Xi9TzXbeEViGnyX3mgugwVFj/W6rQhHznjrQ3ju GpC7SHIr6Yu4UcyYG8N3agxlF9rEfz7KBbdVqnO4IMyGCNEt+3F8BLoNRRisyXS9tzT9 tL0jYdD/Ef645+XVLODEVhEYTBJ3NbK3NMcMCaE7zzx/t6NEnlFlBy4VcKKDzgtDsv6a qcxSAW5aeuuy+n1kdjetHLz+Kdhb1nCQZXi3R6uKnUoLd1qjJ3NFkpuHwuJVWZbfQ1wk Mtqw== 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; bh=Dn3T/Q0d9aQheDGMy+OaTURuhfWKkx83TyCMS1BTVoQ=; fh=jF+j1UEDAwnYbShW3HmO1TshMsWh36Jt7pSLTP62NeE=; b=OJvvL70aE9ZuVyBXgZJ2DJc6o022A+3r+mWBGAXUXejdzaHZhQwjTUylEhnNegt+FZ zzMxgsFQK/Wz+Lfvxoraxqt26qFHABjr11Vlj3T6VajKBz5MNptmbwJYI5D+4p7oz2i5 TIzVJMY7c45iGmKiejB442qdS8T4jJW7flJaRGa17iXo8QcYUMT0g4QjurI7g6c4JI5y fXiKzHI3FzjVa9Y4AjvPoA51yKCZb5Flzq58lNOFNhx5rzOrysRCRV/Kjk/dorVRku0U 3AjHTrR7QWEwYmG5k07c7ZWk0jdruRAUGWzSV4A/rtLA6r9fW66UmhMZIzntYVAfYHEq kB9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id z8-20020a170903018800b001cffbe81706si3344751plg.354.2023.11.29.03.09.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 03:09:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 7B56A80A9E01; Wed, 29 Nov 2023 03:08:57 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231749AbjK2LIO (ORCPT + 99 others); Wed, 29 Nov 2023 06:08:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231470AbjK2LIE (ORCPT ); Wed, 29 Nov 2023 06:08:04 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 240BA1998; Wed, 29 Nov 2023 03:08:10 -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 1BADA1424; Wed, 29 Nov 2023 03:08:57 -0800 (PST) Received: from e129166.arm.com (unknown [10.57.4.241]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7EEDF3F5A1; Wed, 29 Nov 2023 03:08:07 -0800 (PST) From: Lukasz Luba To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rafael@kernel.org Cc: lukasz.luba@arm.com, dietmar.eggemann@arm.com, rui.zhang@intel.com, amit.kucheria@verdurent.com, amit.kachhap@gmail.com, daniel.lezcano@linaro.org, viresh.kumar@linaro.org, len.brown@intel.com, pavel@ucw.cz, mhiramat@kernel.org, qyousef@layalina.io, wvw@google.com Subject: [PATCH v5 03/23] PM: EM: Find first CPU active while updating OPP efficiency Date: Wed, 29 Nov 2023 11:08:33 +0000 Message-Id: <20231129110853.94344-4-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231129110853.94344-1-lukasz.luba@arm.com> References: <20231129110853.94344-1-lukasz.luba@arm.com> 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 fry.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 (fry.vger.email [0.0.0.0]); Wed, 29 Nov 2023 03:08:57 -0800 (PST) The Energy Model might be updated at runtime and the energy efficiency for each OPP may change. Thus, there is a need to update also the cpufreq framework and make it aligned to the new values. In order to do that, use a first active CPU from the Performance Domain. This is needed since the first CPU in the cpumask might be offline when we run this code path. Signed-off-by: Lukasz Luba --- kernel/power/energy_model.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c index 42486674b834..aa7c89f9e115 100644 --- a/kernel/power/energy_model.c +++ b/kernel/power/energy_model.c @@ -243,12 +243,19 @@ em_cpufreq_update_efficiencies(struct device *dev, struct em_perf_state *table) struct em_perf_domain *pd = dev->em_pd; struct cpufreq_policy *policy; int found = 0; - int i; + int i, cpu; if (!_is_cpu_device(dev) || !pd) return; - policy = cpufreq_cpu_get(cpumask_first(em_span_cpus(pd))); + /* Try to get a CPU which is active and in this PD */ + cpu = cpumask_first_and(em_span_cpus(pd), cpu_active_mask); + if (cpu >= nr_cpu_ids) { + dev_warn(dev, "EM: No online CPU for CPUFreq policy\n"); + return; + } + + policy = cpufreq_cpu_get(cpu); if (!policy) { dev_warn(dev, "EM: Access to CPUFreq policy failed\n"); return; -- 2.25.1