From: Thomas Renninger References: 98178 Leave thermal passive cooling when machine cooled down. Without this patch the polling frequency will always stay at passive cooling trip point polling frequency (tsp - BIOS) instead of tzp value (BIOS) or the possibly overridden value by /proc/acpi/thermal_zone/*/polling_frequency. This will cause critical shutdowns on hot machines with a high tsp value exported by BIOS (e.g. the debugged machine (Thinkpad) exported a value of 600 which means in passive mode the temperature is only polled each 60 seconds). Acked-by: Cc: "Brown, Len" Signed-off-by: Andrew Morton --- drivers/acpi/processor_thermal.c | 14 +++++---- drivers/acpi/thermal.c | 58 ++++++++++++++++++++++----------------- 2 files changed, 42 insertions(+), 30 deletions(-) diff -puN drivers/acpi/processor_thermal.c~acpi-leave-thermal-passive-cooling-when-machine-cooled-down drivers/acpi/processor_thermal.c --- devel/drivers/acpi/processor_thermal.c~acpi-leave-thermal-passive-cooling-when-machine-cooled-down 2005-11-22 20:43:46.000000000 -0800 +++ devel-akpm/drivers/acpi/processor_thermal.c 2005-11-22 20:43:46.000000000 -0800 @@ -127,10 +127,10 @@ static int acpi_thermal_cpufreq_decrease if (cpufreq_thermal_reduction_pctg[cpu] > 20) cpufreq_thermal_reduction_pctg[cpu] -= 20; - else - cpufreq_thermal_reduction_pctg[cpu] = 0; + else + cpufreq_thermal_reduction_pctg[cpu] = 0; cpufreq_update_policy(cpu); - // We reached max freq again and can leave passive mode + /* We reached max freq again and can leave passive mode */ return !cpufreq_thermal_reduction_pctg[cpu]; } @@ -258,7 +258,7 @@ int acpi_processor_set_thermal_limit(acp if (pr->flags.throttling) { if (tx == 0) { - max_tx_px = 1; + max_tx_px = 1; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "At minimum throttling state\n")); } else { @@ -269,8 +269,10 @@ int acpi_processor_set_thermal_limit(acp result = acpi_thermal_cpufreq_decrease(pr->id); if (result) { - // We only could get -ERANGE, 1 or 0. - // In the first two cases we reached max freq again. + /* + * We only could get -ERANGE, 1 or 0. + * In the first two cases we reached max freq again. + */ ACPI_DEBUG_PRINT((ACPI_DB_INFO, "At minimum performance state\n")); max_tx_px = 1; diff -puN drivers/acpi/thermal.c~acpi-leave-thermal-passive-cooling-when-machine-cooled-down drivers/acpi/thermal.c --- devel/drivers/acpi/thermal.c~acpi-leave-thermal-passive-cooling-when-machine-cooled-down 2005-11-22 20:43:46.000000000 -0800 +++ devel-akpm/drivers/acpi/thermal.c 2005-11-22 20:43:46.000000000 -0800 @@ -558,15 +558,22 @@ static void acpi_thermal_passive(struct /* Cooling off? */ else if (trend < 0) { for (i = 0; i < passive->devices.count; i++) - // assume that we are on highest freq/lowest thrott - // and can leave passive mode, even in error case - if (!acpi_processor_set_thermal_limit( - passive->devices.handles[i], - ACPI_PROCESSOR_LIMIT_DECREMENT)) + /* + * assume that we are on highest + * freq/lowest thrott and can leave + * passive mode, even in error case + */ + if (!acpi_processor_set_thermal_limit + (passive->devices.handles[i], + ACPI_PROCESSOR_LIMIT_DECREMENT)) result = 0; - // 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) + /* + * 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, @@ -587,14 +594,14 @@ static void acpi_thermal_passive(struct if (!passive->flags.enabled) return; for (i = 0; i < passive->devices.count; i++) - if (!acpi_processor_set_thermal_limit( - passive->devices.handles[i], - ACPI_PROCESSOR_LIMIT_DECREMENT)) + if (!acpi_processor_set_thermal_limit + (passive->devices.handles[i], + ACPI_PROCESSOR_LIMIT_DECREMENT)) result = 0; if (result) { passive->flags.enabled = 0; ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Disabling passive cooling (zone is cool)\n")); + "Disabling passive cooling (zone is cool)\n")); } } @@ -624,22 +631,25 @@ static void acpi_thermal_active(struct a */ if (active->temperature > maxtemp) tz->state.active_index = i; - maxtemp = active->temperature; + maxtemp = active->temperature; if (active->flags.enabled) continue; for (j = 0; j < active->devices.count; j++) { - result = acpi_bus_set_power(active->devices.handles[j], - ACPI_STATE_D0); + result = + acpi_bus_set_power(active->devices. + handles[j], + ACPI_STATE_D0); if (result) { ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Unable to turn cooling device [%p] 'on'\n", - active->devices.handles[j])); + "Unable to turn cooling device [%p] 'on'\n", + active->devices. + handles[j])); continue; } active->flags.enabled = 1; ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Cooling device [%p] now 'on'\n", - active->devices.handles[j])); + "Cooling device [%p] now 'on'\n", + active->devices.handles[j])); } continue; } @@ -653,17 +663,17 @@ static void acpi_thermal_active(struct a */ for (j = 0; j < active->devices.count; j++) { result = acpi_bus_set_power(active->devices.handles[j], - ACPI_STATE_D3); + ACPI_STATE_D3); if (result) { ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Unable to turn cooling device [%p] 'off'\n", - active->devices.handles[j])); + "Unable to turn cooling device [%p] 'off'\n", + active->devices.handles[j])); continue; } active->flags.enabled = 0; ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Cooling device [%p] now 'off'\n", - active->devices.handles[j])); + "Cooling device [%p] now 'off'\n", + active->devices.handles[j])); } } } _