debuggers.hg

view xen/include/acpi/cpufreq/cpufreq.h @ 17943:baaea9f0db5e

x86: Add cpufreq logic to S3 suspend/resume

When suspend to S3, stop the cpufreq dbs governor. When resume from
S3, firstly sync cpu state and freq at the 1st dbs timer; from 2nd dbs
timer on, cpufreq dbs governor control cpu px transfer according to
its workload algorithm. Px statistic is also handled.

Signed-off-by: Liu Jinsong <jinsong.liu@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jun 27 16:16:47 2008 +0100 (2008-06-27)
parents 50fb7620d05a
children f875aaa791f0 f125e481d8b6
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 #include <xen/types.h>
15 #include <xen/list.h>
16 #include <xen/cpumask.h>
18 #include "processor_perf.h"
20 #define CPUFREQ_NAME_LEN 16
22 struct cpufreq_cpuinfo {
23 unsigned int max_freq;
24 unsigned int min_freq;
25 unsigned int transition_latency; /* in 10^(-9) s = nanoseconds */
26 };
28 struct cpufreq_policy {
29 cpumask_t cpus; /* affected CPUs */
30 unsigned int shared_type; /* ANY or ALL affected CPUs
31 should set cpufreq */
32 unsigned int cpu; /* cpu nr of registered CPU */
33 struct cpufreq_cpuinfo cpuinfo; /* see above */
35 unsigned int min; /* in kHz */
36 unsigned int max; /* in kHz */
37 unsigned int cur; /* in kHz, only needed if cpufreq
38 * governors are used */
39 unsigned int resume; /* flag for cpufreq 1st run
40 * S3 wakeup, hotplug cpu, etc */
41 };
42 extern struct cpufreq_policy xen_px_policy[NR_CPUS];
44 #define CPUFREQ_SHARED_TYPE_NONE (0) /* None */
45 #define CPUFREQ_SHARED_TYPE_HW (1) /* HW does needed coordination */
46 #define CPUFREQ_SHARED_TYPE_ALL (2) /* All dependent CPUs should set freq */
47 #define CPUFREQ_SHARED_TYPE_ANY (3) /* Freq can be set from any dependent CPU*/
49 /******************** cpufreq transition notifiers *******************/
51 struct cpufreq_freqs {
52 unsigned int cpu; /* cpu nr */
53 unsigned int old;
54 unsigned int new;
55 u8 flags; /* flags of cpufreq_driver, see below. */
56 };
59 /*********************************************************************
60 * CPUFREQ GOVERNORS *
61 *********************************************************************/
63 #define CPUFREQ_GOV_START 1
64 #define CPUFREQ_GOV_STOP 2
65 #define CPUFREQ_GOV_LIMITS 3
67 /* pass a target to the cpufreq driver */
68 extern int __cpufreq_driver_target(struct cpufreq_policy *policy,
69 unsigned int target_freq,
70 unsigned int relation);
71 extern int __cpufreq_driver_getavg(struct cpufreq_policy *policy);
74 /*********************************************************************
75 * CPUFREQ DRIVER INTERFACE *
76 *********************************************************************/
78 #define CPUFREQ_RELATION_L 0 /* lowest frequency at or above target */
79 #define CPUFREQ_RELATION_H 1 /* highest frequency below or at target */
81 struct cpufreq_driver {
82 int (*init)(struct cpufreq_policy *policy);
83 int (*verify)(struct cpufreq_policy *policy);
84 int (*target)(struct cpufreq_policy *policy,
85 unsigned int target_freq,
86 unsigned int relation);
87 unsigned int (*get)(unsigned int cpu);
88 unsigned int (*getavg)(unsigned int cpu);
89 int (*exit)(struct cpufreq_policy *policy);
90 };
92 extern struct cpufreq_driver *cpufreq_driver;
94 void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state);
96 /*********************************************************************
97 * FREQUENCY TABLE HELPERS *
98 *********************************************************************/
100 #define CPUFREQ_ENTRY_INVALID ~0
101 #define CPUFREQ_TABLE_END ~1
103 struct cpufreq_frequency_table {
104 unsigned int index; /* any */
105 unsigned int frequency; /* kHz - doesn't need to be in ascending
106 * order */
107 };
109 int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
110 struct cpufreq_frequency_table *table);
112 int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
113 struct cpufreq_frequency_table *table,
114 unsigned int target_freq,
115 unsigned int relation,
116 unsigned int *index);
119 /*********************************************************************
120 * UNIFIED DEBUG HELPERS *
121 *********************************************************************/
123 struct cpu_dbs_info_s {
124 uint64_t prev_cpu_idle;
125 uint64_t prev_cpu_wall;
126 struct cpufreq_policy *cur_policy;
127 struct cpufreq_frequency_table *freq_table;
128 int cpu;
129 unsigned int enable:1;
130 };
132 int cpufreq_governor_dbs(struct cpufreq_policy *policy, unsigned int event);