Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp10039377rwr; Fri, 12 May 2023 03:00:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5lx7jl6qKPwzpz/kwnaw7mO0NDkrWQQaLkebBTtYjuNY3a5M6sRkccT6KGhtLYjbxZS4kZ X-Received: by 2002:a17:90b:246:b0:24e:243b:8735 with SMTP id fz6-20020a17090b024600b0024e243b8735mr33208044pjb.13.1683885601353; Fri, 12 May 2023 03:00:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683885601; cv=none; d=google.com; s=arc-20160816; b=eU3hfwIcxFLCNSF7Gs//CAo+mr/KaTa9y85f6lJWb4b1/M9GfqM+Dz5UjDiSapF2a1 mgutf5ngy0NmnZYDQaqx9Tek00ZsKcUYZ2TrrUjHdKn7LsA+J+rg2DSxjLx4oJaP+K9u 0baoZEQbbElyjRQBiP1St7pn1DT409wWfNstmcqAKypNWO8q/Hwx6kTZ675W0B5fo1hz lh2pUgdjwTepoavPwWwFPRgxbHh4n3+Bko8345KxtYIaKTEF0R4Y3lzx57oIQEvEZGXd 9EMTI2GXiFP39x3ymsbzDkqgYewKZOosd5VF3+vtlYBD7k0G1kDAZisccKSLplmvE+Rj 2IQA== 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=0f7A+J7qoAVqGJHnUSp7JB5CygJ8bFgjrXQY5hOqp8g=; b=ub/8cGq8sHmtQ2HD6FSXUpnO3i1Lka11DUi4fdidq/D+3ZkJ3ti7kdslWhokkS0X4k sUz0y/XjNxV4xrwYKUDe7bAVyCkmAbpOssNDBUQ2x+3XL0euMYJV5liU9lefJ+k8zK8B TB/wG8LWE4k5vYSUAzQj3SMqojCuZAq11xucQ1/LOuBMQmycNiVp8ldH5BT1SVxl+iIC 7V2mDvDoX466TrU9AE+w6GEEcs9fpQeN/PJClFDiUcmlVnaqcH7/MLRLupmPexiWD7Lj aOeHp9vfDIXd23mEoA7J5JG/cGcb4nTqf2mjhLdyySq0IJ2wNQiz9XsPluUzaI2jWnQ5 WvYw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i8-20020a639d08000000b00520dfb861fbsi9542655pgd.416.2023.05.12.02.59.46; Fri, 12 May 2023 03:00:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240641AbjELJ6f (ORCPT + 99 others); Fri, 12 May 2023 05:58:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240655AbjELJ6U (ORCPT ); Fri, 12 May 2023 05:58:20 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D9CA410E6E; Fri, 12 May 2023 02:58:03 -0700 (PDT) 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 2E27C139F; Fri, 12 May 2023 02:58:48 -0700 (PDT) Received: from e123648.arm.com (unknown [10.57.22.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D9E8A3F5A1; Fri, 12 May 2023 02:58:00 -0700 (PDT) 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, Pierre.Gondois@arm.com, ionela.voinescu@arm.com, rostedt@goodmis.org, mhiramat@kernel.org Subject: [PATCH v2 02/17] PM: EM: Find first CPU online while updating OPP efficiency Date: Fri, 12 May 2023 10:57:28 +0100 Message-Id: <20230512095743.3393563-3-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230512095743.3393563-1-lukasz.luba@arm.com> References: <20230512095743.3393563-1-lukasz.luba@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 online CPU from the Performance Domain. 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 0d037f3c4e58..85a70b7da023 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 online 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"); return; -- 2.25.1