Lines 72-78
Link Here
|
72 |
#define _COMPONENT ACPI_THERMAL_COMPONENT |
72 |
#define _COMPONENT ACPI_THERMAL_COMPONENT |
73 |
ACPI_MODULE_NAME("acpi_thermal") |
73 |
ACPI_MODULE_NAME("acpi_thermal") |
74 |
|
74 |
|
75 |
MODULE_AUTHOR("Paul Diefenbaugh"); |
75 |
MODULE_AUTHOR("Paul Diefenbaugh"); |
76 |
MODULE_DESCRIPTION(ACPI_THERMAL_DRIVER_NAME); |
76 |
MODULE_DESCRIPTION(ACPI_THERMAL_DRIVER_NAME); |
77 |
MODULE_LICENSE("GPL"); |
77 |
MODULE_LICENSE("GPL"); |
78 |
|
78 |
|
Lines 517-525
static int acpi_thermal_hot(struct acpi_
Link Here
|
517 |
return_VALUE(0); |
517 |
return_VALUE(0); |
518 |
} |
518 |
} |
519 |
|
519 |
|
520 |
static int acpi_thermal_passive(struct acpi_thermal *tz) |
520 |
static void acpi_thermal_passive(struct acpi_thermal *tz) |
521 |
{ |
521 |
{ |
522 |
int result = 0; |
522 |
int result = 1; |
523 |
struct acpi_thermal_passive *passive = NULL; |
523 |
struct acpi_thermal_passive *passive = NULL; |
524 |
int trend = 0; |
524 |
int trend = 0; |
525 |
int i = 0; |
525 |
int i = 0; |
Lines 527-533
static int acpi_thermal_passive(struct a
Link Here
|
527 |
ACPI_FUNCTION_TRACE("acpi_thermal_passive"); |
527 |
ACPI_FUNCTION_TRACE("acpi_thermal_passive"); |
528 |
|
528 |
|
529 |
if (!tz || !tz->trips.passive.flags.valid) |
529 |
if (!tz || !tz->trips.passive.flags.valid) |
530 |
return_VALUE(-EINVAL); |
530 |
return; |
531 |
|
531 |
|
532 |
passive = &(tz->trips.passive); |
532 |
passive = &(tz->trips.passive); |
533 |
|
533 |
|
Lines 547-553
static int acpi_thermal_passive(struct a
Link Here
|
547 |
trend, passive->tc1, tz->temperature, |
547 |
trend, passive->tc1, tz->temperature, |
548 |
tz->last_temperature, passive->tc2, |
548 |
tz->last_temperature, passive->tc2, |
549 |
tz->temperature, passive->temperature)); |
549 |
tz->temperature, passive->temperature)); |
550 |
tz->trips.passive.flags.enabled = 1; |
550 |
passive->flags.enabled = 1; |
551 |
/* Heating up? */ |
551 |
/* Heating up? */ |
552 |
if (trend > 0) |
552 |
if (trend > 0) |
553 |
for (i = 0; i < passive->devices.count; i++) |
553 |
for (i = 0; i < passive->devices.count; i++) |
Lines 556-567
static int acpi_thermal_passive(struct a
Link Here
|
556 |
handles[i], |
556 |
handles[i], |
557 |
ACPI_PROCESSOR_LIMIT_INCREMENT); |
557 |
ACPI_PROCESSOR_LIMIT_INCREMENT); |
558 |
/* Cooling off? */ |
558 |
/* Cooling off? */ |
559 |
else if (trend < 0) |
559 |
else if (trend < 0) { |
560 |
for (i = 0; i < passive->devices.count; i++) |
560 |
for (i = 0; i < passive->devices.count; i++) |
561 |
acpi_processor_set_thermal_limit(passive-> |
561 |
// assume that we are on highest freq/lowest thrott |
562 |
devices. |
562 |
// and can leave passive mode, even in error case |
563 |
handles[i], |
563 |
if (!acpi_processor_set_thermal_limit( |
564 |
ACPI_PROCESSOR_LIMIT_DECREMENT); |
564 |
passive->devices.handles[i], |
|
|
565 |
ACPI_PROCESSOR_LIMIT_DECREMENT)) |
566 |
result = 0; |
567 |
// Leave cooling mode, even if the temp might higher than trip point. |
568 |
// This is because some machines might have long thermal polling frequencies |
569 |
// (tsp) defined. We will fall back into passive mode in next cycle (probably quicker) |
570 |
if (result) { |
571 |
passive->flags.enabled = 0; |
572 |
ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
573 |
"Disabling passive cooling, still above threshold," |
574 |
" but we are cooling down\n")); |
575 |
} |
576 |
} |
577 |
return; |
565 |
} |
578 |
} |
566 |
|
579 |
|
567 |
/* |
580 |
/* |
Lines 571-593
static int acpi_thermal_passive(struct a
Link Here
|
571 |
* and avoid thrashing around the passive trip point. Note that we |
584 |
* and avoid thrashing around the passive trip point. Note that we |
572 |
* assume symmetry. |
585 |
* assume symmetry. |
573 |
*/ |
586 |
*/ |
574 |
else if (tz->trips.passive.flags.enabled) { |
587 |
if (!passive->flags.enabled) |
575 |
for (i = 0; i < passive->devices.count; i++) |
588 |
return; |
576 |
result = |
589 |
for (i = 0; i < passive->devices.count; i++) |
577 |
acpi_processor_set_thermal_limit(passive->devices. |
590 |
if (!acpi_processor_set_thermal_limit( |
578 |
handles[i], |
591 |
passive->devices.handles[i], |
579 |
ACPI_PROCESSOR_LIMIT_DECREMENT); |
592 |
ACPI_PROCESSOR_LIMIT_DECREMENT)) |
580 |
if (result == 1) { |
593 |
result = 0; |
581 |
tz->trips.passive.flags.enabled = 0; |
594 |
if (result) { |
582 |
ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
595 |
passive->flags.enabled = 0; |
583 |
"Disabling passive cooling (zone is cool)\n")); |
596 |
ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
584 |
} |
597 |
"Disabling passive cooling (zone is cool)\n")); |
585 |
} |
598 |
} |
586 |
|
|
|
587 |
return_VALUE(0); |
588 |
} |
599 |
} |
589 |
|
600 |
|
590 |
static int acpi_thermal_active(struct acpi_thermal *tz) |
601 |
static void acpi_thermal_active(struct acpi_thermal *tz) |
591 |
{ |
602 |
{ |
592 |
int result = 0; |
603 |
int result = 0; |
593 |
struct acpi_thermal_active *active = NULL; |
604 |
struct acpi_thermal_active *active = NULL; |
Lines 598-671
static int acpi_thermal_active(struct ac
Link Here
|
598 |
ACPI_FUNCTION_TRACE("acpi_thermal_active"); |
609 |
ACPI_FUNCTION_TRACE("acpi_thermal_active"); |
599 |
|
610 |
|
600 |
if (!tz) |
611 |
if (!tz) |
601 |
return_VALUE(-EINVAL); |
612 |
return; |
602 |
|
613 |
|
603 |
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { |
614 |
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { |
604 |
|
|
|
605 |
active = &(tz->trips.active[i]); |
615 |
active = &(tz->trips.active[i]); |
606 |
if (!active || !active->flags.valid) |
616 |
if (!active || !active->flags.valid) |
607 |
break; |
617 |
break; |
608 |
|
|
|
609 |
/* |
610 |
* Above Threshold? |
611 |
* ---------------- |
612 |
* If not already enabled, turn ON all cooling devices |
613 |
* associated with this active threshold. |
614 |
*/ |
615 |
if (tz->temperature >= active->temperature) { |
618 |
if (tz->temperature >= active->temperature) { |
|
|
619 |
/* |
620 |
* Above Threshold? |
621 |
* ---------------- |
622 |
* If not already enabled, turn ON all cooling devices |
623 |
* associated with this active threshold. |
624 |
*/ |
616 |
if (active->temperature > maxtemp) |
625 |
if (active->temperature > maxtemp) |
617 |
tz->state.active_index = i, maxtemp = |
626 |
tz->state.active_index = i; |
618 |
active->temperature; |
627 |
maxtemp = active->temperature; |
619 |
if (!active->flags.enabled) { |
628 |
if (active->flags.enabled) |
620 |
for (j = 0; j < active->devices.count; j++) { |
629 |
continue; |
621 |
result = |
630 |
for (j = 0; j < active->devices.count; j++) { |
622 |
acpi_bus_set_power(active->devices. |
631 |
result = acpi_bus_set_power(active->devices.handles[j], |
623 |
handles[j], |
632 |
ACPI_STATE_D0); |
624 |
ACPI_STATE_D0); |
633 |
if (result) { |
625 |
if (result) { |
634 |
ACPI_DEBUG_PRINT((ACPI_DB_WARN, |
626 |
ACPI_DEBUG_PRINT((ACPI_DB_WARN, |
635 |
"Unable to turn cooling device [%p] 'on'\n", |
627 |
"Unable to turn cooling device [%p] 'on'\n", |
636 |
active->devices.handles[j])); |
628 |
active-> |
637 |
continue; |
629 |
devices. |
|
|
630 |
handles[j])); |
631 |
continue; |
632 |
} |
633 |
active->flags.enabled = 1; |
634 |
ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
635 |
"Cooling device [%p] now 'on'\n", |
636 |
active->devices. |
637 |
handles[j])); |
638 |
} |
638 |
} |
|
|
639 |
active->flags.enabled = 1; |
640 |
ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
641 |
"Cooling device [%p] now 'on'\n", |
642 |
active->devices.handles[j])); |
639 |
} |
643 |
} |
|
|
644 |
continue; |
640 |
} |
645 |
} |
|
|
646 |
if (!active->flags.enabled) |
647 |
continue; |
641 |
/* |
648 |
/* |
642 |
* Below Threshold? |
649 |
* Below Threshold? |
643 |
* ---------------- |
650 |
* ---------------- |
644 |
* Turn OFF all cooling devices associated with this |
651 |
* Turn OFF all cooling devices associated with this |
645 |
* threshold. |
652 |
* threshold. |
646 |
*/ |
653 |
*/ |
647 |
else if (active->flags.enabled) { |
654 |
for (j = 0; j < active->devices.count; j++) { |
648 |
for (j = 0; j < active->devices.count; j++) { |
655 |
result = acpi_bus_set_power(active->devices.handles[j], |
649 |
result = |
656 |
ACPI_STATE_D3); |
650 |
acpi_bus_set_power(active->devices. |
657 |
if (result) { |
651 |
handles[j], |
658 |
ACPI_DEBUG_PRINT((ACPI_DB_WARN, |
652 |
ACPI_STATE_D3); |
659 |
"Unable to turn cooling device [%p] 'off'\n", |
653 |
if (result) { |
660 |
active->devices.handles[j])); |
654 |
ACPI_DEBUG_PRINT((ACPI_DB_WARN, |
661 |
continue; |
655 |
"Unable to turn cooling device [%p] 'off'\n", |
|
|
656 |
active->devices. |
657 |
handles[j])); |
658 |
continue; |
659 |
} |
660 |
active->flags.enabled = 0; |
661 |
ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
662 |
"Cooling device [%p] now 'off'\n", |
663 |
active->devices.handles[j])); |
664 |
} |
662 |
} |
|
|
663 |
active->flags.enabled = 0; |
664 |
ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
665 |
"Cooling device [%p] now 'off'\n", |
666 |
active->devices.handles[j])); |
665 |
} |
667 |
} |
666 |
} |
668 |
} |
667 |
|
|
|
668 |
return_VALUE(0); |
669 |
} |
669 |
} |
670 |
|
670 |
|
671 |
static void acpi_thermal_check(void *context); |
671 |
static void acpi_thermal_check(void *context); |
Lines 744-758
static void acpi_thermal_check(void *dat
Link Here
|
744 |
* Again, separated from the above two to allow independent policy |
744 |
* Again, separated from the above two to allow independent policy |
745 |
* decisions. |
745 |
* decisions. |
746 |
*/ |
746 |
*/ |
747 |
if (tz->trips.critical.flags.enabled) |
747 |
tz->state.critical = tz->trips.critical.flags.enabled; |
748 |
tz->state.critical = 1; |
748 |
tz->state.hot = tz->trips.hot.flags.enabled; |
749 |
if (tz->trips.hot.flags.enabled) |
749 |
tz->state.passive = tz->trips.passive.flags.enabled; |
750 |
tz->state.hot = 1; |
750 |
tz->state.active = 0; |
751 |
if (tz->trips.passive.flags.enabled) |
|
|
752 |
tz->state.passive = 1; |
753 |
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) |
751 |
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) |
754 |
if (tz->trips.active[i].flags.enabled) |
752 |
tz->state.active |= tz->trips.active[i].flags.enabled; |
755 |
tz->state.active = 1; |
|
|
756 |
|
753 |
|
757 |
/* |
754 |
/* |
758 |
* Calculate Sleep Time |
755 |
* Calculate Sleep Time |