aboutsummaryrefslogtreecommitdiffstats
path: root/xen/include/acpi
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-09-12 10:34:50 +0100
committerKeir Fraser <keir.fraser@citrix.com>2008-09-12 10:34:50 +0100
commitea9aa98036459b0fc3a475cdd20962d23079072a (patch)
tree66f88aece8d36a6a71289bee21793260ba1b07cf /xen/include/acpi
parentb0a9e1205f87e7067be87744ed388e405777425b (diff)
downloadxen-ea9aa98036459b0fc3a475cdd20962d23079072a.tar.gz
xen-ea9aa98036459b0fc3a475cdd20962d23079072a.tar.bz2
xen-ea9aa98036459b0fc3a475cdd20962d23079072a.zip
x86: Clean up cpufreq core logic
Clean up cpufreq core logic, which now can cope with cpu online/offline event, and also dynamic platform limitation event (_PPC). Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
Diffstat (limited to 'xen/include/acpi')
-rw-r--r--xen/include/acpi/cpufreq/cpufreq.h74
-rw-r--r--xen/include/acpi/cpufreq/processor_perf.h19
2 files changed, 79 insertions, 14 deletions
diff --git a/xen/include/acpi/cpufreq/cpufreq.h b/xen/include/acpi/cpufreq/cpufreq.h
index c82ad5b886..59ceac34f5 100644
--- a/xen/include/acpi/cpufreq/cpufreq.h
+++ b/xen/include/acpi/cpufreq/cpufreq.h
@@ -19,6 +19,8 @@
#define CPUFREQ_NAME_LEN 16
+struct cpufreq_governor;
+
struct cpufreq_cpuinfo {
unsigned int max_freq;
unsigned int min_freq;
@@ -30,16 +32,21 @@ struct cpufreq_policy {
unsigned int shared_type; /* ANY or ALL affected CPUs
should set cpufreq */
unsigned int cpu; /* cpu nr of registered CPU */
- struct cpufreq_cpuinfo cpuinfo; /* see above */
+ struct cpufreq_cpuinfo cpuinfo;
unsigned int min; /* in kHz */
unsigned int max; /* in kHz */
unsigned int cur; /* in kHz, only needed if cpufreq
* governors are used */
+ struct cpufreq_governor *governor;
+
unsigned int resume; /* flag for cpufreq 1st run
* S3 wakeup, hotplug cpu, etc */
};
-extern struct cpufreq_policy xen_px_policy[NR_CPUS];
+extern struct cpufreq_policy *cpufreq_cpu_policy[NR_CPUS];
+
+extern int __cpufreq_set_policy(struct cpufreq_policy *data,
+ struct cpufreq_policy *policy);
#define CPUFREQ_SHARED_TYPE_NONE (0) /* None */
#define CPUFREQ_SHARED_TYPE_HW (1) /* HW does needed coordination */
@@ -64,12 +71,27 @@ struct cpufreq_freqs {
#define CPUFREQ_GOV_STOP 2
#define CPUFREQ_GOV_LIMITS 3
+struct cpufreq_governor {
+ char name[CPUFREQ_NAME_LEN];
+ int (*governor)(struct cpufreq_policy *policy,
+ unsigned int event);
+};
+
+extern struct cpufreq_governor cpufreq_gov_dbs;
+#define CPUFREQ_DEFAULT_GOVERNOR &cpufreq_gov_dbs
+
/* pass a target to the cpufreq driver */
extern int __cpufreq_driver_target(struct cpufreq_policy *policy,
unsigned int target_freq,
unsigned int relation);
extern int __cpufreq_driver_getavg(struct cpufreq_policy *policy);
+static __inline__ int
+__cpufreq_governor(struct cpufreq_policy *policy, unsigned int event)
+{
+ return policy->governor->governor(policy, event);
+}
+
/*********************************************************************
* CPUFREQ DRIVER INTERFACE *
@@ -91,7 +113,50 @@ struct cpufreq_driver {
extern struct cpufreq_driver *cpufreq_driver;
-void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state);
+static __inline__
+int cpufreq_register_driver(struct cpufreq_driver *driver_data)
+{
+ if (!driver_data ||
+ !driver_data->init ||
+ !driver_data->exit ||
+ !driver_data->verify ||
+ !driver_data->target)
+ return -EINVAL;
+
+ if (cpufreq_driver)
+ return -EBUSY;
+
+ cpufreq_driver = driver_data;
+ return 0;
+}
+
+static __inline__
+int cpufreq_unregister_driver(struct cpufreq_driver *driver)
+{
+ if (!cpufreq_driver || (driver != cpufreq_driver))
+ return -EINVAL;
+
+ cpufreq_driver = NULL;
+ return 0;
+}
+
+static __inline__
+void cpufreq_verify_within_limits(struct cpufreq_policy *policy,
+ unsigned int min, unsigned int max)
+{
+ if (policy->min < min)
+ policy->min = min;
+ if (policy->max < min)
+ policy->max = min;
+ if (policy->min > max)
+ policy->min = max;
+ if (policy->max > max)
+ policy->max = max;
+ if (policy->min > policy->max)
+ policy->min = policy->max;
+ return;
+}
+
/*********************************************************************
* FREQUENCY TABLE HELPERS *
@@ -109,6 +174,9 @@ struct cpufreq_frequency_table {
int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
struct cpufreq_frequency_table *table);
+int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,
+ struct cpufreq_frequency_table *table);
+
int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
struct cpufreq_frequency_table *table,
unsigned int target_freq,
diff --git a/xen/include/acpi/cpufreq/processor_perf.h b/xen/include/acpi/cpufreq/processor_perf.h
index f5251a553c..025c123da9 100644
--- a/xen/include/acpi/cpufreq/processor_perf.h
+++ b/xen/include/acpi/cpufreq/processor_perf.h
@@ -7,26 +7,23 @@
#define XEN_PX_INIT 0x80000000
int get_cpu_id(u8);
-int acpi_cpufreq_init(void);
int powernow_cpufreq_init(void);
void px_statistic_update(cpumask_t, uint8_t, uint8_t);
-int px_statistic_init(int);
-void px_statistic_reset(int);
-void px_statistic_suspend(void);
-void px_statistic_resume(void);
+int px_statistic_init(unsigned int);
+void px_statistic_exit(unsigned int);
+void px_statistic_reset(unsigned int);
-void cpufreq_dom_exit(void);
-int cpufreq_dom_init(void);
-int cpufreq_dom_dbs(unsigned int);
-void cpufreq_suspend(void);
-int cpufreq_resume(void);
+int cpufreq_limit_change(unsigned int);
+
+int cpufreq_add_cpu(unsigned int);
+int cpufreq_del_cpu(unsigned int);
uint64_t get_cpu_idle_time(unsigned int);
struct processor_performance {
uint32_t state;
- uint32_t ppc;
+ uint32_t platform_limit;
struct xen_pct_register control_register;
struct xen_pct_register status_register;
uint32_t state_count;