Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp209587rdb; Thu, 8 Feb 2024 03:57:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IEoW/iedpFg6jy17+t0f6w8sUvT8DnS7OQdhMppd+gZDs4y1DfnXd+5a+IapqHh5mjuz+Ka X-Received: by 2002:aa7:cb53:0:b0:561:aa3:f9e6 with SMTP id w19-20020aa7cb53000000b005610aa3f9e6mr1032090edt.15.1707393429618; Thu, 08 Feb 2024 03:57:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707393429; cv=pass; d=google.com; s=arc-20160816; b=aekd9uj19AG8FjIc7qWJExeoN4s3fTfub9MXDYf0Cq/Ydrb/rQWfJXx5SwAcByIRrS giLEue2I48NDNcH2sJGDppmMIv6zaaiprj67Beq4PjNOEcfTY80fnj8Hd/ckTpKSMNxS zJzGqKJbDebvqN3dFH+R2N5Ez+TbvEm5S3O2APmNmwBhKx1r9x+nF5w3i0wGvtaajGab GOWBpdQc1qon+Clinn8ZP5XEL+3d6Hmv0A6GkCkDkVrP7EqrVPGmpp+QBd4GFHXEOuuw XufE3CW9Iejm8JbbfVPpj8cBIjeUcDbRtLE/iudHzg1s6zNIgpHFFxSjmF4HL1FFbfTq Dmfw== ARC-Message-Signature: i=2; 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=BClLa1cGaKPpdCiU5OhSccGOFmQHmqZiM4CmxfNWV2Y=; fh=TzGeYECFd+iBRSUZou4v47BIaXcmcV5RqCL5OvSHk58=; b=YYHSzrUYQDfe81sPVzTScuCKM8D1MphD3Dq+sXbeNQpT+O8ARS6NeVza0G8eWGCng+ mz3unl9+2jzvcYX39r+PxnWa4612babJfcg0gCLZv4+BN2gg3SgGt4oiLbxOHyk8UwSu 5AaizCe2RZ/Ey4DbTbmdwF4pP0q0Mcuj3a6j+VcLKZ59d6fqrTj7SAhAriUFY+YNF202 yUlYH2AXcc7Yd8oP3/6H33aXeBvwgGkbr0dsrA6PwYZ/1FgdTfXXS7HJ42Z0YHotE7Ws UwJhOm8oJpqTVDvduClm8tLhz2BOD9skH5FJConZTLjmcYBf6Nuk7kSxlGaCR0dgQvT/ nwFg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-57996-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57996-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCVqzXwM3mRaYszXRKnVFuizjHXLVI4iI9RqvJtWv2qTylrDazDaoJWiMmYApIYYKAEPv7d+JXA+G/vHVdT6QsQvPaJZVuYRhKa83P5Qiw== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id cn3-20020a0564020ca300b0056004738692si841451edb.590.2024.02.08.03.57.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 03:57:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57996-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-57996-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57996-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 55C811F20F1B for ; Thu, 8 Feb 2024 11:57:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7169576035; Thu, 8 Feb 2024 11:56:17 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5115A5427E; Thu, 8 Feb 2024 11:56:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707393377; cv=none; b=K93qfj+r6H7SBJgXTxc0j32FTr2wXNqZAvD6G3gan2x7arVMo4+ois6nixR61/nOvorDR651qaZ1C+utbkwPE53uAIEH+NNoA4c9MRTNOUsug3SAL1dzke3fGK+t1L1GopiU/c+AOkc1cubfMoQ8Cp2nkE+siz9n5wXAIqAbBG0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707393377; c=relaxed/simple; bh=vFMblhCLavHFIcqb3d9HPoVvxX4CxDbS2BZT1wAG2Rs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rJz5/EC2Os2br+fyerKhK26+1d5H93XJSwyt6lGOCj2UToxN2WHFa6dgtY2fZ0SjFC0kLXnhu3Cz2cKO7lTxFWWeMhkZlprgQkcsVxjy7JwOYEwFe/2YSPBVdNZD7Kg8yGSrkWfh7WlMhHTT6VCC5QPi0WbXcA1RBCwIIb2FOho= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 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 D9E641FB; Thu, 8 Feb 2024 03:56:56 -0800 (PST) Received: from e129166.arm.com (unknown [10.57.8.23]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D51B93F5A1; Thu, 8 Feb 2024 03:56:11 -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, xuewen.yan94@gmail.com, Hongyan Xia Subject: [PATCH v8 03/23] PM: EM: Find first CPU active while updating OPP efficiency Date: Thu, 8 Feb 2024 11:55:37 +0000 Message-Id: <20240208115557.1273962-4-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240208115557.1273962-1-lukasz.luba@arm.com> References: <20240208115557.1273962-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. Reviewed-by: Hongyan Xia Reviewed-by: Dietmar Eggemann Tested-by: Dietmar Eggemann 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 8c373b151875..0c3220ff54f7 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)) 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