Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'pm+acpi-3.18-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull ACPI and power management updates from Rafael Wysocki:
"This is material that didn't make it to my 3.18-rc1 pull request for
various reasons, mostly related to timing and travel (LinuxCon EU /
LPC) plus a couple of fixes for recent bugs.

The only really new thing here is the PM QoS class for memory
bandwidth, but it is simple enough and users of it will be added in
the next cycle. One major change in behavior is that platform devices
enumerated by ACPI will use 32-bit DMA mask by default. Also included
is an ACPICA update to a new upstream release, but that's mostly
cleanups, changes in tools and similar. The rest is fixes and
cleanups mostly.

Specifics:

- Fix for a recent PCI power management change that overlooked the
fact that some IRQ chips might not be able to configure PCIe PME
for system wakeup from Lucas Stach.

- Fix for a bug introduced in 3.17 where acpi_device_wakeup() is
called with a wrong ordering of arguments from Zhang Rui.

- A bunch of intel_pstate driver fixes (all -stable candidates) from
Dirk Brandewie, Gabriele Mazzotta and Pali Rohár.

- Fixes for a rather long-standing problem with the OOM killer and
the freezer that frozen processes killed by the OOM do not actually
release any memory until they are thawed, so OOM-killing them is
rather pointless, with a couple of cleanups on top (Michal Hocko,
Cong Wang, Rafael J Wysocki).

- ACPICA update to upstream release 20140926, inlcuding mostly
cleanups reducing differences between the upstream ACPICA and the
kernel code, tools changes (acpidump, acpiexec) and support for the
_DDN object (Bob Moore, Lv Zheng).

- New PM QoS class for memory bandwidth from Tomeu Vizoso.

- Default 32-bit DMA mask for platform devices enumerated by ACPI
(this change is mostly needed for some drivers development in
progress targeted at 3.19) from Heikki Krogerus.

- ACPI EC driver cleanups, mostly related to debugging, from Lv
Zheng.

- cpufreq-dt driver updates from Thomas Petazzoni.

- powernv cpuidle driver update from Preeti U Murthy"

* tag 'pm+acpi-3.18-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (34 commits)
intel_pstate: Correct BYT VID values.
intel_pstate: Fix BYT frequency reporting
intel_pstate: Don't lose sysfs settings during cpu offline
cpufreq: intel_pstate: Reflect current no_turbo state correctly
cpufreq: expose scaling_cur_freq sysfs file for set_policy() drivers
cpufreq: intel_pstate: Fix setting max_perf_pct in performance policy
PCI / PM: handle failure to enable wakeup on PCIe PME
ACPI: invoke acpi_device_wakeup() with correct parameters
PM / freezer: Clean up code after recent fixes
PM: convert do_each_thread to for_each_process_thread
OOM, PM: OOM killed task shouldn't escape PM suspend
freezer: remove obsolete comments in __thaw_task()
freezer: Do not freeze tasks killed by OOM killer
ACPI / platform: provide default DMA mask
cpuidle: powernv: Populate cpuidle state details by querying the device-tree
cpufreq: cpufreq-dt: adjust message related to regulators
cpufreq: cpufreq-dt: extend with platform_data
cpufreq: allow driver-specific data
ACPI / EC: Cleanup coding style.
ACPI / EC: Refine event/query debugging messages.
...

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