No reason for it to be a separate per-CPU item; it's connected to a
struct cpufreq_policy instance just like other driver data.

This also eliminates the concern over amd_cppc_cpufreq_cpu_init() being
called for all CPUs, or a CPU going offline that's recorded in policy->cpu
(which would result in accesses of per-CPU data of offline CPUs).

Signed-off-by: Jan Beulich <[email protected]>

--- a/xen/arch/x86/acpi/cpufreq/amd-cppc.c
+++ b/xen/arch/x86/acpi/cpufreq/amd-cppc.c
@@ -30,11 +30,6 @@
         printk(XENLOG_DEBUG "AMD-CPPC: CPU%u " fmt, cpu, ## args);  \
 })
 
-/*
- * Core max frequency read from PstateDef as anchor point
- * for freq-to-perf transition
- */
-static DEFINE_PER_CPU_READ_MOSTLY(unsigned int, pxfreq_mhz);
 #ifndef NDEBUG
 static bool __ro_after_init opt_active_mode;
 #else
@@ -117,7 +112,7 @@ static int amd_cppc_khz_to_perf(const st
     {
         /* Read Processor Max Speed(MHz) as anchor point */
         mul = data->caps.highest_perf;
-        div = this_cpu(pxfreq_mhz);
+        div = data->pxfreq_mhz;
         if ( !div )
             return -EOPNOTSUPP;
     }
@@ -160,7 +155,7 @@ static int amd_get_cpc_freq(const struct
     }
 
     /* Read Processor Max Speed(MHz) as anchor point */
-    mul = this_cpu(pxfreq_mhz);
+    mul = data->pxfreq_mhz;
     if ( !mul )
         return -EOPNOTSUPP;
     div = data->caps.highest_perf;
@@ -287,7 +282,7 @@ static void cf_check amd_cppc_init_msrs(
     }
 
     amd_process_freq(&cpu_data[policy->cpu],
-                     NULL, NULL, &this_cpu(pxfreq_mhz));
+                     NULL, NULL, &data->pxfreq_mhz);
 
     data->err = amd_get_cpc_freq(data, data->cppc_data->cpc.lowest_mhz,
                                  data->caps.lowest_perf, &min_freq);
--- a/xen/include/acpi/cpufreq/cpufreq.h
+++ b/xen/include/acpi/cpufreq/cpufreq.h
@@ -145,6 +145,12 @@ struct amd_cppc_drv_data {
 
     uint8_t epp_init;
 
+    /*
+     * Core max frequency read from PstateDef as anchor point
+     * for freq-to-perf transition
+     */
+    unsigned int pxfreq_mhz;
+
     int err;
 };
 


Reply via email to