171
172 int
173 cpupm_set_policy(cpupm_policy_t new_policy)
174 {
175 static int gov_init = 0;
176 int result = 0;
177
178 mutex_enter(&cpu_lock);
179 if (new_policy == cpupm_policy) {
180 mutex_exit(&cpu_lock);
181 return (result);
182 }
183
184 /*
185 * Pausing CPUs causes a high priority thread to be scheduled
186 * on all other CPUs (besides the current one). This locks out
187 * other CPUs from making CPUPM state transitions.
188 */
189 switch (new_policy) {
190 case CPUPM_POLICY_DISABLED:
191 pause_cpus(NULL);
192 cpupm_policy = CPUPM_POLICY_DISABLED;
193 start_cpus();
194
195 result = cmt_pad_disable(PGHW_POW_ACTIVE);
196
197 /*
198 * Once PAD has been enabled, it should always be possible
199 * to disable it.
200 */
201 ASSERT(result == 0);
202
203 /*
204 * Bring all the active power domains to the maximum
205 * performance state.
206 */
207 cpupm_state_change_global(CPUPM_DTYPE_ACTIVE,
208 CPUPM_STATE_MAX_PERF);
209
210 break;
211 case CPUPM_POLICY_ELASTIC:
212
213 result = cmt_pad_enable(PGHW_POW_ACTIVE);
214 if (result < 0) {
215 /*
216 * Failed to enable PAD across the active power
217 * domains, which may well be because none were
218 * enumerated.
219 */
220 break;
221 }
222
223 /*
224 * Initialize the governor parameters the first time through.
225 */
226 if (gov_init == 0) {
227 cpupm_governor_initialize();
228 gov_init = 1;
229 }
230
231 pause_cpus(NULL);
232 cpupm_policy = CPUPM_POLICY_ELASTIC;
233 start_cpus();
234
235 break;
236 default:
237 cmn_err(CE_WARN, "Attempt to set unknown CPUPM policy %d\n",
238 new_policy);
239 ASSERT(0);
240 break;
241 }
242 mutex_exit(&cpu_lock);
243
244 return (result);
245 }
246
247 /*
248 * Look for an existing power domain
249 */
250 static cpupm_domain_t *
251 cpupm_domain_find(id_t id, cpupm_dtype_t type)
|
171
172 int
173 cpupm_set_policy(cpupm_policy_t new_policy)
174 {
175 static int gov_init = 0;
176 int result = 0;
177
178 mutex_enter(&cpu_lock);
179 if (new_policy == cpupm_policy) {
180 mutex_exit(&cpu_lock);
181 return (result);
182 }
183
184 /*
185 * Pausing CPUs causes a high priority thread to be scheduled
186 * on all other CPUs (besides the current one). This locks out
187 * other CPUs from making CPUPM state transitions.
188 */
189 switch (new_policy) {
190 case CPUPM_POLICY_DISABLED:
191 pause_cpus(NULL, NULL);
192 cpupm_policy = CPUPM_POLICY_DISABLED;
193 start_cpus();
194
195 result = cmt_pad_disable(PGHW_POW_ACTIVE);
196
197 /*
198 * Once PAD has been enabled, it should always be possible
199 * to disable it.
200 */
201 ASSERT(result == 0);
202
203 /*
204 * Bring all the active power domains to the maximum
205 * performance state.
206 */
207 cpupm_state_change_global(CPUPM_DTYPE_ACTIVE,
208 CPUPM_STATE_MAX_PERF);
209
210 break;
211 case CPUPM_POLICY_ELASTIC:
212
213 result = cmt_pad_enable(PGHW_POW_ACTIVE);
214 if (result < 0) {
215 /*
216 * Failed to enable PAD across the active power
217 * domains, which may well be because none were
218 * enumerated.
219 */
220 break;
221 }
222
223 /*
224 * Initialize the governor parameters the first time through.
225 */
226 if (gov_init == 0) {
227 cpupm_governor_initialize();
228 gov_init = 1;
229 }
230
231 pause_cpus(NULL, NULL);
232 cpupm_policy = CPUPM_POLICY_ELASTIC;
233 start_cpus();
234
235 break;
236 default:
237 cmn_err(CE_WARN, "Attempt to set unknown CPUPM policy %d\n",
238 new_policy);
239 ASSERT(0);
240 break;
241 }
242 mutex_exit(&cpu_lock);
243
244 return (result);
245 }
246
247 /*
248 * Look for an existing power domain
249 */
250 static cpupm_domain_t *
251 cpupm_domain_find(id_t id, cpupm_dtype_t type)
|