diff options
36 files changed, 527 insertions, 150 deletions
diff --git a/Documentation/power/pm_qos_interface.txt b/Documentation/power/pm_qos_interface.txt index a5da5c7e7128..129f7c0e1483 100644 --- a/Documentation/power/pm_qos_interface.txt +++ b/Documentation/power/pm_qos_interface.txt | |||
@@ -5,7 +5,8 @@ performance expectations by drivers, subsystems and user space applications on | |||
5 | one of the parameters. | 5 | one of the parameters. |
6 | 6 | ||
7 | Two different PM QoS frameworks are available: | 7 | Two different PM QoS frameworks are available: |
8 | 1. PM QoS classes for cpu_dma_latency, network_latency, network_throughput. | 8 | 1. PM QoS classes for cpu_dma_latency, network_latency, network_throughput, |
9 | memory_bandwidth. | ||
9 | 2. the per-device PM QoS framework provides the API to manage the per-device latency | 10 | 2. the per-device PM QoS framework provides the API to manage the per-device latency |
10 | constraints and PM QoS flags. | 11 | constraints and PM QoS flags. |
11 | 12 | ||
@@ -13,6 +14,7 @@ Each parameters have defined units: | |||
13 | * latency: usec | 14 | * latency: usec |
14 | * timeout: usec | 15 | * timeout: usec |
15 | * throughput: kbs (kilo bit / sec) | 16 | * throughput: kbs (kilo bit / sec) |
17 | * memory bandwidth: mbs (mega bit / sec) | ||
16 | 18 | ||
17 | 19 | ||
18 | 1. PM QoS framework | 20 | 1. PM QoS framework |
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c index a3c89a1bcf54..6ba8beb6b9d2 100644 --- a/drivers/acpi/acpi_platform.c +++ b/drivers/acpi/acpi_platform.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/err.h> | 16 | #include <linux/err.h> |
17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/dma-mapping.h> | ||
19 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
20 | 21 | ||
21 | #include "internal.h" | 22 | #include "internal.h" |
@@ -102,6 +103,7 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev) | |||
102 | pdevinfo.res = resources; | 103 | pdevinfo.res = resources; |
103 | pdevinfo.num_res = count; | 104 | pdevinfo.num_res = count; |
104 | pdevinfo.acpi_node.companion = adev; | 105 | pdevinfo.acpi_node.companion = adev; |
106 | pdevinfo.dma_mask = DMA_BIT_MASK(32); | ||
105 | pdev = platform_device_register_full(&pdevinfo); | 107 | pdev = platform_device_register_full(&pdevinfo); |
106 | if (IS_ERR(pdev)) | 108 | if (IS_ERR(pdev)) |
107 | dev_err(&adev->dev, "platform device creation failed: %ld\n", | 109 | dev_err(&adev->dev, "platform device creation failed: %ld\n", |
diff --git a/drivers/acpi/acpica/achware.h b/drivers/acpi/acpica/achware.h index 2ad2351a9833..c318d3e27893 100644 --- a/drivers/acpi/acpica/achware.h +++ b/drivers/acpi/acpica/achware.h | |||
@@ -127,7 +127,7 @@ acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, | |||
127 | 127 | ||
128 | acpi_status | 128 | acpi_status |
129 | acpi_hw_get_gpe_status(struct acpi_gpe_event_info *gpe_event_info, | 129 | acpi_hw_get_gpe_status(struct acpi_gpe_event_info *gpe_event_info, |
130 | acpi_event_status * event_status); | 130 | acpi_event_status *event_status); |
131 | 131 | ||
132 | acpi_status acpi_hw_disable_all_gpes(void); | 132 | acpi_status acpi_hw_disable_all_gpes(void); |
133 | 133 | ||
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h index 2747279fbe3c..c00e7e41ad75 100644 --- a/drivers/acpi/acpica/aclocal.h +++ b/drivers/acpi/acpica/aclocal.h | |||
@@ -413,8 +413,8 @@ struct acpi_gpe_handler_info { | |||
413 | acpi_gpe_handler address; /* Address of handler, if any */ | 413 | acpi_gpe_handler address; /* Address of handler, if any */ |
414 | void *context; /* Context to be passed to handler */ | 414 | void *context; /* Context to be passed to handler */ |
415 | struct acpi_namespace_node *method_node; /* Method node for this GPE level (saved) */ | 415 | struct acpi_namespace_node *method_node; /* Method node for this GPE level (saved) */ |
416 | u8 original_flags; /* Original (pre-handler) GPE info */ | 416 | u8 original_flags; /* Original (pre-handler) GPE info */ |
417 | u8 originally_enabled; /* True if GPE was originally enabled */ | 417 | u8 originally_enabled; /* True if GPE was originally enabled */ |
418 | }; | 418 | }; |
419 | 419 | ||
420 | /* Notify info for implicit notify, multiple device objects */ | 420 | /* Notify info for implicit notify, multiple device objects */ |
diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h index f14882788eee..1afe46e44dac 100644 --- a/drivers/acpi/acpica/actables.h +++ b/drivers/acpi/acpica/actables.h | |||
@@ -49,6 +49,8 @@ acpi_status acpi_allocate_root_table(u32 initial_table_count); | |||
49 | /* | 49 | /* |
50 | * tbxfroot - Root pointer utilities | 50 | * tbxfroot - Root pointer utilities |
51 | */ | 51 | */ |
52 | u32 acpi_tb_get_rsdp_length(struct acpi_table_rsdp *rsdp); | ||
53 | |||
52 | acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp); | 54 | acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp); |
53 | 55 | ||
54 | u8 *acpi_tb_scan_memory_for_rsdp(u8 *start_address, u32 length); | 56 | u8 *acpi_tb_scan_memory_for_rsdp(u8 *start_address, u32 length); |
diff --git a/drivers/acpi/acpica/amlresrc.h b/drivers/acpi/acpica/amlresrc.h index f3f834408441..3a0beeb86ba5 100644 --- a/drivers/acpi/acpica/amlresrc.h +++ b/drivers/acpi/acpica/amlresrc.h | |||
@@ -117,6 +117,12 @@ struct asl_resource_node { | |||
117 | struct asl_resource_node *next; | 117 | struct asl_resource_node *next; |
118 | }; | 118 | }; |
119 | 119 | ||
120 | struct asl_resource_info { | ||
121 | union acpi_parse_object *descriptor_type_op; /* Resource descriptor parse node */ | ||
122 | union acpi_parse_object *mapping_op; /* Used for mapfile support */ | ||
123 | u32 current_byte_offset; /* Offset in resource template */ | ||
124 | }; | ||
125 | |||
120 | /* Macros used to generate AML resource length fields */ | 126 | /* Macros used to generate AML resource length fields */ |
121 | 127 | ||
122 | #define ACPI_AML_SIZE_LARGE(r) (sizeof (r) - sizeof (struct aml_resource_large_header)) | 128 | #define ACPI_AML_SIZE_LARGE(r) (sizeof (r) - sizeof (struct aml_resource_large_header)) |
@@ -449,4 +455,32 @@ union aml_resource { | |||
449 | u8 byte_item; | 455 | u8 byte_item; |
450 | }; | 456 | }; |
451 | 457 | ||
458 | /* Interfaces used by both the disassembler and compiler */ | ||
459 | |||
460 | void | ||
461 | mp_save_gpio_info(union acpi_parse_object *op, | ||
462 | union aml_resource *resource, | ||
463 | u32 pin_count, u16 *pin_list, char *device_name); | ||
464 | |||
465 | void | ||
466 | mp_save_serial_info(union acpi_parse_object *op, | ||
467 | union aml_resource *resource, char *device_name); | ||
468 | |||
469 | char *mp_get_hid_from_parse_tree(struct acpi_namespace_node *hid_node); | ||
470 | |||
471 | char *mp_get_hid_via_namestring(char *device_name); | ||
472 | |||
473 | char *mp_get_connection_info(union acpi_parse_object *op, | ||
474 | u32 pin_index, | ||
475 | struct acpi_namespace_node **target_node, | ||
476 | char **target_name); | ||
477 | |||
478 | char *mp_get_parent_device_hid(union acpi_parse_object *op, | ||
479 | struct acpi_namespace_node **target_node, | ||
480 | char **parent_device_name); | ||
481 | |||
482 | char *mp_get_ddn_value(char *device_name); | ||
483 | |||
484 | char *mp_get_hid_value(struct acpi_namespace_node *device_node); | ||
485 | |||
452 | #endif | 486 | #endif |
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c index e4ba4dec86af..2095dfb72bcb 100644 --- a/drivers/acpi/acpica/evgpe.c +++ b/drivers/acpi/acpica/evgpe.c | |||
@@ -100,13 +100,14 @@ acpi_ev_update_gpe_enable_mask(struct acpi_gpe_event_info *gpe_event_info) | |||
100 | * | 100 | * |
101 | * FUNCTION: acpi_ev_enable_gpe | 101 | * FUNCTION: acpi_ev_enable_gpe |
102 | * | 102 | * |
103 | * PARAMETERS: gpe_event_info - GPE to enable | 103 | * PARAMETERS: gpe_event_info - GPE to enable |
104 | * | 104 | * |
105 | * RETURN: Status | 105 | * RETURN: Status |
106 | * | 106 | * |
107 | * DESCRIPTION: Clear a GPE of stale events and enable it. | 107 | * DESCRIPTION: Clear a GPE of stale events and enable it. |
108 | * | 108 | * |
109 | ******************************************************************************/ | 109 | ******************************************************************************/ |
110 | |||
110 | acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info) | 111 | acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info) |
111 | { | 112 | { |
112 | acpi_status status; | 113 | acpi_status status; |
@@ -125,6 +126,7 @@ acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info) | |||
125 | } | 126 | } |
126 | 127 | ||
127 | /* Clear the GPE (of stale events) */ | 128 | /* Clear the GPE (of stale events) */ |
129 | |||
128 | status = acpi_hw_clear_gpe(gpe_event_info); | 130 | status = acpi_hw_clear_gpe(gpe_event_info); |
129 | if (ACPI_FAILURE(status)) { | 131 | if (ACPI_FAILURE(status)) { |
130 | return_ACPI_STATUS(status); | 132 | return_ACPI_STATUS(status); |
@@ -136,7 +138,6 @@ acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info) | |||
136 | return_ACPI_STATUS(status); | 138 | return_ACPI_STATUS(status); |
137 | } | 139 | } |
138 | 140 | ||
139 | |||
140 | /******************************************************************************* | 141 | /******************************************************************************* |
141 | * | 142 | * |
142 | * FUNCTION: acpi_ev_add_gpe_reference | 143 | * FUNCTION: acpi_ev_add_gpe_reference |
@@ -212,7 +213,7 @@ acpi_ev_remove_gpe_reference(struct acpi_gpe_event_info *gpe_event_info) | |||
212 | if (ACPI_SUCCESS(status)) { | 213 | if (ACPI_SUCCESS(status)) { |
213 | status = | 214 | status = |
214 | acpi_hw_low_set_gpe(gpe_event_info, | 215 | acpi_hw_low_set_gpe(gpe_event_info, |
215 | ACPI_GPE_DISABLE); | 216 | ACPI_GPE_DISABLE); |
216 | } | 217 | } |
217 | 218 | ||
218 | if (ACPI_FAILURE(status)) { | 219 | if (ACPI_FAILURE(status)) { |
@@ -334,7 +335,7 @@ struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device, | |||
334 | * | 335 | * |
335 | ******************************************************************************/ | 336 | ******************************************************************************/ |
336 | 337 | ||
337 | u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list) | 338 | u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info *gpe_xrupt_list) |
338 | { | 339 | { |
339 | acpi_status status; | 340 | acpi_status status; |
340 | struct acpi_gpe_block_info *gpe_block; | 341 | struct acpi_gpe_block_info *gpe_block; |
@@ -427,7 +428,7 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list) | |||
427 | 428 | ||
428 | /* Check if there is anything active at all in this register */ | 429 | /* Check if there is anything active at all in this register */ |
429 | 430 | ||
430 | enabled_status_byte = (u8) (status_reg & enable_reg); | 431 | enabled_status_byte = (u8)(status_reg & enable_reg); |
431 | if (!enabled_status_byte) { | 432 | if (!enabled_status_byte) { |
432 | 433 | ||
433 | /* No active GPEs in this register, move on */ | 434 | /* No active GPEs in this register, move on */ |
@@ -450,7 +451,7 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list) | |||
450 | acpi_ev_gpe_dispatch(gpe_block-> | 451 | acpi_ev_gpe_dispatch(gpe_block-> |
451 | node, | 452 | node, |
452 | &gpe_block-> | 453 | &gpe_block-> |
453 | event_info[((acpi_size) i * ACPI_GPE_REGISTER_WIDTH) + j], j + gpe_register_info->base_gpe_number); | 454 | event_info[((acpi_size) i * ACPI_GPE_REGISTER_WIDTH) + j], j + gpe_register_info->base_gpe_number); |
454 | } | 455 | } |
455 | } | 456 | } |
456 | } | 457 | } |
@@ -636,7 +637,7 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_enable_gpe(void *context) | |||
636 | * | 637 | * |
637 | ******************************************************************************/ | 638 | ******************************************************************************/ |
638 | 639 | ||
639 | acpi_status acpi_ev_finish_gpe(struct acpi_gpe_event_info *gpe_event_info) | 640 | acpi_status acpi_ev_finish_gpe(struct acpi_gpe_event_info * gpe_event_info) |
640 | { | 641 | { |
641 | acpi_status status; | 642 | acpi_status status; |
642 | 643 | ||
@@ -666,9 +667,9 @@ acpi_status acpi_ev_finish_gpe(struct acpi_gpe_event_info *gpe_event_info) | |||
666 | * | 667 | * |
667 | * FUNCTION: acpi_ev_gpe_dispatch | 668 | * FUNCTION: acpi_ev_gpe_dispatch |
668 | * | 669 | * |
669 | * PARAMETERS: gpe_device - Device node. NULL for GPE0/GPE1 | 670 | * PARAMETERS: gpe_device - Device node. NULL for GPE0/GPE1 |
670 | * gpe_event_info - Info for this GPE | 671 | * gpe_event_info - Info for this GPE |
671 | * gpe_number - Number relative to the parent GPE block | 672 | * gpe_number - Number relative to the parent GPE block |
672 | * | 673 | * |
673 | * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED | 674 | * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED |
674 | * | 675 | * |
@@ -681,7 +682,7 @@ acpi_status acpi_ev_finish_gpe(struct acpi_gpe_event_info *gpe_event_info) | |||
681 | 682 | ||
682 | u32 | 683 | u32 |
683 | acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device, | 684 | acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device, |
684 | struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number) | 685 | struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number) |
685 | { | 686 | { |
686 | acpi_status status; | 687 | acpi_status status; |
687 | u32 return_value; | 688 | u32 return_value; |
diff --git a/drivers/acpi/acpica/evgpeinit.c b/drivers/acpi/acpica/evgpeinit.c index 49fc7effd961..7be928379879 100644 --- a/drivers/acpi/acpica/evgpeinit.c +++ b/drivers/acpi/acpica/evgpeinit.c | |||
@@ -424,6 +424,7 @@ acpi_ev_match_gpe_method(acpi_handle obj_handle, | |||
424 | } | 424 | } |
425 | 425 | ||
426 | /* Disable the GPE in case it's been enabled already. */ | 426 | /* Disable the GPE in case it's been enabled already. */ |
427 | |||
427 | (void)acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_DISABLE); | 428 | (void)acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_DISABLE); |
428 | 429 | ||
429 | /* | 430 | /* |
diff --git a/drivers/acpi/acpica/evxface.c b/drivers/acpi/acpica/evxface.c index 11e5803b8b41..55a58f3ec8df 100644 --- a/drivers/acpi/acpica/evxface.c +++ b/drivers/acpi/acpica/evxface.c | |||
@@ -786,18 +786,26 @@ acpi_install_gpe_handler(acpi_handle gpe_device, | |||
786 | handler->method_node = gpe_event_info->dispatch.method_node; | 786 | handler->method_node = gpe_event_info->dispatch.method_node; |
787 | handler->original_flags = (u8)(gpe_event_info->flags & | 787 | handler->original_flags = (u8)(gpe_event_info->flags & |
788 | (ACPI_GPE_XRUPT_TYPE_MASK | | 788 | (ACPI_GPE_XRUPT_TYPE_MASK | |
789 | ACPI_GPE_DISPATCH_MASK)); | 789 | ACPI_GPE_DISPATCH_MASK)); |
790 | 790 | ||
791 | /* | 791 | /* |
792 | * If the GPE is associated with a method, it may have been enabled | 792 | * If the GPE is associated with a method, it may have been enabled |
793 | * automatically during initialization, in which case it has to be | 793 | * automatically during initialization, in which case it has to be |
794 | * disabled now to avoid spurious execution of the handler. | 794 | * disabled now to avoid spurious execution of the handler. |
795 | */ | 795 | */ |
796 | 796 | if (((handler->original_flags & ACPI_GPE_DISPATCH_METHOD) || | |
797 | if ((handler->original_flags & ACPI_GPE_DISPATCH_METHOD) | 797 | (handler->original_flags & ACPI_GPE_DISPATCH_NOTIFY)) && |
798 | && gpe_event_info->runtime_count) { | 798 | gpe_event_info->runtime_count) { |
799 | handler->originally_enabled = 1; | 799 | handler->originally_enabled = TRUE; |
800 | (void)acpi_ev_remove_gpe_reference(gpe_event_info); | 800 | (void)acpi_ev_remove_gpe_reference(gpe_event_info); |
801 | |||
802 | /* Sanity check of original type against new type */ | ||
803 | |||
804 | if (type != | ||
805 | (u32)(gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK)) { | ||
806 | ACPI_WARNING((AE_INFO, | ||
807 | "GPE type mismatch (level/edge)")); | ||
808 | } | ||
801 | } | 809 | } |
802 | 810 | ||
803 | /* Install the handler */ | 811 | /* Install the handler */ |
@@ -808,7 +816,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device, | |||
808 | 816 | ||
809 | gpe_event_info->flags &= | 817 | gpe_event_info->flags &= |
810 | ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); | 818 | ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); |
811 | gpe_event_info->flags |= (u8) (type | ACPI_GPE_DISPATCH_HANDLER); | 819 | gpe_event_info->flags |= (u8)(type | ACPI_GPE_DISPATCH_HANDLER); |
812 | 820 | ||
813 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); | 821 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); |
814 | 822 | ||
@@ -893,7 +901,7 @@ acpi_remove_gpe_handler(acpi_handle gpe_device, | |||
893 | 901 | ||
894 | gpe_event_info->dispatch.method_node = handler->method_node; | 902 | gpe_event_info->dispatch.method_node = handler->method_node; |
895 | gpe_event_info->flags &= | 903 | gpe_event_info->flags &= |
896 | ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); | 904 | ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); |
897 | gpe_event_info->flags |= handler->original_flags; | 905 | gpe_event_info->flags |= handler->original_flags; |
898 | 906 | ||
899 | /* | 907 | /* |
@@ -901,7 +909,8 @@ acpi_remove_gpe_handler(acpi_handle gpe_device, | |||
901 | * enabled, it should be enabled at this point to restore the | 909 | * enabled, it should be enabled at this point to restore the |
902 | * post-initialization configuration. | 910 | * post-initialization configuration. |
903 | */ | 911 | */ |
904 | if ((handler->original_flags & ACPI_GPE_DISPATCH_METHOD) && | 912 | if (((handler->original_flags & ACPI_GPE_DISPATCH_METHOD) || |
913 | (handler->original_flags & ACPI_GPE_DISPATCH_NOTIFY)) && | ||
905 | handler->originally_enabled) { | 914 | handler->originally_enabled) { |
906 | (void)acpi_ev_add_gpe_reference(gpe_event_info); | 915 | (void)acpi_ev_add_gpe_reference(gpe_event_info); |
907 | } | 916 | } |
@@ -946,7 +955,7 @@ ACPI_EXPORT_SYMBOL(acpi_remove_gpe_handler) | |||
946 | * handle is returned. | 955 | * handle is returned. |
947 | * | 956 | * |
948 | ******************************************************************************/ | 957 | ******************************************************************************/ |
949 | acpi_status acpi_acquire_global_lock(u16 timeout, u32 * handle) | 958 | acpi_status acpi_acquire_global_lock(u16 timeout, u32 *handle) |
950 | { | 959 | { |
951 | acpi_status status; | 960 | acpi_status status; |
952 | 961 | ||
diff --git a/drivers/acpi/acpica/evxfevnt.c b/drivers/acpi/acpica/evxfevnt.c index e286640ad4ff..bb8cbf5961bf 100644 --- a/drivers/acpi/acpica/evxfevnt.c +++ b/drivers/acpi/acpica/evxfevnt.c | |||
@@ -324,8 +324,9 @@ ACPI_EXPORT_SYMBOL(acpi_clear_event) | |||
324 | ******************************************************************************/ | 324 | ******************************************************************************/ |
325 | acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status) | 325 | acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status) |
326 | { | 326 | { |
327 | acpi_status status = AE_OK; | 327 | acpi_status status; |
328 | u32 value; | 328 | acpi_event_status local_event_status = 0; |
329 | u32 in_byte; | ||
329 | 330 | ||
330 | ACPI_FUNCTION_TRACE(acpi_get_event_status); | 331 | ACPI_FUNCTION_TRACE(acpi_get_event_status); |
331 | 332 | ||
@@ -339,29 +340,40 @@ acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status) | |||
339 | return_ACPI_STATUS(AE_BAD_PARAMETER); | 340 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
340 | } | 341 | } |
341 | 342 | ||
342 | /* Get the status of the requested fixed event */ | 343 | /* Fixed event currently can be dispatched? */ |
344 | |||
345 | if (acpi_gbl_fixed_event_handlers[event].handler) { | ||
346 | local_event_status |= ACPI_EVENT_FLAG_HAS_HANDLER; | ||
347 | } | ||
348 | |||
349 | /* Fixed event currently enabled? */ | ||
343 | 350 | ||
344 | status = | 351 | status = |
345 | acpi_read_bit_register(acpi_gbl_fixed_event_info[event]. | 352 | acpi_read_bit_register(acpi_gbl_fixed_event_info[event]. |
346 | enable_register_id, &value); | 353 | enable_register_id, &in_byte); |
347 | if (ACPI_FAILURE(status)) | 354 | if (ACPI_FAILURE(status)) { |
348 | return_ACPI_STATUS(status); | 355 | return_ACPI_STATUS(status); |
356 | } | ||
349 | 357 | ||
350 | *event_status = value; | 358 | if (in_byte) { |
359 | local_event_status |= ACPI_EVENT_FLAG_ENABLED; | ||
360 | } | ||
361 | |||
362 | /* Fixed event currently active? */ | ||
351 | 363 | ||
352 | status = | 364 | status = |
353 | acpi_read_bit_register(acpi_gbl_fixed_event_info[event]. | 365 | acpi_read_bit_register(acpi_gbl_fixed_event_info[event]. |
354 | status_register_id, &value); | 366 | status_register_id, &in_byte); |
355 | if (ACPI_FAILURE(status)) | 367 | if (ACPI_FAILURE(status)) { |
356 | return_ACPI_STATUS(status); | 368 | return_ACPI_STATUS(status); |
369 | } | ||
357 | 370 | ||
358 | if (value) | 371 | if (in_byte) { |
359 | *event_status |= ACPI_EVENT_FLAG_SET; | 372 | local_event_status |= ACPI_EVENT_FLAG_SET; |
360 | 373 | } | |
361 | if (acpi_gbl_fixed_event_handlers[event].handler) | ||
362 | *event_status |= ACPI_EVENT_FLAG_HANDLE; | ||
363 | 374 | ||
364 | return_ACPI_STATUS(status); | 375 | (*event_status) = local_event_status; |
376 | return_ACPI_STATUS(AE_OK); | ||
365 | } | 377 | } |
366 | 378 | ||
367 | ACPI_EXPORT_SYMBOL(acpi_get_event_status) | 379 | ACPI_EXPORT_SYMBOL(acpi_get_event_status) |
diff --git a/drivers/acpi/acpica/evxfgpe.c b/drivers/acpi/acpica/evxfgpe.c index 56710a03c9b0..e889a5304abd 100644 --- a/drivers/acpi/acpica/evxfgpe.c +++ b/drivers/acpi/acpica/evxfgpe.c | |||
@@ -106,8 +106,8 @@ ACPI_EXPORT_SYMBOL(acpi_update_all_gpes) | |||
106 | * | 106 | * |
107 | * FUNCTION: acpi_enable_gpe | 107 | * FUNCTION: acpi_enable_gpe |
108 | * | 108 | * |
109 | * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1 | 109 | * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1 |
110 | * gpe_number - GPE level within the GPE block | 110 | * gpe_number - GPE level within the GPE block |
111 | * | 111 | * |
112 | * RETURN: Status | 112 | * RETURN: Status |
113 | * | 113 | * |
@@ -115,7 +115,6 @@ ACPI_EXPORT_SYMBOL(acpi_update_all_gpes) | |||
115 | * hardware-enabled. | 115 | * hardware-enabled. |
116 | * | 116 | * |
117 | ******************************************************************************/ | 117 | ******************************************************************************/ |
118 | |||
119 | acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number) | 118 | acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number) |
120 | { | 119 | { |
121 | acpi_status status = AE_BAD_PARAMETER; | 120 | acpi_status status = AE_BAD_PARAMETER; |
@@ -490,8 +489,8 @@ ACPI_EXPORT_SYMBOL(acpi_clear_gpe) | |||
490 | * | 489 | * |
491 | * FUNCTION: acpi_get_gpe_status | 490 | * FUNCTION: acpi_get_gpe_status |
492 | * | 491 | * |
493 | * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1 | 492 | * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1 |
494 | * gpe_number - GPE level within the GPE block | 493 | * gpe_number - GPE level within the GPE block |
495 | * event_status - Where the current status of the event | 494 | * event_status - Where the current status of the event |
496 | * will be returned | 495 | * will be returned |
497 | * | 496 | * |
@@ -524,9 +523,6 @@ acpi_get_gpe_status(acpi_handle gpe_device, | |||
524 | 523 | ||
525 | status = acpi_hw_get_gpe_status(gpe_event_info, event_status); | 524 | status = acpi_hw_get_gpe_status(gpe_event_info, event_status); |
526 | 525 | ||
527 | if (gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) | ||
528 | *event_status |= ACPI_EVENT_FLAG_HANDLE; | ||
529 | |||
530 | unlock_and_exit: | 526 | unlock_and_exit: |
531 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); | 527 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); |
532 | return_ACPI_STATUS(status); | 528 | return_ACPI_STATUS(status); |
diff --git a/drivers/acpi/acpica/hwgpe.c b/drivers/acpi/acpica/hwgpe.c index ea62d40fd161..48ac7b7b59cd 100644 --- a/drivers/acpi/acpica/hwgpe.c +++ b/drivers/acpi/acpica/hwgpe.c | |||
@@ -202,7 +202,7 @@ acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info * gpe_event_info) | |||
202 | 202 | ||
203 | acpi_status | 203 | acpi_status |
204 | acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info, | 204 | acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info, |
205 | acpi_event_status * event_status) | 205 | acpi_event_status *event_status) |
206 | { | 206 | { |
207 | u32 in_byte; | 207 | u32 in_byte; |
208 | u32 register_bit; | 208 | u32 register_bit; |
@@ -216,6 +216,13 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info, | |||
216 | return (AE_BAD_PARAMETER); | 216 | return (AE_BAD_PARAMETER); |
217 | } | 217 | } |
218 | 218 | ||
219 | /* GPE currently handled? */ | ||
220 | |||
221 | if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) != | ||
222 | ACPI_GPE_DISPATCH_NONE) { | ||
223 | local_event_status |= ACPI_EVENT_FLAG_HAS_HANDLER; | ||
224 | } | ||
225 | |||
219 | /* Get the info block for the entire GPE register */ | 226 | /* Get the info block for the entire GPE register */ |
220 | 227 | ||
221 | gpe_register_info = gpe_event_info->register_info; | 228 | gpe_register_info = gpe_event_info->register_info; |
diff --git a/drivers/acpi/acpica/tbxfroot.c b/drivers/acpi/acpica/tbxfroot.c index 65ab8fed3d5e..43a54af2b548 100644 --- a/drivers/acpi/acpica/tbxfroot.c +++ b/drivers/acpi/acpica/tbxfroot.c | |||
@@ -50,6 +50,36 @@ ACPI_MODULE_NAME("tbxfroot") | |||
50 | 50 | ||
51 | /******************************************************************************* | 51 | /******************************************************************************* |
52 | * | 52 | * |
53 | * FUNCTION: acpi_tb_get_rsdp_length | ||
54 | * | ||
55 | * PARAMETERS: rsdp - Pointer to RSDP | ||
56 | * | ||
57 | * RETURN: Table length | ||
58 | * | ||
59 | * DESCRIPTION: Get the length of the RSDP | ||
60 | * | ||
61 | ******************************************************************************/ | ||
62 | u32 acpi_tb_get_rsdp_length(struct acpi_table_rsdp *rsdp) | ||
63 | { | ||
64 | |||
65 | if (!ACPI_VALIDATE_RSDP_SIG(rsdp->signature)) { | ||
66 | |||
67 | /* BAD Signature */ | ||
68 | |||
69 | return (0); | ||
70 | } | ||
71 | |||
72 | /* "Length" field is available if table version >= 2 */ | ||
73 | |||
74 | if (rsdp->revision >= 2) { | ||
75 | return (rsdp->length); | ||
76 | } else { | ||
77 | return (ACPI_RSDP_CHECKSUM_LENGTH); | ||
78 | } | ||
79 | } | ||
80 | |||
81 | /******************************************************************************* | ||
82 | * | ||
53 | * FUNCTION: acpi_tb_validate_rsdp | 83 | * FUNCTION: acpi_tb_validate_rsdp |
54 | * | 84 | * |
55 | * PARAMETERS: rsdp - Pointer to unvalidated RSDP | 85 | * PARAMETERS: rsdp - Pointer to unvalidated RSDP |
@@ -59,7 +89,8 @@ ACPI_MODULE_NAME("tbxfroot") | |||
59 | * DESCRIPTION: Validate the RSDP (ptr) | 89 | * DESCRIPTION: Validate the RSDP (ptr) |
60 | * | 90 | * |
61 | ******************************************************************************/ | 91 | ******************************************************************************/ |
62 | acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp) | 92 | |
93 | acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp * rsdp) | ||
63 | { | 94 | { |
64 | 95 | ||
65 | /* | 96 | /* |
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index 7103de034c9e..143ec6ea1468 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c | |||
@@ -711,7 +711,7 @@ int acpi_pm_device_run_wake(struct device *phys_dev, bool enable) | |||
711 | return -ENODEV; | 711 | return -ENODEV; |
712 | } | 712 | } |
713 | 713 | ||
714 | return acpi_device_wakeup(adev, enable, ACPI_STATE_S0); | 714 | return acpi_device_wakeup(adev, ACPI_STATE_S0, enable); |
715 | } | 715 | } |
716 | EXPORT_SYMBOL(acpi_pm_device_run_wake); | 716 | EXPORT_SYMBOL(acpi_pm_device_run_wake); |
717 | #endif /* CONFIG_PM_RUNTIME */ | 717 | #endif /* CONFIG_PM_RUNTIME */ |
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index cb6066c809ea..3d304ff7f095 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -128,12 +128,13 @@ static int EC_FLAGS_SKIP_DSDT_SCAN; /* Not all BIOS survive early DSDT scan */ | |||
128 | static int EC_FLAGS_CLEAR_ON_RESUME; /* Needs acpi_ec_clear() on boot/resume */ | 128 | static int EC_FLAGS_CLEAR_ON_RESUME; /* Needs acpi_ec_clear() on boot/resume */ |
129 | 129 | ||
130 | /* -------------------------------------------------------------------------- | 130 | /* -------------------------------------------------------------------------- |
131 | Transaction Management | 131 | * Transaction Management |
132 | -------------------------------------------------------------------------- */ | 132 | * -------------------------------------------------------------------------- */ |
133 | 133 | ||
134 | static inline u8 acpi_ec_read_status(struct acpi_ec *ec) | 134 | static inline u8 acpi_ec_read_status(struct acpi_ec *ec) |
135 | { | 135 | { |
136 | u8 x = inb(ec->command_addr); | 136 | u8 x = inb(ec->command_addr); |
137 | |||
137 | pr_debug("EC_SC(R) = 0x%2.2x " | 138 | pr_debug("EC_SC(R) = 0x%2.2x " |
138 | "SCI_EVT=%d BURST=%d CMD=%d IBF=%d OBF=%d\n", | 139 | "SCI_EVT=%d BURST=%d CMD=%d IBF=%d OBF=%d\n", |
139 | x, | 140 | x, |
@@ -148,6 +149,7 @@ static inline u8 acpi_ec_read_status(struct acpi_ec *ec) | |||
148 | static inline u8 acpi_ec_read_data(struct acpi_ec *ec) | 149 | static inline u8 acpi_ec_read_data(struct acpi_ec *ec) |
149 | { | 150 | { |
150 | u8 x = inb(ec->data_addr); | 151 | u8 x = inb(ec->data_addr); |
152 | |||
151 | pr_debug("EC_DATA(R) = 0x%2.2x\n", x); | 153 | pr_debug("EC_DATA(R) = 0x%2.2x\n", x); |
152 | return x; | 154 | return x; |
153 | } | 155 | } |
@@ -164,10 +166,32 @@ static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data) | |||
164 | outb(data, ec->data_addr); | 166 | outb(data, ec->data_addr); |
165 | } | 167 | } |
166 | 168 | ||
169 | #ifdef DEBUG | ||
170 | static const char *acpi_ec_cmd_string(u8 cmd) | ||
171 | { | ||
172 | switch (cmd) { | ||
173 | case 0x80: | ||
174 | return "RD_EC"; | ||
175 | case 0x81: | ||
176 | return "WR_EC"; | ||
177 | case 0x82: | ||
178 | return "BE_EC"; | ||
179 | case 0x83: | ||
180 | return "BD_EC"; | ||
181 | case 0x84: | ||
182 | return "QR_EC"; | ||
183 | } | ||
184 | return "UNKNOWN"; | ||
185 | } | ||
186 | #else | ||
187 | #define acpi_ec_cmd_string(cmd) "UNDEF" | ||
188 | #endif | ||
189 | |||
167 | static int ec_transaction_completed(struct acpi_ec *ec) | 190 | static int ec_transaction_completed(struct acpi_ec *ec) |
168 | { | 191 | { |
169 | unsigned long flags; | 192 | unsigned long flags; |
170 | int ret = 0; | 193 | int ret = 0; |
194 | |||
171 | spin_lock_irqsave(&ec->lock, flags); | 195 | spin_lock_irqsave(&ec->lock, flags); |
172 | if (ec->curr && (ec->curr->flags & ACPI_EC_COMMAND_COMPLETE)) | 196 | if (ec->curr && (ec->curr->flags & ACPI_EC_COMMAND_COMPLETE)) |
173 | ret = 1; | 197 | ret = 1; |
@@ -181,7 +205,8 @@ static bool advance_transaction(struct acpi_ec *ec) | |||
181 | u8 status; | 205 | u8 status; |
182 | bool wakeup = false; | 206 | bool wakeup = false; |
183 | 207 | ||
184 | pr_debug("===== %s =====\n", in_interrupt() ? "IRQ" : "TASK"); | 208 | pr_debug("===== %s (%d) =====\n", |
209 | in_interrupt() ? "IRQ" : "TASK", smp_processor_id()); | ||
185 | status = acpi_ec_read_status(ec); | 210 | status = acpi_ec_read_status(ec); |
186 | t = ec->curr; | 211 | t = ec->curr; |
187 | if (!t) | 212 | if (!t) |
@@ -198,7 +223,8 @@ static bool advance_transaction(struct acpi_ec *ec) | |||
198 | if (t->rlen == t->ri) { | 223 | if (t->rlen == t->ri) { |
199 | t->flags |= ACPI_EC_COMMAND_COMPLETE; | 224 | t->flags |= ACPI_EC_COMMAND_COMPLETE; |
200 | if (t->command == ACPI_EC_COMMAND_QUERY) | 225 | if (t->command == ACPI_EC_COMMAND_QUERY) |
201 | pr_debug("hardware QR_EC completion\n"); | 226 | pr_debug("***** Command(%s) hardware completion *****\n", |
227 | acpi_ec_cmd_string(t->command)); | ||
202 | wakeup = true; | 228 | wakeup = true; |
203 | } | 229 | } |
204 | } else | 230 | } else |
@@ -221,7 +247,8 @@ static bool advance_transaction(struct acpi_ec *ec) | |||
221 | t->flags |= ACPI_EC_COMMAND_POLL; | 247 | t->flags |= ACPI_EC_COMMAND_POLL; |
222 | t->rdata[t->ri++] = 0x00; | 248 | t->rdata[t->ri++] = 0x00; |
223 | t->flags |= ACPI_EC_COMMAND_COMPLETE; | 249 | t->flags |= ACPI_EC_COMMAND_COMPLETE; |
224 | pr_debug("software QR_EC completion\n"); | 250 | pr_debug("***** Command(%s) software completion *****\n", |
251 | acpi_ec_cmd_string(t->command)); | ||
225 | wakeup = true; | 252 | wakeup = true; |
226 | } else if ((status & ACPI_EC_FLAG_IBF) == 0) { | 253 | } else if ((status & ACPI_EC_FLAG_IBF) == 0) { |
227 | acpi_ec_write_cmd(ec, t->command); | 254 | acpi_ec_write_cmd(ec, t->command); |
@@ -264,6 +291,7 @@ static int ec_poll(struct acpi_ec *ec) | |||
264 | { | 291 | { |
265 | unsigned long flags; | 292 | unsigned long flags; |
266 | int repeat = 5; /* number of command restarts */ | 293 | int repeat = 5; /* number of command restarts */ |
294 | |||
267 | while (repeat--) { | 295 | while (repeat--) { |
268 | unsigned long delay = jiffies + | 296 | unsigned long delay = jiffies + |
269 | msecs_to_jiffies(ec_delay); | 297 | msecs_to_jiffies(ec_delay); |
@@ -296,18 +324,25 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, | |||
296 | { | 324 | { |
297 | unsigned long tmp; | 325 | unsigned long tmp; |
298 | int ret = 0; | 326 | int ret = 0; |
327 | |||
299 | if (EC_FLAGS_MSI) | 328 | if (EC_FLAGS_MSI) |
300 | udelay(ACPI_EC_MSI_UDELAY); | 329 | udelay(ACPI_EC_MSI_UDELAY); |
301 | /* start transaction */ | 330 | /* start transaction */ |
302 | spin_lock_irqsave(&ec->lock, tmp); | 331 | spin_lock_irqsave(&ec->lock, tmp); |
303 | /* following two actions should be kept atomic */ | 332 | /* following two actions should be kept atomic */ |
304 | ec->curr = t; | 333 | ec->curr = t; |
334 | pr_debug("***** Command(%s) started *****\n", | ||
335 | acpi_ec_cmd_string(t->command)); | ||
305 | start_transaction(ec); | 336 | start_transaction(ec); |
306 | spin_unlock_irqrestore(&ec->lock, tmp); | 337 | spin_unlock_irqrestore(&ec->lock, tmp); |
307 | ret = ec_poll(ec); | 338 | ret = ec_poll(ec); |
308 | spin_lock_irqsave(&ec->lock, tmp); | 339 | spin_lock_irqsave(&ec->lock, tmp); |
309 | if (ec->curr->command == ACPI_EC_COMMAND_QUERY) | 340 | if (ec->curr->command == ACPI_EC_COMMAND_QUERY) { |
310 | clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); | 341 | clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); |
342 | pr_debug("***** Event stopped *****\n"); | ||
343 | } | ||
344 | pr_debug("***** Command(%s) stopped *****\n", | ||
345 | acpi_ec_cmd_string(t->command)); | ||
311 | ec->curr = NULL; | 346 | ec->curr = NULL; |
312 | spin_unlock_irqrestore(&ec->lock, tmp); | 347 | spin_unlock_irqrestore(&ec->lock, tmp); |
313 | return ret; | 348 | return ret; |
@@ -317,6 +352,7 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t) | |||
317 | { | 352 | { |
318 | int status; | 353 | int status; |
319 | u32 glk; | 354 | u32 glk; |
355 | |||
320 | if (!ec || (!t) || (t->wlen && !t->wdata) || (t->rlen && !t->rdata)) | 356 | if (!ec || (!t) || (t->wlen && !t->wdata) || (t->rlen && !t->rdata)) |
321 | return -EINVAL; | 357 | return -EINVAL; |
322 | if (t->rdata) | 358 | if (t->rdata) |
@@ -333,8 +369,6 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t) | |||
333 | goto unlock; | 369 | goto unlock; |
334 | } | 370 | } |
335 | } | 371 | } |
336 | pr_debug("transaction start (cmd=0x%02x, addr=0x%02x)\n", | ||
337 | t->command, t->wdata ? t->wdata[0] : 0); | ||
338 | /* disable GPE during transaction if storm is detected */ | 372 | /* disable GPE during transaction if storm is detected */ |
339 | if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) { | 373 | if (test_bit(EC_FLAGS_GPE_STORM, &ec->flags)) { |
340 | /* It has to be disabled, so that it doesn't trigger. */ | 374 | /* It has to be disabled, so that it doesn't trigger. */ |
@@ -355,7 +389,6 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t) | |||
355 | t->irq_count); | 389 | t->irq_count); |
356 | set_bit(EC_FLAGS_GPE_STORM, &ec->flags); | 390 | set_bit(EC_FLAGS_GPE_STORM, &ec->flags); |
357 | } | 391 | } |
358 | pr_debug("transaction end\n"); | ||
359 | if (ec->global_lock) | 392 | if (ec->global_lock) |
360 | acpi_release_global_lock(glk); | 393 | acpi_release_global_lock(glk); |
361 | unlock: | 394 | unlock: |
@@ -383,7 +416,7 @@ static int acpi_ec_burst_disable(struct acpi_ec *ec) | |||
383 | acpi_ec_transaction(ec, &t) : 0; | 416 | acpi_ec_transaction(ec, &t) : 0; |
384 | } | 417 | } |
385 | 418 | ||
386 | static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 * data) | 419 | static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 *data) |
387 | { | 420 | { |
388 | int result; | 421 | int result; |
389 | u8 d; | 422 | u8 d; |
@@ -419,10 +452,9 @@ int ec_read(u8 addr, u8 *val) | |||
419 | if (!err) { | 452 | if (!err) { |
420 | *val = temp_data; | 453 | *val = temp_data; |
421 | return 0; | 454 | return 0; |
422 | } else | 455 | } |
423 | return err; | 456 | return err; |
424 | } | 457 | } |
425 | |||
426 | EXPORT_SYMBOL(ec_read); | 458 | EXPORT_SYMBOL(ec_read); |
427 | 459 | ||
428 | int ec_write(u8 addr, u8 val) | 460 | int ec_write(u8 addr, u8 val) |
@@ -436,22 +468,21 @@ int ec_write(u8 addr, u8 val) | |||
436 | 468 | ||
437 | return err; | 469 | return err; |
438 | } | 470 | } |
439 | |||
440 | EXPORT_SYMBOL(ec_write); | 471 | EXPORT_SYMBOL(ec_write); |
441 | 472 | ||
442 | int ec_transaction(u8 command, | 473 | int ec_transaction(u8 command, |
443 | const u8 * wdata, unsigned wdata_len, | 474 | const u8 *wdata, unsigned wdata_len, |
444 | u8 * rdata, unsigned rdata_len) | 475 | u8 *rdata, unsigned rdata_len) |
445 | { | 476 | { |
446 | struct transaction t = {.command = command, | 477 | struct transaction t = {.command = command, |
447 | .wdata = wdata, .rdata = rdata, | 478 | .wdata = wdata, .rdata = rdata, |
448 | .wlen = wdata_len, .rlen = rdata_len}; | 479 | .wlen = wdata_len, .rlen = rdata_len}; |
480 | |||
449 | if (!first_ec) | 481 | if (!first_ec) |
450 | return -ENODEV; | 482 | return -ENODEV; |
451 | 483 | ||
452 | return acpi_ec_transaction(first_ec, &t); | 484 | return acpi_ec_transaction(first_ec, &t); |
453 | } | 485 | } |
454 | |||
455 | EXPORT_SYMBOL(ec_transaction); | 486 | EXPORT_SYMBOL(ec_transaction); |
456 | 487 | ||
457 | /* Get the handle to the EC device */ | 488 | /* Get the handle to the EC device */ |
@@ -461,7 +492,6 @@ acpi_handle ec_get_handle(void) | |||
461 | return NULL; | 492 | return NULL; |
462 | return first_ec->handle; | 493 | return first_ec->handle; |
463 | } | 494 | } |
464 | |||
465 | EXPORT_SYMBOL(ec_get_handle); | 495 | EXPORT_SYMBOL(ec_get_handle); |
466 | 496 | ||
467 | /* | 497 | /* |
@@ -525,13 +555,14 @@ void acpi_ec_unblock_transactions_early(void) | |||
525 | clear_bit(EC_FLAGS_BLOCKED, &first_ec->flags); | 555 | clear_bit(EC_FLAGS_BLOCKED, &first_ec->flags); |
526 | } | 556 | } |
527 | 557 | ||
528 | static int acpi_ec_query_unlocked(struct acpi_ec *ec, u8 * data) | 558 | static int acpi_ec_query_unlocked(struct acpi_ec *ec, u8 *data) |
529 | { | 559 | { |
530 | int result; | 560 | int result; |
531 | u8 d; | 561 | u8 d; |
532 | struct transaction t = {.command = ACPI_EC_COMMAND_QUERY, | 562 | struct transaction t = {.command = ACPI_EC_COMMAND_QUERY, |
533 | .wdata = NULL, .rdata = &d, | 563 | .wdata = NULL, .rdata = &d, |
534 | .wlen = 0, .rlen = 1}; | 564 | .wlen = 0, .rlen = 1}; |
565 | |||
535 | if (!ec || !data) | 566 | if (!ec || !data) |
536 | return -EINVAL; | 567 | return -EINVAL; |
537 | /* | 568 | /* |
@@ -557,6 +588,7 @@ int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit, | |||
557 | { | 588 | { |
558 | struct acpi_ec_query_handler *handler = | 589 | struct acpi_ec_query_handler *handler = |
559 | kzalloc(sizeof(struct acpi_ec_query_handler), GFP_KERNEL); | 590 | kzalloc(sizeof(struct acpi_ec_query_handler), GFP_KERNEL); |
591 | |||
560 | if (!handler) | 592 | if (!handler) |
561 | return -ENOMEM; | 593 | return -ENOMEM; |
562 | 594 | ||
@@ -569,12 +601,12 @@ int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit, | |||
569 | mutex_unlock(&ec->mutex); | 601 | mutex_unlock(&ec->mutex); |
570 | return 0; | 602 | return 0; |
571 | } | 603 | } |
572 | |||
573 | EXPORT_SYMBOL_GPL(acpi_ec_add_query_handler); | 604 | EXPORT_SYMBOL_GPL(acpi_ec_add_query_handler); |
574 | 605 | ||
575 | void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit) | 606 | void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit) |
576 | { | 607 | { |
577 | struct acpi_ec_query_handler *handler, *tmp; | 608 | struct acpi_ec_query_handler *handler, *tmp; |
609 | |||
578 | mutex_lock(&ec->mutex); | 610 | mutex_lock(&ec->mutex); |
579 | list_for_each_entry_safe(handler, tmp, &ec->list, node) { | 611 | list_for_each_entry_safe(handler, tmp, &ec->list, node) { |
580 | if (query_bit == handler->query_bit) { | 612 | if (query_bit == handler->query_bit) { |
@@ -584,20 +616,20 @@ void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit) | |||
584 | } | 616 | } |
585 | mutex_unlock(&ec->mutex); | 617 | mutex_unlock(&ec->mutex); |
586 | } | 618 | } |
587 | |||
588 | EXPORT_SYMBOL_GPL(acpi_ec_remove_query_handler); | 619 | EXPORT_SYMBOL_GPL(acpi_ec_remove_query_handler); |
589 | 620 | ||
590 | static void acpi_ec_run(void *cxt) | 621 | static void acpi_ec_run(void *cxt) |
591 | { | 622 | { |
592 | struct acpi_ec_query_handler *handler = cxt; | 623 | struct acpi_ec_query_handler *handler = cxt; |
624 | |||
593 | if (!handler) | 625 | if (!handler) |
594 | return; | 626 | return; |
595 | pr_debug("start query execution\n"); | 627 | pr_debug("##### Query(0x%02x) started #####\n", handler->query_bit); |
596 | if (handler->func) | 628 | if (handler->func) |
597 | handler->func(handler->data); | 629 | handler->func(handler->data); |
598 | else if (handler->handle) | 630 | else if (handler->handle) |
599 | acpi_evaluate_object(handler->handle, NULL, NULL, NULL); | 631 | acpi_evaluate_object(handler->handle, NULL, NULL, NULL); |
600 | pr_debug("stop query execution\n"); | 632 | pr_debug("##### Query(0x%02x) stopped #####\n", handler->query_bit); |
601 | kfree(handler); | 633 | kfree(handler); |
602 | } | 634 | } |
603 | 635 | ||
@@ -620,8 +652,8 @@ static int acpi_ec_sync_query(struct acpi_ec *ec, u8 *data) | |||
620 | if (!copy) | 652 | if (!copy) |
621 | return -ENOMEM; | 653 | return -ENOMEM; |
622 | memcpy(copy, handler, sizeof(*copy)); | 654 | memcpy(copy, handler, sizeof(*copy)); |
623 | pr_debug("push query execution (0x%2x) on queue\n", | 655 | pr_debug("##### Query(0x%02x) scheduled #####\n", |
624 | value); | 656 | handler->query_bit); |
625 | return acpi_os_execute((copy->func) ? | 657 | return acpi_os_execute((copy->func) ? |
626 | OSL_NOTIFY_HANDLER : OSL_GPE_HANDLER, | 658 | OSL_NOTIFY_HANDLER : OSL_GPE_HANDLER, |
627 | acpi_ec_run, copy); | 659 | acpi_ec_run, copy); |
@@ -633,6 +665,7 @@ static int acpi_ec_sync_query(struct acpi_ec *ec, u8 *data) | |||
633 | static void acpi_ec_gpe_query(void *ec_cxt) | 665 | static void acpi_ec_gpe_query(void *ec_cxt) |
634 | { | 666 | { |
635 | struct acpi_ec *ec = ec_cxt; | 667 | struct acpi_ec *ec = ec_cxt; |
668 | |||
636 | if (!ec) | 669 | if (!ec) |
637 | return; | 670 | return; |
638 | mutex_lock(&ec->mutex); | 671 | mutex_lock(&ec->mutex); |
@@ -644,7 +677,7 @@ static int ec_check_sci(struct acpi_ec *ec, u8 state) | |||
644 | { | 677 | { |
645 | if (state & ACPI_EC_FLAG_SCI) { | 678 | if (state & ACPI_EC_FLAG_SCI) { |
646 | if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) { | 679 | if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) { |
647 | pr_debug("push gpe query to the queue\n"); | 680 | pr_debug("***** Event started *****\n"); |
648 | return acpi_os_execute(OSL_NOTIFY_HANDLER, | 681 | return acpi_os_execute(OSL_NOTIFY_HANDLER, |
649 | acpi_ec_gpe_query, ec); | 682 | acpi_ec_gpe_query, ec); |
650 | } | 683 | } |
@@ -667,8 +700,8 @@ static u32 acpi_ec_gpe_handler(acpi_handle gpe_device, | |||
667 | } | 700 | } |
668 | 701 | ||
669 | /* -------------------------------------------------------------------------- | 702 | /* -------------------------------------------------------------------------- |
670 | Address Space Management | 703 | * Address Space Management |
671 | -------------------------------------------------------------------------- */ | 704 | * -------------------------------------------------------------------------- */ |
672 | 705 | ||
673 | static acpi_status | 706 | static acpi_status |
674 | acpi_ec_space_handler(u32 function, acpi_physical_address address, | 707 | acpi_ec_space_handler(u32 function, acpi_physical_address address, |
@@ -699,27 +732,26 @@ acpi_ec_space_handler(u32 function, acpi_physical_address address, | |||
699 | switch (result) { | 732 | switch (result) { |
700 | case -EINVAL: | 733 | case -EINVAL: |
701 | return AE_BAD_PARAMETER; | 734 | return AE_BAD_PARAMETER; |
702 | break; | ||
703 | case -ENODEV: | 735 | case -ENODEV: |
704 | return AE_NOT_FOUND; | 736 | return AE_NOT_FOUND; |
705 | break; | ||
706 | case -ETIME: | 737 | case -ETIME: |
707 | return AE_TIME; | 738 | return AE_TIME; |
708 | break; | ||
709 | default: | 739 | default: |
710 | return AE_OK; | 740 | return AE_OK; |
711 | } | 741 | } |
712 | } | 742 | } |
713 | 743 | ||
714 | /* -------------------------------------------------------------------------- | 744 | /* -------------------------------------------------------------------------- |
715 | Driver Interface | 745 | * Driver Interface |
716 | -------------------------------------------------------------------------- */ | 746 | * -------------------------------------------------------------------------- */ |
747 | |||
717 | static acpi_status | 748 | static acpi_status |
718 | ec_parse_io_ports(struct acpi_resource *resource, void *context); | 749 | ec_parse_io_ports(struct acpi_resource *resource, void *context); |
719 | 750 | ||
720 | static struct acpi_ec *make_acpi_ec(void) | 751 | static struct acpi_ec *make_acpi_ec(void) |
721 | { | 752 | { |
722 | struct acpi_ec *ec = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL); | 753 | struct acpi_ec *ec = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL); |
754 | |||
723 | if (!ec) | 755 | if (!ec) |
724 | return NULL; | 756 | return NULL; |
725 | ec->flags = 1 << EC_FLAGS_QUERY_PENDING; | 757 | ec->flags = 1 << EC_FLAGS_QUERY_PENDING; |
@@ -742,9 +774,8 @@ acpi_ec_register_query_methods(acpi_handle handle, u32 level, | |||
742 | 774 | ||
743 | status = acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer); | 775 | status = acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer); |
744 | 776 | ||
745 | if (ACPI_SUCCESS(status) && sscanf(node_name, "_Q%x", &value) == 1) { | 777 | if (ACPI_SUCCESS(status) && sscanf(node_name, "_Q%x", &value) == 1) |
746 | acpi_ec_add_query_handler(ec, value, handle, NULL, NULL); | 778 | acpi_ec_add_query_handler(ec, value, handle, NULL, NULL); |
747 | } | ||
748 | return AE_OK; | 779 | return AE_OK; |
749 | } | 780 | } |
750 | 781 | ||
@@ -753,7 +784,6 @@ ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval) | |||
753 | { | 784 | { |
754 | acpi_status status; | 785 | acpi_status status; |
755 | unsigned long long tmp = 0; | 786 | unsigned long long tmp = 0; |
756 | |||
757 | struct acpi_ec *ec = context; | 787 | struct acpi_ec *ec = context; |
758 | 788 | ||
759 | /* clear addr values, ec_parse_io_ports depend on it */ | 789 | /* clear addr values, ec_parse_io_ports depend on it */ |
@@ -781,6 +811,7 @@ ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval) | |||
781 | static int ec_install_handlers(struct acpi_ec *ec) | 811 | static int ec_install_handlers(struct acpi_ec *ec) |
782 | { | 812 | { |
783 | acpi_status status; | 813 | acpi_status status; |
814 | |||
784 | if (test_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags)) | 815 | if (test_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags)) |
785 | return 0; | 816 | return 0; |
786 | status = acpi_install_gpe_handler(NULL, ec->gpe, | 817 | status = acpi_install_gpe_handler(NULL, ec->gpe, |
@@ -1078,7 +1109,8 @@ int __init acpi_ec_ecdt_probe(void) | |||
1078 | boot_ec->data_addr = ecdt_ptr->data.address; | 1109 | boot_ec->data_addr = ecdt_ptr->data.address; |
1079 | boot_ec->gpe = ecdt_ptr->gpe; | 1110 | boot_ec->gpe = ecdt_ptr->gpe; |
1080 | boot_ec->handle = ACPI_ROOT_OBJECT; | 1111 | boot_ec->handle = ACPI_ROOT_OBJECT; |
1081 | acpi_get_handle(ACPI_ROOT_OBJECT, ecdt_ptr->id, &boot_ec->handle); | 1112 | acpi_get_handle(ACPI_ROOT_OBJECT, ecdt_ptr->id, |
1113 | &boot_ec->handle); | ||
1082 | /* Don't trust ECDT, which comes from ASUSTek */ | 1114 | /* Don't trust ECDT, which comes from ASUSTek */ |
1083 | if (!EC_FLAGS_VALIDATE_ECDT) | 1115 | if (!EC_FLAGS_VALIDATE_ECDT) |
1084 | goto install; | 1116 | goto install; |
@@ -1162,6 +1194,5 @@ static void __exit acpi_ec_exit(void) | |||
1162 | { | 1194 | { |
1163 | 1195 | ||
1164 | acpi_bus_unregister_driver(&acpi_ec_driver); | 1196 | acpi_bus_unregister_driver(&acpi_ec_driver); |
1165 | return; | ||
1166 | } | 1197 | } |
1167 | #endif /* 0 */ | 1198 | #endif /* 0 */ |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 095c6ddde8a3..d670158a26c5 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -1470,7 +1470,7 @@ static void acpi_wakeup_gpe_init(struct acpi_device *device) | |||
1470 | if (ACPI_FAILURE(status)) | 1470 | if (ACPI_FAILURE(status)) |
1471 | return; | 1471 | return; |
1472 | 1472 | ||
1473 | wakeup->flags.run_wake = !!(event_status & ACPI_EVENT_FLAG_HANDLE); | 1473 | wakeup->flags.run_wake = !!(event_status & ACPI_EVENT_FLAG_HAS_HANDLER); |
1474 | } | 1474 | } |
1475 | 1475 | ||
1476 | static void acpi_bus_get_wakeup_device_flags(struct acpi_device *device) | 1476 | static void acpi_bus_get_wakeup_device_flags(struct acpi_device *device) |
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c index 38cb9782d4b8..13e577c80201 100644 --- a/drivers/acpi/sysfs.c +++ b/drivers/acpi/sysfs.c | |||
@@ -537,7 +537,7 @@ static ssize_t counter_show(struct kobject *kobj, | |||
537 | if (result) | 537 | if (result) |
538 | goto end; | 538 | goto end; |
539 | 539 | ||
540 | if (!(status & ACPI_EVENT_FLAG_HANDLE)) | 540 | if (!(status & ACPI_EVENT_FLAG_HAS_HANDLER)) |
541 | size += sprintf(buf + size, " invalid"); | 541 | size += sprintf(buf + size, " invalid"); |
542 | else if (status & ACPI_EVENT_FLAG_ENABLED) | 542 | else if (status & ACPI_EVENT_FLAG_ENABLED) |
543 | size += sprintf(buf + size, " enabled"); | 543 | size += sprintf(buf + size, " enabled"); |
@@ -581,7 +581,7 @@ static ssize_t counter_set(struct kobject *kobj, | |||
581 | if (result) | 581 | if (result) |
582 | goto end; | 582 | goto end; |
583 | 583 | ||
584 | if (!(status & ACPI_EVENT_FLAG_HANDLE)) { | 584 | if (!(status & ACPI_EVENT_FLAG_HAS_HANDLER)) { |
585 | printk(KERN_WARNING PREFIX | 585 | printk(KERN_WARNING PREFIX |
586 | "Can not change Invalid GPE/Fixed Event status\n"); | 586 | "Can not change Invalid GPE/Fixed Event status\n"); |
587 | return -EINVAL; | 587 | return -EINVAL; |
diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c index 6bbb8b913446..92c162af5045 100644 --- a/drivers/cpufreq/cpufreq-dt.c +++ b/drivers/cpufreq/cpufreq-dt.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/cpu.h> | 18 | #include <linux/cpu.h> |
19 | #include <linux/cpu_cooling.h> | 19 | #include <linux/cpu_cooling.h> |
20 | #include <linux/cpufreq.h> | 20 | #include <linux/cpufreq.h> |
21 | #include <linux/cpufreq-dt.h> | ||
21 | #include <linux/cpumask.h> | 22 | #include <linux/cpumask.h> |
22 | #include <linux/err.h> | 23 | #include <linux/err.h> |
23 | #include <linux/module.h> | 24 | #include <linux/module.h> |
@@ -146,8 +147,8 @@ try_again: | |||
146 | goto try_again; | 147 | goto try_again; |
147 | } | 148 | } |
148 | 149 | ||
149 | dev_warn(cpu_dev, "failed to get cpu%d regulator: %ld\n", | 150 | dev_dbg(cpu_dev, "no regulator for cpu%d: %ld\n", |
150 | cpu, PTR_ERR(cpu_reg)); | 151 | cpu, PTR_ERR(cpu_reg)); |
151 | } | 152 | } |
152 | 153 | ||
153 | cpu_clk = clk_get(cpu_dev, NULL); | 154 | cpu_clk = clk_get(cpu_dev, NULL); |
@@ -178,6 +179,7 @@ try_again: | |||
178 | 179 | ||
179 | static int cpufreq_init(struct cpufreq_policy *policy) | 180 | static int cpufreq_init(struct cpufreq_policy *policy) |
180 | { | 181 | { |
182 | struct cpufreq_dt_platform_data *pd; | ||
181 | struct cpufreq_frequency_table *freq_table; | 183 | struct cpufreq_frequency_table *freq_table; |
182 | struct thermal_cooling_device *cdev; | 184 | struct thermal_cooling_device *cdev; |
183 | struct device_node *np; | 185 | struct device_node *np; |
@@ -265,9 +267,18 @@ static int cpufreq_init(struct cpufreq_policy *policy) | |||
265 | policy->driver_data = priv; | 267 | policy->driver_data = priv; |
266 | 268 | ||
267 | policy->clk = cpu_clk; | 269 | policy->clk = cpu_clk; |
268 | ret = cpufreq_generic_init(policy, freq_table, transition_latency); | 270 | ret = cpufreq_table_validate_and_show(policy, freq_table); |
269 | if (ret) | 271 | if (ret) { |
272 | dev_err(cpu_dev, "%s: invalid frequency table: %d\n", __func__, | ||
273 | ret); | ||
270 | goto out_cooling_unregister; | 274 | goto out_cooling_unregister; |
275 | } | ||
276 | |||
277 | policy->cpuinfo.transition_latency = transition_latency; | ||
278 | |||
279 | pd = cpufreq_get_driver_data(); | ||
280 | if (pd && !pd->independent_clocks) | ||
281 | cpumask_setall(policy->cpus); | ||
271 | 282 | ||
272 | of_node_put(np); | 283 | of_node_put(np); |
273 | 284 | ||
@@ -335,6 +346,8 @@ static int dt_cpufreq_probe(struct platform_device *pdev) | |||
335 | if (!IS_ERR(cpu_reg)) | 346 | if (!IS_ERR(cpu_reg)) |
336 | regulator_put(cpu_reg); | 347 | regulator_put(cpu_reg); |
337 | 348 | ||
349 | dt_cpufreq_driver.driver_data = dev_get_platdata(&pdev->dev); | ||
350 | |||
338 | ret = cpufreq_register_driver(&dt_cpufreq_driver); | 351 | ret = cpufreq_register_driver(&dt_cpufreq_driver); |
339 | if (ret) | 352 | if (ret) |
340 | dev_err(cpu_dev, "failed register driver: %d\n", ret); | 353 | dev_err(cpu_dev, "failed register driver: %d\n", ret); |
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 24bf76fba141..644b54e1e7d1 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -512,7 +512,18 @@ show_one(cpuinfo_max_freq, cpuinfo.max_freq); | |||
512 | show_one(cpuinfo_transition_latency, cpuinfo.transition_latency); | 512 | show_one(cpuinfo_transition_latency, cpuinfo.transition_latency); |
513 | show_one(scaling_min_freq, min); | 513 | show_one(scaling_min_freq, min); |
514 | show_one(scaling_max_freq, max); | 514 | show_one(scaling_max_freq, max); |
515 | show_one(scaling_cur_freq, cur); | 515 | |
516 | static ssize_t show_scaling_cur_freq( | ||
517 | struct cpufreq_policy *policy, char *buf) | ||
518 | { | ||
519 | ssize_t ret; | ||
520 | |||
521 | if (cpufreq_driver && cpufreq_driver->setpolicy && cpufreq_driver->get) | ||
522 | ret = sprintf(buf, "%u\n", cpufreq_driver->get(policy->cpu)); | ||
523 | else | ||
524 | ret = sprintf(buf, "%u\n", policy->cur); | ||
525 | return ret; | ||
526 | } | ||
516 | 527 | ||
517 | static int cpufreq_set_policy(struct cpufreq_policy *policy, | 528 | static int cpufreq_set_policy(struct cpufreq_policy *policy, |
518 | struct cpufreq_policy *new_policy); | 529 | struct cpufreq_policy *new_policy); |
@@ -906,11 +917,11 @@ static int cpufreq_add_dev_interface(struct cpufreq_policy *policy, | |||
906 | if (ret) | 917 | if (ret) |
907 | goto err_out_kobj_put; | 918 | goto err_out_kobj_put; |
908 | } | 919 | } |
909 | if (has_target()) { | 920 | |
910 | ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr); | 921 | ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr); |
911 | if (ret) | 922 | if (ret) |
912 | goto err_out_kobj_put; | 923 | goto err_out_kobj_put; |
913 | } | 924 | |
914 | if (cpufreq_driver->bios_limit) { | 925 | if (cpufreq_driver->bios_limit) { |
915 | ret = sysfs_create_file(&policy->kobj, &bios_limit.attr); | 926 | ret = sysfs_create_file(&policy->kobj, &bios_limit.attr); |
916 | if (ret) | 927 | if (ret) |
@@ -1731,6 +1742,21 @@ const char *cpufreq_get_current_driver(void) | |||
1731 | } | 1742 | } |
1732 | EXPORT_SYMBOL_GPL(cpufreq_get_current_driver); | 1743 | EXPORT_SYMBOL_GPL(cpufreq_get_current_driver); |
1733 | 1744 | ||
1745 | /** | ||
1746 | * cpufreq_get_driver_data - return current driver data | ||
1747 | * | ||
1748 | * Return the private data of the currently loaded cpufreq | ||
1749 | * driver, or NULL if no cpufreq driver is loaded. | ||
1750 | */ | ||
1751 | void *cpufreq_get_driver_data(void) | ||
1752 | { | ||
1753 | if (cpufreq_driver) | ||
1754 | return cpufreq_driver->driver_data; | ||
1755 | |||
1756 | return NULL; | ||
1757 | } | ||
1758 | EXPORT_SYMBOL_GPL(cpufreq_get_driver_data); | ||
1759 | |||
1734 | /********************************************************************* | 1760 | /********************************************************************* |
1735 | * NOTIFIER LISTS INTERFACE * | 1761 | * NOTIFIER LISTS INTERFACE * |
1736 | *********************************************************************/ | 1762 | *********************************************************************/ |
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 0668b389c516..27bb6d3877ed 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
@@ -52,6 +52,17 @@ static inline int32_t div_fp(int32_t x, int32_t y) | |||
52 | return div_s64((int64_t)x << FRAC_BITS, y); | 52 | return div_s64((int64_t)x << FRAC_BITS, y); |
53 | } | 53 | } |
54 | 54 | ||
55 | static inline int ceiling_fp(int32_t x) | ||
56 | { | ||
57 | int mask, ret; | ||
58 | |||
59 | ret = fp_toint(x); | ||
60 | mask = (1 << FRAC_BITS) - 1; | ||
61 | if (x & mask) | ||
62 | ret += 1; | ||
63 | return ret; | ||
64 | } | ||
65 | |||
55 | struct sample { | 66 | struct sample { |
56 | int32_t core_pct_busy; | 67 | int32_t core_pct_busy; |
57 | u64 aperf; | 68 | u64 aperf; |
@@ -64,6 +75,7 @@ struct pstate_data { | |||
64 | int current_pstate; | 75 | int current_pstate; |
65 | int min_pstate; | 76 | int min_pstate; |
66 | int max_pstate; | 77 | int max_pstate; |
78 | int scaling; | ||
67 | int turbo_pstate; | 79 | int turbo_pstate; |
68 | }; | 80 | }; |
69 | 81 | ||
@@ -113,6 +125,7 @@ struct pstate_funcs { | |||
113 | int (*get_max)(void); | 125 | int (*get_max)(void); |
114 | int (*get_min)(void); | 126 | int (*get_min)(void); |
115 | int (*get_turbo)(void); | 127 | int (*get_turbo)(void); |
128 | int (*get_scaling)(void); | ||
116 | void (*set)(struct cpudata*, int pstate); | 129 | void (*set)(struct cpudata*, int pstate); |
117 | void (*get_vid)(struct cpudata *); | 130 | void (*get_vid)(struct cpudata *); |
118 | }; | 131 | }; |
@@ -138,6 +151,7 @@ struct perf_limits { | |||
138 | 151 | ||
139 | static struct perf_limits limits = { | 152 | static struct perf_limits limits = { |
140 | .no_turbo = 0, | 153 | .no_turbo = 0, |
154 | .turbo_disabled = 0, | ||
141 | .max_perf_pct = 100, | 155 | .max_perf_pct = 100, |
142 | .max_perf = int_tofp(1), | 156 | .max_perf = int_tofp(1), |
143 | .min_perf_pct = 0, | 157 | .min_perf_pct = 0, |
@@ -218,6 +232,18 @@ static inline void intel_pstate_reset_all_pid(void) | |||
218 | } | 232 | } |
219 | } | 233 | } |
220 | 234 | ||
235 | static inline void update_turbo_state(void) | ||
236 | { | ||
237 | u64 misc_en; | ||
238 | struct cpudata *cpu; | ||
239 | |||
240 | cpu = all_cpu_data[0]; | ||
241 | rdmsrl(MSR_IA32_MISC_ENABLE, misc_en); | ||
242 | limits.turbo_disabled = | ||
243 | (misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE || | ||
244 | cpu->pstate.max_pstate == cpu->pstate.turbo_pstate); | ||
245 | } | ||
246 | |||
221 | /************************** debugfs begin ************************/ | 247 | /************************** debugfs begin ************************/ |
222 | static int pid_param_set(void *data, u64 val) | 248 | static int pid_param_set(void *data, u64 val) |
223 | { | 249 | { |
@@ -274,6 +300,20 @@ static void __init intel_pstate_debug_expose_params(void) | |||
274 | return sprintf(buf, "%u\n", limits.object); \ | 300 | return sprintf(buf, "%u\n", limits.object); \ |
275 | } | 301 | } |
276 | 302 | ||
303 | static ssize_t show_no_turbo(struct kobject *kobj, | ||
304 | struct attribute *attr, char *buf) | ||
305 | { | ||
306 | ssize_t ret; | ||
307 | |||
308 | update_turbo_state(); | ||
309 | if (limits.turbo_disabled) | ||
310 | ret = sprintf(buf, "%u\n", limits.turbo_disabled); | ||
311 | else | ||
312 | ret = sprintf(buf, "%u\n", limits.no_turbo); | ||
313 | |||
314 | return ret; | ||
315 | } | ||
316 | |||
277 | static ssize_t store_no_turbo(struct kobject *a, struct attribute *b, | 317 | static ssize_t store_no_turbo(struct kobject *a, struct attribute *b, |
278 | const char *buf, size_t count) | 318 | const char *buf, size_t count) |
279 | { | 319 | { |
@@ -283,11 +323,14 @@ static ssize_t store_no_turbo(struct kobject *a, struct attribute *b, | |||
283 | ret = sscanf(buf, "%u", &input); | 323 | ret = sscanf(buf, "%u", &input); |
284 | if (ret != 1) | 324 | if (ret != 1) |
285 | return -EINVAL; | 325 | return -EINVAL; |
286 | limits.no_turbo = clamp_t(int, input, 0 , 1); | 326 | |
327 | update_turbo_state(); | ||
287 | if (limits.turbo_disabled) { | 328 | if (limits.turbo_disabled) { |
288 | pr_warn("Turbo disabled by BIOS or unavailable on processor\n"); | 329 | pr_warn("Turbo disabled by BIOS or unavailable on processor\n"); |
289 | limits.no_turbo = limits.turbo_disabled; | 330 | return -EPERM; |
290 | } | 331 | } |
332 | limits.no_turbo = clamp_t(int, input, 0, 1); | ||
333 | |||
291 | return count; | 334 | return count; |
292 | } | 335 | } |
293 | 336 | ||
@@ -323,7 +366,6 @@ static ssize_t store_min_perf_pct(struct kobject *a, struct attribute *b, | |||
323 | return count; | 366 | return count; |
324 | } | 367 | } |
325 | 368 | ||
326 | show_one(no_turbo, no_turbo); | ||
327 | show_one(max_perf_pct, max_perf_pct); | 369 | show_one(max_perf_pct, max_perf_pct); |
328 | show_one(min_perf_pct, min_perf_pct); | 370 | show_one(min_perf_pct, min_perf_pct); |
329 | 371 | ||
@@ -394,7 +436,7 @@ static void byt_set_pstate(struct cpudata *cpudata, int pstate) | |||
394 | cpudata->vid.ratio); | 436 | cpudata->vid.ratio); |
395 | 437 | ||
396 | vid_fp = clamp_t(int32_t, vid_fp, cpudata->vid.min, cpudata->vid.max); | 438 | vid_fp = clamp_t(int32_t, vid_fp, cpudata->vid.min, cpudata->vid.max); |
397 | vid = fp_toint(vid_fp); | 439 | vid = ceiling_fp(vid_fp); |
398 | 440 | ||
399 | if (pstate > cpudata->pstate.max_pstate) | 441 | if (pstate > cpudata->pstate.max_pstate) |
400 | vid = cpudata->vid.turbo; | 442 | vid = cpudata->vid.turbo; |
@@ -404,6 +446,22 @@ static void byt_set_pstate(struct cpudata *cpudata, int pstate) | |||
404 | wrmsrl(MSR_IA32_PERF_CTL, val); | 446 | wrmsrl(MSR_IA32_PERF_CTL, val); |
405 | } | 447 | } |
406 | 448 | ||
449 | #define BYT_BCLK_FREQS 5 | ||
450 | static int byt_freq_table[BYT_BCLK_FREQS] = { 833, 1000, 1333, 1167, 800}; | ||
451 | |||
452 | static int byt_get_scaling(void) | ||
453 | { | ||
454 | u64 value; | ||
455 | int i; | ||
456 | |||
457 | rdmsrl(MSR_FSB_FREQ, value); | ||
458 | i = value & 0x3; | ||
459 | |||
460 | BUG_ON(i > BYT_BCLK_FREQS); | ||
461 | |||
462 | return byt_freq_table[i] * 100; | ||
463 | } | ||
464 | |||
407 | static void byt_get_vid(struct cpudata *cpudata) | 465 | static void byt_get_vid(struct cpudata *cpudata) |
408 | { | 466 | { |
409 | u64 value; | 467 | u64 value; |
@@ -449,6 +507,11 @@ static int core_get_turbo_pstate(void) | |||
449 | return ret; | 507 | return ret; |
450 | } | 508 | } |
451 | 509 | ||
510 | static inline int core_get_scaling(void) | ||
511 | { | ||
512 | return 100000; | ||
513 | } | ||
514 | |||
452 | static void core_set_pstate(struct cpudata *cpudata, int pstate) | 515 | static void core_set_pstate(struct cpudata *cpudata, int pstate) |
453 | { | 516 | { |
454 | u64 val; | 517 | u64 val; |
@@ -473,6 +536,7 @@ static struct cpu_defaults core_params = { | |||
473 | .get_max = core_get_max_pstate, | 536 | .get_max = core_get_max_pstate, |
474 | .get_min = core_get_min_pstate, | 537 | .get_min = core_get_min_pstate, |
475 | .get_turbo = core_get_turbo_pstate, | 538 | .get_turbo = core_get_turbo_pstate, |
539 | .get_scaling = core_get_scaling, | ||
476 | .set = core_set_pstate, | 540 | .set = core_set_pstate, |
477 | }, | 541 | }, |
478 | }; | 542 | }; |
@@ -491,6 +555,7 @@ static struct cpu_defaults byt_params = { | |||
491 | .get_min = byt_get_min_pstate, | 555 | .get_min = byt_get_min_pstate, |
492 | .get_turbo = byt_get_turbo_pstate, | 556 | .get_turbo = byt_get_turbo_pstate, |
493 | .set = byt_set_pstate, | 557 | .set = byt_set_pstate, |
558 | .get_scaling = byt_get_scaling, | ||
494 | .get_vid = byt_get_vid, | 559 | .get_vid = byt_get_vid, |
495 | }, | 560 | }, |
496 | }; | 561 | }; |
@@ -501,7 +566,7 @@ static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max) | |||
501 | int max_perf_adj; | 566 | int max_perf_adj; |
502 | int min_perf; | 567 | int min_perf; |
503 | 568 | ||
504 | if (limits.no_turbo) | 569 | if (limits.no_turbo || limits.turbo_disabled) |
505 | max_perf = cpu->pstate.max_pstate; | 570 | max_perf = cpu->pstate.max_pstate; |
506 | 571 | ||
507 | max_perf_adj = fp_toint(mul_fp(int_tofp(max_perf), limits.max_perf)); | 572 | max_perf_adj = fp_toint(mul_fp(int_tofp(max_perf), limits.max_perf)); |
@@ -516,6 +581,8 @@ static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate) | |||
516 | { | 581 | { |
517 | int max_perf, min_perf; | 582 | int max_perf, min_perf; |
518 | 583 | ||
584 | update_turbo_state(); | ||
585 | |||
519 | intel_pstate_get_min_max(cpu, &min_perf, &max_perf); | 586 | intel_pstate_get_min_max(cpu, &min_perf, &max_perf); |
520 | 587 | ||
521 | pstate = clamp_t(int, pstate, min_perf, max_perf); | 588 | pstate = clamp_t(int, pstate, min_perf, max_perf); |
@@ -523,7 +590,7 @@ static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate) | |||
523 | if (pstate == cpu->pstate.current_pstate) | 590 | if (pstate == cpu->pstate.current_pstate) |
524 | return; | 591 | return; |
525 | 592 | ||
526 | trace_cpu_frequency(pstate * 100000, cpu->cpu); | 593 | trace_cpu_frequency(pstate * cpu->pstate.scaling, cpu->cpu); |
527 | 594 | ||
528 | cpu->pstate.current_pstate = pstate; | 595 | cpu->pstate.current_pstate = pstate; |
529 | 596 | ||
@@ -535,6 +602,7 @@ static void intel_pstate_get_cpu_pstates(struct cpudata *cpu) | |||
535 | cpu->pstate.min_pstate = pstate_funcs.get_min(); | 602 | cpu->pstate.min_pstate = pstate_funcs.get_min(); |
536 | cpu->pstate.max_pstate = pstate_funcs.get_max(); | 603 | cpu->pstate.max_pstate = pstate_funcs.get_max(); |
537 | cpu->pstate.turbo_pstate = pstate_funcs.get_turbo(); | 604 | cpu->pstate.turbo_pstate = pstate_funcs.get_turbo(); |
605 | cpu->pstate.scaling = pstate_funcs.get_scaling(); | ||
538 | 606 | ||
539 | if (pstate_funcs.get_vid) | 607 | if (pstate_funcs.get_vid) |
540 | pstate_funcs.get_vid(cpu); | 608 | pstate_funcs.get_vid(cpu); |
@@ -550,7 +618,9 @@ static inline void intel_pstate_calc_busy(struct cpudata *cpu) | |||
550 | core_pct = div64_u64(core_pct, int_tofp(sample->mperf)); | 618 | core_pct = div64_u64(core_pct, int_tofp(sample->mperf)); |
551 | 619 | ||
552 | sample->freq = fp_toint( | 620 | sample->freq = fp_toint( |
553 | mul_fp(int_tofp(cpu->pstate.max_pstate * 1000), core_pct)); | 621 | mul_fp(int_tofp( |
622 | cpu->pstate.max_pstate * cpu->pstate.scaling / 100), | ||
623 | core_pct)); | ||
554 | 624 | ||
555 | sample->core_pct_busy = (int32_t)core_pct; | 625 | sample->core_pct_busy = (int32_t)core_pct; |
556 | } | 626 | } |
@@ -671,7 +741,9 @@ static int intel_pstate_init_cpu(unsigned int cpunum) | |||
671 | { | 741 | { |
672 | struct cpudata *cpu; | 742 | struct cpudata *cpu; |
673 | 743 | ||
674 | all_cpu_data[cpunum] = kzalloc(sizeof(struct cpudata), GFP_KERNEL); | 744 | if (!all_cpu_data[cpunum]) |
745 | all_cpu_data[cpunum] = kzalloc(sizeof(struct cpudata), | ||
746 | GFP_KERNEL); | ||
675 | if (!all_cpu_data[cpunum]) | 747 | if (!all_cpu_data[cpunum]) |
676 | return -ENOMEM; | 748 | return -ENOMEM; |
677 | 749 | ||
@@ -714,9 +786,10 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy) | |||
714 | if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) { | 786 | if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) { |
715 | limits.min_perf_pct = 100; | 787 | limits.min_perf_pct = 100; |
716 | limits.min_perf = int_tofp(1); | 788 | limits.min_perf = int_tofp(1); |
789 | limits.max_policy_pct = 100; | ||
717 | limits.max_perf_pct = 100; | 790 | limits.max_perf_pct = 100; |
718 | limits.max_perf = int_tofp(1); | 791 | limits.max_perf = int_tofp(1); |
719 | limits.no_turbo = limits.turbo_disabled; | 792 | limits.no_turbo = 0; |
720 | return 0; | 793 | return 0; |
721 | } | 794 | } |
722 | limits.min_perf_pct = (policy->min * 100) / policy->cpuinfo.max_freq; | 795 | limits.min_perf_pct = (policy->min * 100) / policy->cpuinfo.max_freq; |
@@ -751,15 +824,12 @@ static void intel_pstate_stop_cpu(struct cpufreq_policy *policy) | |||
751 | 824 | ||
752 | del_timer_sync(&all_cpu_data[cpu_num]->timer); | 825 | del_timer_sync(&all_cpu_data[cpu_num]->timer); |
753 | intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate); | 826 | intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate); |
754 | kfree(all_cpu_data[cpu_num]); | ||
755 | all_cpu_data[cpu_num] = NULL; | ||
756 | } | 827 | } |
757 | 828 | ||
758 | static int intel_pstate_cpu_init(struct cpufreq_policy *policy) | 829 | static int intel_pstate_cpu_init(struct cpufreq_policy *policy) |
759 | { | 830 | { |
760 | struct cpudata *cpu; | 831 | struct cpudata *cpu; |
761 | int rc; | 832 | int rc; |
762 | u64 misc_en; | ||
763 | 833 | ||
764 | rc = intel_pstate_init_cpu(policy->cpu); | 834 | rc = intel_pstate_init_cpu(policy->cpu); |
765 | if (rc) | 835 | if (rc) |
@@ -767,23 +837,18 @@ static int intel_pstate_cpu_init(struct cpufreq_policy *policy) | |||
767 | 837 | ||
768 | cpu = all_cpu_data[policy->cpu]; | 838 | cpu = all_cpu_data[policy->cpu]; |
769 | 839 | ||
770 | rdmsrl(MSR_IA32_MISC_ENABLE, misc_en); | ||
771 | if (misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE || | ||
772 | cpu->pstate.max_pstate == cpu->pstate.turbo_pstate) { | ||
773 | limits.turbo_disabled = 1; | ||
774 | limits.no_turbo = 1; | ||
775 | } | ||
776 | if (limits.min_perf_pct == 100 && limits.max_perf_pct == 100) | 840 | if (limits.min_perf_pct == 100 && limits.max_perf_pct == 100) |
777 | policy->policy = CPUFREQ_POLICY_PERFORMANCE; | 841 | policy->policy = CPUFREQ_POLICY_PERFORMANCE; |
778 | else | 842 | else |
779 | policy->policy = CPUFREQ_POLICY_POWERSAVE; | 843 | policy->policy = CPUFREQ_POLICY_POWERSAVE; |
780 | 844 | ||
781 | policy->min = cpu->pstate.min_pstate * 100000; | 845 | policy->min = cpu->pstate.min_pstate * cpu->pstate.scaling; |
782 | policy->max = cpu->pstate.turbo_pstate * 100000; | 846 | policy->max = cpu->pstate.turbo_pstate * cpu->pstate.scaling; |
783 | 847 | ||
784 | /* cpuinfo and default policy values */ | 848 | /* cpuinfo and default policy values */ |
785 | policy->cpuinfo.min_freq = cpu->pstate.min_pstate * 100000; | 849 | policy->cpuinfo.min_freq = cpu->pstate.min_pstate * cpu->pstate.scaling; |
786 | policy->cpuinfo.max_freq = cpu->pstate.turbo_pstate * 100000; | 850 | policy->cpuinfo.max_freq = |
851 | cpu->pstate.turbo_pstate * cpu->pstate.scaling; | ||
787 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; | 852 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; |
788 | cpumask_set_cpu(policy->cpu, policy->cpus); | 853 | cpumask_set_cpu(policy->cpu, policy->cpus); |
789 | 854 | ||
@@ -841,6 +906,7 @@ static void copy_cpu_funcs(struct pstate_funcs *funcs) | |||
841 | pstate_funcs.get_max = funcs->get_max; | 906 | pstate_funcs.get_max = funcs->get_max; |
842 | pstate_funcs.get_min = funcs->get_min; | 907 | pstate_funcs.get_min = funcs->get_min; |
843 | pstate_funcs.get_turbo = funcs->get_turbo; | 908 | pstate_funcs.get_turbo = funcs->get_turbo; |
909 | pstate_funcs.get_scaling = funcs->get_scaling; | ||
844 | pstate_funcs.set = funcs->set; | 910 | pstate_funcs.set = funcs->set; |
845 | pstate_funcs.get_vid = funcs->get_vid; | 911 | pstate_funcs.get_vid = funcs->get_vid; |
846 | } | 912 | } |
diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c index a64be578dab2..7d3a3497dd4c 100644 --- a/drivers/cpuidle/cpuidle-powernv.c +++ b/drivers/cpuidle/cpuidle-powernv.c | |||
@@ -163,7 +163,8 @@ static int powernv_add_idle_states(void) | |||
163 | int nr_idle_states = 1; /* Snooze */ | 163 | int nr_idle_states = 1; /* Snooze */ |
164 | int dt_idle_states; | 164 | int dt_idle_states; |
165 | const __be32 *idle_state_flags; | 165 | const __be32 *idle_state_flags; |
166 | u32 len_flags, flags; | 166 | const __be32 *idle_state_latency; |
167 | u32 len_flags, flags, latency_ns; | ||
167 | int i; | 168 | int i; |
168 | 169 | ||
169 | /* Currently we have snooze statically defined */ | 170 | /* Currently we have snooze statically defined */ |
@@ -180,18 +181,32 @@ static int powernv_add_idle_states(void) | |||
180 | return nr_idle_states; | 181 | return nr_idle_states; |
181 | } | 182 | } |
182 | 183 | ||
184 | idle_state_latency = of_get_property(power_mgt, | ||
185 | "ibm,cpu-idle-state-latencies-ns", NULL); | ||
186 | if (!idle_state_latency) { | ||
187 | pr_warn("DT-PowerMgmt: missing ibm,cpu-idle-state-latencies-ns\n"); | ||
188 | return nr_idle_states; | ||
189 | } | ||
190 | |||
183 | dt_idle_states = len_flags / sizeof(u32); | 191 | dt_idle_states = len_flags / sizeof(u32); |
184 | 192 | ||
185 | for (i = 0; i < dt_idle_states; i++) { | 193 | for (i = 0; i < dt_idle_states; i++) { |
186 | 194 | ||
187 | flags = be32_to_cpu(idle_state_flags[i]); | 195 | flags = be32_to_cpu(idle_state_flags[i]); |
196 | |||
197 | /* Cpuidle accepts exit_latency in us and we estimate | ||
198 | * target residency to be 10x exit_latency | ||
199 | */ | ||
200 | latency_ns = be32_to_cpu(idle_state_latency[i]); | ||
188 | if (flags & IDLE_USE_INST_NAP) { | 201 | if (flags & IDLE_USE_INST_NAP) { |
189 | /* Add NAP state */ | 202 | /* Add NAP state */ |
190 | strcpy(powernv_states[nr_idle_states].name, "Nap"); | 203 | strcpy(powernv_states[nr_idle_states].name, "Nap"); |
191 | strcpy(powernv_states[nr_idle_states].desc, "Nap"); | 204 | strcpy(powernv_states[nr_idle_states].desc, "Nap"); |
192 | powernv_states[nr_idle_states].flags = CPUIDLE_FLAG_TIME_VALID; | 205 | powernv_states[nr_idle_states].flags = CPUIDLE_FLAG_TIME_VALID; |
193 | powernv_states[nr_idle_states].exit_latency = 10; | 206 | powernv_states[nr_idle_states].exit_latency = |
194 | powernv_states[nr_idle_states].target_residency = 100; | 207 | ((unsigned int)latency_ns) / 1000; |
208 | powernv_states[nr_idle_states].target_residency = | ||
209 | ((unsigned int)latency_ns / 100); | ||
195 | powernv_states[nr_idle_states].enter = &nap_loop; | 210 | powernv_states[nr_idle_states].enter = &nap_loop; |
196 | nr_idle_states++; | 211 | nr_idle_states++; |
197 | } | 212 | } |
@@ -202,8 +217,10 @@ static int powernv_add_idle_states(void) | |||
202 | strcpy(powernv_states[nr_idle_states].desc, "FastSleep"); | 217 | strcpy(powernv_states[nr_idle_states].desc, "FastSleep"); |
203 | powernv_states[nr_idle_states].flags = | 218 | powernv_states[nr_idle_states].flags = |
204 | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TIMER_STOP; | 219 | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TIMER_STOP; |
205 | powernv_states[nr_idle_states].exit_latency = 300; | 220 | powernv_states[nr_idle_states].exit_latency = |
206 | powernv_states[nr_idle_states].target_residency = 1000000; | 221 | ((unsigned int)latency_ns) / 1000; |
222 | powernv_states[nr_idle_states].target_residency = | ||
223 | ((unsigned int)latency_ns / 100); | ||
207 | powernv_states[nr_idle_states].enter = &fastsleep_loop; | 224 | powernv_states[nr_idle_states].enter = &fastsleep_loop; |
208 | nr_idle_states++; | 225 | nr_idle_states++; |
209 | } | 226 | } |
diff --git a/drivers/pci/pcie/pme.c b/drivers/pci/pcie/pme.c index a9f9c46e5022..63fc63911295 100644 --- a/drivers/pci/pcie/pme.c +++ b/drivers/pci/pcie/pme.c | |||
@@ -397,6 +397,7 @@ static int pcie_pme_suspend(struct pcie_device *srv) | |||
397 | struct pcie_pme_service_data *data = get_service_data(srv); | 397 | struct pcie_pme_service_data *data = get_service_data(srv); |
398 | struct pci_dev *port = srv->port; | 398 | struct pci_dev *port = srv->port; |
399 | bool wakeup; | 399 | bool wakeup; |
400 | int ret; | ||
400 | 401 | ||
401 | if (device_may_wakeup(&port->dev)) { | 402 | if (device_may_wakeup(&port->dev)) { |
402 | wakeup = true; | 403 | wakeup = true; |
@@ -407,9 +408,10 @@ static int pcie_pme_suspend(struct pcie_device *srv) | |||
407 | } | 408 | } |
408 | spin_lock_irq(&data->lock); | 409 | spin_lock_irq(&data->lock); |
409 | if (wakeup) { | 410 | if (wakeup) { |
410 | enable_irq_wake(srv->irq); | 411 | ret = enable_irq_wake(srv->irq); |
411 | data->suspend_level = PME_SUSPEND_WAKEUP; | 412 | data->suspend_level = PME_SUSPEND_WAKEUP; |
412 | } else { | 413 | } |
414 | if (!wakeup || ret) { | ||
413 | struct pci_dev *port = srv->port; | 415 | struct pci_dev *port = srv->port; |
414 | 416 | ||
415 | pcie_pme_interrupt_enable(port, false); | 417 | pcie_pme_interrupt_enable(port, false); |
diff --git a/include/acpi/acnames.h b/include/acpi/acnames.h index f97804bdf1ff..7461327e14e4 100644 --- a/include/acpi/acnames.h +++ b/include/acpi/acnames.h | |||
@@ -52,6 +52,7 @@ | |||
52 | #define METHOD_NAME__CBA "_CBA" | 52 | #define METHOD_NAME__CBA "_CBA" |
53 | #define METHOD_NAME__CID "_CID" | 53 | #define METHOD_NAME__CID "_CID" |
54 | #define METHOD_NAME__CRS "_CRS" | 54 | #define METHOD_NAME__CRS "_CRS" |
55 | #define METHOD_NAME__DDN "_DDN" | ||
55 | #define METHOD_NAME__HID "_HID" | 56 | #define METHOD_NAME__HID "_HID" |
56 | #define METHOD_NAME__INI "_INI" | 57 | #define METHOD_NAME__INI "_INI" |
57 | #define METHOD_NAME__PLD "_PLD" | 58 | #define METHOD_NAME__PLD "_PLD" |
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h index 9fc1d71c82bc..ab2acf629a64 100644 --- a/include/acpi/acpixf.h +++ b/include/acpi/acpixf.h | |||
@@ -46,7 +46,7 @@ | |||
46 | 46 | ||
47 | /* Current ACPICA subsystem version in YYYYMMDD format */ | 47 | /* Current ACPICA subsystem version in YYYYMMDD format */ |
48 | 48 | ||
49 | #define ACPI_CA_VERSION 0x20140828 | 49 | #define ACPI_CA_VERSION 0x20140926 |
50 | 50 | ||
51 | #include <acpi/acconfig.h> | 51 | #include <acpi/acconfig.h> |
52 | #include <acpi/actypes.h> | 52 | #include <acpi/actypes.h> |
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index ac03ec81d342..7000e66f768e 100644 --- a/include/acpi/actypes.h +++ b/include/acpi/actypes.h | |||
@@ -721,7 +721,7 @@ typedef u32 acpi_event_type; | |||
721 | * | | | +--- Enabled for wake? | 721 | * | | | +--- Enabled for wake? |
722 | * | | +----- Set? | 722 | * | | +----- Set? |
723 | * | +------- Has a handler? | 723 | * | +------- Has a handler? |
724 | * +----------- <Reserved> | 724 | * +------------- <Reserved> |
725 | */ | 725 | */ |
726 | typedef u32 acpi_event_status; | 726 | typedef u32 acpi_event_status; |
727 | 727 | ||
@@ -729,7 +729,7 @@ typedef u32 acpi_event_status; | |||
729 | #define ACPI_EVENT_FLAG_ENABLED (acpi_event_status) 0x01 | 729 | #define ACPI_EVENT_FLAG_ENABLED (acpi_event_status) 0x01 |
730 | #define ACPI_EVENT_FLAG_WAKE_ENABLED (acpi_event_status) 0x02 | 730 | #define ACPI_EVENT_FLAG_WAKE_ENABLED (acpi_event_status) 0x02 |
731 | #define ACPI_EVENT_FLAG_SET (acpi_event_status) 0x04 | 731 | #define ACPI_EVENT_FLAG_SET (acpi_event_status) 0x04 |
732 | #define ACPI_EVENT_FLAG_HANDLE (acpi_event_status) 0x08 | 732 | #define ACPI_EVENT_FLAG_HAS_HANDLER (acpi_event_status) 0x08 |
733 | 733 | ||
734 | /* Actions for acpi_set_gpe, acpi_gpe_wakeup, acpi_hw_low_set_gpe */ | 734 | /* Actions for acpi_set_gpe, acpi_gpe_wakeup, acpi_hw_low_set_gpe */ |
735 | 735 | ||
diff --git a/include/linux/cpufreq-dt.h b/include/linux/cpufreq-dt.h new file mode 100644 index 000000000000..0414009e2c30 --- /dev/null +++ b/include/linux/cpufreq-dt.h | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014 Marvell | ||
3 | * Thomas Petazzoni <thomas.petazzoni@free-electrons.com> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License version 2 as | ||
7 | * published by the Free Software Foundation. | ||
8 | */ | ||
9 | |||
10 | #ifndef __CPUFREQ_DT_H__ | ||
11 | #define __CPUFREQ_DT_H__ | ||
12 | |||
13 | struct cpufreq_dt_platform_data { | ||
14 | /* | ||
15 | * True when each CPU has its own clock to control its | ||
16 | * frequency, false when all CPUs are controlled by a single | ||
17 | * clock. | ||
18 | */ | ||
19 | bool independent_clocks; | ||
20 | }; | ||
21 | |||
22 | #endif /* __CPUFREQ_DT_H__ */ | ||
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 138336b6bb04..503b085b7832 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h | |||
@@ -219,6 +219,7 @@ __ATTR(_name, 0644, show_##_name, store_##_name) | |||
219 | struct cpufreq_driver { | 219 | struct cpufreq_driver { |
220 | char name[CPUFREQ_NAME_LEN]; | 220 | char name[CPUFREQ_NAME_LEN]; |
221 | u8 flags; | 221 | u8 flags; |
222 | void *driver_data; | ||
222 | 223 | ||
223 | /* needed by all drivers */ | 224 | /* needed by all drivers */ |
224 | int (*init) (struct cpufreq_policy *policy); | 225 | int (*init) (struct cpufreq_policy *policy); |
@@ -312,6 +313,7 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data); | |||
312 | int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); | 313 | int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); |
313 | 314 | ||
314 | const char *cpufreq_get_current_driver(void); | 315 | const char *cpufreq_get_current_driver(void); |
316 | void *cpufreq_get_driver_data(void); | ||
315 | 317 | ||
316 | static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, | 318 | static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, |
317 | unsigned int min, unsigned int max) | 319 | unsigned int min, unsigned int max) |
diff --git a/include/linux/oom.h b/include/linux/oom.h index 647395a1a550..e8d6e1058723 100644 --- a/include/linux/oom.h +++ b/include/linux/oom.h | |||
@@ -50,6 +50,9 @@ static inline bool oom_task_origin(const struct task_struct *p) | |||
50 | extern unsigned long oom_badness(struct task_struct *p, | 50 | extern unsigned long oom_badness(struct task_struct *p, |
51 | struct mem_cgroup *memcg, const nodemask_t *nodemask, | 51 | struct mem_cgroup *memcg, const nodemask_t *nodemask, |
52 | unsigned long totalpages); | 52 | unsigned long totalpages); |
53 | |||
54 | extern int oom_kills_count(void); | ||
55 | extern void note_oom_kill(void); | ||
53 | extern void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order, | 56 | extern void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order, |
54 | unsigned int points, unsigned long totalpages, | 57 | unsigned int points, unsigned long totalpages, |
55 | struct mem_cgroup *memcg, nodemask_t *nodemask, | 58 | struct mem_cgroup *memcg, nodemask_t *nodemask, |
diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h index 9ab4bf7c4646..636e82834506 100644 --- a/include/linux/pm_qos.h +++ b/include/linux/pm_qos.h | |||
@@ -15,6 +15,7 @@ enum { | |||
15 | PM_QOS_CPU_DMA_LATENCY, | 15 | PM_QOS_CPU_DMA_LATENCY, |
16 | PM_QOS_NETWORK_LATENCY, | 16 | PM_QOS_NETWORK_LATENCY, |
17 | PM_QOS_NETWORK_THROUGHPUT, | 17 | PM_QOS_NETWORK_THROUGHPUT, |
18 | PM_QOS_MEMORY_BANDWIDTH, | ||
18 | 19 | ||
19 | /* insert new class ID */ | 20 | /* insert new class ID */ |
20 | PM_QOS_NUM_CLASSES, | 21 | PM_QOS_NUM_CLASSES, |
@@ -32,6 +33,7 @@ enum pm_qos_flags_status { | |||
32 | #define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) | 33 | #define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) |
33 | #define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) | 34 | #define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) |
34 | #define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 | 35 | #define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 |
36 | #define PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE 0 | ||
35 | #define PM_QOS_RESUME_LATENCY_DEFAULT_VALUE 0 | 37 | #define PM_QOS_RESUME_LATENCY_DEFAULT_VALUE 0 |
36 | #define PM_QOS_LATENCY_TOLERANCE_DEFAULT_VALUE 0 | 38 | #define PM_QOS_LATENCY_TOLERANCE_DEFAULT_VALUE 0 |
37 | #define PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT (-1) | 39 | #define PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT (-1) |
@@ -69,7 +71,8 @@ struct dev_pm_qos_request { | |||
69 | enum pm_qos_type { | 71 | enum pm_qos_type { |
70 | PM_QOS_UNITIALIZED, | 72 | PM_QOS_UNITIALIZED, |
71 | PM_QOS_MAX, /* return the largest value */ | 73 | PM_QOS_MAX, /* return the largest value */ |
72 | PM_QOS_MIN /* return the smallest value */ | 74 | PM_QOS_MIN, /* return the smallest value */ |
75 | PM_QOS_SUM /* return the sum */ | ||
73 | }; | 76 | }; |
74 | 77 | ||
75 | /* | 78 | /* |
diff --git a/kernel/freezer.c b/kernel/freezer.c index aa6a8aadb911..a8900a3bc27a 100644 --- a/kernel/freezer.c +++ b/kernel/freezer.c | |||
@@ -42,6 +42,9 @@ bool freezing_slow_path(struct task_struct *p) | |||
42 | if (p->flags & (PF_NOFREEZE | PF_SUSPEND_TASK)) | 42 | if (p->flags & (PF_NOFREEZE | PF_SUSPEND_TASK)) |
43 | return false; | 43 | return false; |
44 | 44 | ||
45 | if (test_thread_flag(TIF_MEMDIE)) | ||
46 | return false; | ||
47 | |||
45 | if (pm_nosig_freezing || cgroup_freezing(p)) | 48 | if (pm_nosig_freezing || cgroup_freezing(p)) |
46 | return true; | 49 | return true; |
47 | 50 | ||
@@ -147,12 +150,6 @@ void __thaw_task(struct task_struct *p) | |||
147 | { | 150 | { |
148 | unsigned long flags; | 151 | unsigned long flags; |
149 | 152 | ||
150 | /* | ||
151 | * Clear freezing and kick @p if FROZEN. Clearing is guaranteed to | ||
152 | * be visible to @p as waking up implies wmb. Waking up inside | ||
153 | * freezer_lock also prevents wakeups from leaking outside | ||
154 | * refrigerator. | ||
155 | */ | ||
156 | spin_lock_irqsave(&freezer_lock, flags); | 153 | spin_lock_irqsave(&freezer_lock, flags); |
157 | if (frozen(p)) | 154 | if (frozen(p)) |
158 | wake_up_process(p); | 155 | wake_up_process(p); |
diff --git a/kernel/power/process.c b/kernel/power/process.c index 7b323221b9ee..5a6ec8678b9a 100644 --- a/kernel/power/process.c +++ b/kernel/power/process.c | |||
@@ -46,13 +46,13 @@ static int try_to_freeze_tasks(bool user_only) | |||
46 | while (true) { | 46 | while (true) { |
47 | todo = 0; | 47 | todo = 0; |
48 | read_lock(&tasklist_lock); | 48 | read_lock(&tasklist_lock); |
49 | do_each_thread(g, p) { | 49 | for_each_process_thread(g, p) { |
50 | if (p == current || !freeze_task(p)) | 50 | if (p == current || !freeze_task(p)) |
51 | continue; | 51 | continue; |
52 | 52 | ||
53 | if (!freezer_should_skip(p)) | 53 | if (!freezer_should_skip(p)) |
54 | todo++; | 54 | todo++; |
55 | } while_each_thread(g, p); | 55 | } |
56 | read_unlock(&tasklist_lock); | 56 | read_unlock(&tasklist_lock); |
57 | 57 | ||
58 | if (!user_only) { | 58 | if (!user_only) { |
@@ -93,11 +93,11 @@ static int try_to_freeze_tasks(bool user_only) | |||
93 | 93 | ||
94 | if (!wakeup) { | 94 | if (!wakeup) { |
95 | read_lock(&tasklist_lock); | 95 | read_lock(&tasklist_lock); |
96 | do_each_thread(g, p) { | 96 | for_each_process_thread(g, p) { |
97 | if (p != current && !freezer_should_skip(p) | 97 | if (p != current && !freezer_should_skip(p) |
98 | && freezing(p) && !frozen(p)) | 98 | && freezing(p) && !frozen(p)) |
99 | sched_show_task(p); | 99 | sched_show_task(p); |
100 | } while_each_thread(g, p); | 100 | } |
101 | read_unlock(&tasklist_lock); | 101 | read_unlock(&tasklist_lock); |
102 | } | 102 | } |
103 | } else { | 103 | } else { |
@@ -108,6 +108,30 @@ static int try_to_freeze_tasks(bool user_only) | |||
108 | return todo ? -EBUSY : 0; | 108 | return todo ? -EBUSY : 0; |
109 | } | 109 | } |
110 | 110 | ||
111 | static bool __check_frozen_processes(void) | ||
112 | { | ||
113 | struct task_struct *g, *p; | ||
114 | |||
115 | for_each_process_thread(g, p) | ||
116 | if (p != current && !freezer_should_skip(p) && !frozen(p)) | ||
117 | return false; | ||
118 | |||
119 | return true; | ||
120 | } | ||
121 | |||
122 | /* | ||
123 | * Returns true if all freezable tasks (except for current) are frozen already | ||
124 | */ | ||
125 | static bool check_frozen_processes(void) | ||
126 | { | ||
127 | bool ret; | ||
128 | |||
129 | read_lock(&tasklist_lock); | ||
130 | ret = __check_frozen_processes(); | ||
131 | read_unlock(&tasklist_lock); | ||
132 | return ret; | ||
133 | } | ||
134 | |||
111 | /** | 135 | /** |
112 | * freeze_processes - Signal user space processes to enter the refrigerator. | 136 | * freeze_processes - Signal user space processes to enter the refrigerator. |
113 | * The current thread will not be frozen. The same process that calls | 137 | * The current thread will not be frozen. The same process that calls |
@@ -118,6 +142,7 @@ static int try_to_freeze_tasks(bool user_only) | |||
118 | int freeze_processes(void) | 142 | int freeze_processes(void) |
119 | { | 143 | { |
120 | int error; | 144 | int error; |
145 | int oom_kills_saved; | ||
121 | 146 | ||
122 | error = __usermodehelper_disable(UMH_FREEZING); | 147 | error = __usermodehelper_disable(UMH_FREEZING); |
123 | if (error) | 148 | if (error) |
@@ -132,11 +157,25 @@ int freeze_processes(void) | |||
132 | pm_wakeup_clear(); | 157 | pm_wakeup_clear(); |
133 | printk("Freezing user space processes ... "); | 158 | printk("Freezing user space processes ... "); |
134 | pm_freezing = true; | 159 | pm_freezing = true; |
160 | oom_kills_saved = oom_kills_count(); | ||
135 | error = try_to_freeze_tasks(true); | 161 | error = try_to_freeze_tasks(true); |
136 | if (!error) { | 162 | if (!error) { |
137 | printk("done."); | ||
138 | __usermodehelper_set_disable_depth(UMH_DISABLED); | 163 | __usermodehelper_set_disable_depth(UMH_DISABLED); |
139 | oom_killer_disable(); | 164 | oom_killer_disable(); |
165 | |||
166 | /* | ||
167 | * There might have been an OOM kill while we were | ||
168 | * freezing tasks and the killed task might be still | ||
169 | * on the way out so we have to double check for race. | ||
170 | */ | ||
171 | if (oom_kills_count() != oom_kills_saved && | ||
172 | !check_frozen_processes()) { | ||
173 | __usermodehelper_set_disable_depth(UMH_ENABLED); | ||
174 | printk("OOM in progress."); | ||
175 | error = -EBUSY; | ||
176 | } else { | ||
177 | printk("done."); | ||
178 | } | ||
140 | } | 179 | } |
141 | printk("\n"); | 180 | printk("\n"); |
142 | BUG_ON(in_atomic()); | 181 | BUG_ON(in_atomic()); |
@@ -191,11 +230,11 @@ void thaw_processes(void) | |||
191 | thaw_workqueues(); | 230 | thaw_workqueues(); |
192 | 231 | ||
193 | read_lock(&tasklist_lock); | 232 | read_lock(&tasklist_lock); |
194 | do_each_thread(g, p) { | 233 | for_each_process_thread(g, p) { |
195 | /* No other threads should have PF_SUSPEND_TASK set */ | 234 | /* No other threads should have PF_SUSPEND_TASK set */ |
196 | WARN_ON((p != curr) && (p->flags & PF_SUSPEND_TASK)); | 235 | WARN_ON((p != curr) && (p->flags & PF_SUSPEND_TASK)); |
197 | __thaw_task(p); | 236 | __thaw_task(p); |
198 | } while_each_thread(g, p); | 237 | } |
199 | read_unlock(&tasklist_lock); | 238 | read_unlock(&tasklist_lock); |
200 | 239 | ||
201 | WARN_ON(!(curr->flags & PF_SUSPEND_TASK)); | 240 | WARN_ON(!(curr->flags & PF_SUSPEND_TASK)); |
@@ -218,10 +257,10 @@ void thaw_kernel_threads(void) | |||
218 | thaw_workqueues(); | 257 | thaw_workqueues(); |
219 | 258 | ||
220 | read_lock(&tasklist_lock); | 259 | read_lock(&tasklist_lock); |
221 | do_each_thread(g, p) { | 260 | for_each_process_thread(g, p) { |
222 | if (p->flags & (PF_KTHREAD | PF_WQ_WORKER)) | 261 | if (p->flags & (PF_KTHREAD | PF_WQ_WORKER)) |
223 | __thaw_task(p); | 262 | __thaw_task(p); |
224 | } while_each_thread(g, p); | 263 | } |
225 | read_unlock(&tasklist_lock); | 264 | read_unlock(&tasklist_lock); |
226 | 265 | ||
227 | schedule(); | 266 | schedule(); |
diff --git a/kernel/power/qos.c b/kernel/power/qos.c index 884b77058864..5f4c006c4b1e 100644 --- a/kernel/power/qos.c +++ b/kernel/power/qos.c | |||
@@ -105,11 +105,27 @@ static struct pm_qos_object network_throughput_pm_qos = { | |||
105 | }; | 105 | }; |
106 | 106 | ||
107 | 107 | ||
108 | static BLOCKING_NOTIFIER_HEAD(memory_bandwidth_notifier); | ||
109 | static struct pm_qos_constraints memory_bw_constraints = { | ||
110 | .list = PLIST_HEAD_INIT(memory_bw_constraints.list), | ||
111 | .target_value = PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE, | ||
112 | .default_value = PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE, | ||
113 | .no_constraint_value = PM_QOS_MEMORY_BANDWIDTH_DEFAULT_VALUE, | ||
114 | .type = PM_QOS_SUM, | ||
115 | .notifiers = &memory_bandwidth_notifier, | ||
116 | }; | ||
117 | static struct pm_qos_object memory_bandwidth_pm_qos = { | ||
118 | .constraints = &memory_bw_constraints, | ||
119 | .name = "memory_bandwidth", | ||
120 | }; | ||
121 | |||
122 | |||
108 | static struct pm_qos_object *pm_qos_array[] = { | 123 | static struct pm_qos_object *pm_qos_array[] = { |
109 | &null_pm_qos, | 124 | &null_pm_qos, |
110 | &cpu_dma_pm_qos, | 125 | &cpu_dma_pm_qos, |
111 | &network_lat_pm_qos, | 126 | &network_lat_pm_qos, |
112 | &network_throughput_pm_qos | 127 | &network_throughput_pm_qos, |
128 | &memory_bandwidth_pm_qos, | ||
113 | }; | 129 | }; |
114 | 130 | ||
115 | static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf, | 131 | static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf, |
@@ -130,6 +146,9 @@ static const struct file_operations pm_qos_power_fops = { | |||
130 | /* unlocked internal variant */ | 146 | /* unlocked internal variant */ |
131 | static inline int pm_qos_get_value(struct pm_qos_constraints *c) | 147 | static inline int pm_qos_get_value(struct pm_qos_constraints *c) |
132 | { | 148 | { |
149 | struct plist_node *node; | ||
150 | int total_value = 0; | ||
151 | |||
133 | if (plist_head_empty(&c->list)) | 152 | if (plist_head_empty(&c->list)) |
134 | return c->no_constraint_value; | 153 | return c->no_constraint_value; |
135 | 154 | ||
@@ -140,6 +159,12 @@ static inline int pm_qos_get_value(struct pm_qos_constraints *c) | |||
140 | case PM_QOS_MAX: | 159 | case PM_QOS_MAX: |
141 | return plist_last(&c->list)->prio; | 160 | return plist_last(&c->list)->prio; |
142 | 161 | ||
162 | case PM_QOS_SUM: | ||
163 | plist_for_each(node, &c->list) | ||
164 | total_value += node->prio; | ||
165 | |||
166 | return total_value; | ||
167 | |||
143 | default: | 168 | default: |
144 | /* runtime check for not using enum */ | 169 | /* runtime check for not using enum */ |
145 | BUG(); | 170 | BUG(); |
diff --git a/mm/oom_kill.c b/mm/oom_kill.c index bbf405a3a18f..5340f6b91312 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c | |||
@@ -404,6 +404,23 @@ static void dump_header(struct task_struct *p, gfp_t gfp_mask, int order, | |||
404 | dump_tasks(memcg, nodemask); | 404 | dump_tasks(memcg, nodemask); |
405 | } | 405 | } |
406 | 406 | ||
407 | /* | ||
408 | * Number of OOM killer invocations (including memcg OOM killer). | ||
409 | * Primarily used by PM freezer to check for potential races with | ||
410 | * OOM killed frozen task. | ||
411 | */ | ||
412 | static atomic_t oom_kills = ATOMIC_INIT(0); | ||
413 | |||
414 | int oom_kills_count(void) | ||
415 | { | ||
416 | return atomic_read(&oom_kills); | ||
417 | } | ||
418 | |||
419 | void note_oom_kill(void) | ||
420 | { | ||
421 | atomic_inc(&oom_kills); | ||
422 | } | ||
423 | |||
407 | #define K(x) ((x) << (PAGE_SHIFT-10)) | 424 | #define K(x) ((x) << (PAGE_SHIFT-10)) |
408 | /* | 425 | /* |
409 | * Must be called while holding a reference to p, which will be released upon | 426 | * Must be called while holding a reference to p, which will be released upon |
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 736d8e1b6381..9cd36b822444 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -2252,6 +2252,14 @@ __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order, | |||
2252 | } | 2252 | } |
2253 | 2253 | ||
2254 | /* | 2254 | /* |
2255 | * PM-freezer should be notified that there might be an OOM killer on | ||
2256 | * its way to kill and wake somebody up. This is too early and we might | ||
2257 | * end up not killing anything but false positives are acceptable. | ||
2258 | * See freeze_processes. | ||
2259 | */ | ||
2260 | note_oom_kill(); | ||
2261 | |||
2262 | /* | ||
2255 | * Go through the zonelist yet one more time, keep very high watermark | 2263 | * Go through the zonelist yet one more time, keep very high watermark |
2256 | * here, this is only to catch a parallel oom killing, we must fail if | 2264 | * here, this is only to catch a parallel oom killing, we must fail if |
2257 | * we're still under heavy pressure. | 2265 | * we're still under heavy pressure. |
diff --git a/tools/power/acpi/os_specific/service_layers/osunixxf.c b/tools/power/acpi/os_specific/service_layers/osunixxf.c index 60b58cd18410..7ccb073f8316 100644 --- a/tools/power/acpi/os_specific/service_layers/osunixxf.c +++ b/tools/power/acpi/os_specific/service_layers/osunixxf.c | |||
@@ -122,6 +122,14 @@ static void os_enter_line_edit_mode(void) | |||
122 | { | 122 | { |
123 | struct termios local_term_attributes; | 123 | struct termios local_term_attributes; |
124 | 124 | ||
125 | term_attributes_were_set = 0; | ||
126 | |||
127 | /* STDIN must be a terminal */ | ||
128 | |||
129 | if (!isatty(STDIN_FILENO)) { | ||
130 | return; | ||
131 | } | ||
132 | |||
125 | /* Get and keep the original attributes */ | 133 | /* Get and keep the original attributes */ |
126 | 134 | ||
127 | if (tcgetattr(STDIN_FILENO, &original_term_attributes)) { | 135 | if (tcgetattr(STDIN_FILENO, &original_term_attributes)) { |
diff --git a/tools/power/acpi/tools/acpidump/apdump.c b/tools/power/acpi/tools/acpidump/apdump.c index 53cee781e24e..24d32968802d 100644 --- a/tools/power/acpi/tools/acpidump/apdump.c +++ b/tools/power/acpi/tools/acpidump/apdump.c | |||
@@ -146,7 +146,7 @@ u32 ap_get_table_length(struct acpi_table_header *table) | |||
146 | 146 | ||
147 | if (ACPI_VALIDATE_RSDP_SIG(table->signature)) { | 147 | if (ACPI_VALIDATE_RSDP_SIG(table->signature)) { |
148 | rsdp = ACPI_CAST_PTR(struct acpi_table_rsdp, table); | 148 | rsdp = ACPI_CAST_PTR(struct acpi_table_rsdp, table); |
149 | return (rsdp->length); | 149 | return (acpi_tb_get_rsdp_length(rsdp)); |
150 | } | 150 | } |
151 | 151 | ||
152 | /* Normal ACPI table */ | 152 | /* Normal ACPI table */ |