summaryrefslogtreecommitdiffstats
path: root/power/power.h
blob: db031cfcd8937b058d569fc685886f45d0b07c0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/*
 * Copyright (C) 2016 The CyanogenMod Project <http://www.cyanogenmod.org>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

enum {
    PROFILE_POWER_SAVE = 0,
    PROFILE_BALANCED,
    PROFILE_PERFORMANCE,
    PROFILE_MAX
};

typedef struct governor_settings {
    // freq values for core up/down
    int hotplug_freq_1_1;
    int hotplug_freq_2_0;
    int hotplug_freq_2_1;
    int hotplug_freq_3_0;
    int hotplug_freq_3_1;
    int hotplug_freq_4_0;
    // rq sizes for up/down
    int hotplug_rq_1_1;
    int hotplug_rq_2_0;
    int hotplug_rq_2_1;
    int hotplug_rq_3_0;
    int hotplug_rq_3_1;
    int hotplug_rq_4_0;
    // max/min freqs (-1 for default)
    int max_freq;
    int min_freq;
    // load at which to start scaling up
    int up_threshold;
    // higher down_differential == slower downscaling
    int down_differential;
    // min/max num of cpus to have online
    int min_cpu_lock;
    int max_cpu_lock;
    // wait sampling_rate * cpu_down_rate us before trying to downscale
    int cpu_down_rate;
    int sampling_rate; // in microseconds
    int io_is_busy;
} power_profile;

static power_profile profiles[PROFILE_MAX] = {
    [PROFILE_POWER_SAVE] = {
        .hotplug_freq_1_1 = 800000,
        .hotplug_freq_2_0 = 700000,
        .hotplug_freq_2_1 = 1000000,
        .hotplug_freq_3_0 = 900000,
        .hotplug_freq_3_1 = 1200000,
        .hotplug_freq_4_0 = 1100000,
        .hotplug_rq_1_1 = 200,
        .hotplug_rq_2_0 = 200,
        .hotplug_rq_2_1 = 300,
        .hotplug_rq_3_0 = 300,
        .hotplug_rq_3_1 = 400,
        .hotplug_rq_4_0 = 400,
        .max_freq = 1000000,
        .min_freq = -1,
        .up_threshold = 95,
        .down_differential = 2,
        .min_cpu_lock = 0,
        .max_cpu_lock = 3,
        .cpu_down_rate = 5,
        .sampling_rate = 200000,
        .io_is_busy = 0,
    },
    [PROFILE_BALANCED] = {
        .hotplug_freq_1_1 = 500000,
        .hotplug_freq_2_0 = 500000,
        .hotplug_freq_2_1 = 700000,
        .hotplug_freq_3_0 = 700000,
        .hotplug_freq_3_1 = 900000,
        .hotplug_freq_4_0 = 900000,
        .hotplug_rq_1_1 = 150,
        .hotplug_rq_2_0 = 150,
        .hotplug_rq_2_1 = 250,
        .hotplug_rq_3_0 = 250,
        .hotplug_rq_3_1 = 350,
        .hotplug_rq_4_0 = 350,
        .max_freq = -1,
        .min_freq = -1,
        .up_threshold = 90,
        .down_differential = 3,
        .min_cpu_lock = 0,
        .max_cpu_lock = 0,
        .cpu_down_rate = 10,
        .sampling_rate = 200000,
        .io_is_busy = 0,
    },
    [PROFILE_PERFORMANCE] = {
        .hotplug_freq_1_1 = 500000,
        .hotplug_freq_2_0 = 200000,
        .hotplug_freq_2_1 = 500000,
        .hotplug_freq_3_0 = 200000,
        .hotplug_freq_3_1 = 700000,
        .hotplug_freq_4_0 = 200000,
        .hotplug_rq_1_1 = 150,
        .hotplug_rq_2_0 = 100,
        .hotplug_rq_2_1 = 200,
        .hotplug_rq_3_0 = 150,
        .hotplug_rq_3_1 = 250,
        .hotplug_rq_4_0 = 200,
        .min_freq = -1,
        .max_freq = -1,
        .up_threshold = 80,
        .down_differential = 5,
        .min_cpu_lock = 0,
        .max_cpu_lock = 0,
        .cpu_down_rate = 20,
        .sampling_rate = 200000,
        .io_is_busy = 1,
    },
};

static power_profile profiles_low_power[PROFILE_MAX] = {
    [PROFILE_POWER_SAVE] = {
        .hotplug_freq_1_1 = 800000,
        .hotplug_freq_2_0 = 800000,
        .hotplug_freq_2_1 = 900000,
        .hotplug_freq_3_0 = 900000,
        .hotplug_freq_3_1 = 1200000,
        .hotplug_freq_4_0 = 1100000,
        .hotplug_rq_1_1 = 200,
        .hotplug_rq_2_0 = 200,
        .hotplug_rq_2_1 = 300,
        .hotplug_rq_3_0 = 300,
        .hotplug_rq_3_1 = 400,
        .hotplug_rq_4_0 = 400,
        .max_freq = 900000,
        .min_freq = -1,
        .up_threshold = 95,
        .down_differential = 1,
        .min_cpu_lock = 0,
        .max_cpu_lock = 2,
        .cpu_down_rate = 5,
        .sampling_rate = 200000,
        .io_is_busy = 0,
    },
    [PROFILE_BALANCED] = {
        .hotplug_freq_1_1 = 700000,
        .hotplug_freq_2_0 = 700000,
        .hotplug_freq_2_1 = 900000,
        .hotplug_freq_3_0 = 900000,
        .hotplug_freq_3_1 = 1100000,
        .hotplug_freq_4_0 = 1100000,
        .hotplug_rq_1_1 = 150,
        .hotplug_rq_2_0 = 150,
        .hotplug_rq_2_1 = 250,
        .hotplug_rq_3_0 = 250,
        .hotplug_rq_3_1 = 350,
        .hotplug_rq_4_0 = 350,
        .max_freq = 1200000,
        .min_freq = -1,
        .up_threshold = 90,
        .down_differential = 2,
        .min_cpu_lock = 0,
        .max_cpu_lock = 0,
        .cpu_down_rate = 8,
        .sampling_rate = 200000,
        .io_is_busy = 0,
    },
    [PROFILE_PERFORMANCE] = {
        .hotplug_freq_1_1 = 800000,
        .hotplug_freq_2_0 = 500000,
        .hotplug_freq_2_1 = 800000,
        .hotplug_freq_3_0 = 500000,
        .hotplug_freq_3_1 = 1000000,
        .hotplug_freq_4_0 = 700000,
        .hotplug_rq_1_1 = 150,
        .hotplug_rq_2_0 = 100,
        .hotplug_rq_2_1 = 200,
        .hotplug_rq_3_0 = 150,
        .hotplug_rq_3_1 = 250,
        .hotplug_rq_4_0 = 200,
        .min_freq = -1,
        .max_freq = -1,
        .up_threshold = 85,
        .down_differential = 5,
        .min_cpu_lock = 0,
        .max_cpu_lock = 0,
        .cpu_down_rate = 15,
        .sampling_rate = 200000,
        .io_is_busy = 1,
    },
};