debuggers.hg

view xen/include/acpi/cpufreq/cpufreq.h @ 20954:a06e9def02bb

xenpm: Allow user to enable/disable dbs governor turbo mode.

Signed-off-by: Lu Guanqun <guanqun.lu@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Feb 08 08:48:40 2010 +0000 (2010-02-08)
parents 757359a36785
children 7b63f677f245
line source
1 /*
2 * xen/include/acpi/cpufreq/cpufreq.h
3 *
4 * Copyright (C) 2001 Russell King
5 * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de>
6 *
7 * $Id: cpufreq.h,v 1.36 2003/01/20 17:31:48 db Exp $
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
14 #ifndef __XEN_CPUFREQ_PM_H__
15 #define __XEN_CPUFREQ_PM_H__
17 #include <xen/types.h>
18 #include <xen/list.h>
19 #include <xen/cpumask.h>
21 #include "processor_perf.h"
23 DECLARE_PER_CPU(spinlock_t, cpufreq_statistic_lock);
25 struct cpufreq_governor;
27 struct acpi_cpufreq_data {
28 struct processor_performance *acpi_data;
29 struct cpufreq_frequency_table *freq_table;
30 unsigned int max_freq;
31 unsigned int cpu_feature;
32 };
34 struct cpufreq_cpuinfo {
35 unsigned int max_freq;
36 unsigned int second_max_freq; /* P1 if Turbo Mode is on */
37 unsigned int min_freq;
38 unsigned int transition_latency; /* in 10^(-9) s = nanoseconds */
39 };
41 struct cpufreq_policy {
42 cpumask_t cpus; /* affected CPUs */
43 unsigned int shared_type; /* ANY or ALL affected CPUs
44 should set cpufreq */
45 unsigned int cpu; /* cpu nr of registered CPU */
46 struct cpufreq_cpuinfo cpuinfo;
48 unsigned int min; /* in kHz */
49 unsigned int max; /* in kHz */
50 unsigned int cur; /* in kHz, only needed if cpufreq
51 * governors are used */
52 struct cpufreq_governor *governor;
54 unsigned int resume; /* flag for cpufreq 1st run
55 * S3 wakeup, hotplug cpu, etc */
56 };
57 extern struct cpufreq_policy *cpufreq_cpu_policy[NR_CPUS];
59 extern int __cpufreq_set_policy(struct cpufreq_policy *data,
60 struct cpufreq_policy *policy);
62 void cpufreq_cmdline_parse(char *);
64 #define CPUFREQ_SHARED_TYPE_NONE (0) /* None */
65 #define CPUFREQ_SHARED_TYPE_HW (1) /* HW does needed coordination */
66 #define CPUFREQ_SHARED_TYPE_ALL (2) /* All dependent CPUs should set freq */
67 #define CPUFREQ_SHARED_TYPE_ANY (3) /* Freq can be set from any dependent CPU*/
69 /******************** cpufreq transition notifiers *******************/
71 struct cpufreq_freqs {
72 unsigned int cpu; /* cpu nr */
73 unsigned int old;
74 unsigned int new;
75 u8 flags; /* flags of cpufreq_driver, see below. */
76 };
79 /*********************************************************************
80 * CPUFREQ GOVERNORS *
81 *********************************************************************/
83 #define CPUFREQ_GOV_START 1
84 #define CPUFREQ_GOV_STOP 2
85 #define CPUFREQ_GOV_LIMITS 3
87 struct cpufreq_governor {
88 char name[CPUFREQ_NAME_LEN];
89 int (*governor)(struct cpufreq_policy *policy,
90 unsigned int event);
91 void (*handle_option)(const char *name, const char *value);
92 struct list_head governor_list;
93 };
95 extern struct cpufreq_governor *cpufreq_opt_governor;
96 extern struct cpufreq_governor cpufreq_gov_dbs;
97 extern struct cpufreq_governor cpufreq_gov_userspace;
98 extern struct cpufreq_governor cpufreq_gov_performance;
99 extern struct cpufreq_governor cpufreq_gov_powersave;
101 extern int cpufreq_register_governor(struct cpufreq_governor *governor);
102 extern int cpufreq_unregister_governor(struct cpufreq_governor *governor);
103 extern struct cpufreq_governor *__find_governor(const char *governor);
104 #define CPUFREQ_DEFAULT_GOVERNOR &cpufreq_gov_dbs
106 /* pass a target to the cpufreq driver */
107 extern int __cpufreq_driver_target(struct cpufreq_policy *policy,
108 unsigned int target_freq,
109 unsigned int relation);
111 #define GOV_GETAVG 1
112 #define USR_GETAVG 2
113 extern int cpufreq_driver_getavg(unsigned int cpu, unsigned int flag);
115 static __inline__ int
116 __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event)
117 {
118 return policy->governor->governor(policy, event);
119 }
122 /*********************************************************************
123 * CPUFREQ DRIVER INTERFACE *
124 *********************************************************************/
126 #define CPUFREQ_RELATION_L 0 /* lowest frequency at or above target */
127 #define CPUFREQ_RELATION_H 1 /* highest frequency below or at target */
129 struct cpufreq_driver {
130 char name[CPUFREQ_NAME_LEN];
131 int (*init)(struct cpufreq_policy *policy);
132 int (*verify)(struct cpufreq_policy *policy);
133 int (*target)(struct cpufreq_policy *policy,
134 unsigned int target_freq,
135 unsigned int relation);
136 unsigned int (*get)(unsigned int cpu);
137 unsigned int (*getavg)(unsigned int cpu, unsigned int flag);
138 int (*exit)(struct cpufreq_policy *policy);
139 };
141 extern struct cpufreq_driver *cpufreq_driver;
143 static __inline__
144 int cpufreq_register_driver(struct cpufreq_driver *driver_data)
145 {
146 if (!driver_data ||
147 !driver_data->init ||
148 !driver_data->exit ||
149 !driver_data->verify ||
150 !driver_data->target)
151 return -EINVAL;
153 if (cpufreq_driver)
154 return -EBUSY;
156 cpufreq_driver = driver_data;
157 return 0;
158 }
160 static __inline__
161 int cpufreq_unregister_driver(struct cpufreq_driver *driver)
162 {
163 if (!cpufreq_driver || (driver != cpufreq_driver))
164 return -EINVAL;
166 cpufreq_driver = NULL;
167 return 0;
168 }
170 static __inline__
171 void cpufreq_verify_within_limits(struct cpufreq_policy *policy,
172 unsigned int min, unsigned int max)
173 {
174 if (policy->min < min)
175 policy->min = min;
176 if (policy->max < min)
177 policy->max = min;
178 if (policy->min > max)
179 policy->min = max;
180 if (policy->max > max)
181 policy->max = max;
182 if (policy->min > policy->max)
183 policy->min = policy->max;
184 return;
185 }
188 /*********************************************************************
189 * FREQUENCY TABLE HELPERS *
190 *********************************************************************/
192 #define CPUFREQ_ENTRY_INVALID ~0
193 #define CPUFREQ_TABLE_END ~1
195 struct cpufreq_frequency_table {
196 unsigned int index; /* any */
197 unsigned int frequency; /* kHz - doesn't need to be in ascending
198 * order */
199 };
201 int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
202 struct cpufreq_frequency_table *table);
204 int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,
205 struct cpufreq_frequency_table *table);
207 int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
208 struct cpufreq_frequency_table *table,
209 unsigned int target_freq,
210 unsigned int relation,
211 unsigned int *index);
214 /*********************************************************************
215 * UNIFIED DEBUG HELPERS *
216 *********************************************************************/
218 struct cpu_dbs_info_s {
219 uint64_t prev_cpu_idle;
220 uint64_t prev_cpu_wall;
221 struct cpufreq_policy *cur_policy;
222 struct cpufreq_frequency_table *freq_table;
223 int cpu;
224 unsigned int enable:1;
225 unsigned int stoppable:1;
226 unsigned int turbo_enabled:1;
227 };
229 int cpufreq_governor_dbs(struct cpufreq_policy *policy, unsigned int event);
230 int get_cpufreq_ondemand_para(uint32_t *sampling_rate_max,
231 uint32_t *sampling_rate_min,
232 uint32_t *sampling_rate,
233 uint32_t *up_threshold);
234 int write_ondemand_sampling_rate(unsigned int sampling_rate);
235 int write_ondemand_up_threshold(unsigned int up_threshold);
237 int write_userspace_scaling_setspeed(unsigned int cpu, unsigned int freq);
239 void cpufreq_dbs_timer_suspend(void);
240 void cpufreq_dbs_timer_resume(void);
242 void cpufreq_dbs_enable_turbo(int cpuid);
243 void cpufreq_dbs_disable_turbo(int cpuid);
244 unsigned int cpufreq_dbs_get_turbo_status(int cpuid);
245 #endif /* __XEN_CPUFREQ_PM_H__ */