From 11ccc0f249cb01a129f54760b8ff087f242935d4 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Mon, 30 Apr 2007 22:36:01 -0400 Subject: ACPI: thermal trip points are read-only /proc/acpi/thermal_zone/*/trip_points displays what the kernel reads from the BIOS via ACPI. If you echo a string of ':' deliminted numbers to this file then it will change what it displays. But it shouldn't, since the kernel has no way to communicate these changes to ACPI thermal zones. ACPI thermal zone trip points are read-only. The kernel does have the opportunity to ask the BIOS to change the trip points with _SCP - Set Cooling Policy. Request Active Cooling Mode: # echo 0 > /proc/acpi/thermal_zone/*/cooling_policy Request Passive Cooling Mode: # echo 1 > /proc/acpi/thermal_zone/*/cooling_policy However, in practice it is quite rare for the BIOS to support the optional _SCP, and it is even more rare for the BIOS to export an _SCP that actually changes the trip points. Signed-off-by: Len Brown --- drivers/acpi/thermal.c | 65 -------------------------------------------------- 1 file changed, 65 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 589b98b7b21..73b6fe7093e 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -86,9 +86,6 @@ static int acpi_thermal_resume(struct acpi_device *device); static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file); static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file); static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file); -static ssize_t acpi_thermal_write_trip_points(struct file *, - const char __user *, size_t, - loff_t *); static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file); static ssize_t acpi_thermal_write_cooling_mode(struct file *, const char __user *, size_t, @@ -193,7 +190,6 @@ static const struct file_operations acpi_thermal_temp_fops = { static const struct file_operations acpi_thermal_trip_fops = { .open = acpi_thermal_trip_open_fs, .read = seq_read, - .write = acpi_thermal_write_trip_points, .llseek = seq_lseek, .release = single_release, }; @@ -889,67 +885,6 @@ static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file) return single_open(file, acpi_thermal_trip_seq_show, PDE(inode)->data); } -static ssize_t -acpi_thermal_write_trip_points(struct file *file, - const char __user * buffer, - size_t count, loff_t * ppos) -{ - struct seq_file *m = file->private_data; - struct acpi_thermal *tz = m->private; - - char *limit_string; - int num, critical, hot, passive; - int *active; - int i = 0; - - - limit_string = kzalloc(ACPI_THERMAL_MAX_LIMIT_STR_LEN, GFP_KERNEL); - if (!limit_string) - return -ENOMEM; - - active = kmalloc(ACPI_THERMAL_MAX_ACTIVE * sizeof(int), GFP_KERNEL); - if (!active) { - kfree(limit_string); - return -ENOMEM; - } - - if (!tz || (count > ACPI_THERMAL_MAX_LIMIT_STR_LEN - 1)) { - count = -EINVAL; - goto end; - } - - if (copy_from_user(limit_string, buffer, count)) { - count = -EFAULT; - goto end; - } - - limit_string[count] = '\0'; - - num = sscanf(limit_string, "%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d", - &critical, &hot, &passive, - &active[0], &active[1], &active[2], &active[3], &active[4], - &active[5], &active[6], &active[7], &active[8], - &active[9]); - if (!(num >= 5 && num < (ACPI_THERMAL_MAX_ACTIVE + 3))) { - count = -EINVAL; - goto end; - } - - tz->trips.critical.temperature = CELSIUS_TO_KELVIN(critical); - tz->trips.hot.temperature = CELSIUS_TO_KELVIN(hot); - tz->trips.passive.temperature = CELSIUS_TO_KELVIN(passive); - for (i = 0; i < num - 3; i++) { - if (!(tz->trips.active[i].flags.valid)) - break; - tz->trips.active[i].temperature = CELSIUS_TO_KELVIN(active[i]); - } - - end: - kfree(active); - kfree(limit_string); - return count; -} - static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset) { struct acpi_thermal *tz = seq->private; -- cgit v1.2.3 From eaca2d3f6c4de9d4274a4e2be54c9693e76b0303 Mon Sep 17 00:00:00 2001 From: Len Brown Date: Mon, 30 Apr 2007 23:27:43 -0400 Subject: ACPI: delete un-reliable concept of cooling mode The scheme where the thermal driver displayed the cooling mode /proc/acpi/thermal_zone/*/cooling_mode was flawed in two ways. First, the success of _SCP doesn't actually mean that the BIOS moved any trip points. On many BIOS, _SCP is present, but does nothing. So displaying what _SCP executed actually was wrong more times than it was right. Second, examining the relative position of the trip points when the thermal_zone is added is insufficient -- as the BIOS reserves the right to change the trip points at run-time. The only reliable way for the user to determine if the thermal zone is in active, passive, or critical mode is to examine the relative position of the trip points. The user can do this without the kernel doing it for them by looking in /proc/acpi/thermal_zone/*/trip_points New contents for /proc/acpi/thermal_zone/*/cooling_mode: If _SCP available: "0 - Active; 1 - Passive\n" If _SCP unavailable: "\n" Signed-off-by: Len Brown --- drivers/acpi/thermal.c | 39 ++------------------------------------- 1 file changed, 2 insertions(+), 37 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 73b6fe7093e..1ada017d01e 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -59,8 +59,6 @@ #define ACPI_THERMAL_NOTIFY_CRITICAL 0xF0 #define ACPI_THERMAL_NOTIFY_HOT 0xF1 #define ACPI_THERMAL_MODE_ACTIVE 0x00 -#define ACPI_THERMAL_MODE_PASSIVE 0x01 -#define ACPI_THERMAL_MODE_CRITICAL 0xff #define ACPI_THERMAL_PATH_POWEROFF "/sbin/poweroff" #define ACPI_THERMAL_MAX_ACTIVE 10 @@ -164,7 +162,6 @@ struct acpi_thermal { unsigned long temperature; unsigned long last_temperature; unsigned long polling_frequency; - u8 cooling_mode; volatile u8 zombie; struct acpi_thermal_flags flags; struct acpi_thermal_state state; @@ -293,11 +290,6 @@ static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode) if (ACPI_FAILURE(status)) return -ENODEV; - tz->cooling_mode = mode; - - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cooling mode [%s]\n", - mode ? "passive" : "active")); - return 0; } @@ -893,15 +885,10 @@ static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset) if (!tz) goto end; - if (!tz->flags.cooling_mode) { + if (!tz->flags.cooling_mode) seq_puts(seq, "\n"); - } - - if (tz->cooling_mode == ACPI_THERMAL_MODE_CRITICAL) - seq_printf(seq, "cooling mode: critical\n"); else - seq_printf(seq, "cooling mode: %s\n", - tz->cooling_mode ? "passive" : "active"); + seq_puts(seq, "0 - Active; 1 - Passive\n"); end: return 0; @@ -1158,28 +1145,6 @@ static int acpi_thermal_get_info(struct acpi_thermal *tz) result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE); if (!result) tz->flags.cooling_mode = 1; - else { - /* Oh,we have not _SCP method. - Generally show cooling_mode by _ACx, _PSV,spec 12.2 */ - tz->flags.cooling_mode = 0; - if (tz->trips.active[0].flags.valid - && tz->trips.passive.flags.valid) { - if (tz->trips.passive.temperature > - tz->trips.active[0].temperature) - tz->cooling_mode = ACPI_THERMAL_MODE_ACTIVE; - else - tz->cooling_mode = ACPI_THERMAL_MODE_PASSIVE; - } else if (!tz->trips.active[0].flags.valid - && tz->trips.passive.flags.valid) { - tz->cooling_mode = ACPI_THERMAL_MODE_PASSIVE; - } else if (tz->trips.active[0].flags.valid - && !tz->trips.passive.flags.valid) { - tz->cooling_mode = ACPI_THERMAL_MODE_ACTIVE; - } else { - /* _ACx and _PSV are optional, but _CRT is required */ - tz->cooling_mode = ACPI_THERMAL_MODE_CRITICAL; - } - } /* Get default polling frequency [_TZP] (optional) */ if (tzp) -- cgit v1.2.3