Received: by 2002:a05:7412:8d1c:b0:fa:4c10:6cad with SMTP id bj28csp347769rdb; Wed, 17 Jan 2024 04:05:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IEom0UjcEcUZ+oWl0kYakr8rvKvTm5W2TI8p8Cj8djsU0glzhhHES7DUWd7ht1b3frzLfaJ X-Received: by 2002:a05:620a:2682:b0:783:1b99:6563 with SMTP id c2-20020a05620a268200b007831b996563mr8923298qkp.51.1705493126877; Wed, 17 Jan 2024 04:05:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705493126; cv=pass; d=google.com; s=arc-20160816; b=sZ0XNYsELndocE4OpxQDvdxu0dp4GaXRn4ttHJk/6ycfRW2nA7xR/tk3HIMcV3Yi7B WaR9EONZHjZOkoOhEkHzqYPFn6dgU5V0UEmcwHZkEKQvwJYrbQOYZjn56f99pIqh3hxH E+3Q+Mot8lxUNHQHs6KVFJWdcaOEKABBLx6+lGVCclcnttuORUBHjlD8LkmdTyjKgheJ rdHsyRdPbPYCqItoZoFEiWsnpeFe9BfE7C9gC27Cz46WQjnO/O3+COB76PiGOT6wWX6n xX0NQZ4bMpxoJFbCa0x9SRWPjJCXek1E6RPHlwi+zF0FWS107DbcNk0DN02vY8AxWa/5 TlVA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=Ze//TRAr7uxEmo54a57m4OBHlLio5zKB1gWlzzilrkc=; fh=xT/YCveP2+KQQs7RLDiWHdXgEo9d2VTYL8Gea26jOMI=; b=JbfHv/b85NCRJ2cOmsWiBRid7aa5NQ40AKe5Te2B7fIfEIZhKgmdWnHVRArSiTE/nz bM/VK8yaMub+Ufqqr5v4BtUsGUBtOA5hhU51OsEkQUB3un4Ae3l/fxmcSZFagM5LFgu0 0C2KEWmn+WeCmY/4CK2259hpds4z3iXF26qNSLqSMF/Ys9NbzL8OP9MG0jVaod9J/8Vx IAcrC78mVISPoDNYVb2qqnhETnMSKBh3J6m22qUeJO4lhxZGuzb9teSc0lp56ziFWfOv dGQziKZXWNg6bPYtlB7sjaVMamzUciQa4N7lMbO+xclrA5A0J24S7pFZJ3paaSUAEmdX nOmg== 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-28937-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28937-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id b14-20020a05620a088e00b007830acd06eesi11385142qka.574.2024.01.17.04.05.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 04:05:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-28937-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; 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-28937-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28937-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 9B2E51C226A2 for ; Wed, 17 Jan 2024 12:05:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CD8A11DFE1; Wed, 17 Jan 2024 12:05:18 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2834B1DFCF; Wed, 17 Jan 2024 12:05:15 +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=1705493118; cv=none; b=SnvHFmRKKPA/Ts50acE4GG7jqeekMNRYlaovd9pfFB73XQ4CaeBBxSEFxtFFo2oqmPRSjsMRPkfwhqGhpnBAT4gNW2MQ2Qs+bTBZpOsYR0r0zPUQx9cT7kSMslakLevIFiQ/SMzFzv787i78erCab+wyQ0YS9DL6BIl9DL9oxCg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705493118; c=relaxed/simple; bh=Pmn8h/pdCxhnofqxr02aGCsKkLxC0a+7EXzpM4wIoQE=; h=Received:Received:Message-ID:Date:MIME-Version:User-Agent:Subject: Content-Language:To:Cc:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; b=X1dYT4wKXj6XRF03E3IA0dpGuh0lV0GNfi/cIYX6wfFIjgT84g+RjvCKyoaHfcKAhPS2k321VzH1FNcnVL+rGzcqpM+5PEEbHw7IH11rOoL/68PePXA9P6AIsU2RsiCoTXtQmnwoDTue7BMeun6ygfoaENuz9JP92zAXCgwP/M4= 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 6607911FB; Wed, 17 Jan 2024 04:06:01 -0800 (PST) Received: from [10.57.78.6] (unknown [10.57.78.6]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3EAD43F766; Wed, 17 Jan 2024 04:05:13 -0800 (PST) Message-ID: Date: Wed, 17 Jan 2024 12:05:11 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v7 03/23] PM: EM: Find first CPU active while updating OPP efficiency Content-Language: en-US To: Lukasz Luba , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rafael@kernel.org Cc: 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 References: <20240117095714.1524808-1-lukasz.luba@arm.com> <20240117095714.1524808-4-lukasz.luba@arm.com> From: Hongyan Xia In-Reply-To: <20240117095714.1524808-4-lukasz.luba@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 17/01/2024 09:56, Lukasz Luba wrote: > 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; Reviewed-by: Hongyan Xia