diff options
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/acpica/hwsleep.c | 43 | ||||
-rw-r--r-- | drivers/acpi/acpica/hwvalid.c | 85 | ||||
-rw-r--r-- | drivers/acpi/acpica/rscreate.c | 27 | ||||
-rw-r--r-- | drivers/acpi/ec.c | 1 | ||||
-rw-r--r-- | drivers/acpi/osl.c | 4 | ||||
-rw-r--r-- | drivers/acpi/proc.c | 13 | ||||
-rw-r--r-- | drivers/acpi/processor_idle.c | 31 | ||||
-rw-r--r-- | drivers/acpi/scan.c | 31 | ||||
-rw-r--r-- | drivers/acpi/sleep.c | 35 | ||||
-rw-r--r-- | drivers/acpi/sleep.h | 3 | ||||
-rw-r--r-- | drivers/acpi/system.c | 11 | ||||
-rw-r--r-- | drivers/acpi/thermal.c | 70 | ||||
-rw-r--r-- | drivers/acpi/video.c | 81 | ||||
-rw-r--r-- | drivers/acpi/wakeup.c | 30 |
14 files changed, 254 insertions, 211 deletions
diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c index baa5fc05e124..db307a356f08 100644 --- a/drivers/acpi/acpica/hwsleep.c +++ b/drivers/acpi/acpica/hwsleep.c | |||
@@ -211,6 +211,12 @@ acpi_status acpi_enter_sleep_state_prep(u8 sleep_state) | |||
211 | 211 | ||
212 | ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_prep) | 212 | ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_prep) |
213 | 213 | ||
214 | static unsigned int gts, bfs; | ||
215 | module_param(gts, uint, 0644); | ||
216 | module_param(bfs, uint, 0644); | ||
217 | MODULE_PARM_DESC(gts, "Enable evaluation of _GTS on suspend."); | ||
218 | MODULE_PARM_DESC(bfs, "Enable evaluation of _BFS on resume".); | ||
219 | |||
214 | /******************************************************************************* | 220 | /******************************************************************************* |
215 | * | 221 | * |
216 | * FUNCTION: acpi_enter_sleep_state | 222 | * FUNCTION: acpi_enter_sleep_state |
@@ -278,16 +284,18 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state) | |||
278 | return_ACPI_STATUS(status); | 284 | return_ACPI_STATUS(status); |
279 | } | 285 | } |
280 | 286 | ||
281 | /* Execute the _GTS method */ | 287 | if (gts) { |
288 | /* Execute the _GTS method */ | ||
282 | 289 | ||
283 | arg_list.count = 1; | 290 | arg_list.count = 1; |
284 | arg_list.pointer = &arg; | 291 | arg_list.pointer = &arg; |
285 | arg.type = ACPI_TYPE_INTEGER; | 292 | arg.type = ACPI_TYPE_INTEGER; |
286 | arg.integer.value = sleep_state; | 293 | arg.integer.value = sleep_state; |
287 | 294 | ||
288 | status = acpi_evaluate_object(NULL, METHOD_NAME__GTS, &arg_list, NULL); | 295 | status = acpi_evaluate_object(NULL, METHOD_NAME__GTS, &arg_list, NULL); |
289 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { | 296 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { |
290 | return_ACPI_STATUS(status); | 297 | return_ACPI_STATUS(status); |
298 | } | ||
291 | } | 299 | } |
292 | 300 | ||
293 | /* Get current value of PM1A control */ | 301 | /* Get current value of PM1A control */ |
@@ -513,18 +521,19 @@ acpi_status acpi_leave_sleep_state_prep(u8 sleep_state) | |||
513 | } | 521 | } |
514 | } | 522 | } |
515 | 523 | ||
516 | /* Execute the _BFS method */ | 524 | if (bfs) { |
525 | /* Execute the _BFS method */ | ||
517 | 526 | ||
518 | arg_list.count = 1; | 527 | arg_list.count = 1; |
519 | arg_list.pointer = &arg; | 528 | arg_list.pointer = &arg; |
520 | arg.type = ACPI_TYPE_INTEGER; | 529 | arg.type = ACPI_TYPE_INTEGER; |
521 | arg.integer.value = sleep_state; | 530 | arg.integer.value = sleep_state; |
522 | 531 | ||
523 | status = acpi_evaluate_object(NULL, METHOD_NAME__BFS, &arg_list, NULL); | 532 | status = acpi_evaluate_object(NULL, METHOD_NAME__BFS, &arg_list, NULL); |
524 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { | 533 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { |
525 | ACPI_EXCEPTION((AE_INFO, status, "During Method _BFS")); | 534 | ACPI_EXCEPTION((AE_INFO, status, "During Method _BFS")); |
535 | } | ||
526 | } | 536 | } |
527 | |||
528 | return_ACPI_STATUS(status); | 537 | return_ACPI_STATUS(status); |
529 | } | 538 | } |
530 | 539 | ||
diff --git a/drivers/acpi/acpica/hwvalid.c b/drivers/acpi/acpica/hwvalid.c index bd3c937b0ac0..ec33f270c5b7 100644 --- a/drivers/acpi/acpica/hwvalid.c +++ b/drivers/acpi/acpica/hwvalid.c | |||
@@ -152,7 +152,7 @@ acpi_hw_validate_io_request(acpi_io_address address, u32 bit_width) | |||
152 | ACPI_ERROR((AE_INFO, | 152 | ACPI_ERROR((AE_INFO, |
153 | "Illegal I/O port address/length above 64K: 0x%p/%X", | 153 | "Illegal I/O port address/length above 64K: 0x%p/%X", |
154 | ACPI_CAST_PTR(void, address), byte_width)); | 154 | ACPI_CAST_PTR(void, address), byte_width)); |
155 | return_ACPI_STATUS(AE_AML_ILLEGAL_ADDRESS); | 155 | return_ACPI_STATUS(AE_LIMIT); |
156 | } | 156 | } |
157 | 157 | ||
158 | /* Exit if requested address is not within the protected port table */ | 158 | /* Exit if requested address is not within the protected port table */ |
@@ -179,11 +179,12 @@ acpi_hw_validate_io_request(acpi_io_address address, u32 bit_width) | |||
179 | /* Port illegality may depend on the _OSI calls made by the BIOS */ | 179 | /* Port illegality may depend on the _OSI calls made by the BIOS */ |
180 | 180 | ||
181 | if (acpi_gbl_osi_data >= port_info->osi_dependency) { | 181 | if (acpi_gbl_osi_data >= port_info->osi_dependency) { |
182 | ACPI_ERROR((AE_INFO, | 182 | ACPI_DEBUG_PRINT((ACPI_DB_IO, |
183 | "Denied AML access to port 0x%p/%X (%s 0x%.4X-0x%.4X)", | 183 | "Denied AML access to port 0x%p/%X (%s 0x%.4X-0x%.4X)", |
184 | ACPI_CAST_PTR(void, address), | 184 | ACPI_CAST_PTR(void, address), |
185 | byte_width, port_info->name, | 185 | byte_width, port_info->name, |
186 | port_info->start, port_info->end)); | 186 | port_info->start, |
187 | port_info->end)); | ||
187 | 188 | ||
188 | return_ACPI_STATUS(AE_AML_ILLEGAL_ADDRESS); | 189 | return_ACPI_STATUS(AE_AML_ILLEGAL_ADDRESS); |
189 | } | 190 | } |
@@ -207,7 +208,7 @@ acpi_hw_validate_io_request(acpi_io_address address, u32 bit_width) | |||
207 | * Value Where value is placed | 208 | * Value Where value is placed |
208 | * Width Number of bits | 209 | * Width Number of bits |
209 | * | 210 | * |
210 | * RETURN: Value read from port | 211 | * RETURN: Status and value read from port |
211 | * | 212 | * |
212 | * DESCRIPTION: Read data from an I/O port or register. This is a front-end | 213 | * DESCRIPTION: Read data from an I/O port or register. This is a front-end |
213 | * to acpi_os_read_port that performs validation on both the port | 214 | * to acpi_os_read_port that performs validation on both the port |
@@ -218,14 +219,43 @@ acpi_hw_validate_io_request(acpi_io_address address, u32 bit_width) | |||
218 | acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width) | 219 | acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width) |
219 | { | 220 | { |
220 | acpi_status status; | 221 | acpi_status status; |
222 | u32 one_byte; | ||
223 | u32 i; | ||
224 | |||
225 | /* Validate the entire request and perform the I/O */ | ||
221 | 226 | ||
222 | status = acpi_hw_validate_io_request(address, width); | 227 | status = acpi_hw_validate_io_request(address, width); |
223 | if (ACPI_FAILURE(status)) { | 228 | if (ACPI_SUCCESS(status)) { |
229 | status = acpi_os_read_port(address, value, width); | ||
224 | return status; | 230 | return status; |
225 | } | 231 | } |
226 | 232 | ||
227 | status = acpi_os_read_port(address, value, width); | 233 | if (status != AE_AML_ILLEGAL_ADDRESS) { |
228 | return status; | 234 | return status; |
235 | } | ||
236 | |||
237 | /* | ||
238 | * There has been a protection violation within the request. Fall | ||
239 | * back to byte granularity port I/O and ignore the failing bytes. | ||
240 | * This provides Windows compatibility. | ||
241 | */ | ||
242 | for (i = 0, *value = 0; i < width; i += 8) { | ||
243 | |||
244 | /* Validate and read one byte */ | ||
245 | |||
246 | if (acpi_hw_validate_io_request(address, 8) == AE_OK) { | ||
247 | status = acpi_os_read_port(address, &one_byte, 8); | ||
248 | if (ACPI_FAILURE(status)) { | ||
249 | return status; | ||
250 | } | ||
251 | |||
252 | *value |= (one_byte << i); | ||
253 | } | ||
254 | |||
255 | address++; | ||
256 | } | ||
257 | |||
258 | return AE_OK; | ||
229 | } | 259 | } |
230 | 260 | ||
231 | /****************************************************************************** | 261 | /****************************************************************************** |
@@ -236,7 +266,7 @@ acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width) | |||
236 | * Value Value to write | 266 | * Value Value to write |
237 | * Width Number of bits | 267 | * Width Number of bits |
238 | * | 268 | * |
239 | * RETURN: None | 269 | * RETURN: Status |
240 | * | 270 | * |
241 | * DESCRIPTION: Write data to an I/O port or register. This is a front-end | 271 | * DESCRIPTION: Write data to an I/O port or register. This is a front-end |
242 | * to acpi_os_write_port that performs validation on both the port | 272 | * to acpi_os_write_port that performs validation on both the port |
@@ -247,12 +277,39 @@ acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width) | |||
247 | acpi_status acpi_hw_write_port(acpi_io_address address, u32 value, u32 width) | 277 | acpi_status acpi_hw_write_port(acpi_io_address address, u32 value, u32 width) |
248 | { | 278 | { |
249 | acpi_status status; | 279 | acpi_status status; |
280 | u32 i; | ||
281 | |||
282 | /* Validate the entire request and perform the I/O */ | ||
250 | 283 | ||
251 | status = acpi_hw_validate_io_request(address, width); | 284 | status = acpi_hw_validate_io_request(address, width); |
252 | if (ACPI_FAILURE(status)) { | 285 | if (ACPI_SUCCESS(status)) { |
286 | status = acpi_os_write_port(address, value, width); | ||
253 | return status; | 287 | return status; |
254 | } | 288 | } |
255 | 289 | ||
256 | status = acpi_os_write_port(address, value, width); | 290 | if (status != AE_AML_ILLEGAL_ADDRESS) { |
257 | return status; | 291 | return status; |
292 | } | ||
293 | |||
294 | /* | ||
295 | * There has been a protection violation within the request. Fall | ||
296 | * back to byte granularity port I/O and ignore the failing bytes. | ||
297 | * This provides Windows compatibility. | ||
298 | */ | ||
299 | for (i = 0; i < width; i += 8) { | ||
300 | |||
301 | /* Validate and write one byte */ | ||
302 | |||
303 | if (acpi_hw_validate_io_request(address, 8) == AE_OK) { | ||
304 | status = | ||
305 | acpi_os_write_port(address, (value >> i) & 0xFF, 8); | ||
306 | if (ACPI_FAILURE(status)) { | ||
307 | return status; | ||
308 | } | ||
309 | } | ||
310 | |||
311 | address++; | ||
312 | } | ||
313 | |||
314 | return AE_OK; | ||
258 | } | 315 | } |
diff --git a/drivers/acpi/acpica/rscreate.c b/drivers/acpi/acpica/rscreate.c index 663f692fffcf..a3c23d686d5f 100644 --- a/drivers/acpi/acpica/rscreate.c +++ b/drivers/acpi/acpica/rscreate.c | |||
@@ -191,8 +191,6 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, | |||
191 | user_prt = ACPI_CAST_PTR(struct acpi_pci_routing_table, buffer); | 191 | user_prt = ACPI_CAST_PTR(struct acpi_pci_routing_table, buffer); |
192 | 192 | ||
193 | for (index = 0; index < number_of_elements; index++) { | 193 | for (index = 0; index < number_of_elements; index++) { |
194 | int source_name_index = 2; | ||
195 | int source_index_index = 3; | ||
196 | 194 | ||
197 | /* | 195 | /* |
198 | * Point user_prt past this current structure | 196 | * Point user_prt past this current structure |
@@ -261,27 +259,6 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, | |||
261 | return_ACPI_STATUS(AE_BAD_DATA); | 259 | return_ACPI_STATUS(AE_BAD_DATA); |
262 | } | 260 | } |
263 | 261 | ||
264 | /* | ||
265 | * If BIOS erroneously reversed the _PRT source_name and source_index, | ||
266 | * then reverse them back. | ||
267 | */ | ||
268 | if ((sub_object_list[3])->common.type != | ||
269 | ACPI_TYPE_INTEGER) { | ||
270 | if (acpi_gbl_enable_interpreter_slack) { | ||
271 | source_name_index = 3; | ||
272 | source_index_index = 2; | ||
273 | printk(KERN_WARNING | ||
274 | "ACPI: Handling Garbled _PRT entry\n"); | ||
275 | } else { | ||
276 | ACPI_ERROR((AE_INFO, | ||
277 | "(PRT[%X].source_index) Need Integer, found %s", | ||
278 | index, | ||
279 | acpi_ut_get_object_type_name | ||
280 | (sub_object_list[3]))); | ||
281 | return_ACPI_STATUS(AE_BAD_DATA); | ||
282 | } | ||
283 | } | ||
284 | |||
285 | user_prt->pin = (u32) obj_desc->integer.value; | 262 | user_prt->pin = (u32) obj_desc->integer.value; |
286 | 263 | ||
287 | /* | 264 | /* |
@@ -304,7 +281,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, | |||
304 | * 3) Third subobject: Dereference the PRT.source_name | 281 | * 3) Third subobject: Dereference the PRT.source_name |
305 | * The name may be unresolved (slack mode), so allow a null object | 282 | * The name may be unresolved (slack mode), so allow a null object |
306 | */ | 283 | */ |
307 | obj_desc = sub_object_list[source_name_index]; | 284 | obj_desc = sub_object_list[2]; |
308 | if (obj_desc) { | 285 | if (obj_desc) { |
309 | switch (obj_desc->common.type) { | 286 | switch (obj_desc->common.type) { |
310 | case ACPI_TYPE_LOCAL_REFERENCE: | 287 | case ACPI_TYPE_LOCAL_REFERENCE: |
@@ -378,7 +355,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, | |||
378 | 355 | ||
379 | /* 4) Fourth subobject: Dereference the PRT.source_index */ | 356 | /* 4) Fourth subobject: Dereference the PRT.source_index */ |
380 | 357 | ||
381 | obj_desc = sub_object_list[source_index_index]; | 358 | obj_desc = sub_object_list[3]; |
382 | if (obj_desc->common.type != ACPI_TYPE_INTEGER) { | 359 | if (obj_desc->common.type != ACPI_TYPE_INTEGER) { |
383 | ACPI_ERROR((AE_INFO, | 360 | ACPI_ERROR((AE_INFO, |
384 | "(PRT[%X].SourceIndex) Need Integer, found %s", | 361 | "(PRT[%X].SourceIndex) Need Integer, found %s", |
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 04e90443eff7..391f331674c7 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -1065,6 +1065,7 @@ static int acpi_ec_resume(struct acpi_device *device) | |||
1065 | struct acpi_ec *ec = acpi_driver_data(device); | 1065 | struct acpi_ec *ec = acpi_driver_data(device); |
1066 | /* Enable use of GPE back */ | 1066 | /* Enable use of GPE back */ |
1067 | clear_bit(EC_FLAGS_NO_GPE, &ec->flags); | 1067 | clear_bit(EC_FLAGS_NO_GPE, &ec->flags); |
1068 | set_bit(EC_FLAGS_GPE_MODE, &ec->flags); | ||
1068 | acpi_enable_gpe(NULL, ec->gpe); | 1069 | acpi_enable_gpe(NULL, ec->gpe); |
1069 | return 0; | 1070 | return 0; |
1070 | } | 1071 | } |
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index d59f08ecaf16..d916bea729f1 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c | |||
@@ -353,8 +353,10 @@ static irqreturn_t acpi_irq(int irq, void *dev_id) | |||
353 | if (handled) { | 353 | if (handled) { |
354 | acpi_irq_handled++; | 354 | acpi_irq_handled++; |
355 | return IRQ_HANDLED; | 355 | return IRQ_HANDLED; |
356 | } else | 356 | } else { |
357 | acpi_irq_not_handled++; | ||
357 | return IRQ_NONE; | 358 | return IRQ_NONE; |
359 | } | ||
358 | } | 360 | } |
359 | 361 | ||
360 | acpi_status | 362 | acpi_status |
diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c index 05dfdc96802e..d0d550d22a6d 100644 --- a/drivers/acpi/proc.c +++ b/drivers/acpi/proc.c | |||
@@ -343,9 +343,6 @@ acpi_system_write_alarm(struct file *file, | |||
343 | } | 343 | } |
344 | #endif /* HAVE_ACPI_LEGACY_ALARM */ | 344 | #endif /* HAVE_ACPI_LEGACY_ALARM */ |
345 | 345 | ||
346 | extern struct list_head acpi_wakeup_device_list; | ||
347 | extern spinlock_t acpi_device_lock; | ||
348 | |||
349 | static int | 346 | static int |
350 | acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset) | 347 | acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset) |
351 | { | 348 | { |
@@ -353,7 +350,7 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset) | |||
353 | 350 | ||
354 | seq_printf(seq, "Device\tS-state\t Status Sysfs node\n"); | 351 | seq_printf(seq, "Device\tS-state\t Status Sysfs node\n"); |
355 | 352 | ||
356 | spin_lock(&acpi_device_lock); | 353 | mutex_lock(&acpi_device_lock); |
357 | list_for_each_safe(node, next, &acpi_wakeup_device_list) { | 354 | list_for_each_safe(node, next, &acpi_wakeup_device_list) { |
358 | struct acpi_device *dev = | 355 | struct acpi_device *dev = |
359 | container_of(node, struct acpi_device, wakeup_list); | 356 | container_of(node, struct acpi_device, wakeup_list); |
@@ -361,7 +358,6 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset) | |||
361 | 358 | ||
362 | if (!dev->wakeup.flags.valid) | 359 | if (!dev->wakeup.flags.valid) |
363 | continue; | 360 | continue; |
364 | spin_unlock(&acpi_device_lock); | ||
365 | 361 | ||
366 | ldev = acpi_get_physical_device(dev->handle); | 362 | ldev = acpi_get_physical_device(dev->handle); |
367 | seq_printf(seq, "%s\t S%d\t%c%-8s ", | 363 | seq_printf(seq, "%s\t S%d\t%c%-8s ", |
@@ -376,9 +372,8 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset) | |||
376 | seq_printf(seq, "\n"); | 372 | seq_printf(seq, "\n"); |
377 | put_device(ldev); | 373 | put_device(ldev); |
378 | 374 | ||
379 | spin_lock(&acpi_device_lock); | ||
380 | } | 375 | } |
381 | spin_unlock(&acpi_device_lock); | 376 | mutex_unlock(&acpi_device_lock); |
382 | return 0; | 377 | return 0; |
383 | } | 378 | } |
384 | 379 | ||
@@ -409,7 +404,7 @@ acpi_system_write_wakeup_device(struct file *file, | |||
409 | strbuf[len] = '\0'; | 404 | strbuf[len] = '\0'; |
410 | sscanf(strbuf, "%s", str); | 405 | sscanf(strbuf, "%s", str); |
411 | 406 | ||
412 | spin_lock(&acpi_device_lock); | 407 | mutex_lock(&acpi_device_lock); |
413 | list_for_each_safe(node, next, &acpi_wakeup_device_list) { | 408 | list_for_each_safe(node, next, &acpi_wakeup_device_list) { |
414 | struct acpi_device *dev = | 409 | struct acpi_device *dev = |
415 | container_of(node, struct acpi_device, wakeup_list); | 410 | container_of(node, struct acpi_device, wakeup_list); |
@@ -446,7 +441,7 @@ acpi_system_write_wakeup_device(struct file *file, | |||
446 | } | 441 | } |
447 | } | 442 | } |
448 | } | 443 | } |
449 | spin_unlock(&acpi_device_lock); | 444 | mutex_unlock(&acpi_device_lock); |
450 | return count; | 445 | return count; |
451 | } | 446 | } |
452 | 447 | ||
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 4e6e758bd397..f7ca8c55956b 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c | |||
@@ -145,6 +145,9 @@ static void acpi_timer_check_state(int state, struct acpi_processor *pr, | |||
145 | struct acpi_processor_power *pwr = &pr->power; | 145 | struct acpi_processor_power *pwr = &pr->power; |
146 | u8 type = local_apic_timer_c2_ok ? ACPI_STATE_C3 : ACPI_STATE_C2; | 146 | u8 type = local_apic_timer_c2_ok ? ACPI_STATE_C3 : ACPI_STATE_C2; |
147 | 147 | ||
148 | if (cpu_has(&cpu_data(pr->id), X86_FEATURE_ARAT)) | ||
149 | return; | ||
150 | |||
148 | /* | 151 | /* |
149 | * Check, if one of the previous states already marked the lapic | 152 | * Check, if one of the previous states already marked the lapic |
150 | * unstable | 153 | * unstable |
@@ -578,6 +581,11 @@ static int acpi_processor_power_verify(struct acpi_processor *pr) | |||
578 | for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) { | 581 | for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) { |
579 | struct acpi_processor_cx *cx = &pr->power.states[i]; | 582 | struct acpi_processor_cx *cx = &pr->power.states[i]; |
580 | 583 | ||
584 | #if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86) | ||
585 | /* TSC could halt in idle, so notify users */ | ||
586 | if (tsc_halts_in_c(cx->type)) | ||
587 | mark_tsc_unstable("TSC halts in idle");; | ||
588 | #endif | ||
581 | switch (cx->type) { | 589 | switch (cx->type) { |
582 | case ACPI_STATE_C1: | 590 | case ACPI_STATE_C1: |
583 | cx->valid = 1; | 591 | cx->valid = 1; |
@@ -654,11 +662,9 @@ static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset) | |||
654 | 662 | ||
655 | seq_printf(seq, "active state: C%zd\n" | 663 | seq_printf(seq, "active state: C%zd\n" |
656 | "max_cstate: C%d\n" | 664 | "max_cstate: C%d\n" |
657 | "bus master activity: %08x\n" | ||
658 | "maximum allowed latency: %d usec\n", | 665 | "maximum allowed latency: %d usec\n", |
659 | pr->power.state ? pr->power.state - pr->power.states : 0, | 666 | pr->power.state ? pr->power.state - pr->power.states : 0, |
660 | max_cstate, (unsigned)pr->power.bm_activity, | 667 | max_cstate, pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY)); |
661 | pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY)); | ||
662 | 668 | ||
663 | seq_puts(seq, "states:\n"); | 669 | seq_puts(seq, "states:\n"); |
664 | 670 | ||
@@ -868,11 +874,6 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev, | |||
868 | kt2 = ktime_get_real(); | 874 | kt2 = ktime_get_real(); |
869 | idle_time = ktime_to_us(ktime_sub(kt2, kt1)); | 875 | idle_time = ktime_to_us(ktime_sub(kt2, kt1)); |
870 | 876 | ||
871 | #if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86) | ||
872 | /* TSC could halt in idle, so notify users */ | ||
873 | if (tsc_halts_in_c(cx->type)) | ||
874 | mark_tsc_unstable("TSC halts in idle");; | ||
875 | #endif | ||
876 | sleep_ticks = us_to_pm_timer_ticks(idle_time); | 877 | sleep_ticks = us_to_pm_timer_ticks(idle_time); |
877 | 878 | ||
878 | /* Tell the scheduler how much we idled: */ | 879 | /* Tell the scheduler how much we idled: */ |
@@ -952,6 +953,7 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, | |||
952 | */ | 953 | */ |
953 | acpi_state_timer_broadcast(pr, cx, 1); | 954 | acpi_state_timer_broadcast(pr, cx, 1); |
954 | 955 | ||
956 | kt1 = ktime_get_real(); | ||
955 | /* | 957 | /* |
956 | * disable bus master | 958 | * disable bus master |
957 | * bm_check implies we need ARB_DIS | 959 | * bm_check implies we need ARB_DIS |
@@ -973,10 +975,7 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, | |||
973 | ACPI_FLUSH_CPU_CACHE(); | 975 | ACPI_FLUSH_CPU_CACHE(); |
974 | } | 976 | } |
975 | 977 | ||
976 | kt1 = ktime_get_real(); | ||
977 | acpi_idle_do_entry(cx); | 978 | acpi_idle_do_entry(cx); |
978 | kt2 = ktime_get_real(); | ||
979 | idle_time = ktime_to_us(ktime_sub(kt2, kt1)); | ||
980 | 979 | ||
981 | /* Re-enable bus master arbitration */ | 980 | /* Re-enable bus master arbitration */ |
982 | if (pr->flags.bm_check && pr->flags.bm_control) { | 981 | if (pr->flags.bm_check && pr->flags.bm_control) { |
@@ -985,12 +984,9 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, | |||
985 | c3_cpu_count--; | 984 | c3_cpu_count--; |
986 | spin_unlock(&c3_lock); | 985 | spin_unlock(&c3_lock); |
987 | } | 986 | } |
987 | kt2 = ktime_get_real(); | ||
988 | idle_time = ktime_to_us(ktime_sub(kt2, kt1)); | ||
988 | 989 | ||
989 | #if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86) | ||
990 | /* TSC could halt in idle, so notify users */ | ||
991 | if (tsc_halts_in_c(ACPI_STATE_C3)) | ||
992 | mark_tsc_unstable("TSC halts in idle"); | ||
993 | #endif | ||
994 | sleep_ticks = us_to_pm_timer_ticks(idle_time); | 990 | sleep_ticks = us_to_pm_timer_ticks(idle_time); |
995 | /* Tell the scheduler how much we idled: */ | 991 | /* Tell the scheduler how much we idled: */ |
996 | sched_clock_idle_wakeup_event(sleep_ticks*PM_TIMER_TICK_NS); | 992 | sched_clock_idle_wakeup_event(sleep_ticks*PM_TIMER_TICK_NS); |
@@ -1034,6 +1030,9 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr) | |||
1034 | dev->states[i].desc[0] = '\0'; | 1030 | dev->states[i].desc[0] = '\0'; |
1035 | } | 1031 | } |
1036 | 1032 | ||
1033 | if (max_cstate == 0) | ||
1034 | max_cstate = 1; | ||
1035 | |||
1037 | for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) { | 1036 | for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) { |
1038 | cx = &pr->power.states[i]; | 1037 | cx = &pr->power.states[i]; |
1039 | state = &dev->states[count]; | 1038 | state = &dev->states[count]; |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 20c23c049207..8ff510b91d88 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -24,7 +24,7 @@ extern struct acpi_device *acpi_root; | |||
24 | 24 | ||
25 | static LIST_HEAD(acpi_device_list); | 25 | static LIST_HEAD(acpi_device_list); |
26 | static LIST_HEAD(acpi_bus_id_list); | 26 | static LIST_HEAD(acpi_bus_id_list); |
27 | DEFINE_SPINLOCK(acpi_device_lock); | 27 | DEFINE_MUTEX(acpi_device_lock); |
28 | LIST_HEAD(acpi_wakeup_device_list); | 28 | LIST_HEAD(acpi_wakeup_device_list); |
29 | 29 | ||
30 | struct acpi_device_bus_id{ | 30 | struct acpi_device_bus_id{ |
@@ -491,7 +491,6 @@ static int acpi_device_register(struct acpi_device *device, | |||
491 | */ | 491 | */ |
492 | INIT_LIST_HEAD(&device->children); | 492 | INIT_LIST_HEAD(&device->children); |
493 | INIT_LIST_HEAD(&device->node); | 493 | INIT_LIST_HEAD(&device->node); |
494 | INIT_LIST_HEAD(&device->g_list); | ||
495 | INIT_LIST_HEAD(&device->wakeup_list); | 494 | INIT_LIST_HEAD(&device->wakeup_list); |
496 | 495 | ||
497 | new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL); | 496 | new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL); |
@@ -500,7 +499,7 @@ static int acpi_device_register(struct acpi_device *device, | |||
500 | return -ENOMEM; | 499 | return -ENOMEM; |
501 | } | 500 | } |
502 | 501 | ||
503 | spin_lock(&acpi_device_lock); | 502 | mutex_lock(&acpi_device_lock); |
504 | /* | 503 | /* |
505 | * Find suitable bus_id and instance number in acpi_bus_id_list | 504 | * Find suitable bus_id and instance number in acpi_bus_id_list |
506 | * If failed, create one and link it into acpi_bus_id_list | 505 | * If failed, create one and link it into acpi_bus_id_list |
@@ -521,14 +520,12 @@ static int acpi_device_register(struct acpi_device *device, | |||
521 | } | 520 | } |
522 | dev_set_name(&device->dev, "%s:%02x", acpi_device_bus_id->bus_id, acpi_device_bus_id->instance_no); | 521 | dev_set_name(&device->dev, "%s:%02x", acpi_device_bus_id->bus_id, acpi_device_bus_id->instance_no); |
523 | 522 | ||
524 | if (device->parent) { | 523 | if (device->parent) |
525 | list_add_tail(&device->node, &device->parent->children); | 524 | list_add_tail(&device->node, &device->parent->children); |
526 | list_add_tail(&device->g_list, &device->parent->g_list); | 525 | |
527 | } else | ||
528 | list_add_tail(&device->g_list, &acpi_device_list); | ||
529 | if (device->wakeup.flags.valid) | 526 | if (device->wakeup.flags.valid) |
530 | list_add_tail(&device->wakeup_list, &acpi_wakeup_device_list); | 527 | list_add_tail(&device->wakeup_list, &acpi_wakeup_device_list); |
531 | spin_unlock(&acpi_device_lock); | 528 | mutex_unlock(&acpi_device_lock); |
532 | 529 | ||
533 | if (device->parent) | 530 | if (device->parent) |
534 | device->dev.parent = &parent->dev; | 531 | device->dev.parent = &parent->dev; |
@@ -549,28 +546,22 @@ static int acpi_device_register(struct acpi_device *device, | |||
549 | device->removal_type = ACPI_BUS_REMOVAL_NORMAL; | 546 | device->removal_type = ACPI_BUS_REMOVAL_NORMAL; |
550 | return 0; | 547 | return 0; |
551 | end: | 548 | end: |
552 | spin_lock(&acpi_device_lock); | 549 | mutex_lock(&acpi_device_lock); |
553 | if (device->parent) { | 550 | if (device->parent) |
554 | list_del(&device->node); | 551 | list_del(&device->node); |
555 | list_del(&device->g_list); | ||
556 | } else | ||
557 | list_del(&device->g_list); | ||
558 | list_del(&device->wakeup_list); | 552 | list_del(&device->wakeup_list); |
559 | spin_unlock(&acpi_device_lock); | 553 | mutex_unlock(&acpi_device_lock); |
560 | return result; | 554 | return result; |
561 | } | 555 | } |
562 | 556 | ||
563 | static void acpi_device_unregister(struct acpi_device *device, int type) | 557 | static void acpi_device_unregister(struct acpi_device *device, int type) |
564 | { | 558 | { |
565 | spin_lock(&acpi_device_lock); | 559 | mutex_lock(&acpi_device_lock); |
566 | if (device->parent) { | 560 | if (device->parent) |
567 | list_del(&device->node); | 561 | list_del(&device->node); |
568 | list_del(&device->g_list); | ||
569 | } else | ||
570 | list_del(&device->g_list); | ||
571 | 562 | ||
572 | list_del(&device->wakeup_list); | 563 | list_del(&device->wakeup_list); |
573 | spin_unlock(&acpi_device_lock); | 564 | mutex_unlock(&acpi_device_lock); |
574 | 565 | ||
575 | acpi_detach_data(device->handle, acpi_bus_data_handler); | 566 | acpi_detach_data(device->handle, acpi_bus_data_handler); |
576 | 567 | ||
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index 779e4e500df4..01574a066534 100644 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c | |||
@@ -300,9 +300,9 @@ static int acpi_suspend_state_valid(suspend_state_t pm_state) | |||
300 | static struct platform_suspend_ops acpi_suspend_ops = { | 300 | static struct platform_suspend_ops acpi_suspend_ops = { |
301 | .valid = acpi_suspend_state_valid, | 301 | .valid = acpi_suspend_state_valid, |
302 | .begin = acpi_suspend_begin, | 302 | .begin = acpi_suspend_begin, |
303 | .prepare = acpi_pm_prepare, | 303 | .prepare_late = acpi_pm_prepare, |
304 | .enter = acpi_suspend_enter, | 304 | .enter = acpi_suspend_enter, |
305 | .finish = acpi_pm_finish, | 305 | .wake = acpi_pm_finish, |
306 | .end = acpi_pm_end, | 306 | .end = acpi_pm_end, |
307 | }; | 307 | }; |
308 | 308 | ||
@@ -328,9 +328,9 @@ static int acpi_suspend_begin_old(suspend_state_t pm_state) | |||
328 | static struct platform_suspend_ops acpi_suspend_ops_old = { | 328 | static struct platform_suspend_ops acpi_suspend_ops_old = { |
329 | .valid = acpi_suspend_state_valid, | 329 | .valid = acpi_suspend_state_valid, |
330 | .begin = acpi_suspend_begin_old, | 330 | .begin = acpi_suspend_begin_old, |
331 | .prepare = acpi_pm_disable_gpes, | 331 | .prepare_late = acpi_pm_disable_gpes, |
332 | .enter = acpi_suspend_enter, | 332 | .enter = acpi_suspend_enter, |
333 | .finish = acpi_pm_finish, | 333 | .wake = acpi_pm_finish, |
334 | .end = acpi_pm_end, | 334 | .end = acpi_pm_end, |
335 | .recover = acpi_pm_finish, | 335 | .recover = acpi_pm_finish, |
336 | }; | 336 | }; |
@@ -713,6 +713,32 @@ static void acpi_power_off(void) | |||
713 | acpi_enter_sleep_state(ACPI_STATE_S5); | 713 | acpi_enter_sleep_state(ACPI_STATE_S5); |
714 | } | 714 | } |
715 | 715 | ||
716 | /* | ||
717 | * ACPI 2.0 created the optional _GTS and _BFS, | ||
718 | * but industry adoption has been neither rapid nor broad. | ||
719 | * | ||
720 | * Linux gets into trouble when it executes poorly validated | ||
721 | * paths through the BIOS, so disable _GTS and _BFS by default, | ||
722 | * but do speak up and offer the option to enable them. | ||
723 | */ | ||
724 | void __init acpi_gts_bfs_check(void) | ||
725 | { | ||
726 | acpi_handle dummy; | ||
727 | |||
728 | if (ACPI_SUCCESS(acpi_get_handle(ACPI_ROOT_OBJECT, METHOD_NAME__GTS, &dummy))) | ||
729 | { | ||
730 | printk(KERN_NOTICE PREFIX "BIOS offers _GTS\n"); | ||
731 | printk(KERN_NOTICE PREFIX "If \"acpi.gts=1\" improves suspend, " | ||
732 | "please notify linux-acpi@vger.kernel.org\n"); | ||
733 | } | ||
734 | if (ACPI_SUCCESS(acpi_get_handle(ACPI_ROOT_OBJECT, METHOD_NAME__BFS, &dummy))) | ||
735 | { | ||
736 | printk(KERN_NOTICE PREFIX "BIOS offers _BFS\n"); | ||
737 | printk(KERN_NOTICE PREFIX "If \"acpi.bfs=1\" improves resume, " | ||
738 | "please notify linux-acpi@vger.kernel.org\n"); | ||
739 | } | ||
740 | } | ||
741 | |||
716 | int __init acpi_sleep_init(void) | 742 | int __init acpi_sleep_init(void) |
717 | { | 743 | { |
718 | acpi_status status; | 744 | acpi_status status; |
@@ -771,5 +797,6 @@ int __init acpi_sleep_init(void) | |||
771 | * object can also be evaluated when the system enters S5. | 797 | * object can also be evaluated when the system enters S5. |
772 | */ | 798 | */ |
773 | register_reboot_notifier(&tts_notifier); | 799 | register_reboot_notifier(&tts_notifier); |
800 | acpi_gts_bfs_check(); | ||
774 | return 0; | 801 | return 0; |
775 | } | 802 | } |
diff --git a/drivers/acpi/sleep.h b/drivers/acpi/sleep.h index cfaf8f5b0a14..8a8f3b3382a6 100644 --- a/drivers/acpi/sleep.h +++ b/drivers/acpi/sleep.h | |||
@@ -5,3 +5,6 @@ extern int acpi_suspend (u32 state); | |||
5 | extern void acpi_enable_wakeup_device_prep(u8 sleep_state); | 5 | extern void acpi_enable_wakeup_device_prep(u8 sleep_state); |
6 | extern void acpi_enable_wakeup_device(u8 sleep_state); | 6 | extern void acpi_enable_wakeup_device(u8 sleep_state); |
7 | extern void acpi_disable_wakeup_device(u8 sleep_state); | 7 | extern void acpi_disable_wakeup_device(u8 sleep_state); |
8 | |||
9 | extern struct list_head acpi_wakeup_device_list; | ||
10 | extern struct mutex acpi_device_lock; | ||
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c index da51f05ef8d8..0944daec064f 100644 --- a/drivers/acpi/system.c +++ b/drivers/acpi/system.c | |||
@@ -38,6 +38,7 @@ ACPI_MODULE_NAME("system"); | |||
38 | #define ACPI_SYSTEM_DEVICE_NAME "System" | 38 | #define ACPI_SYSTEM_DEVICE_NAME "System" |
39 | 39 | ||
40 | u32 acpi_irq_handled; | 40 | u32 acpi_irq_handled; |
41 | u32 acpi_irq_not_handled; | ||
41 | 42 | ||
42 | /* | 43 | /* |
43 | * Make ACPICA version work as module param | 44 | * Make ACPICA version work as module param |
@@ -214,8 +215,9 @@ err: | |||
214 | 215 | ||
215 | #define COUNT_GPE 0 | 216 | #define COUNT_GPE 0 |
216 | #define COUNT_SCI 1 /* acpi_irq_handled */ | 217 | #define COUNT_SCI 1 /* acpi_irq_handled */ |
217 | #define COUNT_ERROR 2 /* other */ | 218 | #define COUNT_SCI_NOT 2 /* acpi_irq_not_handled */ |
218 | #define NUM_COUNTERS_EXTRA 3 | 219 | #define COUNT_ERROR 3 /* other */ |
220 | #define NUM_COUNTERS_EXTRA 4 | ||
219 | 221 | ||
220 | struct event_counter { | 222 | struct event_counter { |
221 | u32 count; | 223 | u32 count; |
@@ -317,6 +319,8 @@ static ssize_t counter_show(struct kobject *kobj, | |||
317 | 319 | ||
318 | all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_SCI].count = | 320 | all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_SCI].count = |
319 | acpi_irq_handled; | 321 | acpi_irq_handled; |
322 | all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_SCI_NOT].count = | ||
323 | acpi_irq_not_handled; | ||
320 | all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_GPE].count = | 324 | all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_GPE].count = |
321 | acpi_gpe_count; | 325 | acpi_gpe_count; |
322 | 326 | ||
@@ -363,6 +367,7 @@ static ssize_t counter_set(struct kobject *kobj, | |||
363 | all_counters[i].count = 0; | 367 | all_counters[i].count = 0; |
364 | acpi_gpe_count = 0; | 368 | acpi_gpe_count = 0; |
365 | acpi_irq_handled = 0; | 369 | acpi_irq_handled = 0; |
370 | acpi_irq_not_handled = 0; | ||
366 | goto end; | 371 | goto end; |
367 | } | 372 | } |
368 | 373 | ||
@@ -456,6 +461,8 @@ void acpi_irq_stats_init(void) | |||
456 | sprintf(buffer, "gpe_all"); | 461 | sprintf(buffer, "gpe_all"); |
457 | else if (i == num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_SCI) | 462 | else if (i == num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_SCI) |
458 | sprintf(buffer, "sci"); | 463 | sprintf(buffer, "sci"); |
464 | else if (i == num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_SCI_NOT) | ||
465 | sprintf(buffer, "sci_not"); | ||
459 | else if (i == num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_ERROR) | 466 | else if (i == num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_ERROR) |
460 | sprintf(buffer, "error"); | 467 | sprintf(buffer, "error"); |
461 | else | 468 | else |
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index e8c143caf0fd..564ea1424288 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c | |||
@@ -98,6 +98,7 @@ MODULE_PARM_DESC(psv, "Disable or override all passive trip points."); | |||
98 | static int acpi_thermal_add(struct acpi_device *device); | 98 | static int acpi_thermal_add(struct acpi_device *device); |
99 | static int acpi_thermal_remove(struct acpi_device *device, int type); | 99 | static int acpi_thermal_remove(struct acpi_device *device, int type); |
100 | static int acpi_thermal_resume(struct acpi_device *device); | 100 | static int acpi_thermal_resume(struct acpi_device *device); |
101 | static void acpi_thermal_notify(struct acpi_device *device, u32 event); | ||
101 | static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file); | 102 | static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file); |
102 | static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file); | 103 | static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file); |
103 | static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file); | 104 | static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file); |
@@ -123,6 +124,7 @@ static struct acpi_driver acpi_thermal_driver = { | |||
123 | .add = acpi_thermal_add, | 124 | .add = acpi_thermal_add, |
124 | .remove = acpi_thermal_remove, | 125 | .remove = acpi_thermal_remove, |
125 | .resume = acpi_thermal_resume, | 126 | .resume = acpi_thermal_resume, |
127 | .notify = acpi_thermal_notify, | ||
126 | }, | 128 | }, |
127 | }; | 129 | }; |
128 | 130 | ||
@@ -192,6 +194,7 @@ struct acpi_thermal { | |||
192 | struct acpi_handle_list devices; | 194 | struct acpi_handle_list devices; |
193 | struct thermal_zone_device *thermal_zone; | 195 | struct thermal_zone_device *thermal_zone; |
194 | int tz_enabled; | 196 | int tz_enabled; |
197 | int kelvin_offset; | ||
195 | struct mutex lock; | 198 | struct mutex lock; |
196 | }; | 199 | }; |
197 | 200 | ||
@@ -581,7 +584,7 @@ static void acpi_thermal_check(void *data) | |||
581 | } | 584 | } |
582 | 585 | ||
583 | /* sys I/F for generic thermal sysfs support */ | 586 | /* sys I/F for generic thermal sysfs support */ |
584 | #define KELVIN_TO_MILLICELSIUS(t) (t * 100 - 273200) | 587 | #define KELVIN_TO_MILLICELSIUS(t, off) (((t) - (off)) * 100) |
585 | 588 | ||
586 | static int thermal_get_temp(struct thermal_zone_device *thermal, | 589 | static int thermal_get_temp(struct thermal_zone_device *thermal, |
587 | unsigned long *temp) | 590 | unsigned long *temp) |
@@ -596,7 +599,7 @@ static int thermal_get_temp(struct thermal_zone_device *thermal, | |||
596 | if (result) | 599 | if (result) |
597 | return result; | 600 | return result; |
598 | 601 | ||
599 | *temp = KELVIN_TO_MILLICELSIUS(tz->temperature); | 602 | *temp = KELVIN_TO_MILLICELSIUS(tz->temperature, tz->kelvin_offset); |
600 | return 0; | 603 | return 0; |
601 | } | 604 | } |
602 | 605 | ||
@@ -702,7 +705,8 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal, | |||
702 | if (tz->trips.critical.flags.valid) { | 705 | if (tz->trips.critical.flags.valid) { |
703 | if (!trip) { | 706 | if (!trip) { |
704 | *temp = KELVIN_TO_MILLICELSIUS( | 707 | *temp = KELVIN_TO_MILLICELSIUS( |
705 | tz->trips.critical.temperature); | 708 | tz->trips.critical.temperature, |
709 | tz->kelvin_offset); | ||
706 | return 0; | 710 | return 0; |
707 | } | 711 | } |
708 | trip--; | 712 | trip--; |
@@ -711,7 +715,8 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal, | |||
711 | if (tz->trips.hot.flags.valid) { | 715 | if (tz->trips.hot.flags.valid) { |
712 | if (!trip) { | 716 | if (!trip) { |
713 | *temp = KELVIN_TO_MILLICELSIUS( | 717 | *temp = KELVIN_TO_MILLICELSIUS( |
714 | tz->trips.hot.temperature); | 718 | tz->trips.hot.temperature, |
719 | tz->kelvin_offset); | ||
715 | return 0; | 720 | return 0; |
716 | } | 721 | } |
717 | trip--; | 722 | trip--; |
@@ -720,7 +725,8 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal, | |||
720 | if (tz->trips.passive.flags.valid) { | 725 | if (tz->trips.passive.flags.valid) { |
721 | if (!trip) { | 726 | if (!trip) { |
722 | *temp = KELVIN_TO_MILLICELSIUS( | 727 | *temp = KELVIN_TO_MILLICELSIUS( |
723 | tz->trips.passive.temperature); | 728 | tz->trips.passive.temperature, |
729 | tz->kelvin_offset); | ||
724 | return 0; | 730 | return 0; |
725 | } | 731 | } |
726 | trip--; | 732 | trip--; |
@@ -730,7 +736,8 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal, | |||
730 | tz->trips.active[i].flags.valid; i++) { | 736 | tz->trips.active[i].flags.valid; i++) { |
731 | if (!trip) { | 737 | if (!trip) { |
732 | *temp = KELVIN_TO_MILLICELSIUS( | 738 | *temp = KELVIN_TO_MILLICELSIUS( |
733 | tz->trips.active[i].temperature); | 739 | tz->trips.active[i].temperature, |
740 | tz->kelvin_offset); | ||
734 | return 0; | 741 | return 0; |
735 | } | 742 | } |
736 | trip--; | 743 | trip--; |
@@ -745,7 +752,8 @@ static int thermal_get_crit_temp(struct thermal_zone_device *thermal, | |||
745 | 752 | ||
746 | if (tz->trips.critical.flags.valid) { | 753 | if (tz->trips.critical.flags.valid) { |
747 | *temperature = KELVIN_TO_MILLICELSIUS( | 754 | *temperature = KELVIN_TO_MILLICELSIUS( |
748 | tz->trips.critical.temperature); | 755 | tz->trips.critical.temperature, |
756 | tz->kelvin_offset); | ||
749 | return 0; | 757 | return 0; |
750 | } else | 758 | } else |
751 | return -EINVAL; | 759 | return -EINVAL; |
@@ -901,7 +909,7 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) | |||
901 | thermal_zone_device_register("acpitz", trips, tz, | 909 | thermal_zone_device_register("acpitz", trips, tz, |
902 | &acpi_thermal_zone_ops, | 910 | &acpi_thermal_zone_ops, |
903 | 0, 0, 0, | 911 | 0, 0, 0, |
904 | tz->polling_frequency); | 912 | tz->polling_frequency*100); |
905 | if (IS_ERR(tz->thermal_zone)) | 913 | if (IS_ERR(tz->thermal_zone)) |
906 | return -ENODEV; | 914 | return -ENODEV; |
907 | 915 | ||
@@ -1264,17 +1272,14 @@ static int acpi_thermal_remove_fs(struct acpi_device *device) | |||
1264 | Driver Interface | 1272 | Driver Interface |
1265 | -------------------------------------------------------------------------- */ | 1273 | -------------------------------------------------------------------------- */ |
1266 | 1274 | ||
1267 | static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data) | 1275 | static void acpi_thermal_notify(struct acpi_device *device, u32 event) |
1268 | { | 1276 | { |
1269 | struct acpi_thermal *tz = data; | 1277 | struct acpi_thermal *tz = acpi_driver_data(device); |
1270 | struct acpi_device *device = NULL; | ||
1271 | 1278 | ||
1272 | 1279 | ||
1273 | if (!tz) | 1280 | if (!tz) |
1274 | return; | 1281 | return; |
1275 | 1282 | ||
1276 | device = tz->device; | ||
1277 | |||
1278 | switch (event) { | 1283 | switch (event) { |
1279 | case ACPI_THERMAL_NOTIFY_TEMPERATURE: | 1284 | case ACPI_THERMAL_NOTIFY_TEMPERATURE: |
1280 | acpi_thermal_check(tz); | 1285 | acpi_thermal_check(tz); |
@@ -1298,8 +1303,6 @@ static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data) | |||
1298 | "Unsupported event [0x%x]\n", event)); | 1303 | "Unsupported event [0x%x]\n", event)); |
1299 | break; | 1304 | break; |
1300 | } | 1305 | } |
1301 | |||
1302 | return; | ||
1303 | } | 1306 | } |
1304 | 1307 | ||
1305 | static int acpi_thermal_get_info(struct acpi_thermal *tz) | 1308 | static int acpi_thermal_get_info(struct acpi_thermal *tz) |
@@ -1334,10 +1337,28 @@ static int acpi_thermal_get_info(struct acpi_thermal *tz) | |||
1334 | return 0; | 1337 | return 0; |
1335 | } | 1338 | } |
1336 | 1339 | ||
1340 | /* | ||
1341 | * The exact offset between Kelvin and degree Celsius is 273.15. However ACPI | ||
1342 | * handles temperature values with a single decimal place. As a consequence, | ||
1343 | * some implementations use an offset of 273.1 and others use an offset of | ||
1344 | * 273.2. Try to find out which one is being used, to present the most | ||
1345 | * accurate and visually appealing number. | ||
1346 | * | ||
1347 | * The heuristic below should work for all ACPI thermal zones which have a | ||
1348 | * critical trip point with a value being a multiple of 0.5 degree Celsius. | ||
1349 | */ | ||
1350 | static void acpi_thermal_guess_offset(struct acpi_thermal *tz) | ||
1351 | { | ||
1352 | if (tz->trips.critical.flags.valid && | ||
1353 | (tz->trips.critical.temperature % 5) == 1) | ||
1354 | tz->kelvin_offset = 2731; | ||
1355 | else | ||
1356 | tz->kelvin_offset = 2732; | ||
1357 | } | ||
1358 | |||
1337 | static int acpi_thermal_add(struct acpi_device *device) | 1359 | static int acpi_thermal_add(struct acpi_device *device) |
1338 | { | 1360 | { |
1339 | int result = 0; | 1361 | int result = 0; |
1340 | acpi_status status = AE_OK; | ||
1341 | struct acpi_thermal *tz = NULL; | 1362 | struct acpi_thermal *tz = NULL; |
1342 | 1363 | ||
1343 | 1364 | ||
@@ -1360,6 +1381,8 @@ static int acpi_thermal_add(struct acpi_device *device) | |||
1360 | if (result) | 1381 | if (result) |
1361 | goto free_memory; | 1382 | goto free_memory; |
1362 | 1383 | ||
1384 | acpi_thermal_guess_offset(tz); | ||
1385 | |||
1363 | result = acpi_thermal_register_thermal_zone(tz); | 1386 | result = acpi_thermal_register_thermal_zone(tz); |
1364 | if (result) | 1387 | if (result) |
1365 | goto free_memory; | 1388 | goto free_memory; |
@@ -1368,21 +1391,11 @@ static int acpi_thermal_add(struct acpi_device *device) | |||
1368 | if (result) | 1391 | if (result) |
1369 | goto unregister_thermal_zone; | 1392 | goto unregister_thermal_zone; |
1370 | 1393 | ||
1371 | status = acpi_install_notify_handler(device->handle, | ||
1372 | ACPI_DEVICE_NOTIFY, | ||
1373 | acpi_thermal_notify, tz); | ||
1374 | if (ACPI_FAILURE(status)) { | ||
1375 | result = -ENODEV; | ||
1376 | goto remove_fs; | ||
1377 | } | ||
1378 | |||
1379 | printk(KERN_INFO PREFIX "%s [%s] (%ld C)\n", | 1394 | printk(KERN_INFO PREFIX "%s [%s] (%ld C)\n", |
1380 | acpi_device_name(device), acpi_device_bid(device), | 1395 | acpi_device_name(device), acpi_device_bid(device), |
1381 | KELVIN_TO_CELSIUS(tz->temperature)); | 1396 | KELVIN_TO_CELSIUS(tz->temperature)); |
1382 | goto end; | 1397 | goto end; |
1383 | 1398 | ||
1384 | remove_fs: | ||
1385 | acpi_thermal_remove_fs(device); | ||
1386 | unregister_thermal_zone: | 1399 | unregister_thermal_zone: |
1387 | thermal_zone_device_unregister(tz->thermal_zone); | 1400 | thermal_zone_device_unregister(tz->thermal_zone); |
1388 | free_memory: | 1401 | free_memory: |
@@ -1393,7 +1406,6 @@ end: | |||
1393 | 1406 | ||
1394 | static int acpi_thermal_remove(struct acpi_device *device, int type) | 1407 | static int acpi_thermal_remove(struct acpi_device *device, int type) |
1395 | { | 1408 | { |
1396 | acpi_status status = AE_OK; | ||
1397 | struct acpi_thermal *tz = NULL; | 1409 | struct acpi_thermal *tz = NULL; |
1398 | 1410 | ||
1399 | if (!device || !acpi_driver_data(device)) | 1411 | if (!device || !acpi_driver_data(device)) |
@@ -1401,10 +1413,6 @@ static int acpi_thermal_remove(struct acpi_device *device, int type) | |||
1401 | 1413 | ||
1402 | tz = acpi_driver_data(device); | 1414 | tz = acpi_driver_data(device); |
1403 | 1415 | ||
1404 | status = acpi_remove_notify_handler(device->handle, | ||
1405 | ACPI_DEVICE_NOTIFY, | ||
1406 | acpi_thermal_notify); | ||
1407 | |||
1408 | acpi_thermal_remove_fs(device); | 1416 | acpi_thermal_remove_fs(device); |
1409 | acpi_thermal_unregister_thermal_zone(tz); | 1417 | acpi_thermal_unregister_thermal_zone(tz); |
1410 | mutex_destroy(&tz->lock); | 1418 | mutex_destroy(&tz->lock); |
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index ab06143672bc..1705d947ea09 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
@@ -79,6 +79,7 @@ module_param(brightness_switch_enabled, bool, 0644); | |||
79 | static int acpi_video_bus_add(struct acpi_device *device); | 79 | static int acpi_video_bus_add(struct acpi_device *device); |
80 | static int acpi_video_bus_remove(struct acpi_device *device, int type); | 80 | static int acpi_video_bus_remove(struct acpi_device *device, int type); |
81 | static int acpi_video_resume(struct acpi_device *device); | 81 | static int acpi_video_resume(struct acpi_device *device); |
82 | static void acpi_video_bus_notify(struct acpi_device *device, u32 event); | ||
82 | 83 | ||
83 | static const struct acpi_device_id video_device_ids[] = { | 84 | static const struct acpi_device_id video_device_ids[] = { |
84 | {ACPI_VIDEO_HID, 0}, | 85 | {ACPI_VIDEO_HID, 0}, |
@@ -94,6 +95,7 @@ static struct acpi_driver acpi_video_bus = { | |||
94 | .add = acpi_video_bus_add, | 95 | .add = acpi_video_bus_add, |
95 | .remove = acpi_video_bus_remove, | 96 | .remove = acpi_video_bus_remove, |
96 | .resume = acpi_video_resume, | 97 | .resume = acpi_video_resume, |
98 | .notify = acpi_video_bus_notify, | ||
97 | }, | 99 | }, |
98 | }; | 100 | }; |
99 | 101 | ||
@@ -768,10 +770,12 @@ acpi_video_init_brightness(struct acpi_video_device *device) | |||
768 | * In this case, the first two elements in _BCL packages | 770 | * In this case, the first two elements in _BCL packages |
769 | * are also supported brightness levels that OS should take care of. | 771 | * are also supported brightness levels that OS should take care of. |
770 | */ | 772 | */ |
771 | for (i = 2; i < count; i++) | 773 | for (i = 2; i < count; i++) { |
772 | if (br->levels[i] == br->levels[0] || | 774 | if (br->levels[i] == br->levels[0]) |
773 | br->levels[i] == br->levels[1]) | ||
774 | level_ac_battery++; | 775 | level_ac_battery++; |
776 | if (br->levels[i] == br->levels[1]) | ||
777 | level_ac_battery++; | ||
778 | } | ||
775 | 779 | ||
776 | if (level_ac_battery < 2) { | 780 | if (level_ac_battery < 2) { |
777 | level_ac_battery = 2 - level_ac_battery; | 781 | level_ac_battery = 2 - level_ac_battery; |
@@ -805,12 +809,19 @@ acpi_video_init_brightness(struct acpi_video_device *device) | |||
805 | br->flags._BCM_use_index = br->flags._BCL_use_index; | 809 | br->flags._BCM_use_index = br->flags._BCL_use_index; |
806 | 810 | ||
807 | /* _BQC uses INDEX while _BCL uses VALUE in some laptops */ | 811 | /* _BQC uses INDEX while _BCL uses VALUE in some laptops */ |
808 | br->curr = max_level; | 812 | br->curr = level_old = max_level; |
813 | |||
814 | if (!device->cap._BQC) | ||
815 | goto set_level; | ||
816 | |||
809 | result = acpi_video_device_lcd_get_level_current(device, &level_old); | 817 | result = acpi_video_device_lcd_get_level_current(device, &level_old); |
810 | if (result) | 818 | if (result) |
811 | goto out_free_levels; | 819 | goto out_free_levels; |
812 | 820 | ||
813 | result = acpi_video_device_lcd_set_level(device, br->curr); | 821 | /* |
822 | * Set the level to maximum and check if _BQC uses indexed value | ||
823 | */ | ||
824 | result = acpi_video_device_lcd_set_level(device, max_level); | ||
814 | if (result) | 825 | if (result) |
815 | goto out_free_levels; | 826 | goto out_free_levels; |
816 | 827 | ||
@@ -818,25 +829,19 @@ acpi_video_init_brightness(struct acpi_video_device *device) | |||
818 | if (result) | 829 | if (result) |
819 | goto out_free_levels; | 830 | goto out_free_levels; |
820 | 831 | ||
821 | if ((level != level_old) && !br->flags._BCM_use_index) { | 832 | br->flags._BQC_use_index = (level == max_level ? 0 : 1); |
822 | /* Note: | 833 | |
823 | * This piece of code does not work correctly if the current | 834 | if (!br->flags._BQC_use_index) |
824 | * brightness levels is 0. | 835 | goto set_level; |
825 | * But I guess boxes that boot with such a dark screen are rare | 836 | |
826 | * and no more code is needed to cover this specifial case. | 837 | if (br->flags._BCL_reversed) |
827 | */ | 838 | level_old = (br->count - 1) - level_old; |
828 | 839 | level_old = br->levels[level_old]; | |
829 | if (level_ac_battery != 2) { | 840 | |
830 | /* | 841 | set_level: |
831 | * For now, we don't support the _BCL like this: | 842 | result = acpi_video_device_lcd_set_level(device, level_old); |
832 | * 16, 15, 0, 1, 2, 3, ..., 14, 15, 16 | 843 | if (result) |
833 | * because we may mess up the index returned by _BQC. | 844 | goto out_free_levels; |
834 | * Plus: we have not got a box like this. | ||
835 | */ | ||
836 | ACPI_ERROR((AE_INFO, "_BCL not supported\n")); | ||
837 | } | ||
838 | br->flags._BQC_use_index = 1; | ||
839 | } | ||
840 | 845 | ||
841 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 846 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
842 | "found %d brightness levels\n", count - 2)); | 847 | "found %d brightness levels\n", count - 2)); |
@@ -1986,17 +1991,15 @@ static int acpi_video_bus_stop_devices(struct acpi_video_bus *video) | |||
1986 | return acpi_video_bus_DOS(video, 0, 1); | 1991 | return acpi_video_bus_DOS(video, 0, 1); |
1987 | } | 1992 | } |
1988 | 1993 | ||
1989 | static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data) | 1994 | static void acpi_video_bus_notify(struct acpi_device *device, u32 event) |
1990 | { | 1995 | { |
1991 | struct acpi_video_bus *video = data; | 1996 | struct acpi_video_bus *video = acpi_driver_data(device); |
1992 | struct acpi_device *device = NULL; | ||
1993 | struct input_dev *input; | 1997 | struct input_dev *input; |
1994 | int keycode; | 1998 | int keycode; |
1995 | 1999 | ||
1996 | if (!video) | 2000 | if (!video) |
1997 | return; | 2001 | return; |
1998 | 2002 | ||
1999 | device = video->device; | ||
2000 | input = video->input; | 2003 | input = video->input; |
2001 | 2004 | ||
2002 | switch (event) { | 2005 | switch (event) { |
@@ -2127,7 +2130,6 @@ static int acpi_video_resume(struct acpi_device *device) | |||
2127 | 2130 | ||
2128 | static int acpi_video_bus_add(struct acpi_device *device) | 2131 | static int acpi_video_bus_add(struct acpi_device *device) |
2129 | { | 2132 | { |
2130 | acpi_status status; | ||
2131 | struct acpi_video_bus *video; | 2133 | struct acpi_video_bus *video; |
2132 | struct input_dev *input; | 2134 | struct input_dev *input; |
2133 | int error; | 2135 | int error; |
@@ -2169,20 +2171,10 @@ static int acpi_video_bus_add(struct acpi_device *device) | |||
2169 | acpi_video_bus_get_devices(video, device); | 2171 | acpi_video_bus_get_devices(video, device); |
2170 | acpi_video_bus_start_devices(video); | 2172 | acpi_video_bus_start_devices(video); |
2171 | 2173 | ||
2172 | status = acpi_install_notify_handler(device->handle, | ||
2173 | ACPI_DEVICE_NOTIFY, | ||
2174 | acpi_video_bus_notify, video); | ||
2175 | if (ACPI_FAILURE(status)) { | ||
2176 | printk(KERN_ERR PREFIX | ||
2177 | "Error installing notify handler\n"); | ||
2178 | error = -ENODEV; | ||
2179 | goto err_stop_video; | ||
2180 | } | ||
2181 | |||
2182 | video->input = input = input_allocate_device(); | 2174 | video->input = input = input_allocate_device(); |
2183 | if (!input) { | 2175 | if (!input) { |
2184 | error = -ENOMEM; | 2176 | error = -ENOMEM; |
2185 | goto err_uninstall_notify; | 2177 | goto err_stop_video; |
2186 | } | 2178 | } |
2187 | 2179 | ||
2188 | snprintf(video->phys, sizeof(video->phys), | 2180 | snprintf(video->phys, sizeof(video->phys), |
@@ -2218,9 +2210,6 @@ static int acpi_video_bus_add(struct acpi_device *device) | |||
2218 | 2210 | ||
2219 | err_free_input_dev: | 2211 | err_free_input_dev: |
2220 | input_free_device(input); | 2212 | input_free_device(input); |
2221 | err_uninstall_notify: | ||
2222 | acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, | ||
2223 | acpi_video_bus_notify); | ||
2224 | err_stop_video: | 2213 | err_stop_video: |
2225 | acpi_video_bus_stop_devices(video); | 2214 | acpi_video_bus_stop_devices(video); |
2226 | acpi_video_bus_put_devices(video); | 2215 | acpi_video_bus_put_devices(video); |
@@ -2235,7 +2224,6 @@ static int acpi_video_bus_add(struct acpi_device *device) | |||
2235 | 2224 | ||
2236 | static int acpi_video_bus_remove(struct acpi_device *device, int type) | 2225 | static int acpi_video_bus_remove(struct acpi_device *device, int type) |
2237 | { | 2226 | { |
2238 | acpi_status status = 0; | ||
2239 | struct acpi_video_bus *video = NULL; | 2227 | struct acpi_video_bus *video = NULL; |
2240 | 2228 | ||
2241 | 2229 | ||
@@ -2245,11 +2233,6 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type) | |||
2245 | video = acpi_driver_data(device); | 2233 | video = acpi_driver_data(device); |
2246 | 2234 | ||
2247 | acpi_video_bus_stop_devices(video); | 2235 | acpi_video_bus_stop_devices(video); |
2248 | |||
2249 | status = acpi_remove_notify_handler(video->device->handle, | ||
2250 | ACPI_DEVICE_NOTIFY, | ||
2251 | acpi_video_bus_notify); | ||
2252 | |||
2253 | acpi_video_bus_put_devices(video); | 2236 | acpi_video_bus_put_devices(video); |
2254 | acpi_video_bus_remove_fs(device); | 2237 | acpi_video_bus_remove_fs(device); |
2255 | 2238 | ||
diff --git a/drivers/acpi/wakeup.c b/drivers/acpi/wakeup.c index 5aee8c26cc9f..88725dcdf8bc 100644 --- a/drivers/acpi/wakeup.c +++ b/drivers/acpi/wakeup.c | |||
@@ -12,12 +12,14 @@ | |||
12 | #include "internal.h" | 12 | #include "internal.h" |
13 | #include "sleep.h" | 13 | #include "sleep.h" |
14 | 14 | ||
15 | /* | ||
16 | * We didn't lock acpi_device_lock in the file, because it invokes oops in | ||
17 | * suspend/resume and isn't really required as this is called in S-state. At | ||
18 | * that time, there is no device hotplug | ||
19 | **/ | ||
15 | #define _COMPONENT ACPI_SYSTEM_COMPONENT | 20 | #define _COMPONENT ACPI_SYSTEM_COMPONENT |
16 | ACPI_MODULE_NAME("wakeup_devices") | 21 | ACPI_MODULE_NAME("wakeup_devices") |
17 | 22 | ||
18 | extern struct list_head acpi_wakeup_device_list; | ||
19 | extern spinlock_t acpi_device_lock; | ||
20 | |||
21 | /** | 23 | /** |
22 | * acpi_enable_wakeup_device_prep - prepare wakeup devices | 24 | * acpi_enable_wakeup_device_prep - prepare wakeup devices |
23 | * @sleep_state: ACPI state | 25 | * @sleep_state: ACPI state |
@@ -29,7 +31,6 @@ void acpi_enable_wakeup_device_prep(u8 sleep_state) | |||
29 | { | 31 | { |
30 | struct list_head *node, *next; | 32 | struct list_head *node, *next; |
31 | 33 | ||
32 | spin_lock(&acpi_device_lock); | ||
33 | list_for_each_safe(node, next, &acpi_wakeup_device_list) { | 34 | list_for_each_safe(node, next, &acpi_wakeup_device_list) { |
34 | struct acpi_device *dev = container_of(node, | 35 | struct acpi_device *dev = container_of(node, |
35 | struct acpi_device, | 36 | struct acpi_device, |
@@ -40,11 +41,8 @@ void acpi_enable_wakeup_device_prep(u8 sleep_state) | |||
40 | (sleep_state > (u32) dev->wakeup.sleep_state)) | 41 | (sleep_state > (u32) dev->wakeup.sleep_state)) |
41 | continue; | 42 | continue; |
42 | 43 | ||
43 | spin_unlock(&acpi_device_lock); | ||
44 | acpi_enable_wakeup_device_power(dev, sleep_state); | 44 | acpi_enable_wakeup_device_power(dev, sleep_state); |
45 | spin_lock(&acpi_device_lock); | ||
46 | } | 45 | } |
47 | spin_unlock(&acpi_device_lock); | ||
48 | } | 46 | } |
49 | 47 | ||
50 | /** | 48 | /** |
@@ -60,7 +58,6 @@ void acpi_enable_wakeup_device(u8 sleep_state) | |||
60 | * Caution: this routine must be invoked when interrupt is disabled | 58 | * Caution: this routine must be invoked when interrupt is disabled |
61 | * Refer ACPI2.0: P212 | 59 | * Refer ACPI2.0: P212 |
62 | */ | 60 | */ |
63 | spin_lock(&acpi_device_lock); | ||
64 | list_for_each_safe(node, next, &acpi_wakeup_device_list) { | 61 | list_for_each_safe(node, next, &acpi_wakeup_device_list) { |
65 | struct acpi_device *dev = | 62 | struct acpi_device *dev = |
66 | container_of(node, struct acpi_device, wakeup_list); | 63 | container_of(node, struct acpi_device, wakeup_list); |
@@ -74,22 +71,17 @@ void acpi_enable_wakeup_device(u8 sleep_state) | |||
74 | if ((!dev->wakeup.state.enabled && !dev->wakeup.flags.prepared) | 71 | if ((!dev->wakeup.state.enabled && !dev->wakeup.flags.prepared) |
75 | || sleep_state > (u32) dev->wakeup.sleep_state) { | 72 | || sleep_state > (u32) dev->wakeup.sleep_state) { |
76 | if (dev->wakeup.flags.run_wake) { | 73 | if (dev->wakeup.flags.run_wake) { |
77 | spin_unlock(&acpi_device_lock); | ||
78 | /* set_gpe_type will disable GPE, leave it like that */ | 74 | /* set_gpe_type will disable GPE, leave it like that */ |
79 | acpi_set_gpe_type(dev->wakeup.gpe_device, | 75 | acpi_set_gpe_type(dev->wakeup.gpe_device, |
80 | dev->wakeup.gpe_number, | 76 | dev->wakeup.gpe_number, |
81 | ACPI_GPE_TYPE_RUNTIME); | 77 | ACPI_GPE_TYPE_RUNTIME); |
82 | spin_lock(&acpi_device_lock); | ||
83 | } | 78 | } |
84 | continue; | 79 | continue; |
85 | } | 80 | } |
86 | spin_unlock(&acpi_device_lock); | ||
87 | if (!dev->wakeup.flags.run_wake) | 81 | if (!dev->wakeup.flags.run_wake) |
88 | acpi_enable_gpe(dev->wakeup.gpe_device, | 82 | acpi_enable_gpe(dev->wakeup.gpe_device, |
89 | dev->wakeup.gpe_number); | 83 | dev->wakeup.gpe_number); |
90 | spin_lock(&acpi_device_lock); | ||
91 | } | 84 | } |
92 | spin_unlock(&acpi_device_lock); | ||
93 | } | 85 | } |
94 | 86 | ||
95 | /** | 87 | /** |
@@ -101,7 +93,6 @@ void acpi_disable_wakeup_device(u8 sleep_state) | |||
101 | { | 93 | { |
102 | struct list_head *node, *next; | 94 | struct list_head *node, *next; |
103 | 95 | ||
104 | spin_lock(&acpi_device_lock); | ||
105 | list_for_each_safe(node, next, &acpi_wakeup_device_list) { | 96 | list_for_each_safe(node, next, &acpi_wakeup_device_list) { |
106 | struct acpi_device *dev = | 97 | struct acpi_device *dev = |
107 | container_of(node, struct acpi_device, wakeup_list); | 98 | container_of(node, struct acpi_device, wakeup_list); |
@@ -112,19 +103,16 @@ void acpi_disable_wakeup_device(u8 sleep_state) | |||
112 | if ((!dev->wakeup.state.enabled && !dev->wakeup.flags.prepared) | 103 | if ((!dev->wakeup.state.enabled && !dev->wakeup.flags.prepared) |
113 | || sleep_state > (u32) dev->wakeup.sleep_state) { | 104 | || sleep_state > (u32) dev->wakeup.sleep_state) { |
114 | if (dev->wakeup.flags.run_wake) { | 105 | if (dev->wakeup.flags.run_wake) { |
115 | spin_unlock(&acpi_device_lock); | ||
116 | acpi_set_gpe_type(dev->wakeup.gpe_device, | 106 | acpi_set_gpe_type(dev->wakeup.gpe_device, |
117 | dev->wakeup.gpe_number, | 107 | dev->wakeup.gpe_number, |
118 | ACPI_GPE_TYPE_WAKE_RUN); | 108 | ACPI_GPE_TYPE_WAKE_RUN); |
119 | /* Re-enable it, since set_gpe_type will disable it */ | 109 | /* Re-enable it, since set_gpe_type will disable it */ |
120 | acpi_enable_gpe(dev->wakeup.gpe_device, | 110 | acpi_enable_gpe(dev->wakeup.gpe_device, |
121 | dev->wakeup.gpe_number); | 111 | dev->wakeup.gpe_number); |
122 | spin_lock(&acpi_device_lock); | ||
123 | } | 112 | } |
124 | continue; | 113 | continue; |
125 | } | 114 | } |
126 | 115 | ||
127 | spin_unlock(&acpi_device_lock); | ||
128 | acpi_disable_wakeup_device_power(dev); | 116 | acpi_disable_wakeup_device_power(dev); |
129 | /* Never disable run-wake GPE */ | 117 | /* Never disable run-wake GPE */ |
130 | if (!dev->wakeup.flags.run_wake) { | 118 | if (!dev->wakeup.flags.run_wake) { |
@@ -133,16 +121,14 @@ void acpi_disable_wakeup_device(u8 sleep_state) | |||
133 | acpi_clear_gpe(dev->wakeup.gpe_device, | 121 | acpi_clear_gpe(dev->wakeup.gpe_device, |
134 | dev->wakeup.gpe_number, ACPI_NOT_ISR); | 122 | dev->wakeup.gpe_number, ACPI_NOT_ISR); |
135 | } | 123 | } |
136 | spin_lock(&acpi_device_lock); | ||
137 | } | 124 | } |
138 | spin_unlock(&acpi_device_lock); | ||
139 | } | 125 | } |
140 | 126 | ||
141 | int __init acpi_wakeup_device_init(void) | 127 | int __init acpi_wakeup_device_init(void) |
142 | { | 128 | { |
143 | struct list_head *node, *next; | 129 | struct list_head *node, *next; |
144 | 130 | ||
145 | spin_lock(&acpi_device_lock); | 131 | mutex_lock(&acpi_device_lock); |
146 | list_for_each_safe(node, next, &acpi_wakeup_device_list) { | 132 | list_for_each_safe(node, next, &acpi_wakeup_device_list) { |
147 | struct acpi_device *dev = container_of(node, | 133 | struct acpi_device *dev = container_of(node, |
148 | struct acpi_device, | 134 | struct acpi_device, |
@@ -150,15 +136,13 @@ int __init acpi_wakeup_device_init(void) | |||
150 | /* In case user doesn't load button driver */ | 136 | /* In case user doesn't load button driver */ |
151 | if (!dev->wakeup.flags.run_wake || dev->wakeup.state.enabled) | 137 | if (!dev->wakeup.flags.run_wake || dev->wakeup.state.enabled) |
152 | continue; | 138 | continue; |
153 | spin_unlock(&acpi_device_lock); | ||
154 | acpi_set_gpe_type(dev->wakeup.gpe_device, | 139 | acpi_set_gpe_type(dev->wakeup.gpe_device, |
155 | dev->wakeup.gpe_number, | 140 | dev->wakeup.gpe_number, |
156 | ACPI_GPE_TYPE_WAKE_RUN); | 141 | ACPI_GPE_TYPE_WAKE_RUN); |
157 | acpi_enable_gpe(dev->wakeup.gpe_device, | 142 | acpi_enable_gpe(dev->wakeup.gpe_device, |
158 | dev->wakeup.gpe_number); | 143 | dev->wakeup.gpe_number); |
159 | dev->wakeup.state.enabled = 1; | 144 | dev->wakeup.state.enabled = 1; |
160 | spin_lock(&acpi_device_lock); | ||
161 | } | 145 | } |
162 | spin_unlock(&acpi_device_lock); | 146 | mutex_unlock(&acpi_device_lock); |
163 | return 0; | 147 | return 0; |
164 | } | 148 | } |