From nobody Sat Oct 4 09:40:51 2025 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B58532848A2; Tue, 19 Aug 2025 07:30:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755588611; cv=none; b=LP4Mc1SLR8Lc340BOte7Nc3AtEWIhXRG5Oli8vs6BMB4N4194PVDwk4V7ui1YXcWEuyuL9WhidU01eMvkjIjjgCYR+yMQBEKp8saLZk3+x6xyvKi9x5wnUhTMRnXZR0S/7bPcwfUquc/HAVgMNIBk7jXiHN1nzdzvHVoWmX1HhY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755588611; c=relaxed/simple; bh=B7cxUmOPIsERLccuPdLVQ0iR/od4JFn901Rk8cBMZAw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ilVNZwSQ2dtxk6rFsP81JAQMyxainu+QrlKN+xjb0ksNQFJhWe634x1uAb7pUDkCtD9X/deNDoD6cTunfHkZ6kUJXG7qIBy9LEb6jr4YSJZ4zldDRZpRwDbYlWc5DAiRCCYSIhknosHJ7j2aIcL1Lrir9A798pHShaCnCgSexZw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4c5h390yk0z13NF3; Tue, 19 Aug 2025 15:26:29 +0800 (CST) Received: from kwepemh100008.china.huawei.com (unknown [7.202.181.93]) by mail.maildlp.com (Postfix) with ESMTPS id F1917140158; Tue, 19 Aug 2025 15:30:00 +0800 (CST) Received: from localhost.localdomain (10.50.165.33) by kwepemh100008.china.huawei.com (7.202.181.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 19 Aug 2025 15:30:00 +0800 From: Lifeng Zheng To: , , , , , CC: , , , , , , , , , , , , Subject: [PATCH v5 2/3] cpufreq: Add a new function to get cpufreq policy without checking if the CPU is online Date: Tue, 19 Aug 2025 15:29:30 +0800 Message-ID: <20250819072931.1647431-3-zhenglifeng1@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20250819072931.1647431-1-zhenglifeng1@huawei.com> References: <20250819072931.1647431-1-zhenglifeng1@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems200002.china.huawei.com (7.221.188.68) To kwepemh100008.china.huawei.com (7.202.181.93) Content-Type: text/plain; charset="utf-8" cpufreq_cpu_get_raw() gets cpufreq policy only if the CPU is in policy->cpus mask, which means the CPU is already online. But in some cases, the policy is needed before the CPU is added to cpus mask. Add a function to get the policy in these cases. Signed-off-by: Lifeng Zheng Reviewed-by: Jie Zhan Reviewed-by: Rafael J. Wysocki (Intel) --- drivers/cpufreq/cpufreq.c | 6 ++++++ include/linux/cpufreq.h | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index fc7eace8b65b..78ca68ea754d 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -198,6 +198,12 @@ struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned in= t cpu) } EXPORT_SYMBOL_GPL(cpufreq_cpu_get_raw); =20 +struct cpufreq_policy *cpufreq_cpu_policy(unsigned int cpu) +{ + return per_cpu(cpufreq_cpu_data, cpu); +} +EXPORT_SYMBOL_GPL(cpufreq_cpu_policy); + unsigned int cpufreq_generic_get(unsigned int cpu) { struct cpufreq_policy *policy =3D cpufreq_cpu_get_raw(cpu); diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 95f3807c8c55..26b3c3310d5b 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -205,6 +205,7 @@ struct cpufreq_freqs { =20 #ifdef CONFIG_CPU_FREQ struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu); +struct cpufreq_policy *cpufreq_cpu_policy(unsigned int cpu); struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu); void cpufreq_cpu_put(struct cpufreq_policy *policy); #else @@ -212,6 +213,10 @@ static inline struct cpufreq_policy *cpufreq_cpu_get_r= aw(unsigned int cpu) { return NULL; } +static inline struct cpufreq_policy *cpufreq_cpu_policy(unsigned int cpu) +{ + return NULL; +} static inline struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu) { return NULL; --=20 2.33.0