Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7843436rdb; Thu, 4 Jan 2024 09:17:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IFg17Dlp3NUkl88YMu3O3U/L/uA8pbRFiOybK/q9KAimNMMZHH/I9ys3tsAMZHS0DjQITHs X-Received: by 2002:a50:c048:0:b0:554:42ed:d306 with SMTP id u8-20020a50c048000000b0055442edd306mr526062edd.60.1704388638081; Thu, 04 Jan 2024 09:17:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704388638; cv=none; d=google.com; s=arc-20160816; b=UqZX8eTA2asbIYNrtUUC8D6AhzFf5WC+b5YQ23Bjc3ph4FmJTkQcnd3so6oteoc2bp VQPc78iFvyMxzwKuVVSuvKMNvt3BCUPo2ftAmbIuPe/d3+ue0wN5M0vgsssnBPq8DA4X pQYh0nX1ckgkJUWjmROWN1J1JKn1YAnGc85mO9tu0YoscRzu2GYZsWPvgJ7zRPs7ccr8 vca/lwwdYXZCa4KVTrd/vjeQzx2NYV4/vwhRRS9VEkWhV8Df/bZijxFbBFMx0wmLghxP CzWfnE+t7Hc3AkGuDv/sPoLZf700xXtJGWHahEBBXj05PCWpxsDR8roZoPPpp5XVlA+e xWow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=Dn3T/Q0d9aQheDGMy+OaTURuhfWKkx83TyCMS1BTVoQ=; fh=jF+j1UEDAwnYbShW3HmO1TshMsWh36Jt7pSLTP62NeE=; b=ceQecyYECx5PgUV0MsJ7mVrynA3LI+2gMiYN+VRn6sInGDEeFDQHfzm0i2zyYDCB5G wEAoBrdtv5m3YFGRO5hydxkZtjEYJzfV1OwM8dWsLSJ0W+yZfqLP3IgxSsrwF6N9Ew6Z NDwOxIVAcWUoGL+LmtbLkRef4Qe9vkJNap+ywjBx1sGwDX1Kj0STG9ThAnCy0ODD0n/b e6gBmEtknx3WxPqRpDVI8ciouqhwFXWiL3o1M6ETTNrJ37KOL8K7Ab2/d6byOk4qKa4u k8p0Wb7EuHP5xBL5nFItOhL8CCUIUYav0EhDwROtUDkpq07Ni8fTlnLZgVvMVLXm2zIA CoFA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-17006-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17006-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f18-20020a50a6d2000000b00553db3db65asi12924888edc.227.2024.01.04.09.17.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 09:17:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17006-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-17006-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17006-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D01C81F22B6D for ; Thu, 4 Jan 2024 17:17:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 136B328E2E; Thu, 4 Jan 2024 17:15:00 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6033428E23; Thu, 4 Jan 2024 17:14:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 D26CF153B; Thu, 4 Jan 2024 09:15:43 -0800 (PST) Received: from e129166.arm.com (unknown [10.57.88.128]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 677083F64C; Thu, 4 Jan 2024 09:14:55 -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 v6 03/23] PM: EM: Find first CPU active while updating OPP efficiency Date: Thu, 4 Jan 2024 17:15:33 +0000 Message-Id: <20240104171553.2080674-4-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240104171553.2080674-1-lukasz.luba@arm.com> References: <20240104171553.2080674-1-lukasz.luba@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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