View | Details | Raw Unified | Return to bug 3410 | Differences between
and this patch

Collapse All | Expand All

(-)a/drivers/acpi/processor_thermal.c (-15 / +21 lines)
Lines 101-109 static unsigned int acpi_thermal_cpufreq Link Here
101
static int cpu_has_cpufreq(unsigned int cpu)
101
static int cpu_has_cpufreq(unsigned int cpu)
102
{
102
{
103
	struct cpufreq_policy policy;
103
	struct cpufreq_policy policy;
104
	if (!acpi_thermal_cpufreq_is_init)
104
	if (!acpi_thermal_cpufreq_is_init || cpufreq_get_policy(&policy, cpu))
105
		return -ENODEV;
106
	if (!cpufreq_get_policy(&policy, cpu))
107
		return -ENODEV;
105
		return -ENODEV;
108
	return 0;
106
	return 0;
109
}
107
}
Lines 127-139 static int acpi_thermal_cpufreq_decrease Link Here
127
	if (!cpu_has_cpufreq(cpu))
125
	if (!cpu_has_cpufreq(cpu))
128
		return -ENODEV;
126
		return -ENODEV;
129
127
130
	if (cpufreq_thermal_reduction_pctg[cpu] >= 20) {
128
	if (cpufreq_thermal_reduction_pctg[cpu] > 20)
131
		cpufreq_thermal_reduction_pctg[cpu] -= 20;
129
		cpufreq_thermal_reduction_pctg[cpu] -= 20;
132
		cpufreq_update_policy(cpu);
130
        else
133
		return 0;
131
                cpufreq_thermal_reduction_pctg[cpu] = 0;
134
	}
132
	cpufreq_update_policy(cpu);
135
133
	// We reached max freq again and can leave passive mode
136
	return -ERANGE;
134
	return !cpufreq_thermal_reduction_pctg[cpu];
137
}
135
}
138
136
139
static int acpi_thermal_cpufreq_notifier(struct notifier_block *nb,
137
static int acpi_thermal_cpufreq_notifier(struct notifier_block *nb,
Lines 200-206 int acpi_processor_set_thermal_limit(acp Link Here
200
	int result = 0;
198
	int result = 0;
201
	struct acpi_processor *pr = NULL;
199
	struct acpi_processor *pr = NULL;
202
	struct acpi_device *device = NULL;
200
	struct acpi_device *device = NULL;
203
	int tx = 0;
201
	int tx = 0, max_tx_px = 0;
204
202
205
	ACPI_FUNCTION_TRACE("acpi_processor_set_thermal_limit");
203
	ACPI_FUNCTION_TRACE("acpi_processor_set_thermal_limit");
206
204
Lines 259-277 int acpi_processor_set_thermal_limit(acp Link Here
259
		/* if going down: T-states first, P-states later */
257
		/* if going down: T-states first, P-states later */
260
258
261
		if (pr->flags.throttling) {
259
		if (pr->flags.throttling) {
262
			if (tx == 0)
260
			if (tx == 0) {
261
                                max_tx_px = 1;
263
				ACPI_DEBUG_PRINT((ACPI_DB_INFO,
262
				ACPI_DEBUG_PRINT((ACPI_DB_INFO,
264
						  "At minimum throttling state\n"));
263
						  "At minimum throttling state\n"));
265
			else {
264
			} else {
266
				tx--;
265
				tx--;
267
				goto end;
266
				goto end;
268
			}
267
			}
269
		}
268
		}
270
269
271
		result = acpi_thermal_cpufreq_decrease(pr->id);
270
		result = acpi_thermal_cpufreq_decrease(pr->id);
272
		if (result == -ERANGE)
271
		if (result) {
272
			// We only could get -ERANGE, 1 or 0.
273
			// In the first two cases we reached max freq again.
273
			ACPI_DEBUG_PRINT((ACPI_DB_INFO,
274
			ACPI_DEBUG_PRINT((ACPI_DB_INFO,
274
					  "At minimum performance state\n"));
275
					  "At minimum performance state\n"));
276
			max_tx_px = 1;
277
		} else
278
			max_tx_px = 0;
275
279
276
		break;
280
		break;
277
	}
281
	}
Lines 290-297 int acpi_processor_set_thermal_limit(acp Link Here
290
				  pr->limit.thermal.px, pr->limit.thermal.tx));
294
				  pr->limit.thermal.px, pr->limit.thermal.tx));
291
	} else
295
	} else
292
		result = 0;
296
		result = 0;
293
297
	if (max_tx_px)
294
	return_VALUE(result);
298
		return_VALUE(1);
299
	else
300
		return_VALUE(result);
295
}
301
}
296
302
297
int acpi_processor_get_limit_info(struct acpi_processor *pr)
303
int acpi_processor_get_limit_info(struct acpi_processor *pr)
(-)a/drivers/acpi/thermal.c (-81 / +78 lines)
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

Return to bug 3410