[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v6 17/19] xen/cpufreq: introduce helper cpufreq_in_cppc_passive_mode()


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Fri, 11 Jul 2025 11:51:04 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=t3xVA3KdE1o525Bs+jAGrF2sREXD+fWa1Ior5V3zAjQ=; b=BHMP5yiljO7yJ55mhHcqqzatkwoOeHiuRa4LPu4PetzkVraFgeJzWvnZOrjQ6axBiUy1+Lr2mYngHj83yrf+sdZRxS6irnl9iZ19i2ZARyJVy9AN+UwDZgpGKjQKL4YDxJfBnVnhW0z+wwJVlC6XfWb3276CK/d8QuUD2pslWmH4TcyXvFX98Kv6w0/Ml+7Ut99osTU1xbTAIoIBzHhVlJ5Yg9rwVGMGqTaeau328XlyOE3RsKNOXRRelx83oovXRdSui+PPMPjAbBJ4YtL15NiRvuk8Gpe6WxhfkvRi0SARe9p8rMe0d0dlmq+DyyNx2Nkv74dIkB8HNrCT4hOXAg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZYFA5LxbX+51Q+PfZFe9C0SkCpDSPvwg7rXKyOdtpKbx1v+zwlh+O0YViQfLO/h10ZhUj5aKdBhHCko4hD9VsVKo2ykt3gz4ezRDAu/Ypy2XWvC7Iei2IM+AeJjFJnzVNKckR54qvTJyV/DLyh8y09ErNwlxtaM6u6470LhhsgliCEivAh/r87cu8+m/2LNLS33p4KmxTt9NaJRWCVvx4/v7c+3hqNuGhP/DdD+ILYgg8ul7MoM6ErblotFFsQYwv4GT/iHVLuDlGKZRymXbuaSPAMcL5K8r2u3LsTenjhvYICy2bnh09JaUvjj8xuHRW8lsOeglM79BDis3ziniAQ==
  • Cc: <ray.huang@xxxxxxx>, Penny Zheng <Penny.Zheng@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • Delivery-date: Fri, 11 Jul 2025 04:01:04 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

When cpufreq driver in cppc passive mode, it has both cppc and governor
info. We need to invoke two sysctl sub-ops ("get-cpufreq-cppc" and
"get-cpufreq-para") to produce both info.

A new helper cpufreq_in_cppc_passive_mode() is introduced to tell whether
cpufreq driver supports cppc passive mode.

Signed-off-by: Penny Zheng <Penny.Zheng@xxxxxxx>
---
v5 -> v6
- new commit
---
 xen/drivers/acpi/pm-op.c           | 10 +++++++++-
 xen/drivers/cpufreq/cpufreq.c      |  6 ++++++
 xen/include/acpi/cpufreq/cpufreq.h |  2 ++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/xen/drivers/acpi/pm-op.c b/xen/drivers/acpi/pm-op.c
index 0723cea34c..077efdfc5c 100644
--- a/xen/drivers/acpi/pm-op.c
+++ b/xen/drivers/acpi/pm-op.c
@@ -152,7 +152,15 @@ static int get_cpufreq_para(struct xen_sysctl_pm_op *op)
     else
         strlcpy(op->u.get_para.scaling_driver, "Unknown", CPUFREQ_NAME_LEN);
 
-    ret = get_cpufreq_cppc(op->cpuid, &op->u.get_para.u.cppc_para);
+    /*
+     * When cpufreq driver in cppc passive mode, it has both cppc and governor
+     * info. Users could only rely on "get-cpufreq-cppc" to acquire CPPC info.
+     * And it returns governor info in "get-cpufreq-para"
+     */
+    if ( cpufreq_in_cppc_passive_mode(op->cpuid) )
+        ret = -ENODEV;
+    else
+        ret = get_cpufreq_cppc(op->cpuid, &op->u.get_para.u.cppc_para);
     if ( ret == -ENODEV )
     {
         if ( !(scaling_available_governors =
diff --git a/xen/drivers/cpufreq/cpufreq.c b/xen/drivers/cpufreq/cpufreq.c
index cf1fcf1d22..431f2903f8 100644
--- a/xen/drivers/cpufreq/cpufreq.c
+++ b/xen/drivers/cpufreq/cpufreq.c
@@ -962,3 +962,9 @@ int __init cpufreq_register_driver(const struct 
cpufreq_driver *driver_data)
 
     return 0;
 }
+
+bool cpufreq_in_cppc_passive_mode(unsigned int cpuid)
+{
+    return processor_pminfo[cpuid]->init & XEN_CPPC_INIT &&
+           cpufreq_driver.target;
+}
diff --git a/xen/include/acpi/cpufreq/cpufreq.h 
b/xen/include/acpi/cpufreq/cpufreq.h
index b0b22d1c9c..dd55d268c0 100644
--- a/xen/include/acpi/cpufreq/cpufreq.h
+++ b/xen/include/acpi/cpufreq/cpufreq.h
@@ -295,4 +295,6 @@ int acpi_cpufreq_register(void);
 int amd_cppc_cmdline_parse(const char *s, const char *e);
 int amd_cppc_register_driver(void);
 
+bool cpufreq_in_cppc_passive_mode(unsigned int cpuid);
+
 #endif /* __XEN_CPUFREQ_PM_H__ */
-- 
2.34.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.