diff options
author | Frans Pop <elendil@planet.nl> | 2009-08-26 17:29:29 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-08-26 23:06:53 -0400 |
commit | 2a908002c7b1b666616103e9df2419b38d7c6f1f (patch) | |
tree | e525ac0c224091b1d71ffa9aec4c4f39c8223c62 | |
parent | f3d83e2415445e5b157bef404d38674e9e8de169 (diff) |
ACPI processor: force throttling state when BIOS returns incorrect value
If the BIOS reports an invalid throttling state (which seems to be
fairly common after system boot), a reset is done to state T0.
Because of a check in acpi_processor_get_throttling_ptc(), the reset
never actually gets executed, which results in the error reoccurring
on every access of for example /proc/acpi/processor/CPU0/throttling.
Add a 'force' option to acpi_processor_set_throttling() to ensure
the reset really takes effect.
Addresses http://bugzilla.kernel.org/show_bug.cgi?id=13389
This patch, together with the next one, fixes a regression introduced in
2.6.30, listed on the regression list. They have been available for 2.5
months now in bugzilla, but have not been picked up, despite various
reminders and without any reason given.
Google shows that numerous people are hitting this issue. The issue is in
itself relatively minor, but the bug in the code is clear.
The patches have been in all my kernels and today testing has shown that
throttling works correctly with the patches applied when the system
overheats (http://bugzilla.kernel.org/show_bug.cgi?id=13918#c14).
Signed-off-by: Frans Pop <elendil@planet.nl>
Acked-by: Zhang Rui <rui.zhang@intel.com>
Cc: Len Brown <lenb@kernel.org>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/acpi/processor_thermal.c | 6 | ||||
-rw-r--r-- | drivers/acpi/processor_throttling.c | 26 | ||||
-rw-r--r-- | include/acpi/processor.h | 5 |
3 files changed, 20 insertions, 17 deletions
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c index 39838c666032..31adda1099e0 100644 --- a/drivers/acpi/processor_thermal.c +++ b/drivers/acpi/processor_thermal.c | |||
@@ -66,7 +66,7 @@ static int acpi_processor_apply_limit(struct acpi_processor *pr) | |||
66 | if (pr->limit.thermal.tx > tx) | 66 | if (pr->limit.thermal.tx > tx) |
67 | tx = pr->limit.thermal.tx; | 67 | tx = pr->limit.thermal.tx; |
68 | 68 | ||
69 | result = acpi_processor_set_throttling(pr, tx); | 69 | result = acpi_processor_set_throttling(pr, tx, false); |
70 | if (result) | 70 | if (result) |
71 | goto end; | 71 | goto end; |
72 | } | 72 | } |
@@ -421,12 +421,12 @@ processor_set_cur_state(struct thermal_cooling_device *cdev, | |||
421 | 421 | ||
422 | if (state <= max_pstate) { | 422 | if (state <= max_pstate) { |
423 | if (pr->flags.throttling && pr->throttling.state) | 423 | if (pr->flags.throttling && pr->throttling.state) |
424 | result = acpi_processor_set_throttling(pr, 0); | 424 | result = acpi_processor_set_throttling(pr, 0, false); |
425 | cpufreq_set_cur_state(pr->id, state); | 425 | cpufreq_set_cur_state(pr->id, state); |
426 | } else { | 426 | } else { |
427 | cpufreq_set_cur_state(pr->id, max_pstate); | 427 | cpufreq_set_cur_state(pr->id, max_pstate); |
428 | result = acpi_processor_set_throttling(pr, | 428 | result = acpi_processor_set_throttling(pr, |
429 | state - max_pstate); | 429 | state - max_pstate, false); |
430 | } | 430 | } |
431 | return result; | 431 | return result; |
432 | } | 432 | } |
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index 227543789ba9..841be4ee2109 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c | |||
@@ -62,7 +62,8 @@ struct throttling_tstate { | |||
62 | #define THROTTLING_POSTCHANGE (2) | 62 | #define THROTTLING_POSTCHANGE (2) |
63 | 63 | ||
64 | static int acpi_processor_get_throttling(struct acpi_processor *pr); | 64 | static int acpi_processor_get_throttling(struct acpi_processor *pr); |
65 | int acpi_processor_set_throttling(struct acpi_processor *pr, int state); | 65 | int acpi_processor_set_throttling(struct acpi_processor *pr, |
66 | int state, bool force); | ||
66 | 67 | ||
67 | static int acpi_processor_update_tsd_coord(void) | 68 | static int acpi_processor_update_tsd_coord(void) |
68 | { | 69 | { |
@@ -361,7 +362,7 @@ int acpi_processor_tstate_has_changed(struct acpi_processor *pr) | |||
361 | */ | 362 | */ |
362 | target_state = throttling_limit; | 363 | target_state = throttling_limit; |
363 | } | 364 | } |
364 | return acpi_processor_set_throttling(pr, target_state); | 365 | return acpi_processor_set_throttling(pr, target_state, false); |
365 | } | 366 | } |
366 | 367 | ||
367 | /* | 368 | /* |
@@ -842,7 +843,7 @@ static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr) | |||
842 | ACPI_WARNING((AE_INFO, | 843 | ACPI_WARNING((AE_INFO, |
843 | "Invalid throttling state, reset")); | 844 | "Invalid throttling state, reset")); |
844 | state = 0; | 845 | state = 0; |
845 | ret = acpi_processor_set_throttling(pr, state); | 846 | ret = acpi_processor_set_throttling(pr, state, true); |
846 | if (ret) | 847 | if (ret) |
847 | return ret; | 848 | return ret; |
848 | } | 849 | } |
@@ -915,7 +916,7 @@ static int acpi_processor_get_fadt_info(struct acpi_processor *pr) | |||
915 | } | 916 | } |
916 | 917 | ||
917 | static int acpi_processor_set_throttling_fadt(struct acpi_processor *pr, | 918 | static int acpi_processor_set_throttling_fadt(struct acpi_processor *pr, |
918 | int state) | 919 | int state, bool force) |
919 | { | 920 | { |
920 | u32 value = 0; | 921 | u32 value = 0; |
921 | u32 duty_mask = 0; | 922 | u32 duty_mask = 0; |
@@ -930,7 +931,7 @@ static int acpi_processor_set_throttling_fadt(struct acpi_processor *pr, | |||
930 | if (!pr->flags.throttling) | 931 | if (!pr->flags.throttling) |
931 | return -ENODEV; | 932 | return -ENODEV; |
932 | 933 | ||
933 | if (state == pr->throttling.state) | 934 | if (!force && (state == pr->throttling.state)) |
934 | return 0; | 935 | return 0; |
935 | 936 | ||
936 | if (state < pr->throttling_platform_limit) | 937 | if (state < pr->throttling_platform_limit) |
@@ -988,7 +989,7 @@ static int acpi_processor_set_throttling_fadt(struct acpi_processor *pr, | |||
988 | } | 989 | } |
989 | 990 | ||
990 | static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr, | 991 | static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr, |
991 | int state) | 992 | int state, bool force) |
992 | { | 993 | { |
993 | int ret; | 994 | int ret; |
994 | acpi_integer value; | 995 | acpi_integer value; |
@@ -1002,7 +1003,7 @@ static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr, | |||
1002 | if (!pr->flags.throttling) | 1003 | if (!pr->flags.throttling) |
1003 | return -ENODEV; | 1004 | return -ENODEV; |
1004 | 1005 | ||
1005 | if (state == pr->throttling.state) | 1006 | if (!force && (state == pr->throttling.state)) |
1006 | return 0; | 1007 | return 0; |
1007 | 1008 | ||
1008 | if (state < pr->throttling_platform_limit) | 1009 | if (state < pr->throttling_platform_limit) |
@@ -1018,7 +1019,8 @@ static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr, | |||
1018 | return 0; | 1019 | return 0; |
1019 | } | 1020 | } |
1020 | 1021 | ||
1021 | int acpi_processor_set_throttling(struct acpi_processor *pr, int state) | 1022 | int acpi_processor_set_throttling(struct acpi_processor *pr, |
1023 | int state, bool force) | ||
1022 | { | 1024 | { |
1023 | cpumask_var_t saved_mask; | 1025 | cpumask_var_t saved_mask; |
1024 | int ret = 0; | 1026 | int ret = 0; |
@@ -1070,7 +1072,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state) | |||
1070 | /* FIXME: use work_on_cpu() */ | 1072 | /* FIXME: use work_on_cpu() */ |
1071 | set_cpus_allowed_ptr(current, cpumask_of(pr->id)); | 1073 | set_cpus_allowed_ptr(current, cpumask_of(pr->id)); |
1072 | ret = p_throttling->acpi_processor_set_throttling(pr, | 1074 | ret = p_throttling->acpi_processor_set_throttling(pr, |
1073 | t_state.target_state); | 1075 | t_state.target_state, force); |
1074 | } else { | 1076 | } else { |
1075 | /* | 1077 | /* |
1076 | * When the T-state coordination is SW_ALL or HW_ALL, | 1078 | * When the T-state coordination is SW_ALL or HW_ALL, |
@@ -1103,7 +1105,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state) | |||
1103 | set_cpus_allowed_ptr(current, cpumask_of(i)); | 1105 | set_cpus_allowed_ptr(current, cpumask_of(i)); |
1104 | ret = match_pr->throttling. | 1106 | ret = match_pr->throttling. |
1105 | acpi_processor_set_throttling( | 1107 | acpi_processor_set_throttling( |
1106 | match_pr, t_state.target_state); | 1108 | match_pr, t_state.target_state, force); |
1107 | } | 1109 | } |
1108 | } | 1110 | } |
1109 | /* | 1111 | /* |
@@ -1201,7 +1203,7 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr) | |||
1201 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 1203 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
1202 | "Disabling throttling (was T%d)\n", | 1204 | "Disabling throttling (was T%d)\n", |
1203 | pr->throttling.state)); | 1205 | pr->throttling.state)); |
1204 | result = acpi_processor_set_throttling(pr, 0); | 1206 | result = acpi_processor_set_throttling(pr, 0, false); |
1205 | if (result) | 1207 | if (result) |
1206 | goto end; | 1208 | goto end; |
1207 | } | 1209 | } |
@@ -1307,7 +1309,7 @@ static ssize_t acpi_processor_write_throttling(struct file *file, | |||
1307 | if (strcmp(tmpbuf, charp) != 0) | 1309 | if (strcmp(tmpbuf, charp) != 0) |
1308 | return -EINVAL; | 1310 | return -EINVAL; |
1309 | 1311 | ||
1310 | result = acpi_processor_set_throttling(pr, state_val); | 1312 | result = acpi_processor_set_throttling(pr, state_val, false); |
1311 | if (result) | 1313 | if (result) |
1312 | return result; | 1314 | return result; |
1313 | 1315 | ||
diff --git a/include/acpi/processor.h b/include/acpi/processor.h index baf1e0a9a7ee..740ac3ad8fd0 100644 --- a/include/acpi/processor.h +++ b/include/acpi/processor.h | |||
@@ -174,7 +174,7 @@ struct acpi_processor_throttling { | |||
174 | cpumask_var_t shared_cpu_map; | 174 | cpumask_var_t shared_cpu_map; |
175 | int (*acpi_processor_get_throttling) (struct acpi_processor * pr); | 175 | int (*acpi_processor_get_throttling) (struct acpi_processor * pr); |
176 | int (*acpi_processor_set_throttling) (struct acpi_processor * pr, | 176 | int (*acpi_processor_set_throttling) (struct acpi_processor * pr, |
177 | int state); | 177 | int state, bool force); |
178 | 178 | ||
179 | u32 address; | 179 | u32 address; |
180 | u8 duty_offset; | 180 | u8 duty_offset; |
@@ -321,7 +321,8 @@ static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr) | |||
321 | /* in processor_throttling.c */ | 321 | /* in processor_throttling.c */ |
322 | int acpi_processor_tstate_has_changed(struct acpi_processor *pr); | 322 | int acpi_processor_tstate_has_changed(struct acpi_processor *pr); |
323 | int acpi_processor_get_throttling_info(struct acpi_processor *pr); | 323 | int acpi_processor_get_throttling_info(struct acpi_processor *pr); |
324 | extern int acpi_processor_set_throttling(struct acpi_processor *pr, int state); | 324 | extern int acpi_processor_set_throttling(struct acpi_processor *pr, |
325 | int state, bool force); | ||
325 | extern const struct file_operations acpi_processor_throttling_fops; | 326 | extern const struct file_operations acpi_processor_throttling_fops; |
326 | extern void acpi_processor_throttling_init(void); | 327 | extern void acpi_processor_throttling_init(void); |
327 | /* in processor_idle.c */ | 328 | /* in processor_idle.c */ |