示例#1
0
static int
acpi_thermal_passive (
	struct acpi_thermal	*tz)
{
	int			result = 0;
	struct acpi_thermal_passive *passive = NULL;
	int			trend = 0;
	int			i = 0;

	ACPI_FUNCTION_TRACE("acpi_thermal_passive");

	if (!tz || !tz->trips.passive.flags.valid)
		return_VALUE(-EINVAL);

	passive = &(tz->trips.passive);

	/*
	 * Above Trip?
	 * -----------
	 * Calculate the thermal trend (using the passive cooling equation)
	 * and modify the performance limit for all passive cooling devices
	 * accordingly.  Note that we assume symmetry.
	 */
	if (tz->temperature >= passive->temperature) {
		trend = (passive->tc1 * (tz->temperature - tz->last_temperature)) + (passive->tc2 * (tz->temperature - passive->temperature));
		ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
			"trend[%d]=(tc1[%lu]*(tmp[%lu]-last[%lu]))+(tc2[%lu]*(tmp[%lu]-psv[%lu]))\n", 
			trend, passive->tc1, tz->temperature, 
			tz->last_temperature, passive->tc2, 
			tz->temperature, passive->temperature));
		tz->trips.passive.flags.enabled = 1;
		/* Heating up? */
		if (trend > 0)
			for (i=0; i<passive->devices.count; i++)
				acpi_processor_set_thermal_limit(
					passive->devices.handles[i], 
					ACPI_PROCESSOR_LIMIT_INCREMENT);
		/* Cooling off? */
		else if (trend < 0)
			for (i=0; i<passive->devices.count; i++)
				acpi_processor_set_thermal_limit(
					passive->devices.handles[i], 
					ACPI_PROCESSOR_LIMIT_DECREMENT);
	}

	/*
	 * Below Trip?
	 * -----------
	 * Implement passive cooling hysteresis to slowly increase performance
	 * and avoid thrashing around the passive trip point.  Note that we
	 * assume symmetry.
	 */
	else if (tz->trips.passive.flags.enabled) {
		for (i=0; i<passive->devices.count; i++)
			result = acpi_processor_set_thermal_limit(
				passive->devices.handles[i], 
				ACPI_PROCESSOR_LIMIT_DECREMENT);
		if (result == 1) {
			tz->trips.passive.flags.enabled = 0;
			ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
				"Disabling passive cooling (zone is cool)\n"));
		}
	}

	return_VALUE(0);
}
示例#2
0
文件: thermal.c 项目: PyroOS/Pyro
static void
acpi_thermal_passive (
	struct acpi_thermal	*tz)
{
	int			result = 0;
	struct acpi_thermal_passive *passive = NULL;
	int			trend = 0;
	int			i = 0;

	ACPI_FUNCTION_TRACE("acpi_thermal_passive");

	if (!tz || !tz->trips.passive.flags.valid)
		return;

	passive = &(tz->trips.passive);

	/*
	 * Above Trip?
	 * -----------
	 * Calculate the thermal trend (using the passive cooling equation)
	 * and modify the performance limit for all passive cooling devices
	 * accordingly.  Note that we assume symmetry.
	 */
	if (tz->temperature >= passive->temperature) {
		trend = (passive->tc1 * (tz->temperature - tz->last_temperature)) + (passive->tc2 * (tz->temperature - passive->temperature));
		ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
			"trend[%d]=(tc1[%lu]*(tmp[%lu]-last[%lu]))+(tc2[%lu]*(tmp[%lu]-psv[%lu]))\n", 
			trend, passive->tc1, tz->temperature, 
			tz->last_temperature, passive->tc2, 
			tz->temperature, passive->temperature));
		tz->trips.passive.flags.enabled = 1;
		/* Heating up? */
		if (trend > 0)
			for (i=0; i<passive->devices.count; i++) {
				printk( "Error: acpi_processor_set_thermal_limit() not implemented!\n" );
				#if 0
				acpi_processor_set_thermal_limit(
					passive->devices.handles[i], 
					ACPI_PROCESSOR_LIMIT_INCREMENT);
				#endif
			}
		/* Cooling off? */
		else if (trend < 0) {
			for (i=0; i<passive->devices.count; i++) {
				printk( "Error: acpi_processor_set_thermal_limit() not implemented!\n" );
				#if 0
				acpi_processor_set_thermal_limit(
					passive->devices.handles[i], 
					ACPI_PROCESSOR_LIMIT_DECREMENT);
				#endif
			}
			/*
			 * Leave cooling mode, even if the temp might
			 * higher than trip point This is because some
			 * machines might have long thermal polling
			 * frequencies (tsp) defined. We will fall back
			 * into passive mode in next cycle (probably quicker)
			 */
			if (result) {
				passive->flags.enabled = 0;
				ACPI_DEBUG_PRINT((ACPI_DB_INFO,
						  "Disabling passive cooling, still above threshold,"
						  " but we are cooling down\n"));
			}
		}
		return;
	}

	/*
	 * Below Trip?
	 * -----------
	 * Implement passive cooling hysteresis to slowly increase performance
	 * and avoid thrashing around the passive trip point.  Note that we
	 * assume symmetry.
	 */
	if (!passive->flags.enabled)
		return;
	for (i=0; i<passive->devices.count; i++) {
		printk( "Error: acpi_processor_set_thermal_limit() not implemented!\n" );
	#if 0
		result = acpi_processor_set_thermal_limit(
			passive->devices.handles[i], 
			ACPI_PROCESSOR_LIMIT_DECREMENT);
	#endif
	}
	if (result) {
		passive->flags.enabled = 0;
		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
				  "Disabling passive cooling (zone is cool)\n"));
	}
}