// SPDX-License-Identifier: GPL-2.0 /* * temp.c Thermal management for cpu's with Thermal Assist Units * * Written by Troy Benjegerdes <hozer@drgw.net> * * TODO: * dynamic power management to limit peak CPU temp (using ICTC) * calibration??? * * Silly, crazy ideas: use cpu load (from scheduler) and ICTC to extend battery * life in portables, and add a 'performance/watt' metric somewhere in /proc
*/
/* TODO: put these in a /proc interface, with some sanity checks, and maybe
* dynamic adjustment to minimize # of interrupts */ /* configurable values for step size and how much to expand the window when
* we get an interrupt. These are based on the limit that was out of range */ #define step_size 2 /* step size when temp goes out of range */ #define window_expand 1 /* expand the window by this much */ /* configurable values for shrinking the window */ #define shrink_timer 2000 /* period between shrinking the window */ #define min_window 2 /* minimum window size, degrees C */
/* if both thresholds are crossed, the step_sizes cancel out
* and the window winds up getting expanded twice. */
thrm = mfspr(SPRN_THRM1); if ((thrm & bits) == bits) {
mtspr(SPRN_THRM1, 0);
#ifdef CONFIG_TAU_INT /* * TAU interrupts - called when we have a thermal assist unit interrupt * with interrupts disabled
*/
DEFINE_INTERRUPT_HANDLER_ASYNC(TAUException)
{ int cpu = smp_processor_id();
tau[cpu].interrupts++;
TAUupdate(cpu);
} #endif/* CONFIG_TAU_INT */
staticvoid tau_timeout(void * info)
{ int cpu; int size; int shrink;
cpu = smp_processor_id();
if (!tau_int_enable)
TAUupdate(cpu);
/* Stop thermal sensor comparisons and interrupts */
mtspr(SPRN_THRM3, 0);
size = tau[cpu].high - tau[cpu].low; if (size > min_window && ! tau[cpu].grew) { /* do an exponential shrink of half the amount currently over size */
shrink = (2 + size - min_window) / 4; if (shrink) {
tau[cpu].low += shrink;
tau[cpu].high -= shrink;
} else { /* size must have been min_window + 1 */
tau[cpu].low += 1; #if 1 /* debug */ if ((tau[cpu].high - tau[cpu].low) != min_window){
printk(KERN_ERR "temp.c: line %d, logic error\n", __LINE__);
} #endif
}
}
tau[cpu].grew = 0;
set_thresholds(cpu);
/* Restart thermal sensor comparisons and interrupts. * The "PowerPC 740 and PowerPC 750 Microprocessor Datasheet" * recommends that "the maximum value be set in THRM3 under all * conditions."
*/
mtspr(SPRN_THRM3, THRM3_SITV(0x1fff) | THRM3_E);
}
staticstruct workqueue_struct *tau_workq;
staticvoid tau_work_func(struct work_struct *work)
{
msleep(shrink_timer);
on_each_cpu(tau_timeout, NULL, 0); /* schedule ourselves to be run again */
queue_work(tau_workq, work);
}
static DECLARE_WORK(tau_work, tau_work_func);
/* * setup the TAU * * Set things up to use THRM1 as a temperature lower bound, and THRM2 as an upper bound. * Start off at zero
*/
int tau_initialized = 0;
staticvoid __init TAU_init_smp(void *info)
{ unsignedlong cpu = smp_processor_id();
/* set these to a reasonable value and let the timer shrink the
* window */
tau[cpu].low = 5;
tau[cpu].high = 120;
set_thresholds(cpu);
}
staticint __init TAU_init(void)
{ /* We assume in SMP that if one CPU has TAU support, they * all have it --BenH
*/ if (!cpu_has_feature(CPU_FTR_TAU)) {
printk("Thermal assist unit not available\n");
tau_initialized = 0; return 1;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.