Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp151249rwo; Fri, 21 Jul 2023 09:44:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlEMpStCL11u6nhuugAgxDR+6N9kf7u6chpsoOneCuW9mT2zV6Dj7+Vz4FSHJFAyFF55xJCH X-Received: by 2002:a17:90b:2243:b0:263:fa04:4f53 with SMTP id hk3-20020a17090b224300b00263fa044f53mr1791749pjb.2.1689957886218; Fri, 21 Jul 2023 09:44:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689957886; cv=none; d=google.com; s=arc-20160816; b=F41l6xKcFYecsZSQlwUCBY25lzD5b3ug4hFYDALQNkPA3VoU1ycAb8WpVRDNGLH9ba x+3KNVouWxpU1fX9FHaA2WqHHHqUJExciS5C0bKJfpk9Lz53w99BslYFRMRLUk4elWa5 X5clMlJCjqjtC6qNk2D8qscy4/gDYYpowSNjtEjnctqtwlpfQDd4Dsyu7PVtI6Cx+6Qx 20U4ZEufNr0KKcez0YchaPhq4Hi4FE24QeGQd3/Ew9bbeh2jbXl8g8uN/VS663J024j5 T/TLkDRB2G+g3qvXv8oxhtG8SD3Jxg2w8Ctu3rBwdaTbbEjY/WNlD4rbd7tA3TgGdVIu QpzQ== 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=; fh=X59gKo2bTEq2VHcwIFizOsXoeGl1m0HuKLr4L9qvQjg=; b=crodDH0BvTFH5QwSsT4halcrTXeZ2soJWQCZufLcjOWEq7LeQo/pbvqi/Zqt+8IiuN dswrYxGZuvyep8JeV1nCahfhrbcmsh3NE9idHsvzlafy5EZYb7+RMiKWof6gzH4nPdG9 huW6XkCz/lN+GsrlGl8YHzCQRrVdR+ISQMZNL8VIYe3mHYVoy6zhhKdp031MsDT5L6PE 4jPA8zZHzYOQWVo/Cg0TlI2IdUCRAKXGqabJMWRaq0qVXABJ3DEDWFLsjJ+Ui1AiTNEB jpkKHPhu56IEHmcOGZqhJikY6KOEbpioOP+HuPfgwwhMi9BvA+TftVJxrXZ1sroTK1+j jLiA== 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 pg12-20020a17090b1e0c00b00263046538e1si3963354pjb.84.2023.07.21.09.44.33; Fri, 21 Jul 2023 09:44:46 -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 S231693AbjGUPuQ (ORCPT + 99 others); Fri, 21 Jul 2023 11:50:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232282AbjGUPuI (ORCPT ); Fri, 21 Jul 2023 11:50:08 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 88D7219A1; Fri, 21 Jul 2023 08:50:06 -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 BD2A114BF; Fri, 21 Jul 2023 08:50:49 -0700 (PDT) Received: from e129166.arm.com (unknown [10.57.0.79]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8AA573F738; Fri, 21 Jul 2023 08:50:03 -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, mhiramat@kernel.org Subject: [PATCH v3 02/12] PM: EM: Find first CPU online while updating OPP efficiency Date: Fri, 21 Jul 2023 16:50:12 +0100 Message-Id: <20230721155022.2339982-3-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230721155022.2339982-1-lukasz.luba@arm.com> References: <20230721155022.2339982-1-lukasz.luba@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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