Lines Matching +full:power +full:- +full:friendly
1 // SPDX-License-Identifier: GPL-2.0-only
45 * struct _thermal_state - Represent the current thermal event state
52 * or power threshold interrupts.
54 * or power threshold interrupts.
61 * This is used for the purpose of rate-control.
142 unsigned int cpu = dev->id; \
248 get_therm_status(state->level, &hot, &temp); in throttle_active_work()
250 if (!hot && temp > state->baseline_temp) { in throttle_active_work()
251 if (state->rate_control_active) in throttle_active_work()
254 state->level == CORE_LEVEL ? "Core" : "Package", in throttle_active_work()
255 state->count); in throttle_active_work()
257 state->rate_control_active = false; in throttle_active_work()
261 if (time_before64(now, state->next_check) && in throttle_active_work()
262 state->rate_control_active) in throttle_active_work()
265 state->next_check = now + CHECK_INTERVAL; in throttle_active_work()
267 if (state->count != state->last_count) { in throttle_active_work()
269 state->last_count = state->count; in throttle_active_work()
270 state->average = 0; in throttle_active_work()
271 state->sample_count = 0; in throttle_active_work()
272 state->sample_index = 0; in throttle_active_work()
275 state->temp_samples[state->sample_index] = temp; in throttle_active_work()
276 state->sample_count++; in throttle_active_work()
277 state->sample_index = (state->sample_index + 1) % ARRAY_SIZE(state->temp_samples); in throttle_active_work()
278 if (state->sample_count < ARRAY_SIZE(state->temp_samples)) in throttle_active_work()
282 for (i = 0; i < ARRAY_SIZE(state->temp_samples); ++i) in throttle_active_work()
283 avg += state->temp_samples[i]; in throttle_active_work()
285 avg /= ARRAY_SIZE(state->temp_samples); in throttle_active_work()
287 if (state->average > avg) { in throttle_active_work()
290 state->level == CORE_LEVEL ? "Core" : "Package", in throttle_active_work()
291 state->count); in throttle_active_work()
292 state->rate_control_active = true; in throttle_active_work()
295 state->average = avg; in throttle_active_work()
298 clear_therm_status_log(state->level); in throttle_active_work()
299 schedule_delayed_work_on(this_cpu, &state->therm_work, THERM_THROT_POLL_INTERVAL); in throttle_active_work()
303 * therm_throt_process - Process thermal throttling event from interrupt
324 state = &pstate->core_throttle; in therm_throt_process()
326 state = &pstate->core_power_limit; in therm_throt_process()
331 state = &pstate->package_throttle; in therm_throt_process()
333 state = &pstate->package_power_limit; in therm_throt_process()
339 old_event = state->new_event; in therm_throt_process()
340 state->new_event = new_event; in therm_throt_process()
343 state->count++; in therm_throt_process()
348 if (new_event && !state->last_interrupt_time) { in therm_throt_process()
352 get_therm_status(state->level, &hot, &temp); in therm_throt_process()
361 state->baseline_temp = temp; in therm_throt_process()
362 state->last_interrupt_time = now; in therm_throt_process()
363 schedule_delayed_work_on(this_cpu, &state->therm_work, THERM_THROT_POLL_INTERVAL); in therm_throt_process()
364 } else if (old_event && state->last_interrupt_time) { in therm_throt_process()
367 throttle_time = jiffies_delta_to_msecs(now - state->last_interrupt_time); in therm_throt_process()
368 if (throttle_time > state->max_time_ms) in therm_throt_process()
369 state->max_time_ms = throttle_time; in therm_throt_process()
370 state->total_time_ms += throttle_time; in therm_throt_process()
371 state->last_interrupt_time = 0; in therm_throt_process()
383 state = (event == 0) ? &pstate->pkg_thresh0 : in thresh_event_valid()
384 &pstate->pkg_thresh1; in thresh_event_valid()
386 state = (event == 0) ? &pstate->core_thresh0 : in thresh_event_valid()
387 &pstate->core_thresh1; in thresh_event_valid()
389 if (time_before64(now, state->next_check)) in thresh_event_valid()
392 state->next_check = now + CHECK_INTERVAL; in thresh_event_valid()
413 err = sysfs_create_group(&dev->kobj, &thermal_attr_group); in thermal_throttle_add_dev()
418 err = sysfs_add_file_to_group(&dev->kobj, in thermal_throttle_add_dev()
426 err = sysfs_add_file_to_group(&dev->kobj, in thermal_throttle_add_dev()
432 err = sysfs_add_file_to_group(&dev->kobj, in thermal_throttle_add_dev()
438 err = sysfs_add_file_to_group(&dev->kobj, in thermal_throttle_add_dev()
445 err = sysfs_add_file_to_group(&dev->kobj, in thermal_throttle_add_dev()
456 sysfs_remove_group(&dev->kobj, &thermal_attr_group); in thermal_throttle_add_dev()
463 sysfs_remove_group(&dev->kobj, &thermal_attr_group); in thermal_throttle_remove_dev()
466 /* Get notified when a cpu comes on/off. Be hotplug friendly. */
473 state->package_throttle.level = PACKAGE_LEVEL; in thermal_throttle_online()
474 state->core_throttle.level = CORE_LEVEL; in thermal_throttle_online()
476 INIT_DELAYED_WORK(&state->package_throttle.therm_work, throttle_active_work); in thermal_throttle_online()
477 INIT_DELAYED_WORK(&state->core_throttle.therm_work, throttle_active_work); in thermal_throttle_online()
505 cancel_delayed_work_sync(&state->package_throttle.therm_work); in thermal_throttle_offline()
506 cancel_delayed_work_sync(&state->core_throttle.therm_work); in thermal_throttle_offline()
508 state->package_throttle.rate_control_active = false; in thermal_throttle_offline()
509 state->core_throttle.rate_control_active = false; in thermal_throttle_offline()
675 * 0x10000 because APs are woken up by BSP issuing INIT-SIPI-SIPI in intel_init_thermal()
695 if (c->x86 == 6 && (c->x86_model == 9 || c->x86_model == 13)) { in intel_init_thermal()