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

Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux

Pull ACPI & Power Management changes from Len Brown:
- ACPI 5.0 after-ripples, ACPICA/Linux divergence cleanup
- cpuidle evolving, more ARM use
- thermal sub-system evolving, ditto
- assorted other PM bits

Fix up conflicts in various cpuidle implementations due to ARM cpuidle
cleanups (ARM at91 self-refresh and cpu idle code rewritten into
"standby" in asm conflicting with the consolidation of cpuidle time
keeping), trivial SH include file context conflict and RCU tracing fixes
in generic code.

* 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux: (77 commits)
ACPI throttling: fix endian bug in acpi_read_throttling_status()
Disable MCP limit exceeded messages from Intel IPS driver
ACPI video: Don't start video device until its associated input device has been allocated
ACPI video: Harden video bus adding.
ACPI: Add support for exposing BGRT data
ACPI: export acpi_kobj
ACPI: Fix logic for removing mappings in 'acpi_unmap'
CPER failed to handle generic error records with multiple sections
ACPI: Clean redundant codes in scan.c
ACPI: Fix unprotected smp_processor_id() in acpi_processor_cst_has_changed()
ACPI: consistently use should_use_kmap()
PNPACPI: Fix device ref leaking in acpi_pnp_match
ACPI: Fix use-after-free in acpi_map_lsapic
ACPI: processor_driver: add missing kfree
ACPI, APEI: Fix incorrect APEI register bit width check and usage
Update documentation for parameter *notrigger* in einj.txt
ACPI, APEI, EINJ, new parameter to control trigger action
ACPI, APEI, EINJ, limit the range of einj_param
ACPI, APEI, Fix ERST header length check
cpuidle: power_usage should be declared signed integer
...

+3183 -1546
+20
Documentation/ABI/testing/sysfs-firmware-acpi
··· 1 + What: /sys/firmware/acpi/bgrt/ 2 + Date: January 2012 3 + Contact: Matthew Garrett <mjg@redhat.com> 4 + Description: 5 + The BGRT is an ACPI 5.0 feature that allows the OS 6 + to obtain a copy of the firmware boot splash and 7 + some associated metadata. This is intended to be used 8 + by boot splash applications in order to interact with 9 + the firmware boot splash in order to avoid jarring 10 + transitions. 11 + 12 + image: The image bitmap. Currently a 32-bit BMP. 13 + status: 1 if the image is valid, 0 if firmware invalidated it. 14 + type: 0 indicates image is in BMP format. 15 + version: The version of the BGRT. Currently 1. 16 + xoffset: The number of pixels between the left of the screen 17 + and the left edge of the image. 18 + yoffset: The number of pixels between the top of the screen 19 + and the top edge of the image. 20 + 1 21 What: /sys/firmware/acpi/interrupts/ 2 22 Date: February 2008 3 23 Contact: Len Brown <lenb@kernel.org>
+8
Documentation/acpi/apei/einj.txt
··· 53 53 This file is used to set the second error parameter value. Effect of 54 54 parameter depends on error_type specified. 55 55 56 + - notrigger 57 + The EINJ mechanism is a two step process. First inject the error, then 58 + perform some actions to trigger it. Setting "notrigger" to 1 skips the 59 + trigger phase, which *may* allow the user to cause the error in some other 60 + context by a simple access to the cpu, memory location, or device that is 61 + the target of the error injection. Whether this actually works depends 62 + on what operations the BIOS actually includes in the trigger phase. 63 + 56 64 BIOS versions based in the ACPI 4.0 specification have limited options 57 65 to control where the errors are injected. Your BIOS may support an 58 66 extension (enabled with the param_extension=1 module parameter, or
+5
Documentation/cpuidle/sysfs.txt
··· 36 36 /sys/devices/system/cpu/cpu0/cpuidle/state0: 37 37 total 0 38 38 -r--r--r-- 1 root root 4096 Feb 8 10:42 desc 39 + -rw-r--r-- 1 root root 4096 Feb 8 10:42 disable 39 40 -r--r--r-- 1 root root 4096 Feb 8 10:42 latency 40 41 -r--r--r-- 1 root root 4096 Feb 8 10:42 name 41 42 -r--r--r-- 1 root root 4096 Feb 8 10:42 power ··· 46 45 /sys/devices/system/cpu/cpu0/cpuidle/state1: 47 46 total 0 48 47 -r--r--r-- 1 root root 4096 Feb 8 10:42 desc 48 + -rw-r--r-- 1 root root 4096 Feb 8 10:42 disable 49 49 -r--r--r-- 1 root root 4096 Feb 8 10:42 latency 50 50 -r--r--r-- 1 root root 4096 Feb 8 10:42 name 51 51 -r--r--r-- 1 root root 4096 Feb 8 10:42 power ··· 56 54 /sys/devices/system/cpu/cpu0/cpuidle/state2: 57 55 total 0 58 56 -r--r--r-- 1 root root 4096 Feb 8 10:42 desc 57 + -rw-r--r-- 1 root root 4096 Feb 8 10:42 disable 59 58 -r--r--r-- 1 root root 4096 Feb 8 10:42 latency 60 59 -r--r--r-- 1 root root 4096 Feb 8 10:42 name 61 60 -r--r--r-- 1 root root 4096 Feb 8 10:42 power ··· 66 63 /sys/devices/system/cpu/cpu0/cpuidle/state3: 67 64 total 0 68 65 -r--r--r-- 1 root root 4096 Feb 8 10:42 desc 66 + -rw-r--r-- 1 root root 4096 Feb 8 10:42 disable 69 67 -r--r--r-- 1 root root 4096 Feb 8 10:42 latency 70 68 -r--r--r-- 1 root root 4096 Feb 8 10:42 name 71 69 -r--r--r-- 1 root root 4096 Feb 8 10:42 power ··· 76 72 77 73 78 74 * desc : Small description about the idle state (string) 75 + * disable : Option to disable this idle state (bool) 79 76 * latency : Latency to exit out of this idle state (in microseconds) 80 77 * name : Name of the idle state (string) 81 78 * power : Power consumed while in this idle state (in milliwatts)
+29
arch/arm/include/asm/cpuidle.h
··· 1 + #ifndef __ASM_ARM_CPUIDLE_H 2 + #define __ASM_ARM_CPUIDLE_H 3 + 4 + #ifdef CONFIG_CPU_IDLE 5 + extern int arm_cpuidle_simple_enter(struct cpuidle_device *dev, 6 + struct cpuidle_driver *drv, int index); 7 + #else 8 + static inline int arm_cpuidle_simple_enter(struct cpuidle_device *dev, 9 + struct cpuidle_driver *drv, int index) { return -ENODEV; } 10 + #endif 11 + 12 + /* Common ARM WFI state */ 13 + #define ARM_CPUIDLE_WFI_STATE_PWR(p) {\ 14 + .enter = arm_cpuidle_simple_enter,\ 15 + .exit_latency = 1,\ 16 + .target_residency = 1,\ 17 + .power_usage = p,\ 18 + .flags = CPUIDLE_FLAG_TIME_VALID,\ 19 + .name = "WFI",\ 20 + .desc = "ARM WFI",\ 21 + } 22 + 23 + /* 24 + * in case power_specified == 1, give a default WFI power value needed 25 + * by some governors 26 + */ 27 + #define ARM_CPUIDLE_WFI_STATE ARM_CPUIDLE_WFI_STATE_PWR(UINT_MAX) 28 + 29 + #endif
+1 -1
arch/arm/kernel/Makefile
··· 23 23 24 24 obj-$(CONFIG_LEDS) += leds.o 25 25 obj-$(CONFIG_OC_ETM) += etm.o 26 - 26 + obj-$(CONFIG_CPU_IDLE) += cpuidle.o 27 27 obj-$(CONFIG_ISA_DMA_API) += dma.o 28 28 obj-$(CONFIG_FIQ) += fiq.o fiqasm.o 29 29 obj-$(CONFIG_MODULES) += armksyms.o module.o
+21
arch/arm/kernel/cpuidle.c
··· 1 + /* 2 + * Copyright 2012 Linaro Ltd. 3 + * 4 + * The code contained herein is licensed under the GNU General Public 5 + * License. You may obtain a copy of the GNU General Public License 6 + * Version 2 or later at the following locations: 7 + * 8 + * http://www.opensource.org/licenses/gpl-license.html 9 + * http://www.gnu.org/copyleft/gpl.html 10 + */ 11 + 12 + #include <linux/cpuidle.h> 13 + #include <asm/proc-fns.h> 14 + 15 + int arm_cpuidle_simple_enter(struct cpuidle_device *dev, 16 + struct cpuidle_driver *drv, int index) 17 + { 18 + cpu_do_idle(); 19 + 20 + return index; 21 + }
+19 -40
arch/arm/mach-at91/cpuidle.c
··· 17 17 #include <linux/init.h> 18 18 #include <linux/platform_device.h> 19 19 #include <linux/cpuidle.h> 20 - #include <asm/proc-fns.h> 21 20 #include <linux/io.h> 22 21 #include <linux/export.h> 22 + #include <asm/proc-fns.h> 23 + #include <asm/cpuidle.h> 23 24 24 25 #include "pm.h" 25 26 ··· 28 27 29 28 static DEFINE_PER_CPU(struct cpuidle_device, at91_cpuidle_device); 30 29 31 - static struct cpuidle_driver at91_idle_driver = { 32 - .name = "at91_idle", 33 - .owner = THIS_MODULE, 34 - }; 35 - 36 30 /* Actual code that puts the SoC in different idle states */ 37 31 static int at91_enter_idle(struct cpuidle_device *dev, 38 32 struct cpuidle_driver *drv, 39 33 int index) 40 34 { 41 - struct timeval before, after; 42 - int idle_time; 35 + at91_standby(); 43 36 44 - local_irq_disable(); 45 - do_gettimeofday(&before); 46 - if (index == 0) 47 - /* Wait for interrupt state */ 48 - cpu_do_idle(); 49 - else if (index == 1) 50 - at91_standby(); 51 - 52 - do_gettimeofday(&after); 53 - local_irq_enable(); 54 - idle_time = (after.tv_sec - before.tv_sec) * USEC_PER_SEC + 55 - (after.tv_usec - before.tv_usec); 56 - 57 - dev->last_residency = idle_time; 58 37 return index; 59 38 } 39 + 40 + static struct cpuidle_driver at91_idle_driver = { 41 + .name = "at91_idle", 42 + .owner = THIS_MODULE, 43 + .en_core_tk_irqen = 1, 44 + .states[0] = ARM_CPUIDLE_WFI_STATE, 45 + .states[1] = { 46 + .enter = at91_enter_idle, 47 + .exit_latency = 10, 48 + .target_residency = 100000, 49 + .flags = CPUIDLE_FLAG_TIME_VALID, 50 + .name = "RAM_SR", 51 + .desc = "WFI and DDR Self Refresh", 52 + }, 53 + .state_count = AT91_MAX_STATES, 54 + }; 60 55 61 56 /* Initialize CPU idle by registering the idle states */ 62 57 static int at91_init_cpuidle(void) 63 58 { 64 59 struct cpuidle_device *device; 65 - struct cpuidle_driver *driver = &at91_idle_driver; 66 60 67 61 device = &per_cpu(at91_cpuidle_device, smp_processor_id()); 68 62 device->state_count = AT91_MAX_STATES; 69 - driver->state_count = AT91_MAX_STATES; 70 - 71 - /* Wait for interrupt state */ 72 - driver->states[0].enter = at91_enter_idle; 73 - driver->states[0].exit_latency = 1; 74 - driver->states[0].target_residency = 10000; 75 - driver->states[0].flags = CPUIDLE_FLAG_TIME_VALID; 76 - strcpy(driver->states[0].name, "WFI"); 77 - strcpy(driver->states[0].desc, "Wait for interrupt"); 78 - 79 - /* Wait for interrupt and RAM self refresh state */ 80 - driver->states[1].enter = at91_enter_idle; 81 - driver->states[1].exit_latency = 10; 82 - driver->states[1].target_residency = 10000; 83 - driver->states[1].flags = CPUIDLE_FLAG_TIME_VALID; 84 - strcpy(driver->states[1].name, "RAM_SR"); 85 - strcpy(driver->states[1].desc, "WFI and RAM Self Refresh"); 86 63 87 64 cpuidle_register_driver(&at91_idle_driver); 88 65
+34 -49
arch/arm/mach-davinci/cpuidle.c
··· 18 18 #include <linux/io.h> 19 19 #include <linux/export.h> 20 20 #include <asm/proc-fns.h> 21 + #include <asm/cpuidle.h> 21 22 22 23 #include <mach/cpuidle.h> 23 24 #include <mach/ddr2.h> ··· 31 30 u32 flags; 32 31 }; 33 32 33 + /* Actual code that puts the SoC in different idle states */ 34 + static int davinci_enter_idle(struct cpuidle_device *dev, 35 + struct cpuidle_driver *drv, 36 + int index) 37 + { 38 + struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; 39 + struct davinci_ops *ops = cpuidle_get_statedata(state_usage); 40 + 41 + if (ops && ops->enter) 42 + ops->enter(ops->flags); 43 + 44 + index = cpuidle_wrap_enter(dev, drv, index, 45 + arm_cpuidle_simple_enter); 46 + 47 + if (ops && ops->exit) 48 + ops->exit(ops->flags); 49 + 50 + return index; 51 + } 52 + 34 53 /* fields in davinci_ops.flags */ 35 54 #define DAVINCI_CPUIDLE_FLAGS_DDR2_PWDN BIT(0) 36 55 37 56 static struct cpuidle_driver davinci_idle_driver = { 38 - .name = "cpuidle-davinci", 39 - .owner = THIS_MODULE, 57 + .name = "cpuidle-davinci", 58 + .owner = THIS_MODULE, 59 + .en_core_tk_irqen = 1, 60 + .states[0] = ARM_CPUIDLE_WFI_STATE, 61 + .states[1] = { 62 + .enter = davinci_enter_idle, 63 + .exit_latency = 10, 64 + .target_residency = 100000, 65 + .flags = CPUIDLE_FLAG_TIME_VALID, 66 + .name = "DDR SR", 67 + .desc = "WFI and DDR Self Refresh", 68 + }, 69 + .state_count = DAVINCI_CPUIDLE_MAX_STATES, 40 70 }; 41 71 42 72 static DEFINE_PER_CPU(struct cpuidle_device, davinci_cpuidle_device); ··· 109 77 }, 110 78 }; 111 79 112 - /* Actual code that puts the SoC in different idle states */ 113 - static int davinci_enter_idle(struct cpuidle_device *dev, 114 - struct cpuidle_driver *drv, 115 - int index) 116 - { 117 - struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; 118 - struct davinci_ops *ops = cpuidle_get_statedata(state_usage); 119 - struct timeval before, after; 120 - int idle_time; 121 - 122 - local_irq_disable(); 123 - do_gettimeofday(&before); 124 - 125 - if (ops && ops->enter) 126 - ops->enter(ops->flags); 127 - /* Wait for interrupt state */ 128 - cpu_do_idle(); 129 - if (ops && ops->exit) 130 - ops->exit(ops->flags); 131 - 132 - do_gettimeofday(&after); 133 - local_irq_enable(); 134 - idle_time = (after.tv_sec - before.tv_sec) * USEC_PER_SEC + 135 - (after.tv_usec - before.tv_usec); 136 - 137 - dev->last_residency = idle_time; 138 - 139 - return index; 140 - } 141 - 142 80 static int __init davinci_cpuidle_probe(struct platform_device *pdev) 143 81 { 144 82 int ret; 145 83 struct cpuidle_device *device; 146 - struct cpuidle_driver *driver = &davinci_idle_driver; 147 84 struct davinci_cpuidle_config *pdata = pdev->dev.platform_data; 148 85 149 86 device = &per_cpu(davinci_cpuidle_device, smp_processor_id()); ··· 124 123 125 124 ddr2_reg_base = pdata->ddr2_ctlr_base; 126 125 127 - /* Wait for interrupt state */ 128 - driver->states[0].enter = davinci_enter_idle; 129 - driver->states[0].exit_latency = 1; 130 - driver->states[0].target_residency = 10000; 131 - driver->states[0].flags = CPUIDLE_FLAG_TIME_VALID; 132 - strcpy(driver->states[0].name, "WFI"); 133 - strcpy(driver->states[0].desc, "Wait for interrupt"); 134 - 135 - /* Wait for interrupt and DDR self refresh state */ 136 - driver->states[1].enter = davinci_enter_idle; 137 - driver->states[1].exit_latency = 10; 138 - driver->states[1].target_residency = 10000; 139 - driver->states[1].flags = CPUIDLE_FLAG_TIME_VALID; 140 - strcpy(driver->states[1].name, "DDR SR"); 141 - strcpy(driver->states[1].desc, "WFI and DDR Self Refresh"); 142 126 if (pdata->ddr2_pdown) 143 127 davinci_states[1].flags |= DAVINCI_CPUIDLE_FLAGS_DDR2_PWDN; 144 128 cpuidle_set_statedata(&device->states_usage[1], &davinci_states[1]); 145 129 146 130 device->state_count = DAVINCI_CPUIDLE_MAX_STATES; 147 - driver->state_count = DAVINCI_CPUIDLE_MAX_STATES; 148 131 149 132 ret = cpuidle_register_driver(&davinci_idle_driver); 150 133 if (ret) {
+21 -51
arch/arm/mach-kirkwood/cpuidle.c
··· 20 20 #include <linux/io.h> 21 21 #include <linux/export.h> 22 22 #include <asm/proc-fns.h> 23 + #include <asm/cpuidle.h> 23 24 #include <mach/kirkwood.h> 24 25 25 26 #define KIRKWOOD_MAX_STATES 2 26 - 27 - static struct cpuidle_driver kirkwood_idle_driver = { 28 - .name = "kirkwood_idle", 29 - .owner = THIS_MODULE, 30 - }; 31 - 32 - static DEFINE_PER_CPU(struct cpuidle_device, kirkwood_cpuidle_device); 33 27 34 28 /* Actual code that puts the SoC in different idle states */ 35 29 static int kirkwood_enter_idle(struct cpuidle_device *dev, 36 30 struct cpuidle_driver *drv, 37 31 int index) 38 32 { 39 - struct timeval before, after; 40 - int idle_time; 41 - 42 - local_irq_disable(); 43 - do_gettimeofday(&before); 44 - if (index == 0) 45 - /* Wait for interrupt state */ 46 - cpu_do_idle(); 47 - else if (index == 1) { 48 - /* 49 - * Following write will put DDR in self refresh. 50 - * Note that we have 256 cycles before DDR puts it 51 - * self in self-refresh, so the wait-for-interrupt 52 - * call afterwards won't get the DDR from self refresh 53 - * mode. 54 - */ 55 - writel(0x7, DDR_OPERATION_BASE); 56 - cpu_do_idle(); 57 - } 58 - do_gettimeofday(&after); 59 - local_irq_enable(); 60 - idle_time = (after.tv_sec - before.tv_sec) * USEC_PER_SEC + 61 - (after.tv_usec - before.tv_usec); 62 - 63 - /* Update last residency */ 64 - dev->last_residency = idle_time; 33 + writel(0x7, DDR_OPERATION_BASE); 34 + cpu_do_idle(); 65 35 66 36 return index; 67 37 } 38 + 39 + static struct cpuidle_driver kirkwood_idle_driver = { 40 + .name = "kirkwood_idle", 41 + .owner = THIS_MODULE, 42 + .en_core_tk_irqen = 1, 43 + .states[0] = ARM_CPUIDLE_WFI_STATE, 44 + .states[1] = { 45 + .enter = kirkwood_enter_idle, 46 + .exit_latency = 10, 47 + .target_residency = 100000, 48 + .flags = CPUIDLE_FLAG_TIME_VALID, 49 + .name = "DDR SR", 50 + .desc = "WFI and DDR Self Refresh", 51 + }, 52 + .state_count = KIRKWOOD_MAX_STATES, 53 + }; 54 + 55 + static DEFINE_PER_CPU(struct cpuidle_device, kirkwood_cpuidle_device); 68 56 69 57 /* Initialize CPU idle by registering the idle states */ 70 58 static int kirkwood_init_cpuidle(void) 71 59 { 72 60 struct cpuidle_device *device; 73 - struct cpuidle_driver *driver = &kirkwood_idle_driver; 74 61 75 62 device = &per_cpu(kirkwood_cpuidle_device, smp_processor_id()); 76 63 device->state_count = KIRKWOOD_MAX_STATES; 77 - driver->state_count = KIRKWOOD_MAX_STATES; 78 - 79 - /* Wait for interrupt state */ 80 - driver->states[0].enter = kirkwood_enter_idle; 81 - driver->states[0].exit_latency = 1; 82 - driver->states[0].target_residency = 10000; 83 - driver->states[0].flags = CPUIDLE_FLAG_TIME_VALID; 84 - strcpy(driver->states[0].name, "WFI"); 85 - strcpy(driver->states[0].desc, "Wait for interrupt"); 86 - 87 - /* Wait for interrupt and DDR self refresh state */ 88 - driver->states[1].enter = kirkwood_enter_idle; 89 - driver->states[1].exit_latency = 10; 90 - driver->states[1].target_residency = 10000; 91 - driver->states[1].flags = CPUIDLE_FLAG_TIME_VALID; 92 - strcpy(driver->states[1].name, "DDR SR"); 93 - strcpy(driver->states[1].desc, "WFI and DDR Self Refresh"); 94 64 95 65 cpuidle_register_driver(&kirkwood_idle_driver); 96 66 if (cpuidle_register_device(device)) {
+17 -25
arch/arm/mach-omap2/cpuidle34xx.c
··· 87 87 return 0; 88 88 } 89 89 90 - /** 91 - * omap3_enter_idle - Programs OMAP3 to enter the specified state 92 - * @dev: cpuidle device 93 - * @drv: cpuidle driver 94 - * @index: the index of state to be entered 95 - * 96 - * Called from the CPUidle framework to program the device to the 97 - * specified target state selected by the governor. 98 - */ 99 - static int omap3_enter_idle(struct cpuidle_device *dev, 90 + static int __omap3_enter_idle(struct cpuidle_device *dev, 100 91 struct cpuidle_driver *drv, 101 92 int index) 102 93 { 103 94 struct omap3_idle_statedata *cx = 104 95 cpuidle_get_statedata(&dev->states_usage[index]); 105 - struct timespec ts_preidle, ts_postidle, ts_idle; 106 96 u32 mpu_state = cx->mpu_state, core_state = cx->core_state; 107 - int idle_time; 108 97 109 - /* Used to keep track of the total time in idle */ 110 - getnstimeofday(&ts_preidle); 111 - 112 - local_irq_disable(); 113 98 local_fiq_disable(); 114 99 115 100 pwrdm_set_next_pwrst(mpu_pd, mpu_state); ··· 133 148 } 134 149 135 150 return_sleep_time: 136 - getnstimeofday(&ts_postidle); 137 - ts_idle = timespec_sub(ts_postidle, ts_preidle); 138 151 139 - local_irq_enable(); 140 152 local_fiq_enable(); 141 153 142 - idle_time = ts_idle.tv_nsec / NSEC_PER_USEC + ts_idle.tv_sec * \ 143 - USEC_PER_SEC; 144 - 145 - /* Update cpuidle counters */ 146 - dev->last_residency = idle_time; 147 - 148 154 return index; 155 + } 156 + 157 + /** 158 + * omap3_enter_idle - Programs OMAP3 to enter the specified state 159 + * @dev: cpuidle device 160 + * @drv: cpuidle driver 161 + * @index: the index of state to be entered 162 + * 163 + * Called from the CPUidle framework to program the device to the 164 + * specified target state selected by the governor. 165 + */ 166 + static inline int omap3_enter_idle(struct cpuidle_device *dev, 167 + struct cpuidle_driver *drv, 168 + int index) 169 + { 170 + return cpuidle_wrap_enter(dev, drv, index, __omap3_enter_idle); 149 171 } 150 172 151 173 /**
+3 -18
arch/arm/mach-omap2/cpuidle44xx.c
··· 62 62 { 63 63 struct omap4_idle_statedata *cx = 64 64 cpuidle_get_statedata(&dev->states_usage[index]); 65 - struct timespec ts_preidle, ts_postidle, ts_idle; 66 65 u32 cpu1_state; 67 - int idle_time; 68 66 int cpu_id = smp_processor_id(); 69 67 70 - /* Used to keep track of the total time in idle */ 71 - getnstimeofday(&ts_preidle); 72 - 73 - local_irq_disable(); 74 68 local_fiq_disable(); 75 69 76 70 /* ··· 122 128 if (index > 0) 123 129 clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &cpu_id); 124 130 125 - getnstimeofday(&ts_postidle); 126 - ts_idle = timespec_sub(ts_postidle, ts_preidle); 127 - 128 - local_irq_enable(); 129 131 local_fiq_enable(); 130 - 131 - idle_time = ts_idle.tv_nsec / NSEC_PER_USEC + ts_idle.tv_sec * \ 132 - USEC_PER_SEC; 133 - 134 - /* Update cpuidle counters */ 135 - dev->last_residency = idle_time; 136 132 137 133 return index; 138 134 } ··· 130 146 DEFINE_PER_CPU(struct cpuidle_device, omap4_idle_dev); 131 147 132 148 struct cpuidle_driver omap4_idle_driver = { 133 - .name = "omap4_idle", 134 - .owner = THIS_MODULE, 149 + .name = "omap4_idle", 150 + .owner = THIS_MODULE, 151 + .en_core_tk_irqen = 1, 135 152 }; 136 153 137 154 static inline void _fill_cstate(struct cpuidle_driver *drv,
+7 -24
arch/arm/mach-shmobile/cpuidle.c
··· 13 13 #include <linux/suspend.h> 14 14 #include <linux/module.h> 15 15 #include <linux/err.h> 16 + #include <asm/cpuidle.h> 16 17 #include <asm/io.h> 17 18 18 19 static void shmobile_enter_wfi(void) ··· 29 28 struct cpuidle_driver *drv, 30 29 int index) 31 30 { 32 - ktime_t before, after; 33 - 34 - before = ktime_get(); 35 - 36 - local_irq_disable(); 37 - local_fiq_disable(); 38 - 39 31 shmobile_cpuidle_modes[index](); 40 - 41 - local_irq_enable(); 42 - local_fiq_enable(); 43 - 44 - after = ktime_get(); 45 - dev->last_residency = ktime_to_ns(ktime_sub(after, before)) >> 10; 46 32 47 33 return index; 48 34 } 49 35 50 36 static struct cpuidle_device shmobile_cpuidle_dev; 51 37 static struct cpuidle_driver shmobile_cpuidle_driver = { 52 - .name = "shmobile_cpuidle", 53 - .owner = THIS_MODULE, 54 - .states[0] = { 55 - .name = "C1", 56 - .desc = "WFI", 57 - .exit_latency = 1, 58 - .target_residency = 1 * 2, 59 - .flags = CPUIDLE_FLAG_TIME_VALID, 60 - }, 61 - .safe_state_index = 0, /* C1 */ 62 - .state_count = 1, 38 + .name = "shmobile_cpuidle", 39 + .owner = THIS_MODULE, 40 + .en_core_tk_irqen = 1, 41 + .states[0] = ARM_CPUIDLE_WFI_STATE, 42 + .safe_state_index = 0, /* C1 */ 43 + .state_count = 1, 63 44 }; 64 45 65 46 void (*shmobile_cpuidle_setup)(struct cpuidle_driver *drv);
+3 -7
arch/sh/kernel/cpu/shmobile/cpuidle.c
··· 29 29 int index) 30 30 { 31 31 unsigned long allowed_mode = SUSP_SH_SLEEP; 32 - ktime_t before, after; 33 32 int requested_state = index; 34 33 int allowed_state; 35 34 int k; ··· 46 47 */ 47 48 k = min_t(int, allowed_state, requested_state); 48 49 49 - before = ktime_get(); 50 50 sh_mobile_call_standby(cpuidle_mode[k]); 51 - after = ktime_get(); 52 - 53 - dev->last_residency = (int)ktime_to_ns(ktime_sub(after, before)) >> 10; 54 51 55 52 return k; 56 53 } 57 54 58 55 static struct cpuidle_device cpuidle_dev; 59 56 static struct cpuidle_driver cpuidle_driver = { 60 - .name = "sh_idle", 61 - .owner = THIS_MODULE, 57 + .name = "sh_idle", 58 + .owner = THIS_MODULE, 59 + .en_core_tk_irqen = 1, 62 60 }; 63 61 64 62 void sh_mobile_setup_cpuidle(void)
+2 -1
arch/x86/kernel/acpi/boot.c
··· 642 642 kfree(buffer.pointer); 643 643 buffer.length = ACPI_ALLOCATE_BUFFER; 644 644 buffer.pointer = NULL; 645 + lapic = NULL; 645 646 646 647 if (!alloc_cpumask_var(&tmp_map, GFP_KERNEL)) 647 648 goto out; ··· 651 650 goto free_tmp_map; 652 651 653 652 cpumask_copy(tmp_map, cpu_present_mask); 654 - acpi_register_lapic(physid, lapic->lapic_flags & ACPI_MADT_ENABLED); 653 + acpi_register_lapic(physid, ACPI_MADT_ENABLED); 655 654 656 655 /* 657 656 * If mp_register_lapic successfully generates a new logical cpu
+3 -1
arch/x86/kernel/smpboot.c
··· 50 50 #include <linux/tboot.h> 51 51 #include <linux/stackprotector.h> 52 52 #include <linux/gfp.h> 53 + #include <linux/cpuidle.h> 53 54 54 55 #include <asm/acpi.h> 55 56 #include <asm/desc.h> ··· 1405 1404 tboot_shutdown(TB_SHUTDOWN_WFS); 1406 1405 1407 1406 mwait_play_dead(); /* Only returns on failure */ 1408 - hlt_play_dead(); 1407 + if (cpuidle_play_dead()) 1408 + hlt_play_dead(); 1409 1409 } 1410 1410 1411 1411 #else /* ... !CONFIG_HOTPLUG_CPU */
+6 -3
arch/x86/kernel/tboot.c
··· 272 272 offsetof(struct acpi_table_facs, firmware_waking_vector); 273 273 } 274 274 275 - void tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control) 275 + static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control) 276 276 { 277 277 static u32 acpi_shutdown_map[ACPI_S_STATE_COUNT] = { 278 278 /* S0,1,2: */ -1, -1, -1, ··· 281 281 /* S5: */ TB_SHUTDOWN_S5 }; 282 282 283 283 if (!tboot_enabled()) 284 - return; 284 + return 0; 285 285 286 286 tboot_copy_fadt(&acpi_gbl_FADT); 287 287 tboot->acpi_sinfo.pm1a_cnt_val = pm1a_control; ··· 292 292 if (sleep_state >= ACPI_S_STATE_COUNT || 293 293 acpi_shutdown_map[sleep_state] == -1) { 294 294 pr_warning("unsupported sleep state 0x%x\n", sleep_state); 295 - return; 295 + return -1; 296 296 } 297 297 298 298 tboot_shutdown(acpi_shutdown_map[sleep_state]); 299 + return 0; 299 300 } 300 301 301 302 static atomic_t ap_wfs_count; ··· 346 345 347 346 atomic_set(&ap_wfs_count, 0); 348 347 register_hotcpu_notifier(&tboot_cpu_notifier); 348 + 349 + acpi_os_set_prepare_sleep(&tboot_sleep); 349 350 return 0; 350 351 } 351 352
+9
drivers/acpi/Kconfig
··· 384 384 load additional kernel modules after boot, this feature may be used 385 385 to override that restriction). 386 386 387 + config ACPI_BGRT 388 + tristate "Boottime Graphics Resource Table support" 389 + default n 390 + help 391 + This driver adds support for exposing the ACPI Boottime Graphics 392 + Resource Table, which allows the operating system to obtain 393 + data from the firmware boot splash. It will appear under 394 + /sys/firmware/acpi/bgrt/ . 395 + 387 396 source "drivers/acpi/apei/Kconfig" 388 397 389 398 endif # ACPI
+1
drivers/acpi/Makefile
··· 62 62 obj-$(CONFIG_ACPI_HED) += hed.o 63 63 obj-$(CONFIG_ACPI_EC_DEBUGFS) += ec_sys.o 64 64 obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o 65 + obj-$(CONFIG_ACPI_BGRT) += bgrt.o 65 66 66 67 # processor has its own "processor." module_param namespace 67 68 processor-y := processor_driver.o processor_throttling.o
+3 -1
drivers/acpi/acpica/Makefile
··· 68 68 69 69 acpi-y += \ 70 70 hwacpi.o \ 71 + hwesleep.o \ 71 72 hwgpe.o \ 72 73 hwpci.o \ 73 74 hwregs.o \ 74 75 hwsleep.o \ 75 76 hwvalid.o \ 76 - hwxface.o 77 + hwxface.o \ 78 + hwxfsleep.o 77 79 78 80 acpi-$(ACPI_FUTURE_USAGE) += hwtimer.o 79 81
-1
drivers/acpi/acpica/accommon.h
··· 51 51 * 52 52 * Note: The order of these include files is important. 53 53 */ 54 - #include "acconfig.h" /* Global configuration constants */ 55 54 #include "acmacros.h" /* C macros */ 56 55 #include "aclocal.h" /* Internal data types */ 57 56 #include "acobject.h" /* ACPI internal object */
+18 -1
drivers/acpi/acpica/acconfig.h include/acpi/acconfig.h
··· 85 85 */ 86 86 #define ACPI_CHECKSUM_ABORT FALSE 87 87 88 + /* 89 + * Generate a version of ACPICA that only supports "reduced hardware" 90 + * platforms (as defined in ACPI 5.0). Set to TRUE to generate a specialized 91 + * version of ACPICA that ONLY supports the ACPI 5.0 "reduced hardware" 92 + * model. In other words, no ACPI hardware is supported. 93 + * 94 + * If TRUE, this means no support for the following: 95 + * PM Event and Control registers 96 + * SCI interrupt (and handler) 97 + * Fixed Events 98 + * General Purpose Events (GPEs) 99 + * Global Lock 100 + * ACPI PM timer 101 + * FACS table (Waking vectors and Global Lock) 102 + */ 103 + #define ACPI_REDUCED_HARDWARE FALSE 104 + 88 105 /****************************************************************************** 89 106 * 90 107 * Subsystem Constants ··· 110 93 111 94 /* Version of ACPI supported */ 112 95 113 - #define ACPI_CA_SUPPORT_LEVEL 3 96 + #define ACPI_CA_SUPPORT_LEVEL 5 114 97 115 98 /* Maximum count for a semaphore object */ 116 99
+5 -3
drivers/acpi/acpica/acdebug.h
··· 111 111 112 112 void acpi_db_set_scope(char *name); 113 113 114 - acpi_status acpi_db_sleep(char *object_arg); 114 + ACPI_HW_DEPENDENT_RETURN_OK(acpi_status acpi_db_sleep(char *object_arg)) 115 115 116 116 void acpi_db_find_references(char *object_arg); 117 117 ··· 119 119 120 120 void acpi_db_display_resources(char *object_arg); 121 121 122 - void acpi_db_display_gpes(void); 122 + ACPI_HW_DEPENDENT_RETURN_VOID(void acpi_db_display_gpes(void)) 123 123 124 124 void acpi_db_check_integrity(void); 125 125 126 - void acpi_db_generate_gpe(char *gpe_arg, char *block_arg); 126 + ACPI_HW_DEPENDENT_RETURN_VOID(void 127 + acpi_db_generate_gpe(char *gpe_arg, 128 + char *block_arg)) 127 129 128 130 void acpi_db_check_predefined_names(void); 129 131
+11 -10
drivers/acpi/acpica/acevents.h
··· 69 69 */ 70 70 acpi_status acpi_ev_init_global_lock_handler(void); 71 71 72 - acpi_status acpi_ev_acquire_global_lock(u16 timeout); 73 - 74 - acpi_status acpi_ev_release_global_lock(void); 75 - 76 - acpi_status acpi_ev_remove_global_lock_handler(void); 72 + ACPI_HW_DEPENDENT_RETURN_OK(acpi_status 73 + acpi_ev_acquire_global_lock(u16 timeout)) 74 + ACPI_HW_DEPENDENT_RETURN_OK(acpi_status acpi_ev_release_global_lock(void)) 75 + acpi_status acpi_ev_remove_global_lock_handler(void); 77 76 78 77 /* 79 78 * evgpe - Low-level GPE support ··· 113 114 struct acpi_gpe_block_info *gpe_block, 114 115 void *context); 115 116 116 - acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block); 117 + ACPI_HW_DEPENDENT_RETURN_OK(acpi_status 118 + acpi_ev_delete_gpe_block(struct acpi_gpe_block_info 119 + *gpe_block)) 117 120 118 121 u32 119 122 acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device, ··· 127 126 */ 128 127 acpi_status acpi_ev_gpe_initialize(void); 129 128 130 - void acpi_ev_update_gpes(acpi_owner_id table_owner_id); 129 + ACPI_HW_DEPENDENT_RETURN_VOID(void 130 + acpi_ev_update_gpes(acpi_owner_id table_owner_id)) 131 131 132 - acpi_status 132 + acpi_status 133 133 acpi_ev_match_gpe_method(acpi_handle obj_handle, 134 134 u32 level, void *context, void **return_value); 135 135 ··· 239 237 240 238 u32 acpi_ev_initialize_sCI(u32 program_sCI); 241 239 242 - void acpi_ev_terminate(void); 243 - 240 + ACPI_HW_DEPENDENT_RETURN_VOID(void acpi_ev_terminate(void)) 244 241 #endif /* __ACEVENTS_H__ */
+10 -1
drivers/acpi/acpica/acglobal.h
··· 147 147 */ 148 148 u8 acpi_gbl_reduced_hardware; 149 149 150 - #endif 150 + #endif /* DEFINE_ACPI_GLOBALS */ 151 151 152 152 /* Do not disassemble buffers to resource descriptors */ 153 153 ··· 184 184 * found in the RSDT/XSDT. 185 185 */ 186 186 ACPI_EXTERN struct acpi_table_list acpi_gbl_root_table_list; 187 + 188 + #if (!ACPI_REDUCED_HARDWARE) 187 189 ACPI_EXTERN struct acpi_table_facs *acpi_gbl_FACS; 190 + 191 + #endif /* !ACPI_REDUCED_HARDWARE */ 188 192 189 193 /* These addresses are calculated from the FADT Event Block addresses */ 190 194 ··· 401 397 ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head; 402 398 ACPI_EXTERN struct acpi_gpe_block_info 403 399 *acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS]; 400 + 401 + #if (!ACPI_REDUCED_HARDWARE) 402 + 404 403 ACPI_EXTERN u8 acpi_gbl_all_gpes_initialized; 405 404 ACPI_EXTERN ACPI_GBL_EVENT_HANDLER acpi_gbl_global_event_handler; 406 405 ACPI_EXTERN void *acpi_gbl_global_event_handler_context; 406 + 407 + #endif /* !ACPI_REDUCED_HARDWARE */ 407 408 408 409 /***************************************************************************** 409 410 *
+20 -12
drivers/acpi/acpica/achware.h
··· 81 81 acpi_status acpi_hw_clear_acpi_status(void); 82 82 83 83 /* 84 + * hwsleep - sleep/wake support (Legacy sleep registers) 85 + */ 86 + acpi_status acpi_hw_legacy_sleep(u8 sleep_state, u8 flags); 87 + 88 + acpi_status acpi_hw_legacy_wake_prep(u8 sleep_state, u8 flags); 89 + 90 + acpi_status acpi_hw_legacy_wake(u8 sleep_state, u8 flags); 91 + 92 + /* 93 + * hwesleep - sleep/wake support (Extended FADT-V5 sleep registers) 94 + */ 95 + void acpi_hw_execute_sleep_method(char *method_name, u32 integer_argument); 96 + 97 + acpi_status acpi_hw_extended_sleep(u8 sleep_state, u8 flags); 98 + 99 + acpi_status acpi_hw_extended_wake_prep(u8 sleep_state, u8 flags); 100 + 101 + acpi_status acpi_hw_extended_wake(u8 sleep_state, u8 flags); 102 + 103 + /* 84 104 * hwvalid - Port I/O with validation 85 105 */ 86 106 acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width); ··· 147 127 acpi_status 148 128 acpi_hw_derive_pci_id(struct acpi_pci_id *pci_id, 149 129 acpi_handle root_pci_device, acpi_handle pci_region); 150 - 151 - #ifdef ACPI_FUTURE_USAGE 152 - /* 153 - * hwtimer - ACPI Timer prototypes 154 - */ 155 - acpi_status acpi_get_timer_resolution(u32 * resolution); 156 - 157 - acpi_status acpi_get_timer(u32 * ticks); 158 - 159 - acpi_status 160 - acpi_get_timer_duration(u32 start_ticks, u32 end_ticks, u32 * time_elapsed); 161 - #endif /* ACPI_FUTURE_USAGE */ 162 130 163 131 #endif /* __ACHWARE_H__ */
+1
drivers/acpi/acpica/aclocal.h
··· 370 370 /* Defines for Flags field above */ 371 371 372 372 #define ACPI_OBJECT_REPAIRED 1 373 + #define ACPI_OBJECT_WRAPPED 2 373 374 374 375 /* 375 376 * Bitmapped return value types
+6
drivers/acpi/acpica/acmacros.h
··· 516 516 517 517 #endif /* ACPI_DEBUG_OUTPUT */ 518 518 519 + #if (!ACPI_REDUCED_HARDWARE) 520 + #define ACPI_HW_OPTIONAL_FUNCTION(addr) addr 521 + #else 522 + #define ACPI_HW_OPTIONAL_FUNCTION(addr) NULL 523 + #endif 524 + 519 525 /* 520 526 * Some code only gets executed when the debugger is built in. 521 527 * Note that this is entirely independent of whether the
+3 -2
drivers/acpi/acpica/acnamesp.h
··· 283 283 union acpi_operand_object **return_object_ptr); 284 284 285 285 acpi_status 286 - acpi_ns_repair_package_list(struct acpi_predefined_data *data, 287 - union acpi_operand_object **obj_desc_ptr); 286 + acpi_ns_wrap_with_package(struct acpi_predefined_data *data, 287 + union acpi_operand_object *original_object, 288 + union acpi_operand_object **obj_desc_ptr); 288 289 289 290 acpi_status 290 291 acpi_ns_repair_null_element(struct acpi_predefined_data *data,
+5
drivers/acpi/acpica/actables.h
··· 67 67 68 68 acpi_status acpi_tb_verify_table(struct acpi_table_desc *table_desc); 69 69 70 + struct acpi_table_header *acpi_tb_table_override(struct acpi_table_header 71 + *table_header, 72 + struct acpi_table_desc 73 + *table_desc); 74 + 70 75 acpi_status 71 76 acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index); 72 77
+3 -1
drivers/acpi/acpica/evevent.c
··· 47 47 48 48 #define _COMPONENT ACPI_EVENTS 49 49 ACPI_MODULE_NAME("evevent") 50 - 50 + #if (!ACPI_REDUCED_HARDWARE) /* Entire module */ 51 51 /* Local prototypes */ 52 52 static acpi_status acpi_ev_fixed_event_initialize(void); 53 53 ··· 291 291 return ((acpi_gbl_fixed_event_handlers[event]. 292 292 handler) (acpi_gbl_fixed_event_handlers[event].context)); 293 293 } 294 + 295 + #endif /* !ACPI_REDUCED_HARDWARE */
+3 -1
drivers/acpi/acpica/evglock.c
··· 48 48 49 49 #define _COMPONENT ACPI_EVENTS 50 50 ACPI_MODULE_NAME("evglock") 51 - 51 + #if (!ACPI_REDUCED_HARDWARE) /* Entire module */ 52 52 /* Local prototypes */ 53 53 static u32 acpi_ev_global_lock_handler(void *context); 54 54 ··· 339 339 acpi_os_release_mutex(acpi_gbl_global_lock_mutex->mutex.os_mutex); 340 340 return_ACPI_STATUS(status); 341 341 } 342 + 343 + #endif /* !ACPI_REDUCED_HARDWARE */
+3 -1
drivers/acpi/acpica/evgpe.c
··· 48 48 49 49 #define _COMPONENT ACPI_EVENTS 50 50 ACPI_MODULE_NAME("evgpe") 51 - 51 + #if (!ACPI_REDUCED_HARDWARE) /* Entire module */ 52 52 /* Local prototypes */ 53 53 static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context); 54 54 ··· 766 766 767 767 return_UINT32(ACPI_INTERRUPT_HANDLED); 768 768 } 769 + 770 + #endif /* !ACPI_REDUCED_HARDWARE */
+3 -1
drivers/acpi/acpica/evgpeblk.c
··· 48 48 49 49 #define _COMPONENT ACPI_EVENTS 50 50 ACPI_MODULE_NAME("evgpeblk") 51 - 51 + #if (!ACPI_REDUCED_HARDWARE) /* Entire module */ 52 52 /* Local prototypes */ 53 53 static acpi_status 54 54 acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block, ··· 504 504 505 505 return_ACPI_STATUS(AE_OK); 506 506 } 507 + 508 + #endif /* !ACPI_REDUCED_HARDWARE */
+3 -1
drivers/acpi/acpica/evgpeinit.c
··· 48 48 49 49 #define _COMPONENT ACPI_EVENTS 50 50 ACPI_MODULE_NAME("evgpeinit") 51 - 51 + #if (!ACPI_REDUCED_HARDWARE) /* Entire module */ 52 52 /* 53 53 * Note: History of _PRW support in ACPICA 54 54 * ··· 440 440 name, gpe_number)); 441 441 return_ACPI_STATUS(AE_OK); 442 442 } 443 + 444 + #endif /* !ACPI_REDUCED_HARDWARE */
+3
drivers/acpi/acpica/evgpeutil.c
··· 48 48 #define _COMPONENT ACPI_EVENTS 49 49 ACPI_MODULE_NAME("evgpeutil") 50 50 51 + #if (!ACPI_REDUCED_HARDWARE) /* Entire module */ 51 52 /******************************************************************************* 52 53 * 53 54 * FUNCTION: acpi_ev_walk_gpe_list ··· 375 374 376 375 return_ACPI_STATUS(AE_OK); 377 376 } 377 + 378 + #endif /* !ACPI_REDUCED_HARDWARE */
+16 -10
drivers/acpi/acpica/evmisc.c
··· 108 108 ACPI_FUNCTION_NAME(ev_queue_notify_request); 109 109 110 110 /* 111 - * For value 3 (Ejection Request), some device method may need to be run. 112 - * For value 2 (Device Wake) if _PRW exists, the _PS0 method may need 113 - * to be run. 111 + * For value 0x03 (Ejection Request), may need to run a device method. 112 + * For value 0x02 (Device Wake), if _PRW exists, may need to run 113 + * the _PS0 method. 114 114 * For value 0x80 (Status Change) on the power button or sleep button, 115 - * initiate soft-off or sleep operation? 115 + * initiate soft-off or sleep operation. 116 + * 117 + * For all cases, simply dispatch the notify to the handler. 116 118 */ 117 119 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 118 - "Dispatching Notify on [%4.4s] Node %p Value 0x%2.2X (%s)\n", 119 - acpi_ut_get_node_name(node), node, notify_value, 120 - acpi_ut_get_notify_name(notify_value))); 120 + "Dispatching Notify on [%4.4s] (%s) Value 0x%2.2X (%s) Node %p\n", 121 + acpi_ut_get_node_name(node), 122 + acpi_ut_get_type_name(node->type), notify_value, 123 + acpi_ut_get_notify_name(notify_value), node)); 121 124 122 125 /* Get the notify object attached to the NS Node */ 123 126 124 127 obj_desc = acpi_ns_get_attached_object(node); 125 128 if (obj_desc) { 126 129 127 - /* We have the notify object, Get the right handler */ 130 + /* We have the notify object, Get the correct handler */ 128 131 129 132 switch (node->type) { 130 133 131 - /* Notify allowed only on these types */ 134 + /* Notify is allowed only on these types */ 132 135 133 136 case ACPI_TYPE_DEVICE: 134 137 case ACPI_TYPE_THERMAL: ··· 155 152 } 156 153 157 154 /* 158 - * If there is any handler to run, schedule the dispatcher. 155 + * If there is a handler to run, schedule the dispatcher. 159 156 * Check for: 160 157 * 1) Global system notify handler 161 158 * 2) Global device notify handler ··· 273 270 acpi_ut_delete_generic_state(notify_info); 274 271 } 275 272 273 + #if (!ACPI_REDUCED_HARDWARE) 276 274 /****************************************************************************** 277 275 * 278 276 * FUNCTION: acpi_ev_terminate ··· 342 338 } 343 339 return_VOID; 344 340 } 341 + 342 + #endif /* !ACPI_REDUCED_HARDWARE */
+3 -1
drivers/acpi/acpica/evsci.c
··· 48 48 49 49 #define _COMPONENT ACPI_EVENTS 50 50 ACPI_MODULE_NAME("evsci") 51 - 51 + #if (!ACPI_REDUCED_HARDWARE) /* Entire module */ 52 52 /* Local prototypes */ 53 53 static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context); 54 54 ··· 181 181 182 182 return_ACPI_STATUS(status); 183 183 } 184 + 185 + #endif /* !ACPI_REDUCED_HARDWARE */
+220 -216
drivers/acpi/acpica/evxface.c
··· 51 51 #define _COMPONENT ACPI_EVENTS 52 52 ACPI_MODULE_NAME("evxface") 53 53 54 - /******************************************************************************* 55 - * 56 - * FUNCTION: acpi_install_exception_handler 57 - * 58 - * PARAMETERS: Handler - Pointer to the handler function for the 59 - * event 60 - * 61 - * RETURN: Status 62 - * 63 - * DESCRIPTION: Saves the pointer to the handler function 64 - * 65 - ******************************************************************************/ 66 - #ifdef ACPI_FUTURE_USAGE 67 - acpi_status acpi_install_exception_handler(acpi_exception_handler handler) 68 - { 69 - acpi_status status; 70 - 71 - ACPI_FUNCTION_TRACE(acpi_install_exception_handler); 72 - 73 - status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); 74 - if (ACPI_FAILURE(status)) { 75 - return_ACPI_STATUS(status); 76 - } 77 - 78 - /* Don't allow two handlers. */ 79 - 80 - if (acpi_gbl_exception_handler) { 81 - status = AE_ALREADY_EXISTS; 82 - goto cleanup; 83 - } 84 - 85 - /* Install the handler */ 86 - 87 - acpi_gbl_exception_handler = handler; 88 - 89 - cleanup: 90 - (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); 91 - return_ACPI_STATUS(status); 92 - } 93 - 94 - ACPI_EXPORT_SYMBOL(acpi_install_exception_handler) 95 - #endif /* ACPI_FUTURE_USAGE */ 96 - 97 - /******************************************************************************* 98 - * 99 - * FUNCTION: acpi_install_global_event_handler 100 - * 101 - * PARAMETERS: Handler - Pointer to the global event handler function 102 - * Context - Value passed to the handler on each event 103 - * 104 - * RETURN: Status 105 - * 106 - * DESCRIPTION: Saves the pointer to the handler function. The global handler 107 - * is invoked upon each incoming GPE and Fixed Event. It is 108 - * invoked at interrupt level at the time of the event dispatch. 109 - * Can be used to update event counters, etc. 110 - * 111 - ******************************************************************************/ 112 - acpi_status 113 - acpi_install_global_event_handler(ACPI_GBL_EVENT_HANDLER handler, void *context) 114 - { 115 - acpi_status status; 116 - 117 - ACPI_FUNCTION_TRACE(acpi_install_global_event_handler); 118 - 119 - /* Parameter validation */ 120 - 121 - if (!handler) { 122 - return_ACPI_STATUS(AE_BAD_PARAMETER); 123 - } 124 - 125 - status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); 126 - if (ACPI_FAILURE(status)) { 127 - return_ACPI_STATUS(status); 128 - } 129 - 130 - /* Don't allow two handlers. */ 131 - 132 - if (acpi_gbl_global_event_handler) { 133 - status = AE_ALREADY_EXISTS; 134 - goto cleanup; 135 - } 136 - 137 - acpi_gbl_global_event_handler = handler; 138 - acpi_gbl_global_event_handler_context = context; 139 - 140 - cleanup: 141 - (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); 142 - return_ACPI_STATUS(status); 143 - } 144 - 145 - ACPI_EXPORT_SYMBOL(acpi_install_global_event_handler) 146 - 147 - /******************************************************************************* 148 - * 149 - * FUNCTION: acpi_install_fixed_event_handler 150 - * 151 - * PARAMETERS: Event - Event type to enable. 152 - * Handler - Pointer to the handler function for the 153 - * event 154 - * Context - Value passed to the handler on each GPE 155 - * 156 - * RETURN: Status 157 - * 158 - * DESCRIPTION: Saves the pointer to the handler function and then enables the 159 - * event. 160 - * 161 - ******************************************************************************/ 162 - acpi_status 163 - acpi_install_fixed_event_handler(u32 event, 164 - acpi_event_handler handler, void *context) 165 - { 166 - acpi_status status; 167 - 168 - ACPI_FUNCTION_TRACE(acpi_install_fixed_event_handler); 169 - 170 - /* Parameter validation */ 171 - 172 - if (event > ACPI_EVENT_MAX) { 173 - return_ACPI_STATUS(AE_BAD_PARAMETER); 174 - } 175 - 176 - status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); 177 - if (ACPI_FAILURE(status)) { 178 - return_ACPI_STATUS(status); 179 - } 180 - 181 - /* Don't allow two handlers. */ 182 - 183 - if (NULL != acpi_gbl_fixed_event_handlers[event].handler) { 184 - status = AE_ALREADY_EXISTS; 185 - goto cleanup; 186 - } 187 - 188 - /* Install the handler before enabling the event */ 189 - 190 - acpi_gbl_fixed_event_handlers[event].handler = handler; 191 - acpi_gbl_fixed_event_handlers[event].context = context; 192 - 193 - status = acpi_clear_event(event); 194 - if (ACPI_SUCCESS(status)) 195 - status = acpi_enable_event(event, 0); 196 - if (ACPI_FAILURE(status)) { 197 - ACPI_WARNING((AE_INFO, "Could not enable fixed event 0x%X", 198 - event)); 199 - 200 - /* Remove the handler */ 201 - 202 - acpi_gbl_fixed_event_handlers[event].handler = NULL; 203 - acpi_gbl_fixed_event_handlers[event].context = NULL; 204 - } else { 205 - ACPI_DEBUG_PRINT((ACPI_DB_INFO, 206 - "Enabled fixed event %X, Handler=%p\n", event, 207 - handler)); 208 - } 209 - 210 - cleanup: 211 - (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); 212 - return_ACPI_STATUS(status); 213 - } 214 - 215 - ACPI_EXPORT_SYMBOL(acpi_install_fixed_event_handler) 216 - 217 - /******************************************************************************* 218 - * 219 - * FUNCTION: acpi_remove_fixed_event_handler 220 - * 221 - * PARAMETERS: Event - Event type to disable. 222 - * Handler - Address of the handler 223 - * 224 - * RETURN: Status 225 - * 226 - * DESCRIPTION: Disables the event and unregisters the event handler. 227 - * 228 - ******************************************************************************/ 229 - acpi_status 230 - acpi_remove_fixed_event_handler(u32 event, acpi_event_handler handler) 231 - { 232 - acpi_status status = AE_OK; 233 - 234 - ACPI_FUNCTION_TRACE(acpi_remove_fixed_event_handler); 235 - 236 - /* Parameter validation */ 237 - 238 - if (event > ACPI_EVENT_MAX) { 239 - return_ACPI_STATUS(AE_BAD_PARAMETER); 240 - } 241 - 242 - status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); 243 - if (ACPI_FAILURE(status)) { 244 - return_ACPI_STATUS(status); 245 - } 246 - 247 - /* Disable the event before removing the handler */ 248 - 249 - status = acpi_disable_event(event, 0); 250 - 251 - /* Always Remove the handler */ 252 - 253 - acpi_gbl_fixed_event_handlers[event].handler = NULL; 254 - acpi_gbl_fixed_event_handlers[event].context = NULL; 255 - 256 - if (ACPI_FAILURE(status)) { 257 - ACPI_WARNING((AE_INFO, 258 - "Could not write to fixed event enable register 0x%X", 259 - event)); 260 - } else { 261 - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Disabled fixed event %X\n", 262 - event)); 263 - } 264 - 265 - (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); 266 - return_ACPI_STATUS(status); 267 - } 268 - 269 - ACPI_EXPORT_SYMBOL(acpi_remove_fixed_event_handler) 270 54 271 55 /******************************************************************************* 272 56 * ··· 117 333 118 334 return AE_OK; 119 335 } 336 + 120 337 121 338 /******************************************************************************* 122 339 * ··· 490 705 491 706 /******************************************************************************* 492 707 * 708 + * FUNCTION: acpi_install_exception_handler 709 + * 710 + * PARAMETERS: Handler - Pointer to the handler function for the 711 + * event 712 + * 713 + * RETURN: Status 714 + * 715 + * DESCRIPTION: Saves the pointer to the handler function 716 + * 717 + ******************************************************************************/ 718 + #ifdef ACPI_FUTURE_USAGE 719 + acpi_status acpi_install_exception_handler(acpi_exception_handler handler) 720 + { 721 + acpi_status status; 722 + 723 + ACPI_FUNCTION_TRACE(acpi_install_exception_handler); 724 + 725 + status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); 726 + if (ACPI_FAILURE(status)) { 727 + return_ACPI_STATUS(status); 728 + } 729 + 730 + /* Don't allow two handlers. */ 731 + 732 + if (acpi_gbl_exception_handler) { 733 + status = AE_ALREADY_EXISTS; 734 + goto cleanup; 735 + } 736 + 737 + /* Install the handler */ 738 + 739 + acpi_gbl_exception_handler = handler; 740 + 741 + cleanup: 742 + (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); 743 + return_ACPI_STATUS(status); 744 + } 745 + 746 + ACPI_EXPORT_SYMBOL(acpi_install_exception_handler) 747 + #endif /* ACPI_FUTURE_USAGE */ 748 + 749 + #if (!ACPI_REDUCED_HARDWARE) 750 + /******************************************************************************* 751 + * 752 + * FUNCTION: acpi_install_global_event_handler 753 + * 754 + * PARAMETERS: Handler - Pointer to the global event handler function 755 + * Context - Value passed to the handler on each event 756 + * 757 + * RETURN: Status 758 + * 759 + * DESCRIPTION: Saves the pointer to the handler function. The global handler 760 + * is invoked upon each incoming GPE and Fixed Event. It is 761 + * invoked at interrupt level at the time of the event dispatch. 762 + * Can be used to update event counters, etc. 763 + * 764 + ******************************************************************************/ 765 + acpi_status 766 + acpi_install_global_event_handler(ACPI_GBL_EVENT_HANDLER handler, void *context) 767 + { 768 + acpi_status status; 769 + 770 + ACPI_FUNCTION_TRACE(acpi_install_global_event_handler); 771 + 772 + /* Parameter validation */ 773 + 774 + if (!handler) { 775 + return_ACPI_STATUS(AE_BAD_PARAMETER); 776 + } 777 + 778 + status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); 779 + if (ACPI_FAILURE(status)) { 780 + return_ACPI_STATUS(status); 781 + } 782 + 783 + /* Don't allow two handlers. */ 784 + 785 + if (acpi_gbl_global_event_handler) { 786 + status = AE_ALREADY_EXISTS; 787 + goto cleanup; 788 + } 789 + 790 + acpi_gbl_global_event_handler = handler; 791 + acpi_gbl_global_event_handler_context = context; 792 + 793 + cleanup: 794 + (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); 795 + return_ACPI_STATUS(status); 796 + } 797 + 798 + ACPI_EXPORT_SYMBOL(acpi_install_global_event_handler) 799 + 800 + /******************************************************************************* 801 + * 802 + * FUNCTION: acpi_install_fixed_event_handler 803 + * 804 + * PARAMETERS: Event - Event type to enable. 805 + * Handler - Pointer to the handler function for the 806 + * event 807 + * Context - Value passed to the handler on each GPE 808 + * 809 + * RETURN: Status 810 + * 811 + * DESCRIPTION: Saves the pointer to the handler function and then enables the 812 + * event. 813 + * 814 + ******************************************************************************/ 815 + acpi_status 816 + acpi_install_fixed_event_handler(u32 event, 817 + acpi_event_handler handler, void *context) 818 + { 819 + acpi_status status; 820 + 821 + ACPI_FUNCTION_TRACE(acpi_install_fixed_event_handler); 822 + 823 + /* Parameter validation */ 824 + 825 + if (event > ACPI_EVENT_MAX) { 826 + return_ACPI_STATUS(AE_BAD_PARAMETER); 827 + } 828 + 829 + status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); 830 + if (ACPI_FAILURE(status)) { 831 + return_ACPI_STATUS(status); 832 + } 833 + 834 + /* Don't allow two handlers. */ 835 + 836 + if (NULL != acpi_gbl_fixed_event_handlers[event].handler) { 837 + status = AE_ALREADY_EXISTS; 838 + goto cleanup; 839 + } 840 + 841 + /* Install the handler before enabling the event */ 842 + 843 + acpi_gbl_fixed_event_handlers[event].handler = handler; 844 + acpi_gbl_fixed_event_handlers[event].context = context; 845 + 846 + status = acpi_clear_event(event); 847 + if (ACPI_SUCCESS(status)) 848 + status = acpi_enable_event(event, 0); 849 + if (ACPI_FAILURE(status)) { 850 + ACPI_WARNING((AE_INFO, "Could not enable fixed event 0x%X", 851 + event)); 852 + 853 + /* Remove the handler */ 854 + 855 + acpi_gbl_fixed_event_handlers[event].handler = NULL; 856 + acpi_gbl_fixed_event_handlers[event].context = NULL; 857 + } else { 858 + ACPI_DEBUG_PRINT((ACPI_DB_INFO, 859 + "Enabled fixed event %X, Handler=%p\n", event, 860 + handler)); 861 + } 862 + 863 + cleanup: 864 + (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); 865 + return_ACPI_STATUS(status); 866 + } 867 + 868 + ACPI_EXPORT_SYMBOL(acpi_install_fixed_event_handler) 869 + 870 + /******************************************************************************* 871 + * 872 + * FUNCTION: acpi_remove_fixed_event_handler 873 + * 874 + * PARAMETERS: Event - Event type to disable. 875 + * Handler - Address of the handler 876 + * 877 + * RETURN: Status 878 + * 879 + * DESCRIPTION: Disables the event and unregisters the event handler. 880 + * 881 + ******************************************************************************/ 882 + acpi_status 883 + acpi_remove_fixed_event_handler(u32 event, acpi_event_handler handler) 884 + { 885 + acpi_status status = AE_OK; 886 + 887 + ACPI_FUNCTION_TRACE(acpi_remove_fixed_event_handler); 888 + 889 + /* Parameter validation */ 890 + 891 + if (event > ACPI_EVENT_MAX) { 892 + return_ACPI_STATUS(AE_BAD_PARAMETER); 893 + } 894 + 895 + status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); 896 + if (ACPI_FAILURE(status)) { 897 + return_ACPI_STATUS(status); 898 + } 899 + 900 + /* Disable the event before removing the handler */ 901 + 902 + status = acpi_disable_event(event, 0); 903 + 904 + /* Always Remove the handler */ 905 + 906 + acpi_gbl_fixed_event_handlers[event].handler = NULL; 907 + acpi_gbl_fixed_event_handlers[event].context = NULL; 908 + 909 + if (ACPI_FAILURE(status)) { 910 + ACPI_WARNING((AE_INFO, 911 + "Could not write to fixed event enable register 0x%X", 912 + event)); 913 + } else { 914 + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Disabled fixed event %X\n", 915 + event)); 916 + } 917 + 918 + (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); 919 + return_ACPI_STATUS(status); 920 + } 921 + 922 + ACPI_EXPORT_SYMBOL(acpi_remove_fixed_event_handler) 923 + 924 + /******************************************************************************* 925 + * 493 926 * FUNCTION: acpi_install_gpe_handler 494 927 * 495 928 * PARAMETERS: gpe_device - Namespace node for the GPE (NULL for FADT ··· 987 984 } 988 985 989 986 ACPI_EXPORT_SYMBOL(acpi_release_global_lock) 987 + #endif /* !ACPI_REDUCED_HARDWARE */
+2
drivers/acpi/acpica/evxfevnt.c
··· 49 49 #define _COMPONENT ACPI_EVENTS 50 50 ACPI_MODULE_NAME("evxfevnt") 51 51 52 + #if (!ACPI_REDUCED_HARDWARE) /* Entire module */ 52 53 /******************************************************************************* 53 54 * 54 55 * FUNCTION: acpi_enable ··· 353 352 } 354 353 355 354 ACPI_EXPORT_SYMBOL(acpi_get_event_status) 355 + #endif /* !ACPI_REDUCED_HARDWARE */
+2
drivers/acpi/acpica/evxfgpe.c
··· 50 50 #define _COMPONENT ACPI_EVENTS 51 51 ACPI_MODULE_NAME("evxfgpe") 52 52 53 + #if (!ACPI_REDUCED_HARDWARE) /* Entire module */ 53 54 /****************************************************************************** 54 55 * 55 56 * FUNCTION: acpi_update_all_gpes ··· 696 695 } 697 696 698 697 ACPI_EXPORT_SYMBOL(acpi_get_gpe_device) 698 + #endif /* !ACPI_REDUCED_HARDWARE */
+3
drivers/acpi/acpica/hwacpi.c
··· 48 48 #define _COMPONENT ACPI_HARDWARE 49 49 ACPI_MODULE_NAME("hwacpi") 50 50 51 + #if (!ACPI_REDUCED_HARDWARE) /* Entire module */ 51 52 /****************************************************************************** 52 53 * 53 54 * FUNCTION: acpi_hw_set_mode ··· 167 166 return_UINT32(ACPI_SYS_MODE_LEGACY); 168 167 } 169 168 } 169 + 170 + #endif /* !ACPI_REDUCED_HARDWARE */
+247
drivers/acpi/acpica/hwesleep.c
··· 1 + /****************************************************************************** 2 + * 3 + * Name: hwesleep.c - ACPI Hardware Sleep/Wake Support functions for the 4 + * extended FADT-V5 sleep registers. 5 + * 6 + *****************************************************************************/ 7 + 8 + /* 9 + * Copyright (C) 2000 - 2012, Intel Corp. 10 + * All rights reserved. 11 + * 12 + * Redistribution and use in source and binary forms, with or without 13 + * modification, are permitted provided that the following conditions 14 + * are met: 15 + * 1. Redistributions of source code must retain the above copyright 16 + * notice, this list of conditions, and the following disclaimer, 17 + * without modification. 18 + * 2. Redistributions in binary form must reproduce at minimum a disclaimer 19 + * substantially similar to the "NO WARRANTY" disclaimer below 20 + * ("Disclaimer") and any redistribution must be conditioned upon 21 + * including a substantially similar Disclaimer requirement for further 22 + * binary redistribution. 23 + * 3. Neither the names of the above-listed copyright holders nor the names 24 + * of any contributors may be used to endorse or promote products derived 25 + * from this software without specific prior written permission. 26 + * 27 + * Alternatively, this software may be distributed under the terms of the 28 + * GNU General Public License ("GPL") version 2 as published by the Free 29 + * Software Foundation. 30 + * 31 + * NO WARRANTY 32 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 33 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 34 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 35 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 36 + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 38 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 39 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 40 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 41 + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 42 + * POSSIBILITY OF SUCH DAMAGES. 43 + */ 44 + 45 + #include <acpi/acpi.h> 46 + #include "accommon.h" 47 + 48 + #define _COMPONENT ACPI_HARDWARE 49 + ACPI_MODULE_NAME("hwesleep") 50 + 51 + /******************************************************************************* 52 + * 53 + * FUNCTION: acpi_hw_execute_sleep_method 54 + * 55 + * PARAMETERS: method_pathname - Pathname of method to execute 56 + * integer_argument - Argument to pass to the method 57 + * 58 + * RETURN: None 59 + * 60 + * DESCRIPTION: Execute a sleep/wake related method with one integer argument 61 + * and no return value. 62 + * 63 + ******************************************************************************/ 64 + void acpi_hw_execute_sleep_method(char *method_pathname, u32 integer_argument) 65 + { 66 + struct acpi_object_list arg_list; 67 + union acpi_object arg; 68 + acpi_status status; 69 + 70 + ACPI_FUNCTION_TRACE(hw_execute_sleep_method); 71 + 72 + /* One argument, integer_argument; No return value expected */ 73 + 74 + arg_list.count = 1; 75 + arg_list.pointer = &arg; 76 + arg.type = ACPI_TYPE_INTEGER; 77 + arg.integer.value = (u64)integer_argument; 78 + 79 + status = acpi_evaluate_object(NULL, method_pathname, &arg_list, NULL); 80 + if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 81 + ACPI_EXCEPTION((AE_INFO, status, "While executing method %s", 82 + method_pathname)); 83 + } 84 + 85 + return_VOID; 86 + } 87 + 88 + /******************************************************************************* 89 + * 90 + * FUNCTION: acpi_hw_extended_sleep 91 + * 92 + * PARAMETERS: sleep_state - Which sleep state to enter 93 + * Flags - ACPI_EXECUTE_GTS to run optional method 94 + * 95 + * RETURN: Status 96 + * 97 + * DESCRIPTION: Enter a system sleep state via the extended FADT sleep 98 + * registers (V5 FADT). 99 + * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED 100 + * 101 + ******************************************************************************/ 102 + 103 + acpi_status acpi_hw_extended_sleep(u8 sleep_state, u8 flags) 104 + { 105 + acpi_status status; 106 + u8 sleep_type_value; 107 + u64 sleep_status; 108 + 109 + ACPI_FUNCTION_TRACE(hw_extended_sleep); 110 + 111 + /* Extended sleep registers must be valid */ 112 + 113 + if (!acpi_gbl_FADT.sleep_control.address || 114 + !acpi_gbl_FADT.sleep_status.address) { 115 + return_ACPI_STATUS(AE_NOT_EXIST); 116 + } 117 + 118 + /* Clear wake status (WAK_STS) */ 119 + 120 + status = acpi_write(ACPI_X_WAKE_STATUS, &acpi_gbl_FADT.sleep_status); 121 + if (ACPI_FAILURE(status)) { 122 + return_ACPI_STATUS(status); 123 + } 124 + 125 + acpi_gbl_system_awake_and_running = FALSE; 126 + 127 + /* Optionally execute _GTS (Going To Sleep) */ 128 + 129 + if (flags & ACPI_EXECUTE_GTS) { 130 + acpi_hw_execute_sleep_method(METHOD_PATHNAME__GTS, sleep_state); 131 + } 132 + 133 + /* Flush caches, as per ACPI specification */ 134 + 135 + ACPI_FLUSH_CPU_CACHE(); 136 + 137 + /* 138 + * Set the SLP_TYP and SLP_EN bits. 139 + * 140 + * Note: We only use the first value returned by the \_Sx method 141 + * (acpi_gbl_sleep_type_a) - As per ACPI specification. 142 + */ 143 + ACPI_DEBUG_PRINT((ACPI_DB_INIT, 144 + "Entering sleep state [S%u]\n", sleep_state)); 145 + 146 + sleep_type_value = 147 + ((acpi_gbl_sleep_type_a << ACPI_X_SLEEP_TYPE_POSITION) & 148 + ACPI_X_SLEEP_TYPE_MASK); 149 + 150 + status = acpi_write((sleep_type_value | ACPI_X_SLEEP_ENABLE), 151 + &acpi_gbl_FADT.sleep_control); 152 + if (ACPI_FAILURE(status)) { 153 + return_ACPI_STATUS(status); 154 + } 155 + 156 + /* Wait for transition back to Working State */ 157 + 158 + do { 159 + status = acpi_read(&sleep_status, &acpi_gbl_FADT.sleep_status); 160 + if (ACPI_FAILURE(status)) { 161 + return_ACPI_STATUS(status); 162 + } 163 + 164 + } while (!(((u8)sleep_status) & ACPI_X_WAKE_STATUS)); 165 + 166 + return_ACPI_STATUS(AE_OK); 167 + } 168 + 169 + /******************************************************************************* 170 + * 171 + * FUNCTION: acpi_hw_extended_wake_prep 172 + * 173 + * PARAMETERS: sleep_state - Which sleep state we just exited 174 + * Flags - ACPI_EXECUTE_BFS to run optional method 175 + * 176 + * RETURN: Status 177 + * 178 + * DESCRIPTION: Perform first part of OS-independent ACPI cleanup after 179 + * a sleep. Called with interrupts ENABLED. 180 + * 181 + ******************************************************************************/ 182 + 183 + acpi_status acpi_hw_extended_wake_prep(u8 sleep_state, u8 flags) 184 + { 185 + acpi_status status; 186 + u8 sleep_type_value; 187 + 188 + ACPI_FUNCTION_TRACE(hw_extended_wake_prep); 189 + 190 + status = acpi_get_sleep_type_data(ACPI_STATE_S0, 191 + &acpi_gbl_sleep_type_a, 192 + &acpi_gbl_sleep_type_b); 193 + if (ACPI_SUCCESS(status)) { 194 + sleep_type_value = 195 + ((acpi_gbl_sleep_type_a << ACPI_X_SLEEP_TYPE_POSITION) & 196 + ACPI_X_SLEEP_TYPE_MASK); 197 + 198 + (void)acpi_write((sleep_type_value | ACPI_X_SLEEP_ENABLE), 199 + &acpi_gbl_FADT.sleep_control); 200 + } 201 + 202 + /* Optionally execute _BFS (Back From Sleep) */ 203 + 204 + if (flags & ACPI_EXECUTE_BFS) { 205 + acpi_hw_execute_sleep_method(METHOD_PATHNAME__BFS, sleep_state); 206 + } 207 + return_ACPI_STATUS(AE_OK); 208 + } 209 + 210 + /******************************************************************************* 211 + * 212 + * FUNCTION: acpi_hw_extended_wake 213 + * 214 + * PARAMETERS: sleep_state - Which sleep state we just exited 215 + * Flags - Reserved, set to zero 216 + * 217 + * RETURN: Status 218 + * 219 + * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep 220 + * Called with interrupts ENABLED. 221 + * 222 + ******************************************************************************/ 223 + 224 + acpi_status acpi_hw_extended_wake(u8 sleep_state, u8 flags) 225 + { 226 + ACPI_FUNCTION_TRACE(hw_extended_wake); 227 + 228 + /* Ensure enter_sleep_state_prep -> enter_sleep_state ordering */ 229 + 230 + acpi_gbl_sleep_type_a = ACPI_SLEEP_TYPE_INVALID; 231 + 232 + /* Execute the wake methods */ 233 + 234 + acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WAKING); 235 + acpi_hw_execute_sleep_method(METHOD_PATHNAME__WAK, sleep_state); 236 + 237 + /* 238 + * Some BIOS code assumes that WAK_STS will be cleared on resume 239 + * and use it to determine whether the system is rebooting or 240 + * resuming. Clear WAK_STS for compatibility. 241 + */ 242 + (void)acpi_write(ACPI_X_WAKE_STATUS, &acpi_gbl_FADT.sleep_status); 243 + acpi_gbl_system_awake_and_running = TRUE; 244 + 245 + acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WORKING); 246 + return_ACPI_STATUS(AE_OK); 247 + }
+3 -1
drivers/acpi/acpica/hwgpe.c
··· 48 48 49 49 #define _COMPONENT ACPI_HARDWARE 50 50 ACPI_MODULE_NAME("hwgpe") 51 - 51 + #if (!ACPI_REDUCED_HARDWARE) /* Entire module */ 52 52 /* Local prototypes */ 53 53 static acpi_status 54 54 acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, ··· 479 479 status = acpi_ev_walk_gpe_list(acpi_hw_enable_wakeup_gpe_block, NULL); 480 480 return_ACPI_STATUS(status); 481 481 } 482 + 483 + #endif /* !ACPI_REDUCED_HARDWARE */
+13 -3
drivers/acpi/acpica/hwregs.c
··· 51 51 #define _COMPONENT ACPI_HARDWARE 52 52 ACPI_MODULE_NAME("hwregs") 53 53 54 + #if (!ACPI_REDUCED_HARDWARE) 54 55 /* Local Prototypes */ 55 56 static acpi_status 56 57 acpi_hw_read_multiple(u32 *value, ··· 62 61 acpi_hw_write_multiple(u32 value, 63 62 struct acpi_generic_address *register_a, 64 63 struct acpi_generic_address *register_b); 64 + 65 + #endif /* !ACPI_REDUCED_HARDWARE */ 65 66 66 67 /****************************************************************************** 67 68 * ··· 157 154 acpi_status acpi_hw_read(u32 *value, struct acpi_generic_address *reg) 158 155 { 159 156 u64 address; 157 + u64 value64; 160 158 acpi_status status; 161 159 162 160 ACPI_FUNCTION_NAME(hw_read); ··· 179 175 */ 180 176 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { 181 177 status = acpi_os_read_memory((acpi_physical_address) 182 - address, value, reg->bit_width); 178 + address, &value64, reg->bit_width); 179 + 180 + *value = (u32)value64; 183 181 } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ 184 182 185 183 status = acpi_hw_read_port((acpi_io_address) ··· 231 225 */ 232 226 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { 233 227 status = acpi_os_write_memory((acpi_physical_address) 234 - address, value, reg->bit_width); 228 + address, (u64)value, 229 + reg->bit_width); 235 230 } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ 236 231 237 232 status = acpi_hw_write_port((acpi_io_address) ··· 247 240 return (status); 248 241 } 249 242 243 + #if (!ACPI_REDUCED_HARDWARE) 250 244 /******************************************************************************* 251 245 * 252 246 * FUNCTION: acpi_hw_clear_acpi_status ··· 293 285 294 286 /******************************************************************************* 295 287 * 296 - * FUNCTION: acpi_hw_get_register_bit_mask 288 + * FUNCTION: acpi_hw_get_bit_register_info 297 289 * 298 290 * PARAMETERS: register_id - Index of ACPI Register to access 299 291 * ··· 666 658 667 659 return (status); 668 660 } 661 + 662 + #endif /* !ACPI_REDUCED_HARDWARE */
+73 -328
drivers/acpi/acpica/hwsleep.c
··· 1 - 2 1 /****************************************************************************** 3 2 * 4 - * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface 3 + * Name: hwsleep.c - ACPI Hardware Sleep/Wake Support functions for the 4 + * original/legacy sleep/PM registers. 5 5 * 6 6 *****************************************************************************/ 7 7 ··· 43 43 */ 44 44 45 45 #include <acpi/acpi.h> 46 + #include <linux/acpi.h> 46 47 #include "accommon.h" 47 - #include "actables.h" 48 - #include <linux/tboot.h> 49 48 #include <linux/module.h> 50 49 51 50 #define _COMPONENT ACPI_HARDWARE 52 51 ACPI_MODULE_NAME("hwsleep") 53 52 53 + #if (!ACPI_REDUCED_HARDWARE) /* Entire module */ 54 54 /******************************************************************************* 55 55 * 56 - * FUNCTION: acpi_set_firmware_waking_vector 57 - * 58 - * PARAMETERS: physical_address - 32-bit physical address of ACPI real mode 59 - * entry point. 60 - * 61 - * RETURN: Status 62 - * 63 - * DESCRIPTION: Sets the 32-bit firmware_waking_vector field of the FACS 64 - * 65 - ******************************************************************************/ 66 - acpi_status 67 - acpi_set_firmware_waking_vector(u32 physical_address) 68 - { 69 - ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector); 70 - 71 - 72 - /* 73 - * According to the ACPI specification 2.0c and later, the 64-bit 74 - * waking vector should be cleared and the 32-bit waking vector should 75 - * be used, unless we want the wake-up code to be called by the BIOS in 76 - * Protected Mode. Some systems (for example HP dv5-1004nr) are known 77 - * to fail to resume if the 64-bit vector is used. 78 - */ 79 - 80 - /* Set the 32-bit vector */ 81 - 82 - acpi_gbl_FACS->firmware_waking_vector = physical_address; 83 - 84 - /* Clear the 64-bit vector if it exists */ 85 - 86 - if ((acpi_gbl_FACS->length > 32) && (acpi_gbl_FACS->version >= 1)) { 87 - acpi_gbl_FACS->xfirmware_waking_vector = 0; 88 - } 89 - 90 - return_ACPI_STATUS(AE_OK); 91 - } 92 - 93 - ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector) 94 - 95 - #if ACPI_MACHINE_WIDTH == 64 96 - /******************************************************************************* 97 - * 98 - * FUNCTION: acpi_set_firmware_waking_vector64 99 - * 100 - * PARAMETERS: physical_address - 64-bit physical address of ACPI protected 101 - * mode entry point. 102 - * 103 - * RETURN: Status 104 - * 105 - * DESCRIPTION: Sets the 64-bit X_firmware_waking_vector field of the FACS, if 106 - * it exists in the table. This function is intended for use with 107 - * 64-bit host operating systems. 108 - * 109 - ******************************************************************************/ 110 - acpi_status 111 - acpi_set_firmware_waking_vector64(u64 physical_address) 112 - { 113 - ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector64); 114 - 115 - 116 - /* Determine if the 64-bit vector actually exists */ 117 - 118 - if ((acpi_gbl_FACS->length <= 32) || (acpi_gbl_FACS->version < 1)) { 119 - return_ACPI_STATUS(AE_NOT_EXIST); 120 - } 121 - 122 - /* Clear 32-bit vector, set the 64-bit X_ vector */ 123 - 124 - acpi_gbl_FACS->firmware_waking_vector = 0; 125 - acpi_gbl_FACS->xfirmware_waking_vector = physical_address; 126 - 127 - return_ACPI_STATUS(AE_OK); 128 - } 129 - 130 - ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector64) 131 - #endif 132 - 133 - /******************************************************************************* 134 - * 135 - * FUNCTION: acpi_enter_sleep_state_prep 56 + * FUNCTION: acpi_hw_legacy_sleep 136 57 * 137 58 * PARAMETERS: sleep_state - Which sleep state to enter 59 + * Flags - ACPI_EXECUTE_GTS to run optional method 138 60 * 139 61 * RETURN: Status 140 62 * 141 - * DESCRIPTION: Prepare to enter a system sleep state (see ACPI 2.0 spec p 231) 142 - * This function must execute with interrupts enabled. 143 - * We break sleeping into 2 stages so that OSPM can handle 144 - * various OS-specific tasks between the two steps. 145 - * 146 - ******************************************************************************/ 147 - acpi_status acpi_enter_sleep_state_prep(u8 sleep_state) 148 - { 149 - acpi_status status; 150 - struct acpi_object_list arg_list; 151 - union acpi_object arg; 152 - 153 - ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_prep); 154 - 155 - /* _PSW methods could be run here to enable wake-on keyboard, LAN, etc. */ 156 - 157 - status = acpi_get_sleep_type_data(sleep_state, 158 - &acpi_gbl_sleep_type_a, 159 - &acpi_gbl_sleep_type_b); 160 - if (ACPI_FAILURE(status)) { 161 - return_ACPI_STATUS(status); 162 - } 163 - 164 - /* Setup parameter object */ 165 - 166 - arg_list.count = 1; 167 - arg_list.pointer = &arg; 168 - 169 - arg.type = ACPI_TYPE_INTEGER; 170 - arg.integer.value = sleep_state; 171 - 172 - /* Run the _PTS method */ 173 - 174 - status = acpi_evaluate_object(NULL, METHOD_NAME__PTS, &arg_list, NULL); 175 - if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 176 - return_ACPI_STATUS(status); 177 - } 178 - 179 - /* Setup the argument to _SST */ 180 - 181 - switch (sleep_state) { 182 - case ACPI_STATE_S0: 183 - arg.integer.value = ACPI_SST_WORKING; 184 - break; 185 - 186 - case ACPI_STATE_S1: 187 - case ACPI_STATE_S2: 188 - case ACPI_STATE_S3: 189 - arg.integer.value = ACPI_SST_SLEEPING; 190 - break; 191 - 192 - case ACPI_STATE_S4: 193 - arg.integer.value = ACPI_SST_SLEEP_CONTEXT; 194 - break; 195 - 196 - default: 197 - arg.integer.value = ACPI_SST_INDICATOR_OFF; /* Default is off */ 198 - break; 199 - } 200 - 201 - /* 202 - * Set the system indicators to show the desired sleep state. 203 - * _SST is an optional method (return no error if not found) 204 - */ 205 - status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL); 206 - if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 207 - ACPI_EXCEPTION((AE_INFO, status, 208 - "While executing method _SST")); 209 - } 210 - 211 - return_ACPI_STATUS(AE_OK); 212 - } 213 - 214 - ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_prep) 215 - 216 - static unsigned int gts, bfs; 217 - module_param(gts, uint, 0644); 218 - module_param(bfs, uint, 0644); 219 - MODULE_PARM_DESC(gts, "Enable evaluation of _GTS on suspend."); 220 - MODULE_PARM_DESC(bfs, "Enable evaluation of _BFS on resume".); 221 - 222 - /******************************************************************************* 223 - * 224 - * FUNCTION: acpi_enter_sleep_state 225 - * 226 - * PARAMETERS: sleep_state - Which sleep state to enter 227 - * 228 - * RETURN: Status 229 - * 230 - * DESCRIPTION: Enter a system sleep state (see ACPI 2.0 spec p 231) 63 + * DESCRIPTION: Enter a system sleep state via the legacy FADT PM registers 231 64 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED 232 65 * 233 66 ******************************************************************************/ 234 - acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state) 67 + acpi_status acpi_hw_legacy_sleep(u8 sleep_state, u8 flags) 235 68 { 236 - u32 pm1a_control; 237 - u32 pm1b_control; 238 69 struct acpi_bit_register_info *sleep_type_reg_info; 239 70 struct acpi_bit_register_info *sleep_enable_reg_info; 71 + u32 pm1a_control; 72 + u32 pm1b_control; 240 73 u32 in_value; 241 - struct acpi_object_list arg_list; 242 - union acpi_object arg; 243 74 acpi_status status; 244 75 245 - ACPI_FUNCTION_TRACE(acpi_enter_sleep_state); 246 - 247 - if ((acpi_gbl_sleep_type_a > ACPI_SLEEP_TYPE_MAX) || 248 - (acpi_gbl_sleep_type_b > ACPI_SLEEP_TYPE_MAX)) { 249 - ACPI_ERROR((AE_INFO, "Sleep values out of range: A=0x%X B=0x%X", 250 - acpi_gbl_sleep_type_a, acpi_gbl_sleep_type_b)); 251 - return_ACPI_STATUS(AE_AML_OPERAND_VALUE); 252 - } 76 + ACPI_FUNCTION_TRACE(hw_legacy_sleep); 253 77 254 78 sleep_type_reg_info = 255 79 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE); ··· 95 271 return_ACPI_STATUS(status); 96 272 } 97 273 274 + if (sleep_state != ACPI_STATE_S5) { 275 + /* 276 + * Disable BM arbitration. This feature is contained within an 277 + * optional register (PM2 Control), so ignore a BAD_ADDRESS 278 + * exception. 279 + */ 280 + status = acpi_write_bit_register(ACPI_BITREG_ARB_DISABLE, 1); 281 + if (ACPI_FAILURE(status) && (status != AE_BAD_ADDRESS)) { 282 + return_ACPI_STATUS(status); 283 + } 284 + } 285 + 98 286 /* 99 287 * 1) Disable/Clear all GPEs 100 288 * 2) Enable all wakeup GPEs ··· 122 286 return_ACPI_STATUS(status); 123 287 } 124 288 125 - if (gts) { 126 - /* Execute the _GTS method */ 289 + /* Optionally execute _GTS (Going To Sleep) */ 127 290 128 - arg_list.count = 1; 129 - arg_list.pointer = &arg; 130 - arg.type = ACPI_TYPE_INTEGER; 131 - arg.integer.value = sleep_state; 132 - 133 - status = acpi_evaluate_object(NULL, METHOD_NAME__GTS, &arg_list, NULL); 134 - if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 135 - return_ACPI_STATUS(status); 136 - } 291 + if (flags & ACPI_EXECUTE_GTS) { 292 + acpi_hw_execute_sleep_method(METHOD_PATHNAME__GTS, sleep_state); 137 293 } 138 294 139 295 /* Get current value of PM1A control */ ··· 172 344 173 345 ACPI_FLUSH_CPU_CACHE(); 174 346 175 - tboot_sleep(sleep_state, pm1a_control, pm1b_control); 176 - 347 + status = acpi_os_prepare_sleep(sleep_state, pm1a_control, 348 + pm1b_control); 349 + if (ACPI_SKIP(status)) 350 + return_ACPI_STATUS(AE_OK); 351 + if (ACPI_FAILURE(status)) 352 + return_ACPI_STATUS(status); 177 353 /* Write #2: Write both SLP_TYP + SLP_EN */ 178 354 179 355 status = acpi_hw_write_pm1_control(pm1a_control, pm1b_control); ··· 207 375 } 208 376 } 209 377 210 - /* Wait until we enter sleep state */ 378 + /* Wait for transition back to Working State */ 211 379 212 380 do { 213 - status = acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS, 214 - &in_value); 215 - if (ACPI_FAILURE(status)) { 216 - return_ACPI_STATUS(status); 217 - } 218 - 219 - /* Spin until we wake */ 220 - 221 - } while (!in_value); 222 - 223 - return_ACPI_STATUS(AE_OK); 224 - } 225 - 226 - ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state) 227 - 228 - /******************************************************************************* 229 - * 230 - * FUNCTION: acpi_enter_sleep_state_s4bios 231 - * 232 - * PARAMETERS: None 233 - * 234 - * RETURN: Status 235 - * 236 - * DESCRIPTION: Perform a S4 bios request. 237 - * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED 238 - * 239 - ******************************************************************************/ 240 - acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void) 241 - { 242 - u32 in_value; 243 - acpi_status status; 244 - 245 - ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_s4bios); 246 - 247 - /* Clear the wake status bit (PM1) */ 248 - 249 - status = 250 - acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS); 251 - if (ACPI_FAILURE(status)) { 252 - return_ACPI_STATUS(status); 253 - } 254 - 255 - status = acpi_hw_clear_acpi_status(); 256 - if (ACPI_FAILURE(status)) { 257 - return_ACPI_STATUS(status); 258 - } 259 - 260 - /* 261 - * 1) Disable/Clear all GPEs 262 - * 2) Enable all wakeup GPEs 263 - */ 264 - status = acpi_hw_disable_all_gpes(); 265 - if (ACPI_FAILURE(status)) { 266 - return_ACPI_STATUS(status); 267 - } 268 - acpi_gbl_system_awake_and_running = FALSE; 269 - 270 - status = acpi_hw_enable_all_wakeup_gpes(); 271 - if (ACPI_FAILURE(status)) { 272 - return_ACPI_STATUS(status); 273 - } 274 - 275 - ACPI_FLUSH_CPU_CACHE(); 276 - 277 - status = acpi_hw_write_port(acpi_gbl_FADT.smi_command, 278 - (u32) acpi_gbl_FADT.S4bios_request, 8); 279 - 280 - do { 281 - acpi_os_stall(1000); 282 381 status = 283 382 acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS, &in_value); 284 383 if (ACPI_FAILURE(status)) { 285 384 return_ACPI_STATUS(status); 286 385 } 386 + 287 387 } while (!in_value); 288 388 289 389 return_ACPI_STATUS(AE_OK); 290 390 } 291 391 292 - ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios) 293 - 294 392 /******************************************************************************* 295 393 * 296 - * FUNCTION: acpi_leave_sleep_state_prep 394 + * FUNCTION: acpi_hw_legacy_wake_prep 297 395 * 298 - * PARAMETERS: sleep_state - Which sleep state we are exiting 396 + * PARAMETERS: sleep_state - Which sleep state we just exited 397 + * Flags - ACPI_EXECUTE_BFS to run optional method 299 398 * 300 399 * RETURN: Status 301 400 * 302 401 * DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a 303 402 * sleep. 304 - * Called with interrupts DISABLED. 403 + * Called with interrupts ENABLED. 305 404 * 306 405 ******************************************************************************/ 307 - acpi_status acpi_leave_sleep_state_prep(u8 sleep_state) 406 + 407 + acpi_status acpi_hw_legacy_wake_prep(u8 sleep_state, u8 flags) 308 408 { 309 - struct acpi_object_list arg_list; 310 - union acpi_object arg; 311 409 acpi_status status; 312 410 struct acpi_bit_register_info *sleep_type_reg_info; 313 411 struct acpi_bit_register_info *sleep_enable_reg_info; 314 412 u32 pm1a_control; 315 413 u32 pm1b_control; 316 414 317 - ACPI_FUNCTION_TRACE(acpi_leave_sleep_state_prep); 415 + ACPI_FUNCTION_TRACE(hw_legacy_wake_prep); 318 416 319 417 /* 320 418 * Set SLP_TYPE and SLP_EN to state S0. ··· 287 525 } 288 526 } 289 527 290 - if (bfs) { 291 - /* Execute the _BFS method */ 528 + /* Optionally execute _BFS (Back From Sleep) */ 292 529 293 - arg_list.count = 1; 294 - arg_list.pointer = &arg; 295 - arg.type = ACPI_TYPE_INTEGER; 296 - arg.integer.value = sleep_state; 297 - 298 - status = acpi_evaluate_object(NULL, METHOD_NAME__BFS, &arg_list, NULL); 299 - if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 300 - ACPI_EXCEPTION((AE_INFO, status, "During Method _BFS")); 301 - } 530 + if (flags & ACPI_EXECUTE_BFS) { 531 + acpi_hw_execute_sleep_method(METHOD_PATHNAME__BFS, sleep_state); 302 532 } 303 533 return_ACPI_STATUS(status); 304 534 } 305 535 306 536 /******************************************************************************* 307 537 * 308 - * FUNCTION: acpi_leave_sleep_state 538 + * FUNCTION: acpi_hw_legacy_wake 309 539 * 310 540 * PARAMETERS: sleep_state - Which sleep state we just exited 541 + * Flags - Reserved, set to zero 311 542 * 312 543 * RETURN: Status 313 544 * ··· 308 553 * Called with interrupts ENABLED. 309 554 * 310 555 ******************************************************************************/ 311 - acpi_status acpi_leave_sleep_state(u8 sleep_state) 556 + 557 + acpi_status acpi_hw_legacy_wake(u8 sleep_state, u8 flags) 312 558 { 313 - struct acpi_object_list arg_list; 314 - union acpi_object arg; 315 559 acpi_status status; 316 560 317 - ACPI_FUNCTION_TRACE(acpi_leave_sleep_state); 561 + ACPI_FUNCTION_TRACE(hw_legacy_wake); 318 562 319 563 /* Ensure enter_sleep_state_prep -> enter_sleep_state ordering */ 320 564 321 565 acpi_gbl_sleep_type_a = ACPI_SLEEP_TYPE_INVALID; 322 - 323 - /* Setup parameter object */ 324 - 325 - arg_list.count = 1; 326 - arg_list.pointer = &arg; 327 - arg.type = ACPI_TYPE_INTEGER; 328 - 329 - /* Ignore any errors from these methods */ 330 - 331 - arg.integer.value = ACPI_SST_WAKING; 332 - status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL); 333 - if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 334 - ACPI_EXCEPTION((AE_INFO, status, "During Method _SST")); 335 - } 566 + acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WAKING); 336 567 337 568 /* 338 569 * GPEs must be enabled before _WAK is called as GPEs ··· 332 591 if (ACPI_FAILURE(status)) { 333 592 return_ACPI_STATUS(status); 334 593 } 594 + 335 595 status = acpi_hw_enable_all_runtime_gpes(); 336 596 if (ACPI_FAILURE(status)) { 337 597 return_ACPI_STATUS(status); 338 598 } 339 599 340 - arg.integer.value = sleep_state; 341 - status = acpi_evaluate_object(NULL, METHOD_NAME__WAK, &arg_list, NULL); 342 - if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 343 - ACPI_EXCEPTION((AE_INFO, status, "During Method _WAK")); 344 - } 345 - /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */ 600 + /* 601 + * Now we can execute _WAK, etc. Some machines require that the GPEs 602 + * are enabled before the wake methods are executed. 603 + */ 604 + acpi_hw_execute_sleep_method(METHOD_PATHNAME__WAK, sleep_state); 346 605 347 606 /* 348 - * Some BIOSes assume that WAK_STS will be cleared on resume and use 349 - * it to determine whether the system is rebooting or resuming. Clear 350 - * it for compatibility. 607 + * Some BIOS code assumes that WAK_STS will be cleared on resume 608 + * and use it to determine whether the system is rebooting or 609 + * resuming. Clear WAK_STS for compatibility. 351 610 */ 352 611 acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, 1); 353 - 354 612 acpi_gbl_system_awake_and_running = TRUE; 355 613 356 614 /* Enable power button */ 357 615 358 616 (void) 359 617 acpi_write_bit_register(acpi_gbl_fixed_event_info 360 - [ACPI_EVENT_POWER_BUTTON]. 361 - enable_register_id, ACPI_ENABLE_EVENT); 618 + [ACPI_EVENT_POWER_BUTTON]. 619 + enable_register_id, ACPI_ENABLE_EVENT); 362 620 363 621 (void) 364 622 acpi_write_bit_register(acpi_gbl_fixed_event_info 365 - [ACPI_EVENT_POWER_BUTTON]. 366 - status_register_id, ACPI_CLEAR_STATUS); 623 + [ACPI_EVENT_POWER_BUTTON]. 624 + status_register_id, ACPI_CLEAR_STATUS); 367 625 368 - arg.integer.value = ACPI_SST_WORKING; 369 - status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL); 370 - if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 371 - ACPI_EXCEPTION((AE_INFO, status, "During Method _SST")); 626 + /* 627 + * Enable BM arbitration. This feature is contained within an 628 + * optional register (PM2 Control), so ignore a BAD_ADDRESS 629 + * exception. 630 + */ 631 + status = acpi_write_bit_register(ACPI_BITREG_ARB_DISABLE, 0); 632 + if (ACPI_FAILURE(status) && (status != AE_BAD_ADDRESS)) { 633 + return_ACPI_STATUS(status); 372 634 } 373 635 636 + acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WORKING); 374 637 return_ACPI_STATUS(status); 375 638 } 376 639 377 - ACPI_EXPORT_SYMBOL(acpi_leave_sleep_state) 640 + #endif /* !ACPI_REDUCED_HARDWARE */
+2
drivers/acpi/acpica/hwtimer.c
··· 49 49 #define _COMPONENT ACPI_HARDWARE 50 50 ACPI_MODULE_NAME("hwtimer") 51 51 52 + #if (!ACPI_REDUCED_HARDWARE) /* Entire module */ 52 53 /****************************************************************************** 53 54 * 54 55 * FUNCTION: acpi_get_timer_resolution ··· 188 187 } 189 188 190 189 ACPI_EXPORT_SYMBOL(acpi_get_timer_duration) 190 + #endif /* !ACPI_REDUCED_HARDWARE */
+16 -38
drivers/acpi/acpica/hwxface.c
··· 74 74 75 75 /* Check if the reset register is supported */ 76 76 77 - if (!(acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER) || 78 - !reset_reg->address) { 77 + if (!reset_reg->address) { 79 78 return_ACPI_STATUS(AE_NOT_EXIST); 80 79 } 81 80 ··· 137 138 return (status); 138 139 } 139 140 140 - width = reg->bit_width; 141 - if (width == 64) { 142 - width = 32; /* Break into two 32-bit transfers */ 143 - } 144 - 145 141 /* Initialize entire 64-bit return value to zero */ 146 142 147 143 *return_value = 0; ··· 148 154 */ 149 155 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { 150 156 status = acpi_os_read_memory((acpi_physical_address) 151 - address, &value, width); 157 + address, return_value, 158 + reg->bit_width); 152 159 if (ACPI_FAILURE(status)) { 153 160 return (status); 154 161 } 155 - *return_value = value; 156 - 157 - if (reg->bit_width == 64) { 158 - 159 - /* Read the top 32 bits */ 160 - 161 - status = acpi_os_read_memory((acpi_physical_address) 162 - (address + 4), &value, 32); 163 - if (ACPI_FAILURE(status)) { 164 - return (status); 165 - } 166 - *return_value |= ((u64)value << 32); 167 - } 168 162 } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ 163 + 164 + width = reg->bit_width; 165 + if (width == 64) { 166 + width = 32; /* Break into two 32-bit transfers */ 167 + } 169 168 170 169 status = acpi_hw_read_port((acpi_io_address) 171 170 address, &value, width); ··· 218 231 return (status); 219 232 } 220 233 221 - width = reg->bit_width; 222 - if (width == 64) { 223 - width = 32; /* Break into two 32-bit transfers */ 224 - } 225 - 226 234 /* 227 235 * Two address spaces supported: Memory or IO. PCI_Config is 228 236 * not supported here because the GAS structure is insufficient 229 237 */ 230 238 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { 231 239 status = acpi_os_write_memory((acpi_physical_address) 232 - address, ACPI_LODWORD(value), 233 - width); 240 + address, value, reg->bit_width); 234 241 if (ACPI_FAILURE(status)) { 235 242 return (status); 236 243 } 237 - 238 - if (reg->bit_width == 64) { 239 - status = acpi_os_write_memory((acpi_physical_address) 240 - (address + 4), 241 - ACPI_HIDWORD(value), 32); 242 - if (ACPI_FAILURE(status)) { 243 - return (status); 244 - } 245 - } 246 244 } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ 245 + 246 + width = reg->bit_width; 247 + if (width == 64) { 248 + width = 32; /* Break into two 32-bit transfers */ 249 + } 247 250 248 251 status = acpi_hw_write_port((acpi_io_address) 249 252 address, ACPI_LODWORD(value), ··· 263 286 264 287 ACPI_EXPORT_SYMBOL(acpi_write) 265 288 289 + #if (!ACPI_REDUCED_HARDWARE) 266 290 /******************************************************************************* 267 291 * 268 292 * FUNCTION: acpi_read_bit_register ··· 431 453 } 432 454 433 455 ACPI_EXPORT_SYMBOL(acpi_write_bit_register) 434 - 456 + #endif /* !ACPI_REDUCED_HARDWARE */ 435 457 /******************************************************************************* 436 458 * 437 459 * FUNCTION: acpi_get_sleep_type_data
+431
drivers/acpi/acpica/hwxfsleep.c
··· 1 + /****************************************************************************** 2 + * 3 + * Name: hwxfsleep.c - ACPI Hardware Sleep/Wake External Interfaces 4 + * 5 + *****************************************************************************/ 6 + 7 + /* 8 + * Copyright (C) 2000 - 2012, Intel Corp. 9 + * All rights reserved. 10 + * 11 + * Redistribution and use in source and binary forms, with or without 12 + * modification, are permitted provided that the following conditions 13 + * are met: 14 + * 1. Redistributions of source code must retain the above copyright 15 + * notice, this list of conditions, and the following disclaimer, 16 + * without modification. 17 + * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18 + * substantially similar to the "NO WARRANTY" disclaimer below 19 + * ("Disclaimer") and any redistribution must be conditioned upon 20 + * including a substantially similar Disclaimer requirement for further 21 + * binary redistribution. 22 + * 3. Neither the names of the above-listed copyright holders nor the names 23 + * of any contributors may be used to endorse or promote products derived 24 + * from this software without specific prior written permission. 25 + * 26 + * Alternatively, this software may be distributed under the terms of the 27 + * GNU General Public License ("GPL") version 2 as published by the Free 28 + * Software Foundation. 29 + * 30 + * NO WARRANTY 31 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35 + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40 + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41 + * POSSIBILITY OF SUCH DAMAGES. 42 + */ 43 + 44 + #include <acpi/acpi.h> 45 + #include "accommon.h" 46 + #include <linux/module.h> 47 + 48 + #define _COMPONENT ACPI_HARDWARE 49 + ACPI_MODULE_NAME("hwxfsleep") 50 + 51 + /* Local prototypes */ 52 + static acpi_status 53 + acpi_hw_sleep_dispatch(u8 sleep_state, u8 flags, u32 function_id); 54 + 55 + /* 56 + * Dispatch table used to efficiently branch to the various sleep 57 + * functions. 58 + */ 59 + #define ACPI_SLEEP_FUNCTION_ID 0 60 + #define ACPI_WAKE_PREP_FUNCTION_ID 1 61 + #define ACPI_WAKE_FUNCTION_ID 2 62 + 63 + /* Legacy functions are optional, based upon ACPI_REDUCED_HARDWARE */ 64 + 65 + static struct acpi_sleep_functions acpi_sleep_dispatch[] = { 66 + {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_sleep), 67 + acpi_hw_extended_sleep}, 68 + {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake_prep), 69 + acpi_hw_extended_wake_prep}, 70 + {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake), acpi_hw_extended_wake} 71 + }; 72 + 73 + /* 74 + * These functions are removed for the ACPI_REDUCED_HARDWARE case: 75 + * acpi_set_firmware_waking_vector 76 + * acpi_set_firmware_waking_vector64 77 + * acpi_enter_sleep_state_s4bios 78 + */ 79 + 80 + #if (!ACPI_REDUCED_HARDWARE) 81 + /******************************************************************************* 82 + * 83 + * FUNCTION: acpi_set_firmware_waking_vector 84 + * 85 + * PARAMETERS: physical_address - 32-bit physical address of ACPI real mode 86 + * entry point. 87 + * 88 + * RETURN: Status 89 + * 90 + * DESCRIPTION: Sets the 32-bit firmware_waking_vector field of the FACS 91 + * 92 + ******************************************************************************/ 93 + 94 + acpi_status acpi_set_firmware_waking_vector(u32 physical_address) 95 + { 96 + ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector); 97 + 98 + 99 + /* 100 + * According to the ACPI specification 2.0c and later, the 64-bit 101 + * waking vector should be cleared and the 32-bit waking vector should 102 + * be used, unless we want the wake-up code to be called by the BIOS in 103 + * Protected Mode. Some systems (for example HP dv5-1004nr) are known 104 + * to fail to resume if the 64-bit vector is used. 105 + */ 106 + 107 + /* Set the 32-bit vector */ 108 + 109 + acpi_gbl_FACS->firmware_waking_vector = physical_address; 110 + 111 + /* Clear the 64-bit vector if it exists */ 112 + 113 + if ((acpi_gbl_FACS->length > 32) && (acpi_gbl_FACS->version >= 1)) { 114 + acpi_gbl_FACS->xfirmware_waking_vector = 0; 115 + } 116 + 117 + return_ACPI_STATUS(AE_OK); 118 + } 119 + 120 + ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector) 121 + 122 + #if ACPI_MACHINE_WIDTH == 64 123 + /******************************************************************************* 124 + * 125 + * FUNCTION: acpi_set_firmware_waking_vector64 126 + * 127 + * PARAMETERS: physical_address - 64-bit physical address of ACPI protected 128 + * mode entry point. 129 + * 130 + * RETURN: Status 131 + * 132 + * DESCRIPTION: Sets the 64-bit X_firmware_waking_vector field of the FACS, if 133 + * it exists in the table. This function is intended for use with 134 + * 64-bit host operating systems. 135 + * 136 + ******************************************************************************/ 137 + acpi_status acpi_set_firmware_waking_vector64(u64 physical_address) 138 + { 139 + ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector64); 140 + 141 + 142 + /* Determine if the 64-bit vector actually exists */ 143 + 144 + if ((acpi_gbl_FACS->length <= 32) || (acpi_gbl_FACS->version < 1)) { 145 + return_ACPI_STATUS(AE_NOT_EXIST); 146 + } 147 + 148 + /* Clear 32-bit vector, set the 64-bit X_ vector */ 149 + 150 + acpi_gbl_FACS->firmware_waking_vector = 0; 151 + acpi_gbl_FACS->xfirmware_waking_vector = physical_address; 152 + return_ACPI_STATUS(AE_OK); 153 + } 154 + 155 + ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector64) 156 + #endif 157 + 158 + /******************************************************************************* 159 + * 160 + * FUNCTION: acpi_enter_sleep_state_s4bios 161 + * 162 + * PARAMETERS: None 163 + * 164 + * RETURN: Status 165 + * 166 + * DESCRIPTION: Perform a S4 bios request. 167 + * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED 168 + * 169 + ******************************************************************************/ 170 + acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void) 171 + { 172 + u32 in_value; 173 + acpi_status status; 174 + 175 + ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_s4bios); 176 + 177 + /* Clear the wake status bit (PM1) */ 178 + 179 + status = 180 + acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS); 181 + if (ACPI_FAILURE(status)) { 182 + return_ACPI_STATUS(status); 183 + } 184 + 185 + status = acpi_hw_clear_acpi_status(); 186 + if (ACPI_FAILURE(status)) { 187 + return_ACPI_STATUS(status); 188 + } 189 + 190 + /* 191 + * 1) Disable/Clear all GPEs 192 + * 2) Enable all wakeup GPEs 193 + */ 194 + status = acpi_hw_disable_all_gpes(); 195 + if (ACPI_FAILURE(status)) { 196 + return_ACPI_STATUS(status); 197 + } 198 + acpi_gbl_system_awake_and_running = FALSE; 199 + 200 + status = acpi_hw_enable_all_wakeup_gpes(); 201 + if (ACPI_FAILURE(status)) { 202 + return_ACPI_STATUS(status); 203 + } 204 + 205 + ACPI_FLUSH_CPU_CACHE(); 206 + 207 + status = acpi_hw_write_port(acpi_gbl_FADT.smi_command, 208 + (u32)acpi_gbl_FADT.S4bios_request, 8); 209 + 210 + do { 211 + acpi_os_stall(1000); 212 + status = 213 + acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS, &in_value); 214 + if (ACPI_FAILURE(status)) { 215 + return_ACPI_STATUS(status); 216 + } 217 + } while (!in_value); 218 + 219 + return_ACPI_STATUS(AE_OK); 220 + } 221 + 222 + ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios) 223 + #endif /* !ACPI_REDUCED_HARDWARE */ 224 + /******************************************************************************* 225 + * 226 + * FUNCTION: acpi_hw_sleep_dispatch 227 + * 228 + * PARAMETERS: sleep_state - Which sleep state to enter/exit 229 + * function_id - Sleep, wake_prep, or Wake 230 + * 231 + * RETURN: Status from the invoked sleep handling function. 232 + * 233 + * DESCRIPTION: Dispatch a sleep/wake request to the appropriate handling 234 + * function. 235 + * 236 + ******************************************************************************/ 237 + static acpi_status 238 + acpi_hw_sleep_dispatch(u8 sleep_state, u8 flags, u32 function_id) 239 + { 240 + acpi_status status; 241 + struct acpi_sleep_functions *sleep_functions = 242 + &acpi_sleep_dispatch[function_id]; 243 + 244 + #if (!ACPI_REDUCED_HARDWARE) 245 + 246 + /* 247 + * If the Hardware Reduced flag is set (from the FADT), we must 248 + * use the extended sleep registers 249 + */ 250 + if (acpi_gbl_reduced_hardware || acpi_gbl_FADT.sleep_control.address) { 251 + status = sleep_functions->extended_function(sleep_state, flags); 252 + } else { 253 + /* Legacy sleep */ 254 + 255 + status = sleep_functions->legacy_function(sleep_state, flags); 256 + } 257 + 258 + return (status); 259 + 260 + #else 261 + /* 262 + * For the case where reduced-hardware-only code is being generated, 263 + * we know that only the extended sleep registers are available 264 + */ 265 + status = sleep_functions->extended_function(sleep_state, flags); 266 + return (status); 267 + 268 + #endif /* !ACPI_REDUCED_HARDWARE */ 269 + } 270 + 271 + /******************************************************************************* 272 + * 273 + * FUNCTION: acpi_enter_sleep_state_prep 274 + * 275 + * PARAMETERS: sleep_state - Which sleep state to enter 276 + * 277 + * RETURN: Status 278 + * 279 + * DESCRIPTION: Prepare to enter a system sleep state. 280 + * This function must execute with interrupts enabled. 281 + * We break sleeping into 2 stages so that OSPM can handle 282 + * various OS-specific tasks between the two steps. 283 + * 284 + ******************************************************************************/ 285 + 286 + acpi_status acpi_enter_sleep_state_prep(u8 sleep_state) 287 + { 288 + acpi_status status; 289 + struct acpi_object_list arg_list; 290 + union acpi_object arg; 291 + u32 sst_value; 292 + 293 + ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_prep); 294 + 295 + status = acpi_get_sleep_type_data(sleep_state, 296 + &acpi_gbl_sleep_type_a, 297 + &acpi_gbl_sleep_type_b); 298 + if (ACPI_FAILURE(status)) { 299 + return_ACPI_STATUS(status); 300 + } 301 + 302 + /* Execute the _PTS method (Prepare To Sleep) */ 303 + 304 + arg_list.count = 1; 305 + arg_list.pointer = &arg; 306 + arg.type = ACPI_TYPE_INTEGER; 307 + arg.integer.value = sleep_state; 308 + 309 + status = 310 + acpi_evaluate_object(NULL, METHOD_PATHNAME__PTS, &arg_list, NULL); 311 + if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 312 + return_ACPI_STATUS(status); 313 + } 314 + 315 + /* Setup the argument to the _SST method (System STatus) */ 316 + 317 + switch (sleep_state) { 318 + case ACPI_STATE_S0: 319 + sst_value = ACPI_SST_WORKING; 320 + break; 321 + 322 + case ACPI_STATE_S1: 323 + case ACPI_STATE_S2: 324 + case ACPI_STATE_S3: 325 + sst_value = ACPI_SST_SLEEPING; 326 + break; 327 + 328 + case ACPI_STATE_S4: 329 + sst_value = ACPI_SST_SLEEP_CONTEXT; 330 + break; 331 + 332 + default: 333 + sst_value = ACPI_SST_INDICATOR_OFF; /* Default is off */ 334 + break; 335 + } 336 + 337 + /* 338 + * Set the system indicators to show the desired sleep state. 339 + * _SST is an optional method (return no error if not found) 340 + */ 341 + acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, sst_value); 342 + return_ACPI_STATUS(AE_OK); 343 + } 344 + 345 + ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_prep) 346 + 347 + /******************************************************************************* 348 + * 349 + * FUNCTION: acpi_enter_sleep_state 350 + * 351 + * PARAMETERS: sleep_state - Which sleep state to enter 352 + * Flags - ACPI_EXECUTE_GTS to run optional method 353 + * 354 + * RETURN: Status 355 + * 356 + * DESCRIPTION: Enter a system sleep state (see ACPI 2.0 spec p 231) 357 + * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED 358 + * 359 + ******************************************************************************/ 360 + acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state, u8 flags) 361 + { 362 + acpi_status status; 363 + 364 + ACPI_FUNCTION_TRACE(acpi_enter_sleep_state); 365 + 366 + if ((acpi_gbl_sleep_type_a > ACPI_SLEEP_TYPE_MAX) || 367 + (acpi_gbl_sleep_type_b > ACPI_SLEEP_TYPE_MAX)) { 368 + ACPI_ERROR((AE_INFO, "Sleep values out of range: A=0x%X B=0x%X", 369 + acpi_gbl_sleep_type_a, acpi_gbl_sleep_type_b)); 370 + return_ACPI_STATUS(AE_AML_OPERAND_VALUE); 371 + } 372 + 373 + status = 374 + acpi_hw_sleep_dispatch(sleep_state, flags, ACPI_SLEEP_FUNCTION_ID); 375 + return_ACPI_STATUS(status); 376 + } 377 + 378 + ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state) 379 + 380 + /******************************************************************************* 381 + * 382 + * FUNCTION: acpi_leave_sleep_state_prep 383 + * 384 + * PARAMETERS: sleep_state - Which sleep state we are exiting 385 + * Flags - ACPI_EXECUTE_BFS to run optional method 386 + * 387 + * RETURN: Status 388 + * 389 + * DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a 390 + * sleep. 391 + * Called with interrupts DISABLED. 392 + * 393 + ******************************************************************************/ 394 + acpi_status acpi_leave_sleep_state_prep(u8 sleep_state, u8 flags) 395 + { 396 + acpi_status status; 397 + 398 + ACPI_FUNCTION_TRACE(acpi_leave_sleep_state_prep); 399 + 400 + status = 401 + acpi_hw_sleep_dispatch(sleep_state, flags, 402 + ACPI_WAKE_PREP_FUNCTION_ID); 403 + return_ACPI_STATUS(status); 404 + } 405 + 406 + ACPI_EXPORT_SYMBOL(acpi_leave_sleep_state_prep) 407 + 408 + /******************************************************************************* 409 + * 410 + * FUNCTION: acpi_leave_sleep_state 411 + * 412 + * PARAMETERS: sleep_state - Which sleep state we are exiting 413 + * 414 + * RETURN: Status 415 + * 416 + * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep 417 + * Called with interrupts ENABLED. 418 + * 419 + ******************************************************************************/ 420 + acpi_status acpi_leave_sleep_state(u8 sleep_state) 421 + { 422 + acpi_status status; 423 + 424 + ACPI_FUNCTION_TRACE(acpi_leave_sleep_state); 425 + 426 + 427 + status = acpi_hw_sleep_dispatch(sleep_state, 0, ACPI_WAKE_FUNCTION_ID); 428 + return_ACPI_STATUS(status); 429 + } 430 + 431 + ACPI_EXPORT_SYMBOL(acpi_leave_sleep_state)
+14 -1
drivers/acpi/acpica/nsdump.c
··· 242 242 243 243 if (!obj_desc) { 244 244 245 - /* No attached object, we are done */ 245 + /* No attached object. Some types should always have an object */ 246 + 247 + switch (type) { 248 + case ACPI_TYPE_INTEGER: 249 + case ACPI_TYPE_PACKAGE: 250 + case ACPI_TYPE_BUFFER: 251 + case ACPI_TYPE_STRING: 252 + case ACPI_TYPE_METHOD: 253 + acpi_os_printf("<No attached object>"); 254 + break; 255 + 256 + default: 257 + break; 258 + } 246 259 247 260 acpi_os_printf("\n"); 248 261 return (AE_OK);
+1 -1
drivers/acpi/acpica/nsdumpdv.c
··· 121 121 return; 122 122 } 123 123 124 - status = acpi_get_handle(NULL, ACPI_NS_SYSTEM_BUS, &sys_bus_handle); 124 + status = acpi_get_handle(NULL, METHOD_NAME__SB_, &sys_bus_handle); 125 125 if (ACPI_FAILURE(status)) { 126 126 return; 127 127 }
+2 -2
drivers/acpi/acpica/nspredef.c
··· 638 638 /* Create the new outer package and populate it */ 639 639 640 640 status = 641 - acpi_ns_repair_package_list(data, 642 - return_object_ptr); 641 + acpi_ns_wrap_with_package(data, *elements, 642 + return_object_ptr); 643 643 if (ACPI_FAILURE(status)) { 644 644 return (status); 645 645 }
+58 -101
drivers/acpi/acpica/nsrepair.c
··· 71 71 * Buffer -> String 72 72 * Buffer -> Package of Integers 73 73 * Package -> Package of one Package 74 + * An incorrect standalone object is wrapped with required outer package 74 75 * 75 76 * Additional possible repairs: 76 - * 77 77 * Required package elements that are NULL replaced by Integer/String/Buffer 78 - * Incorrect standalone package wrapped with required outer package 79 78 * 80 79 ******************************************************************************/ 81 80 /* Local prototypes */ ··· 89 90 static acpi_status 90 91 acpi_ns_convert_to_buffer(union acpi_operand_object *original_object, 91 92 union acpi_operand_object **return_object); 92 - 93 - static acpi_status 94 - acpi_ns_convert_to_package(union acpi_operand_object *original_object, 95 - union acpi_operand_object **return_object); 96 93 97 94 /******************************************************************************* 98 95 * ··· 146 151 } 147 152 } 148 153 if (expected_btypes & ACPI_RTYPE_PACKAGE) { 149 - status = acpi_ns_convert_to_package(return_object, &new_object); 154 + /* 155 + * A package is expected. We will wrap the existing object with a 156 + * new package object. It is often the case that if a variable-length 157 + * package is required, but there is only a single object needed, the 158 + * BIOS will return that object instead of wrapping it with a Package 159 + * object. Note: after the wrapping, the package will be validated 160 + * for correct contents (expected object type or types). 161 + */ 162 + status = 163 + acpi_ns_wrap_with_package(data, return_object, &new_object); 150 164 if (ACPI_SUCCESS(status)) { 151 - goto object_repaired; 165 + /* 166 + * The original object just had its reference count 167 + * incremented for being inserted into the new package. 168 + */ 169 + *return_object_ptr = new_object; /* New Package object */ 170 + data->flags |= ACPI_OBJECT_REPAIRED; 171 + return (AE_OK); 152 172 } 153 173 } 154 174 ··· 175 165 176 166 /* Object was successfully repaired */ 177 167 178 - /* 179 - * If the original object is a package element, we need to: 180 - * 1. Set the reference count of the new object to match the 181 - * reference count of the old object. 182 - * 2. Decrement the reference count of the original object. 183 - */ 184 168 if (package_index != ACPI_NOT_PACKAGE_ELEMENT) { 185 - new_object->common.reference_count = 186 - return_object->common.reference_count; 169 + /* 170 + * The original object is a package element. We need to 171 + * decrement the reference count of the original object, 172 + * for removing it from the package. 173 + * 174 + * However, if the original object was just wrapped with a 175 + * package object as part of the repair, we don't need to 176 + * change the reference count. 177 + */ 178 + if (!(data->flags & ACPI_OBJECT_WRAPPED)) { 179 + new_object->common.reference_count = 180 + return_object->common.reference_count; 187 181 188 - if (return_object->common.reference_count > 1) { 189 - return_object->common.reference_count--; 182 + if (return_object->common.reference_count > 1) { 183 + return_object->common.reference_count--; 184 + } 190 185 } 191 186 192 187 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, 193 - "%s: Converted %s to expected %s at index %u\n", 188 + "%s: Converted %s to expected %s at Package index %u\n", 194 189 data->pathname, 195 190 acpi_ut_get_object_type_name(return_object), 196 191 acpi_ut_get_object_type_name(new_object), ··· 468 453 469 454 /******************************************************************************* 470 455 * 471 - * FUNCTION: acpi_ns_convert_to_package 472 - * 473 - * PARAMETERS: original_object - Object to be converted 474 - * return_object - Where the new converted object is returned 475 - * 476 - * RETURN: Status. AE_OK if conversion was successful. 477 - * 478 - * DESCRIPTION: Attempt to convert a Buffer object to a Package. Each byte of 479 - * the buffer is converted to a single integer package element. 480 - * 481 - ******************************************************************************/ 482 - 483 - static acpi_status 484 - acpi_ns_convert_to_package(union acpi_operand_object *original_object, 485 - union acpi_operand_object **return_object) 486 - { 487 - union acpi_operand_object *new_object; 488 - union acpi_operand_object **elements; 489 - u32 length; 490 - u8 *buffer; 491 - 492 - switch (original_object->common.type) { 493 - case ACPI_TYPE_BUFFER: 494 - 495 - /* Buffer-to-Package conversion */ 496 - 497 - length = original_object->buffer.length; 498 - new_object = acpi_ut_create_package_object(length); 499 - if (!new_object) { 500 - return (AE_NO_MEMORY); 501 - } 502 - 503 - /* Convert each buffer byte to an integer package element */ 504 - 505 - elements = new_object->package.elements; 506 - buffer = original_object->buffer.pointer; 507 - 508 - while (length--) { 509 - *elements = 510 - acpi_ut_create_integer_object((u64) *buffer); 511 - if (!*elements) { 512 - acpi_ut_remove_reference(new_object); 513 - return (AE_NO_MEMORY); 514 - } 515 - elements++; 516 - buffer++; 517 - } 518 - break; 519 - 520 - default: 521 - return (AE_AML_OPERAND_TYPE); 522 - } 523 - 524 - *return_object = new_object; 525 - return (AE_OK); 526 - } 527 - 528 - /******************************************************************************* 529 - * 530 456 * FUNCTION: acpi_ns_repair_null_element 531 457 * 532 458 * PARAMETERS: Data - Pointer to validation data structure ··· 633 677 634 678 /******************************************************************************* 635 679 * 636 - * FUNCTION: acpi_ns_repair_package_list 680 + * FUNCTION: acpi_ns_wrap_with_package 637 681 * 638 682 * PARAMETERS: Data - Pointer to validation data structure 639 - * obj_desc_ptr - Pointer to the object to repair. The new 640 - * package object is returned here, 641 - * overwriting the old object. 683 + * original_object - Pointer to the object to repair. 684 + * obj_desc_ptr - The new package object is returned here 642 685 * 643 686 * RETURN: Status, new object in *obj_desc_ptr 644 687 * 645 - * DESCRIPTION: Repair a common problem with objects that are defined to return 646 - * a variable-length Package of Packages. If the variable-length 647 - * is one, some BIOS code mistakenly simply declares a single 648 - * Package instead of a Package with one sub-Package. This 649 - * function attempts to repair this error by wrapping a Package 650 - * object around the original Package, creating the correct 651 - * Package with one sub-Package. 688 + * DESCRIPTION: Repair a common problem with objects that are defined to 689 + * return a variable-length Package of sub-objects. If there is 690 + * only one sub-object, some BIOS code mistakenly simply declares 691 + * the single object instead of a Package with one sub-object. 692 + * This function attempts to repair this error by wrapping a 693 + * Package object around the original object, creating the 694 + * correct and expected Package with one sub-object. 652 695 * 653 696 * Names that can be repaired in this manner include: 654 - * _ALR, _CSD, _HPX, _MLS, _PRT, _PSS, _TRT, TSS 697 + * _ALR, _CSD, _HPX, _MLS, _PLD, _PRT, _PSS, _TRT, _TSS, 698 + * _BCL, _DOD, _FIX, _Sx 655 699 * 656 700 ******************************************************************************/ 657 701 658 702 acpi_status 659 - acpi_ns_repair_package_list(struct acpi_predefined_data *data, 660 - union acpi_operand_object **obj_desc_ptr) 703 + acpi_ns_wrap_with_package(struct acpi_predefined_data *data, 704 + union acpi_operand_object *original_object, 705 + union acpi_operand_object **obj_desc_ptr) 661 706 { 662 707 union acpi_operand_object *pkg_obj_desc; 663 708 664 - ACPI_FUNCTION_NAME(ns_repair_package_list); 709 + ACPI_FUNCTION_NAME(ns_wrap_with_package); 665 710 666 711 /* 667 712 * Create the new outer package and populate it. The new package will 668 - * have a single element, the lone subpackage. 713 + * have a single element, the lone sub-object. 669 714 */ 670 715 pkg_obj_desc = acpi_ut_create_package_object(1); 671 716 if (!pkg_obj_desc) { 672 717 return (AE_NO_MEMORY); 673 718 } 674 719 675 - pkg_obj_desc->package.elements[0] = *obj_desc_ptr; 720 + pkg_obj_desc->package.elements[0] = original_object; 721 + 722 + ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, 723 + "%s: Wrapped %s with expected Package object\n", 724 + data->pathname, 725 + acpi_ut_get_object_type_name(original_object))); 676 726 677 727 /* Return the new object in the object pointer */ 678 728 679 729 *obj_desc_ptr = pkg_obj_desc; 680 - data->flags |= ACPI_OBJECT_REPAIRED; 681 - 682 - ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, 683 - "%s: Repaired incorrectly formed Package\n", 684 - data->pathname)); 685 - 730 + data->flags |= ACPI_OBJECT_REPAIRED | ACPI_OBJECT_WRAPPED; 686 731 return (AE_OK); 687 732 }
+1 -1
drivers/acpi/acpica/nsutils.c
··· 341 341 342 342 if (!acpi_ns_valid_path_separator(*external_name) && 343 343 (*external_name != 0)) { 344 - return_ACPI_STATUS(AE_BAD_PARAMETER); 344 + return_ACPI_STATUS(AE_BAD_PATHNAME); 345 345 } 346 346 347 347 /* Move on the next segment */
+4 -4
drivers/acpi/acpica/tbfadt.c
··· 363 363 u32 address32; 364 364 u32 i; 365 365 366 - /* Update the local FADT table header length */ 367 - 368 - acpi_gbl_FADT.header.length = sizeof(struct acpi_table_fadt); 369 - 370 366 /* 371 367 * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary. 372 368 * Later code will always use the X 64-bit field. Also, check for an ··· 403 407 acpi_gbl_FADT.cst_control = 0; 404 408 acpi_gbl_FADT.boot_flags = 0; 405 409 } 410 + 411 + /* Update the local FADT table header length */ 412 + 413 + acpi_gbl_FADT.header.length = sizeof(struct acpi_table_fadt); 406 414 407 415 /* 408 416 * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X"
+97 -20
drivers/acpi/acpica/tbinstal.c
··· 114 114 { 115 115 u32 i; 116 116 acpi_status status = AE_OK; 117 - struct acpi_table_header *override_table = NULL; 118 117 119 118 ACPI_FUNCTION_TRACE(tb_add_table); 120 119 ··· 223 224 /* 224 225 * ACPI Table Override: 225 226 * Allow the host to override dynamically loaded tables. 227 + * NOTE: the table is fully mapped at this point, and the mapping will 228 + * be deleted by tb_table_override if the table is actually overridden. 226 229 */ 227 - status = acpi_os_table_override(table_desc->pointer, &override_table); 228 - if (ACPI_SUCCESS(status) && override_table) { 229 - ACPI_INFO((AE_INFO, 230 - "%4.4s @ 0x%p Table override, replaced with:", 231 - table_desc->pointer->signature, 232 - ACPI_CAST_PTR(void, table_desc->address))); 233 - 234 - /* We can delete the table that was passed as a parameter */ 235 - 236 - acpi_tb_delete_table(table_desc); 237 - 238 - /* Setup descriptor for the new table */ 239 - 240 - table_desc->address = ACPI_PTR_TO_PHYSADDR(override_table); 241 - table_desc->pointer = override_table; 242 - table_desc->length = override_table->length; 243 - table_desc->flags = ACPI_TABLE_ORIGIN_OVERRIDE; 244 - } 230 + (void)acpi_tb_table_override(table_desc->pointer, table_desc); 245 231 246 232 /* Add the table to the global root table list */ 247 233 ··· 243 259 release: 244 260 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); 245 261 return_ACPI_STATUS(status); 262 + } 263 + 264 + /******************************************************************************* 265 + * 266 + * FUNCTION: acpi_tb_table_override 267 + * 268 + * PARAMETERS: table_header - Header for the original table 269 + * table_desc - Table descriptor initialized for the 270 + * original table. May or may not be mapped. 271 + * 272 + * RETURN: Pointer to the entire new table. NULL if table not overridden. 273 + * If overridden, installs the new table within the input table 274 + * descriptor. 275 + * 276 + * DESCRIPTION: Attempt table override by calling the OSL override functions. 277 + * Note: If the table is overridden, then the entire new table 278 + * is mapped and returned by this function. 279 + * 280 + ******************************************************************************/ 281 + 282 + struct acpi_table_header *acpi_tb_table_override(struct acpi_table_header 283 + *table_header, 284 + struct acpi_table_desc 285 + *table_desc) 286 + { 287 + acpi_status status; 288 + struct acpi_table_header *new_table = NULL; 289 + acpi_physical_address new_address = 0; 290 + u32 new_table_length = 0; 291 + u8 new_flags; 292 + char *override_type; 293 + 294 + /* (1) Attempt logical override (returns a logical address) */ 295 + 296 + status = acpi_os_table_override(table_header, &new_table); 297 + if (ACPI_SUCCESS(status) && new_table) { 298 + new_address = ACPI_PTR_TO_PHYSADDR(new_table); 299 + new_table_length = new_table->length; 300 + new_flags = ACPI_TABLE_ORIGIN_OVERRIDE; 301 + override_type = "Logical"; 302 + goto finish_override; 303 + } 304 + 305 + /* (2) Attempt physical override (returns a physical address) */ 306 + 307 + status = acpi_os_physical_table_override(table_header, 308 + &new_address, 309 + &new_table_length); 310 + if (ACPI_SUCCESS(status) && new_address && new_table_length) { 311 + 312 + /* Map the entire new table */ 313 + 314 + new_table = acpi_os_map_memory(new_address, new_table_length); 315 + if (!new_table) { 316 + ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY, 317 + "%4.4s %p Attempted physical table override failed", 318 + table_header->signature, 319 + ACPI_CAST_PTR(void, 320 + table_desc->address))); 321 + return (NULL); 322 + } 323 + 324 + override_type = "Physical"; 325 + new_flags = ACPI_TABLE_ORIGIN_MAPPED; 326 + goto finish_override; 327 + } 328 + 329 + return (NULL); /* There was no override */ 330 + 331 + finish_override: 332 + 333 + ACPI_INFO((AE_INFO, 334 + "%4.4s %p %s table override, new table: %p", 335 + table_header->signature, 336 + ACPI_CAST_PTR(void, table_desc->address), 337 + override_type, new_table)); 338 + 339 + /* We can now unmap/delete the original table (if fully mapped) */ 340 + 341 + acpi_tb_delete_table(table_desc); 342 + 343 + /* Setup descriptor for the new table */ 344 + 345 + table_desc->address = new_address; 346 + table_desc->pointer = new_table; 347 + table_desc->length = new_table_length; 348 + table_desc->flags = new_flags; 349 + 350 + return (new_table); 246 351 } 247 352 248 353 /******************************************************************************* ··· 469 396 case ACPI_TABLE_ORIGIN_ALLOCATED: 470 397 ACPI_FREE(table_desc->pointer); 471 398 break; 472 - default:; 399 + 400 + /* Not mapped or allocated, there is nothing we can do */ 401 + 402 + default: 403 + return; 473 404 } 474 405 475 406 table_desc->pointer = NULL;
+52 -43
drivers/acpi/acpica/tbutils.c
··· 118 118 return AE_OK; 119 119 } 120 120 121 + #if (!ACPI_REDUCED_HARDWARE) 121 122 /******************************************************************************* 122 123 * 123 124 * FUNCTION: acpi_tb_initialize_facs ··· 149 148 &acpi_gbl_FACS)); 150 149 return status; 151 150 } 151 + #endif /* !ACPI_REDUCED_HARDWARE */ 152 152 153 153 /******************************************************************************* 154 154 * ··· 446 444 * RETURN: None 447 445 * 448 446 * DESCRIPTION: Install an ACPI table into the global data structure. The 449 - * table override mechanism is implemented here to allow the host 447 + * table override mechanism is called to allow the host 450 448 * OS to replace any table before it is installed in the root 451 449 * table array. 452 450 * ··· 456 454 acpi_tb_install_table(acpi_physical_address address, 457 455 char *signature, u32 table_index) 458 456 { 459 - u8 flags; 460 - acpi_status status; 461 - struct acpi_table_header *table_to_install; 462 - struct acpi_table_header *mapped_table; 463 - struct acpi_table_header *override_table = NULL; 457 + struct acpi_table_header *table; 458 + struct acpi_table_header *final_table; 459 + struct acpi_table_desc *table_desc; 464 460 465 461 if (!address) { 466 462 ACPI_ERROR((AE_INFO, ··· 469 469 470 470 /* Map just the table header */ 471 471 472 - mapped_table = 473 - acpi_os_map_memory(address, sizeof(struct acpi_table_header)); 474 - if (!mapped_table) { 472 + table = acpi_os_map_memory(address, sizeof(struct acpi_table_header)); 473 + if (!table) { 474 + ACPI_ERROR((AE_INFO, 475 + "Could not map memory for table [%s] at %p", 476 + signature, ACPI_CAST_PTR(void, address))); 475 477 return; 476 478 } 477 479 478 480 /* If a particular signature is expected (DSDT/FACS), it must match */ 479 481 480 - if (signature && !ACPI_COMPARE_NAME(mapped_table->signature, signature)) { 482 + if (signature && !ACPI_COMPARE_NAME(table->signature, signature)) { 481 483 ACPI_ERROR((AE_INFO, 482 484 "Invalid signature 0x%X for ACPI table, expected [%s]", 483 - *ACPI_CAST_PTR(u32, mapped_table->signature), 484 - signature)); 485 + *ACPI_CAST_PTR(u32, table->signature), signature)); 485 486 goto unmap_and_exit; 486 487 } 488 + 489 + /* 490 + * Initialize the table entry. Set the pointer to NULL, since the 491 + * table is not fully mapped at this time. 492 + */ 493 + table_desc = &acpi_gbl_root_table_list.tables[table_index]; 494 + 495 + table_desc->address = address; 496 + table_desc->pointer = NULL; 497 + table_desc->length = table->length; 498 + table_desc->flags = ACPI_TABLE_ORIGIN_MAPPED; 499 + ACPI_MOVE_32_TO_32(table_desc->signature.ascii, table->signature); 487 500 488 501 /* 489 502 * ACPI Table Override: ··· 504 491 * Before we install the table, let the host OS override it with a new 505 492 * one if desired. Any table within the RSDT/XSDT can be replaced, 506 493 * including the DSDT which is pointed to by the FADT. 494 + * 495 + * NOTE: If the table is overridden, then final_table will contain a 496 + * mapped pointer to the full new table. If the table is not overridden, 497 + * or if there has been a physical override, then the table will be 498 + * fully mapped later (in verify table). In any case, we must 499 + * unmap the header that was mapped above. 507 500 */ 508 - status = acpi_os_table_override(mapped_table, &override_table); 509 - if (ACPI_SUCCESS(status) && override_table) { 510 - ACPI_INFO((AE_INFO, 511 - "%4.4s @ 0x%p Table override, replaced with:", 512 - mapped_table->signature, ACPI_CAST_PTR(void, 513 - address))); 514 - 515 - acpi_gbl_root_table_list.tables[table_index].pointer = 516 - override_table; 517 - address = ACPI_PTR_TO_PHYSADDR(override_table); 518 - 519 - table_to_install = override_table; 520 - flags = ACPI_TABLE_ORIGIN_OVERRIDE; 521 - } else { 522 - table_to_install = mapped_table; 523 - flags = ACPI_TABLE_ORIGIN_MAPPED; 501 + final_table = acpi_tb_table_override(table, table_desc); 502 + if (!final_table) { 503 + final_table = table; /* There was no override */ 524 504 } 525 505 526 - /* Initialize the table entry */ 506 + acpi_tb_print_table_header(table_desc->address, final_table); 527 507 528 - acpi_gbl_root_table_list.tables[table_index].address = address; 529 - acpi_gbl_root_table_list.tables[table_index].length = 530 - table_to_install->length; 531 - acpi_gbl_root_table_list.tables[table_index].flags = flags; 532 - 533 - ACPI_MOVE_32_TO_32(& 534 - (acpi_gbl_root_table_list.tables[table_index]. 535 - signature), table_to_install->signature); 536 - 537 - acpi_tb_print_table_header(address, table_to_install); 508 + /* Set the global integer width (based upon revision of the DSDT) */ 538 509 539 510 if (table_index == ACPI_TABLE_INDEX_DSDT) { 511 + acpi_ut_set_integer_width(final_table->revision); 512 + } 540 513 541 - /* Global integer width is based upon revision of the DSDT */ 542 - 543 - acpi_ut_set_integer_width(table_to_install->revision); 514 + /* 515 + * If we have a physical override during this early loading of the ACPI 516 + * tables, unmap the table for now. It will be mapped again later when 517 + * it is actually used. This supports very early loading of ACPI tables, 518 + * before virtual memory is fully initialized and running within the 519 + * host OS. Note: A logical override has the ACPI_TABLE_ORIGIN_OVERRIDE 520 + * flag set and will not be deleted below. 521 + */ 522 + if (final_table != table) { 523 + acpi_tb_delete_table(table_desc); 544 524 } 545 525 546 526 unmap_and_exit: 547 - acpi_os_unmap_memory(mapped_table, sizeof(struct acpi_table_header)); 527 + 528 + /* Always unmap the table header that we mapped above */ 529 + 530 + acpi_os_unmap_memory(table, sizeof(struct acpi_table_header)); 548 531 } 549 532 550 533 /*******************************************************************************
+18 -16
drivers/acpi/acpica/utdecode.c
··· 497 497 498 498 /* Names for Notify() values, used for debug output */ 499 499 500 - static const char *acpi_gbl_notify_value_names[] = { 501 - "Bus Check", 502 - "Device Check", 503 - "Device Wake", 504 - "Eject Request", 505 - "Device Check Light", 506 - "Frequency Mismatch", 507 - "Bus Mode Mismatch", 508 - "Power Fault", 509 - "Capabilities Check", 510 - "Device PLD Check", 511 - "Reserved", 512 - "System Locality Update" 500 + static const char *acpi_gbl_notify_value_names[ACPI_NOTIFY_MAX + 1] = { 501 + /* 00 */ "Bus Check", 502 + /* 01 */ "Device Check", 503 + /* 02 */ "Device Wake", 504 + /* 03 */ "Eject Request", 505 + /* 04 */ "Device Check Light", 506 + /* 05 */ "Frequency Mismatch", 507 + /* 06 */ "Bus Mode Mismatch", 508 + /* 07 */ "Power Fault", 509 + /* 08 */ "Capabilities Check", 510 + /* 09 */ "Device PLD Check", 511 + /* 10 */ "Reserved", 512 + /* 11 */ "System Locality Update", 513 + /* 12 */ "Shutdown Request" 513 514 }; 514 515 515 516 const char *acpi_ut_get_notify_name(u32 notify_value) ··· 520 519 return (acpi_gbl_notify_value_names[notify_value]); 521 520 } else if (notify_value <= ACPI_MAX_SYS_NOTIFY) { 522 521 return ("Reserved"); 523 - } else { /* Greater or equal to 0x80 */ 524 - 525 - return ("**Device Specific**"); 522 + } else if (notify_value <= ACPI_MAX_DEVICE_SPECIFIC_NOTIFY) { 523 + return ("Device Specific"); 524 + } else { 525 + return ("Hardware Specific"); 526 526 } 527 527 } 528 528 #endif
+8 -1
drivers/acpi/acpica/utglobal.c
··· 140 140 {NULL, ACPI_TYPE_ANY, NULL} 141 141 }; 142 142 143 + #if (!ACPI_REDUCED_HARDWARE) 143 144 /****************************************************************************** 144 145 * 145 146 * Event and Hardware globals ··· 237 236 ACPI_BITMASK_RT_CLOCK_STATUS, 238 237 ACPI_BITMASK_RT_CLOCK_ENABLE}, 239 238 }; 239 + #endif /* !ACPI_REDUCED_HARDWARE */ 240 240 241 241 /******************************************************************************* 242 242 * ··· 288 286 289 287 acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; 290 288 289 + #if (!ACPI_REDUCED_HARDWARE) 290 + 291 291 /* GPE support */ 292 292 293 293 acpi_gbl_gpe_xrupt_list_head = NULL; ··· 297 293 acpi_gbl_gpe_fadt_blocks[1] = NULL; 298 294 acpi_current_gpe_count = 0; 299 295 acpi_gbl_all_gpes_initialized = FALSE; 296 + 297 + acpi_gbl_global_event_handler = NULL; 298 + 299 + #endif /* !ACPI_REDUCED_HARDWARE */ 300 300 301 301 /* Global handlers */ 302 302 ··· 310 302 acpi_gbl_init_handler = NULL; 311 303 acpi_gbl_table_handler = NULL; 312 304 acpi_gbl_interface_handler = NULL; 313 - acpi_gbl_global_event_handler = NULL; 314 305 315 306 /* Global Lock support */ 316 307
+32 -5
drivers/acpi/acpica/utinit.c
··· 53 53 /* Local prototypes */ 54 54 static void acpi_ut_terminate(void); 55 55 56 + #if (!ACPI_REDUCED_HARDWARE) 57 + 58 + static void acpi_ut_free_gpe_lists(void); 59 + 60 + #else 61 + 62 + #define acpi_ut_free_gpe_lists() 63 + #endif /* !ACPI_REDUCED_HARDWARE */ 64 + 65 + #if (!ACPI_REDUCED_HARDWARE) 56 66 /****************************************************************************** 57 67 * 58 - * FUNCTION: acpi_ut_terminate 68 + * FUNCTION: acpi_ut_free_gpe_lists 59 69 * 60 70 * PARAMETERS: none 61 71 * 62 72 * RETURN: none 63 73 * 64 - * DESCRIPTION: Free global memory 74 + * DESCRIPTION: Free global GPE lists 65 75 * 66 76 ******************************************************************************/ 67 77 68 - static void acpi_ut_terminate(void) 78 + static void acpi_ut_free_gpe_lists(void) 69 79 { 70 80 struct acpi_gpe_block_info *gpe_block; 71 81 struct acpi_gpe_block_info *next_gpe_block; 72 82 struct acpi_gpe_xrupt_info *gpe_xrupt_info; 73 83 struct acpi_gpe_xrupt_info *next_gpe_xrupt_info; 74 - 75 - ACPI_FUNCTION_TRACE(ut_terminate); 76 84 77 85 /* Free global GPE blocks and related info structures */ 78 86 ··· 99 91 ACPI_FREE(gpe_xrupt_info); 100 92 gpe_xrupt_info = next_gpe_xrupt_info; 101 93 } 94 + } 95 + #endif /* !ACPI_REDUCED_HARDWARE */ 102 96 97 + /****************************************************************************** 98 + * 99 + * FUNCTION: acpi_ut_terminate 100 + * 101 + * PARAMETERS: none 102 + * 103 + * RETURN: none 104 + * 105 + * DESCRIPTION: Free global memory 106 + * 107 + ******************************************************************************/ 108 + 109 + static void acpi_ut_terminate(void) 110 + { 111 + ACPI_FUNCTION_TRACE(ut_terminate); 112 + 113 + acpi_ut_free_gpe_lists(); 103 114 acpi_ut_delete_address_lists(); 104 115 return_VOID; 105 116 }
+5 -1
drivers/acpi/acpica/utxface.c
··· 145 145 146 146 ACPI_FUNCTION_TRACE(acpi_enable_subsystem); 147 147 148 + #if (!ACPI_REDUCED_HARDWARE) 149 + 148 150 /* Enable ACPI mode */ 149 151 150 152 if (!(flags & ACPI_NO_ACPI_ENABLE)) { ··· 171 169 ACPI_WARNING((AE_INFO, "Could not map the FACS table")); 172 170 return_ACPI_STATUS(status); 173 171 } 172 + #endif /* !ACPI_REDUCED_HARDWARE */ 174 173 175 174 /* 176 175 * Install the default op_region handlers. These are installed unless ··· 187 184 return_ACPI_STATUS(status); 188 185 } 189 186 } 190 - 187 + #if (!ACPI_REDUCED_HARDWARE) 191 188 /* 192 189 * Initialize ACPI Event handling (Fixed and General Purpose) 193 190 * ··· 223 220 return_ACPI_STATUS(status); 224 221 } 225 222 } 223 + #endif /* !ACPI_REDUCED_HARDWARE */ 226 224 227 225 return_ACPI_STATUS(status); 228 226 }
+40 -21
drivers/acpi/apei/apei-base.c
··· 558 558 } 559 559 EXPORT_SYMBOL_GPL(apei_resources_release); 560 560 561 - static int apei_check_gar(struct acpi_generic_address *reg, u64 *paddr) 561 + static int apei_check_gar(struct acpi_generic_address *reg, u64 *paddr, 562 + u32 *access_bit_width) 562 563 { 563 - u32 width, space_id; 564 + u32 bit_width, bit_offset, access_size_code, space_id; 564 565 565 - width = reg->bit_width; 566 + bit_width = reg->bit_width; 567 + bit_offset = reg->bit_offset; 568 + access_size_code = reg->access_width; 566 569 space_id = reg->space_id; 567 570 /* Handle possible alignment issues */ 568 571 memcpy(paddr, &reg->address, sizeof(*paddr)); 569 572 if (!*paddr) { 570 573 pr_warning(FW_BUG APEI_PFX 571 - "Invalid physical address in GAR [0x%llx/%u/%u]\n", 572 - *paddr, width, space_id); 574 + "Invalid physical address in GAR [0x%llx/%u/%u/%u/%u]\n", 575 + *paddr, bit_width, bit_offset, access_size_code, 576 + space_id); 573 577 return -EINVAL; 574 578 } 575 579 576 - if ((width != 8) && (width != 16) && (width != 32) && (width != 64)) { 580 + if (access_size_code < 1 || access_size_code > 4) { 577 581 pr_warning(FW_BUG APEI_PFX 578 - "Invalid bit width in GAR [0x%llx/%u/%u]\n", 579 - *paddr, width, space_id); 582 + "Invalid access size code in GAR [0x%llx/%u/%u/%u/%u]\n", 583 + *paddr, bit_width, bit_offset, access_size_code, 584 + space_id); 585 + return -EINVAL; 586 + } 587 + *access_bit_width = 1UL << (access_size_code + 2); 588 + 589 + if ((bit_width + bit_offset) > *access_bit_width) { 590 + pr_warning(FW_BUG APEI_PFX 591 + "Invalid bit width + offset in GAR [0x%llx/%u/%u/%u/%u]\n", 592 + *paddr, bit_width, bit_offset, access_size_code, 593 + space_id); 580 594 return -EINVAL; 581 595 } 582 596 583 597 if (space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY && 584 598 space_id != ACPI_ADR_SPACE_SYSTEM_IO) { 585 599 pr_warning(FW_BUG APEI_PFX 586 - "Invalid address space type in GAR [0x%llx/%u/%u]\n", 587 - *paddr, width, space_id); 600 + "Invalid address space type in GAR [0x%llx/%u/%u/%u/%u]\n", 601 + *paddr, bit_width, bit_offset, access_size_code, 602 + space_id); 588 603 return -EINVAL; 589 604 } 590 605 ··· 610 595 int apei_read(u64 *val, struct acpi_generic_address *reg) 611 596 { 612 597 int rc; 598 + u32 access_bit_width; 613 599 u64 address; 614 600 acpi_status status; 615 601 616 - rc = apei_check_gar(reg, &address); 602 + rc = apei_check_gar(reg, &address, &access_bit_width); 617 603 if (rc) 618 604 return rc; 619 605 620 606 *val = 0; 621 607 switch(reg->space_id) { 622 608 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 623 - status = acpi_os_read_memory64((acpi_physical_address) 624 - address, val, reg->bit_width); 609 + status = acpi_os_read_memory((acpi_physical_address) address, 610 + val, access_bit_width); 625 611 if (ACPI_FAILURE(status)) 626 612 return -EIO; 627 613 break; 628 614 case ACPI_ADR_SPACE_SYSTEM_IO: 629 - status = acpi_os_read_port(address, (u32 *)val, reg->bit_width); 615 + status = acpi_os_read_port(address, (u32 *)val, 616 + access_bit_width); 630 617 if (ACPI_FAILURE(status)) 631 618 return -EIO; 632 619 break; ··· 644 627 int apei_write(u64 val, struct acpi_generic_address *reg) 645 628 { 646 629 int rc; 630 + u32 access_bit_width; 647 631 u64 address; 648 632 acpi_status status; 649 633 650 - rc = apei_check_gar(reg, &address); 634 + rc = apei_check_gar(reg, &address, &access_bit_width); 651 635 if (rc) 652 636 return rc; 653 637 654 638 switch (reg->space_id) { 655 639 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 656 - status = acpi_os_write_memory64((acpi_physical_address) 657 - address, val, reg->bit_width); 640 + status = acpi_os_write_memory((acpi_physical_address) address, 641 + val, access_bit_width); 658 642 if (ACPI_FAILURE(status)) 659 643 return -EIO; 660 644 break; 661 645 case ACPI_ADR_SPACE_SYSTEM_IO: 662 - status = acpi_os_write_port(address, val, reg->bit_width); 646 + status = acpi_os_write_port(address, val, access_bit_width); 663 647 if (ACPI_FAILURE(status)) 664 648 return -EIO; 665 649 break; ··· 679 661 struct apei_resources *resources = data; 680 662 struct acpi_generic_address *reg = &entry->register_region; 681 663 u8 ins = entry->instruction; 664 + u32 access_bit_width; 682 665 u64 paddr; 683 666 int rc; 684 667 685 668 if (!(ctx->ins_table[ins].flags & APEI_EXEC_INS_ACCESS_REGISTER)) 686 669 return 0; 687 670 688 - rc = apei_check_gar(reg, &paddr); 671 + rc = apei_check_gar(reg, &paddr, &access_bit_width); 689 672 if (rc) 690 673 return rc; 691 674 692 675 switch (reg->space_id) { 693 676 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 694 677 return apei_res_add(&resources->iomem, paddr, 695 - reg->bit_width / 8); 678 + access_bit_width / 8); 696 679 case ACPI_ADR_SPACE_SYSTEM_IO: 697 680 return apei_res_add(&resources->ioport, paddr, 698 - reg->bit_width / 8); 681 + access_bit_width / 8); 699 682 default: 700 683 return -EINVAL; 701 684 }
+2
drivers/acpi/apei/cper.c
··· 362 362 gedata_len = gdata->error_data_length; 363 363 apei_estatus_print_section(pfx, gdata, sec_no); 364 364 data_len -= gedata_len + sizeof(*gdata); 365 + gdata = (void *)(gdata + 1) + gedata_len; 365 366 sec_no++; 366 367 } 367 368 } ··· 397 396 if (gedata_len > data_len - sizeof(*gdata)) 398 397 return -EINVAL; 399 398 data_len -= gedata_len + sizeof(*gdata); 399 + gdata = (void *)(gdata + 1) + gedata_len; 400 400 } 401 401 if (data_len) 402 402 return -EINVAL;
+13 -4
drivers/acpi/apei/einj.c
··· 74 74 u8 reserved[3]; 75 75 }; 76 76 77 + static u32 notrigger; 78 + 77 79 static u32 vendor_flags; 78 80 static struct debugfs_blob_wrapper vendor_blob; 79 81 static char vendor_dev[64]; ··· 240 238 return v5param; 241 239 } 242 240 } 243 - if (paddrv4) { 241 + if (param_extension && paddrv4) { 244 242 struct einj_parameter *v4param; 245 243 246 244 v4param = acpi_os_map_memory(paddrv4, sizeof(*v4param)); ··· 498 496 if (rc) 499 497 return rc; 500 498 trigger_paddr = apei_exec_ctx_get_output(&ctx); 501 - rc = __einj_error_trigger(trigger_paddr, type, param1, param2); 502 - if (rc) 503 - return rc; 499 + if (notrigger == 0) { 500 + rc = __einj_error_trigger(trigger_paddr, type, param1, param2); 501 + if (rc) 502 + return rc; 503 + } 504 504 rc = apei_exec_run_optional(&ctx, ACPI_EINJ_END_OPERATION); 505 505 506 506 return rc; ··· 702 698 goto err_unmap; 703 699 fentry = debugfs_create_x64("param2", S_IRUSR | S_IWUSR, 704 700 einj_debug_dir, &error_param2); 701 + if (!fentry) 702 + goto err_unmap; 703 + 704 + fentry = debugfs_create_x32("notrigger", S_IRUSR | S_IWUSR, 705 + einj_debug_dir, &notrigger); 705 706 if (!fentry) 706 707 goto err_unmap; 707 708 }
+1 -1
drivers/acpi/apei/erst.c
··· 917 917 { 918 918 if ((erst_tab->header_length != 919 919 (sizeof(struct acpi_table_erst) - sizeof(erst_tab->header))) 920 - && (erst_tab->header_length != sizeof(struct acpi_table_einj))) 920 + && (erst_tab->header_length != sizeof(struct acpi_table_erst))) 921 921 return -EINVAL; 922 922 if (erst_tab->header.length < sizeof(struct acpi_table_erst)) 923 923 return -EINVAL;
+175
drivers/acpi/bgrt.c
··· 1 + /* 2 + * Copyright 2012 Red Hat, Inc <mjg@redhat.com> 3 + * 4 + * This program is free software; you can redistribute it and/or modify 5 + * it under the terms of the GNU General Public License version 2 as 6 + * published by the Free Software Foundation. 7 + */ 8 + 9 + #include <linux/kernel.h> 10 + #include <linux/module.h> 11 + #include <linux/init.h> 12 + #include <linux/device.h> 13 + #include <linux/sysfs.h> 14 + #include <acpi/acpi.h> 15 + #include <acpi/acpi_bus.h> 16 + 17 + static struct acpi_table_bgrt *bgrt_tab; 18 + static struct kobject *bgrt_kobj; 19 + 20 + struct bmp_header { 21 + u16 id; 22 + u32 size; 23 + } __attribute ((packed)); 24 + 25 + static struct bmp_header bmp_header; 26 + 27 + static ssize_t show_version(struct device *dev, 28 + struct device_attribute *attr, char *buf) 29 + { 30 + return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab->version); 31 + } 32 + static DEVICE_ATTR(version, S_IRUGO, show_version, NULL); 33 + 34 + static ssize_t show_status(struct device *dev, 35 + struct device_attribute *attr, char *buf) 36 + { 37 + return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab->status); 38 + } 39 + static DEVICE_ATTR(status, S_IRUGO, show_status, NULL); 40 + 41 + static ssize_t show_type(struct device *dev, 42 + struct device_attribute *attr, char *buf) 43 + { 44 + return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab->image_type); 45 + } 46 + static DEVICE_ATTR(type, S_IRUGO, show_type, NULL); 47 + 48 + static ssize_t show_xoffset(struct device *dev, 49 + struct device_attribute *attr, char *buf) 50 + { 51 + return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab->image_offset_x); 52 + } 53 + static DEVICE_ATTR(xoffset, S_IRUGO, show_xoffset, NULL); 54 + 55 + static ssize_t show_yoffset(struct device *dev, 56 + struct device_attribute *attr, char *buf) 57 + { 58 + return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab->image_offset_y); 59 + } 60 + static DEVICE_ATTR(yoffset, S_IRUGO, show_yoffset, NULL); 61 + 62 + static ssize_t show_image(struct file *file, struct kobject *kobj, 63 + struct bin_attribute *attr, char *buf, loff_t off, size_t count) 64 + { 65 + int size = attr->size; 66 + void __iomem *image = attr->private; 67 + 68 + if (off >= size) { 69 + count = 0; 70 + } else { 71 + if (off + count > size) 72 + count = size - off; 73 + 74 + memcpy_fromio(buf, image+off, count); 75 + } 76 + 77 + return count; 78 + } 79 + 80 + static struct bin_attribute image_attr = { 81 + .attr = { 82 + .name = "image", 83 + .mode = S_IRUGO, 84 + }, 85 + .read = show_image, 86 + }; 87 + 88 + static struct attribute *bgrt_attributes[] = { 89 + &dev_attr_version.attr, 90 + &dev_attr_status.attr, 91 + &dev_attr_type.attr, 92 + &dev_attr_xoffset.attr, 93 + &dev_attr_yoffset.attr, 94 + NULL, 95 + }; 96 + 97 + static struct attribute_group bgrt_attribute_group = { 98 + .attrs = bgrt_attributes, 99 + }; 100 + 101 + static int __init bgrt_init(void) 102 + { 103 + acpi_status status; 104 + int ret; 105 + void __iomem *bgrt; 106 + 107 + if (acpi_disabled) 108 + return -ENODEV; 109 + 110 + status = acpi_get_table("BGRT", 0, 111 + (struct acpi_table_header **)&bgrt_tab); 112 + 113 + if (ACPI_FAILURE(status)) 114 + return -ENODEV; 115 + 116 + sysfs_bin_attr_init(&image_attr); 117 + 118 + bgrt = ioremap(bgrt_tab->image_address, sizeof(struct bmp_header)); 119 + 120 + if (!bgrt) { 121 + ret = -EINVAL; 122 + goto out_err; 123 + } 124 + 125 + memcpy_fromio(&bmp_header, bgrt, sizeof(bmp_header)); 126 + image_attr.size = bmp_header.size; 127 + iounmap(bgrt); 128 + 129 + image_attr.private = ioremap(bgrt_tab->image_address, image_attr.size); 130 + 131 + if (!image_attr.private) { 132 + ret = -EINVAL; 133 + goto out_err; 134 + } 135 + 136 + 137 + bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj); 138 + if (!bgrt_kobj) { 139 + ret = -EINVAL; 140 + goto out_iounmap; 141 + } 142 + 143 + ret = sysfs_create_group(bgrt_kobj, &bgrt_attribute_group); 144 + if (ret) 145 + goto out_kobject; 146 + 147 + ret = sysfs_create_bin_file(bgrt_kobj, &image_attr); 148 + if (ret) 149 + goto out_group; 150 + 151 + return 0; 152 + 153 + out_group: 154 + sysfs_remove_group(bgrt_kobj, &bgrt_attribute_group); 155 + out_kobject: 156 + kobject_put(bgrt_kobj); 157 + out_iounmap: 158 + iounmap(image_attr.private); 159 + out_err: 160 + return ret; 161 + } 162 + 163 + static void __exit bgrt_exit(void) 164 + { 165 + iounmap(image_attr.private); 166 + sysfs_remove_group(bgrt_kobj, &bgrt_attribute_group); 167 + sysfs_remove_bin_file(bgrt_kobj, &image_attr); 168 + } 169 + 170 + module_init(bgrt_init); 171 + module_exit(bgrt_exit); 172 + 173 + MODULE_AUTHOR("Matthew Garrett"); 174 + MODULE_DESCRIPTION("BGRT boot graphic support"); 175 + MODULE_LICENSE("GPL");
+1
drivers/acpi/bus.c
··· 1010 1010 } 1011 1011 1012 1012 struct kobject *acpi_kobj; 1013 + EXPORT_SYMBOL_GPL(acpi_kobj); 1013 1014 1014 1015 static int __init acpi_init(void) 1015 1016 {
+4 -4
drivers/acpi/ec.c
··· 822 822 first_ec = ec; 823 823 device->driver_data = ec; 824 824 825 - WARN(!request_region(ec->data_addr, 1, "EC data"), 826 - "Could not request EC data io port 0x%lx", ec->data_addr); 827 - WARN(!request_region(ec->command_addr, 1, "EC cmd"), 828 - "Could not request EC cmd io port 0x%lx", ec->command_addr); 825 + ret = !!request_region(ec->data_addr, 1, "EC data"); 826 + WARN(!ret, "Could not request EC data io port 0x%lx", ec->data_addr); 827 + ret = !!request_region(ec->command_addr, 1, "EC cmd"); 828 + WARN(!ret, "Could not request EC cmd io port 0x%lx", ec->command_addr); 829 829 830 830 pr_info(PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n", 831 831 ec->gpe, ec->command_addr, ec->data_addr);
+2 -2
drivers/acpi/nvs.c
··· 95 95 { 96 96 struct nvs_page *entry, *next; 97 97 98 - pr_info("PM: Registering ACPI NVS region at %lx (%ld bytes)\n", 99 - start, size); 98 + pr_info("PM: Registering ACPI NVS region [mem %#010lx-%#010lx] (%ld bytes)\n", 99 + start, start + size - 1, size); 100 100 101 101 while (size > 0) { 102 102 unsigned int nr_bytes;
+38 -86
drivers/acpi/osl.c
··· 77 77 extern char line_buf[80]; 78 78 #endif /*ENABLE_DEBUGGER */ 79 79 80 + static int (*__acpi_os_prepare_sleep)(u8 sleep_state, u32 pm1a_ctrl, 81 + u32 pm1b_ctrl); 82 + 80 83 static acpi_osd_handler acpi_irq_handler; 81 84 static void *acpi_irq_context; 82 85 static struct workqueue_struct *kacpid_wq; ··· 350 347 unsigned long pfn; 351 348 352 349 pfn = pg_off >> PAGE_SHIFT; 353 - if (page_is_ram(pfn)) 350 + if (should_use_kmap(pfn)) 354 351 kunmap(pfn_to_page(pfn)); 355 352 else 356 353 iounmap(vaddr); ··· 557 554 return AE_OK; 558 555 } 559 556 557 + acpi_status 558 + acpi_os_physical_table_override(struct acpi_table_header *existing_table, 559 + acpi_physical_address * new_address, 560 + u32 *new_table_length) 561 + { 562 + return AE_SUPPORT; 563 + } 564 + 565 + 560 566 static irqreturn_t acpi_irq(int irq, void *dev_id) 561 567 { 562 568 u32 handled; ··· 607 595 608 596 acpi_irq_handler = handler; 609 597 acpi_irq_context = context; 610 - if (request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)) { 598 + if (request_threaded_irq(irq, NULL, acpi_irq, IRQF_SHARED, "acpi", 599 + acpi_irq)) { 611 600 printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq); 612 601 acpi_irq_handler = NULL; 613 602 return AE_NOT_ACQUIRED; ··· 712 699 713 700 EXPORT_SYMBOL(acpi_os_write_port); 714 701 715 - acpi_status 716 - acpi_os_read_memory(acpi_physical_address phys_addr, u32 * value, u32 width) 717 - { 718 - void __iomem *virt_addr; 719 - unsigned int size = width / 8; 720 - bool unmap = false; 721 - u32 dummy; 722 - 723 - rcu_read_lock(); 724 - virt_addr = acpi_map_vaddr_lookup(phys_addr, size); 725 - if (!virt_addr) { 726 - rcu_read_unlock(); 727 - virt_addr = acpi_os_ioremap(phys_addr, size); 728 - if (!virt_addr) 729 - return AE_BAD_ADDRESS; 730 - unmap = true; 731 - } 732 - 733 - if (!value) 734 - value = &dummy; 735 - 736 - switch (width) { 737 - case 8: 738 - *(u8 *) value = readb(virt_addr); 739 - break; 740 - case 16: 741 - *(u16 *) value = readw(virt_addr); 742 - break; 743 - case 32: 744 - *(u32 *) value = readl(virt_addr); 745 - break; 746 - default: 747 - BUG(); 748 - } 749 - 750 - if (unmap) 751 - iounmap(virt_addr); 752 - else 753 - rcu_read_unlock(); 754 - 755 - return AE_OK; 756 - } 757 - 758 702 #ifdef readq 759 703 static inline u64 read64(const volatile void __iomem *addr) 760 704 { ··· 728 758 #endif 729 759 730 760 acpi_status 731 - acpi_os_read_memory64(acpi_physical_address phys_addr, u64 *value, u32 width) 761 + acpi_os_read_memory(acpi_physical_address phys_addr, u64 *value, u32 width) 732 762 { 733 763 void __iomem *virt_addr; 734 764 unsigned int size = width / 8; ··· 773 803 return AE_OK; 774 804 } 775 805 776 - acpi_status 777 - acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width) 778 - { 779 - void __iomem *virt_addr; 780 - unsigned int size = width / 8; 781 - bool unmap = false; 782 - 783 - rcu_read_lock(); 784 - virt_addr = acpi_map_vaddr_lookup(phys_addr, size); 785 - if (!virt_addr) { 786 - rcu_read_unlock(); 787 - virt_addr = acpi_os_ioremap(phys_addr, size); 788 - if (!virt_addr) 789 - return AE_BAD_ADDRESS; 790 - unmap = true; 791 - } 792 - 793 - switch (width) { 794 - case 8: 795 - writeb(value, virt_addr); 796 - break; 797 - case 16: 798 - writew(value, virt_addr); 799 - break; 800 - case 32: 801 - writel(value, virt_addr); 802 - break; 803 - default: 804 - BUG(); 805 - } 806 - 807 - if (unmap) 808 - iounmap(virt_addr); 809 - else 810 - rcu_read_unlock(); 811 - 812 - return AE_OK; 813 - } 814 - 815 806 #ifdef writeq 816 807 static inline void write64(u64 val, volatile void __iomem *addr) 817 808 { ··· 787 856 #endif 788 857 789 858 acpi_status 790 - acpi_os_write_memory64(acpi_physical_address phys_addr, u64 value, u32 width) 859 + acpi_os_write_memory(acpi_physical_address phys_addr, u64 value, u32 width) 791 860 { 792 861 void __iomem *virt_addr; 793 862 unsigned int size = width / 8; ··· 1571 1640 destroy_workqueue(kacpi_hotplug_wq); 1572 1641 1573 1642 return AE_OK; 1643 + } 1644 + 1645 + acpi_status acpi_os_prepare_sleep(u8 sleep_state, u32 pm1a_control, 1646 + u32 pm1b_control) 1647 + { 1648 + int rc = 0; 1649 + if (__acpi_os_prepare_sleep) 1650 + rc = __acpi_os_prepare_sleep(sleep_state, 1651 + pm1a_control, pm1b_control); 1652 + if (rc < 0) 1653 + return AE_ERROR; 1654 + else if (rc > 0) 1655 + return AE_CTRL_SKIP; 1656 + 1657 + return AE_OK; 1658 + } 1659 + 1660 + void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state, 1661 + u32 pm1a_ctrl, u32 pm1b_ctrl)) 1662 + { 1663 + __acpi_os_prepare_sleep = func; 1574 1664 }
+164 -2
drivers/acpi/power.c
··· 40 40 #include <linux/init.h> 41 41 #include <linux/types.h> 42 42 #include <linux/slab.h> 43 + #include <linux/pm_runtime.h> 43 44 #include <acpi/acpi_bus.h> 44 45 #include <acpi/acpi_drivers.h> 45 46 #include "sleep.h" 47 + #include "internal.h" 46 48 47 49 #define PREFIX "ACPI: " 48 50 ··· 79 77 }, 80 78 }; 81 79 80 + /* 81 + * A power managed device 82 + * A device may rely on multiple power resources. 83 + * */ 84 + struct acpi_power_managed_device { 85 + struct device *dev; /* The physical device */ 86 + acpi_handle *handle; 87 + }; 88 + 89 + struct acpi_power_resource_device { 90 + struct acpi_power_managed_device *device; 91 + struct acpi_power_resource_device *next; 92 + }; 93 + 82 94 struct acpi_power_resource { 83 95 struct acpi_device * device; 84 96 acpi_bus_id name; ··· 100 84 u32 order; 101 85 unsigned int ref_count; 102 86 struct mutex resource_lock; 87 + 88 + /* List of devices relying on this power resource */ 89 + struct acpi_power_resource_device *devices; 103 90 }; 104 91 105 92 static struct list_head acpi_power_resource_list; ··· 202 183 return 0; 203 184 } 204 185 186 + /* Resume the device when all power resources in _PR0 are on */ 187 + static void acpi_power_on_device(struct acpi_power_managed_device *device) 188 + { 189 + struct acpi_device *acpi_dev; 190 + acpi_handle handle = device->handle; 191 + int state; 192 + 193 + if (acpi_bus_get_device(handle, &acpi_dev)) 194 + return; 195 + 196 + if(acpi_power_get_inferred_state(acpi_dev, &state)) 197 + return; 198 + 199 + if (state == ACPI_STATE_D0 && pm_runtime_suspended(device->dev)) 200 + pm_request_resume(device->dev); 201 + } 202 + 205 203 static int __acpi_power_on(struct acpi_power_resource *resource) 206 204 { 205 + struct acpi_power_resource_device *device_list = resource->devices; 207 206 acpi_status status = AE_OK; 208 207 209 208 status = acpi_evaluate_object(resource->device->handle, "_ON", NULL, NULL); ··· 233 196 234 197 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Power resource [%s] turned on\n", 235 198 resource->name)); 199 + 200 + while (device_list) { 201 + acpi_power_on_device(device_list->device); 202 + 203 + device_list = device_list->next; 204 + } 236 205 237 206 return 0; 238 207 } ··· 340 297 } 341 298 342 299 return result; 300 + } 301 + 302 + static void __acpi_power_resource_unregister_device(struct device *dev, 303 + acpi_handle res_handle) 304 + { 305 + struct acpi_power_resource *resource = NULL; 306 + struct acpi_power_resource_device *prev, *curr; 307 + 308 + if (acpi_power_get_context(res_handle, &resource)) 309 + return; 310 + 311 + mutex_lock(&resource->resource_lock); 312 + prev = NULL; 313 + curr = resource->devices; 314 + while (curr) { 315 + if (curr->device->dev == dev) { 316 + if (!prev) 317 + resource->devices = curr->next; 318 + else 319 + prev->next = curr->next; 320 + 321 + kfree(curr); 322 + break; 323 + } 324 + 325 + prev = curr; 326 + curr = curr->next; 327 + } 328 + mutex_unlock(&resource->resource_lock); 329 + } 330 + 331 + /* Unlink dev from all power resources in _PR0 */ 332 + void acpi_power_resource_unregister_device(struct device *dev, acpi_handle handle) 333 + { 334 + struct acpi_device *acpi_dev; 335 + struct acpi_handle_list *list; 336 + int i; 337 + 338 + if (!dev || !handle) 339 + return; 340 + 341 + if (acpi_bus_get_device(handle, &acpi_dev)) 342 + return; 343 + 344 + list = &acpi_dev->power.states[ACPI_STATE_D0].resources; 345 + 346 + for (i = 0; i < list->count; i++) 347 + __acpi_power_resource_unregister_device(dev, 348 + list->handles[i]); 349 + } 350 + 351 + static int __acpi_power_resource_register_device( 352 + struct acpi_power_managed_device *powered_device, acpi_handle handle) 353 + { 354 + struct acpi_power_resource *resource = NULL; 355 + struct acpi_power_resource_device *power_resource_device; 356 + int result; 357 + 358 + result = acpi_power_get_context(handle, &resource); 359 + if (result) 360 + return result; 361 + 362 + power_resource_device = kzalloc( 363 + sizeof(*power_resource_device), GFP_KERNEL); 364 + if (!power_resource_device) 365 + return -ENOMEM; 366 + 367 + power_resource_device->device = powered_device; 368 + 369 + mutex_lock(&resource->resource_lock); 370 + power_resource_device->next = resource->devices; 371 + resource->devices = power_resource_device; 372 + mutex_unlock(&resource->resource_lock); 373 + 374 + return 0; 375 + } 376 + 377 + /* Link dev to all power resources in _PR0 */ 378 + int acpi_power_resource_register_device(struct device *dev, acpi_handle handle) 379 + { 380 + struct acpi_device *acpi_dev; 381 + struct acpi_handle_list *list; 382 + struct acpi_power_managed_device *powered_device; 383 + int i, ret; 384 + 385 + if (!dev || !handle) 386 + return -ENODEV; 387 + 388 + ret = acpi_bus_get_device(handle, &acpi_dev); 389 + if (ret) 390 + goto no_power_resource; 391 + 392 + if (!acpi_dev->power.flags.power_resources) 393 + goto no_power_resource; 394 + 395 + powered_device = kzalloc(sizeof(*powered_device), GFP_KERNEL); 396 + if (!powered_device) 397 + return -ENOMEM; 398 + 399 + powered_device->dev = dev; 400 + powered_device->handle = handle; 401 + 402 + list = &acpi_dev->power.states[ACPI_STATE_D0].resources; 403 + 404 + for (i = 0; i < list->count; i++) { 405 + ret = __acpi_power_resource_register_device(powered_device, 406 + list->handles[i]); 407 + 408 + if (ret) { 409 + acpi_power_resource_unregister_device(dev, handle); 410 + break; 411 + } 412 + } 413 + 414 + return ret; 415 + 416 + no_power_resource: 417 + printk(KERN_WARNING PREFIX "Invalid Power Resource to register!"); 418 + return -ENODEV; 343 419 } 344 420 345 421 /** ··· 662 500 { 663 501 int result; 664 502 665 - if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3)) 503 + if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3_COLD)) 666 504 return -EINVAL; 667 505 668 506 if (device->power.state == state) 669 507 return 0; 670 508 671 509 if ((device->power.state < ACPI_STATE_D0) 672 - || (device->power.state > ACPI_STATE_D3)) 510 + || (device->power.state > ACPI_STATE_D3_COLD)) 673 511 return -ENODEV; 674 512 675 513 /* TBD: Resources must be ordered. */
+48 -14
drivers/acpi/processor_driver.c
··· 67 67 #define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80 68 68 #define ACPI_PROCESSOR_NOTIFY_POWER 0x81 69 69 #define ACPI_PROCESSOR_NOTIFY_THROTTLING 0x82 70 + #define ACPI_PROCESSOR_DEVICE_HID "ACPI0007" 70 71 71 72 #define ACPI_PROCESSOR_LIMIT_USER 0 72 73 #define ACPI_PROCESSOR_LIMIT_THERMAL 1 ··· 88 87 89 88 static const struct acpi_device_id processor_device_ids[] = { 90 89 {ACPI_PROCESSOR_OBJECT_HID, 0}, 91 - {"ACPI0007", 0}, 90 + {ACPI_PROCESSOR_DEVICE_HID, 0}, 92 91 {"", 0}, 93 92 }; 94 93 MODULE_DEVICE_TABLE(acpi, processor_device_ids); ··· 536 535 return -ENOMEM; 537 536 538 537 if (!zalloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) { 539 - kfree(pr); 540 - return -ENOMEM; 538 + result = -ENOMEM; 539 + goto err_free_pr; 541 540 } 542 541 543 542 pr->handle = device->handle; ··· 577 576 dev = get_cpu_device(pr->id); 578 577 if (sysfs_create_link(&device->dev.kobj, &dev->kobj, "sysdev")) { 579 578 result = -EFAULT; 580 - goto err_free_cpumask; 579 + goto err_clear_processor; 581 580 } 582 581 583 582 /* ··· 595 594 596 595 err_remove_sysfs: 597 596 sysfs_remove_link(&device->dev.kobj, "sysdev"); 597 + err_clear_processor: 598 + /* 599 + * processor_device_array is not cleared to allow checks for buggy BIOS 600 + */ 601 + per_cpu(processors, pr->id) = NULL; 598 602 err_free_cpumask: 599 603 free_cpumask_var(pr->throttling.shared_cpu_map); 600 - 604 + err_free_pr: 605 + kfree(pr); 601 606 return result; 602 607 } 603 608 ··· 748 741 return; 749 742 } 750 743 744 + static acpi_status is_processor_device(acpi_handle handle) 745 + { 746 + struct acpi_device_info *info; 747 + char *hid; 748 + acpi_status status; 749 + 750 + status = acpi_get_object_info(handle, &info); 751 + if (ACPI_FAILURE(status)) 752 + return status; 753 + 754 + if (info->type == ACPI_TYPE_PROCESSOR) { 755 + kfree(info); 756 + return AE_OK; /* found a processor object */ 757 + } 758 + 759 + if (!(info->valid & ACPI_VALID_HID)) { 760 + kfree(info); 761 + return AE_ERROR; 762 + } 763 + 764 + hid = info->hardware_id.string; 765 + if ((hid == NULL) || strcmp(hid, ACPI_PROCESSOR_DEVICE_HID)) { 766 + kfree(info); 767 + return AE_ERROR; 768 + } 769 + 770 + kfree(info); 771 + return AE_OK; /* found a processor device object */ 772 + } 773 + 751 774 static acpi_status 752 775 processor_walk_namespace_cb(acpi_handle handle, 753 776 u32 lvl, void *context, void **rv) 754 777 { 755 778 acpi_status status; 756 779 int *action = context; 757 - acpi_object_type type = 0; 758 780 759 - status = acpi_get_type(handle, &type); 781 + status = is_processor_device(handle); 760 782 if (ACPI_FAILURE(status)) 761 - return (AE_OK); 762 - 763 - if (type != ACPI_TYPE_PROCESSOR) 764 - return (AE_OK); 783 + return AE_OK; /* not a processor; continue to walk */ 765 784 766 785 switch (*action) { 767 786 case INSTALL_NOTIFY_HANDLER: ··· 805 772 break; 806 773 } 807 774 808 - return (AE_OK); 775 + /* found a processor; skip walking underneath */ 776 + return AE_CTRL_DEPTH; 809 777 } 810 778 811 779 static acpi_status acpi_processor_hotadd_init(struct acpi_processor *pr) ··· 864 830 { 865 831 #ifdef CONFIG_ACPI_HOTPLUG_CPU 866 832 int action = INSTALL_NOTIFY_HANDLER; 867 - acpi_walk_namespace(ACPI_TYPE_PROCESSOR, 833 + acpi_walk_namespace(ACPI_TYPE_ANY, 868 834 ACPI_ROOT_OBJECT, 869 835 ACPI_UINT32_MAX, 870 836 processor_walk_namespace_cb, NULL, &action, NULL); ··· 877 843 { 878 844 #ifdef CONFIG_ACPI_HOTPLUG_CPU 879 845 int action = UNINSTALL_NOTIFY_HANDLER; 880 - acpi_walk_namespace(ACPI_TYPE_PROCESSOR, 846 + acpi_walk_namespace(ACPI_TYPE_ANY, 881 847 ACPI_ROOT_OBJECT, 882 848 ACPI_UINT32_MAX, 883 849 processor_walk_namespace_cb, NULL, &action, NULL);
+32 -2
drivers/acpi/processor_idle.c
··· 770 770 return index; 771 771 } 772 772 773 + 774 + /** 775 + * acpi_idle_play_dead - enters an ACPI state for long-term idle (i.e. off-lining) 776 + * @dev: the target CPU 777 + * @index: the index of suggested state 778 + */ 779 + static int acpi_idle_play_dead(struct cpuidle_device *dev, int index) 780 + { 781 + struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; 782 + struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage); 783 + 784 + ACPI_FLUSH_CPU_CACHE(); 785 + 786 + while (1) { 787 + 788 + if (cx->entry_method == ACPI_CSTATE_HALT) 789 + halt(); 790 + else if (cx->entry_method == ACPI_CSTATE_SYSTEMIO) { 791 + inb(cx->address); 792 + /* See comment in acpi_idle_do_entry() */ 793 + inl(acpi_gbl_FADT.xpm_timer_block.address); 794 + } else 795 + return -ENODEV; 796 + } 797 + 798 + /* Never reached */ 799 + return 0; 800 + } 801 + 773 802 /** 774 803 * acpi_idle_enter_simple - enters an ACPI state without BM handling 775 804 * @dev: the target CPU ··· 1106 1077 state->flags |= CPUIDLE_FLAG_TIME_VALID; 1107 1078 1108 1079 state->enter = acpi_idle_enter_c1; 1080 + state->enter_dead = acpi_idle_play_dead; 1109 1081 drv->safe_state_index = count; 1110 1082 break; 1111 1083 1112 1084 case ACPI_STATE_C2: 1113 1085 state->flags |= CPUIDLE_FLAG_TIME_VALID; 1114 1086 state->enter = acpi_idle_enter_simple; 1087 + state->enter_dead = acpi_idle_play_dead; 1115 1088 drv->safe_state_index = count; 1116 1089 break; 1117 1090 ··· 1190 1159 * to make the code that updates C-States be called once. 1191 1160 */ 1192 1161 1193 - if (smp_processor_id() == 0 && 1194 - cpuidle_get_driver() == &acpi_idle_driver) { 1162 + if (pr->id == 0 && cpuidle_get_driver() == &acpi_idle_driver) { 1195 1163 1196 1164 cpuidle_pause_and_lock(); 1197 1165 /* Protect against cpu-hotplug */
+37 -8
drivers/acpi/processor_thermal.c
··· 57 57 static DEFINE_PER_CPU(unsigned int, cpufreq_thermal_reduction_pctg); 58 58 static unsigned int acpi_thermal_cpufreq_is_init = 0; 59 59 60 + #define reduction_pctg(cpu) \ 61 + per_cpu(cpufreq_thermal_reduction_pctg, phys_package_first_cpu(cpu)) 62 + 63 + /* 64 + * Emulate "per package data" using per cpu data (which should really be 65 + * provided elsewhere) 66 + * 67 + * Note we can lose a CPU on cpu hotunplug, in this case we forget the state 68 + * temporarily. Fortunately that's not a big issue here (I hope) 69 + */ 70 + static int phys_package_first_cpu(int cpu) 71 + { 72 + int i; 73 + int id = topology_physical_package_id(cpu); 74 + 75 + for_each_online_cpu(i) 76 + if (topology_physical_package_id(i) == id) 77 + return i; 78 + return 0; 79 + } 80 + 60 81 static int cpu_has_cpufreq(unsigned int cpu) 61 82 { 62 83 struct cpufreq_policy policy; ··· 97 76 98 77 max_freq = ( 99 78 policy->cpuinfo.max_freq * 100 - (100 - per_cpu(cpufreq_thermal_reduction_pctg, policy->cpu) * 20) 79 + (100 - reduction_pctg(policy->cpu) * 20) 101 80 ) / 100; 102 81 103 82 cpufreq_verify_within_limits(policy, 0, max_freq); ··· 123 102 if (!cpu_has_cpufreq(cpu)) 124 103 return 0; 125 104 126 - return per_cpu(cpufreq_thermal_reduction_pctg, cpu); 105 + return reduction_pctg(cpu); 127 106 } 128 107 129 108 static int cpufreq_set_cur_state(unsigned int cpu, int state) 130 109 { 110 + int i; 111 + 131 112 if (!cpu_has_cpufreq(cpu)) 132 113 return 0; 133 114 134 - per_cpu(cpufreq_thermal_reduction_pctg, cpu) = state; 135 - cpufreq_update_policy(cpu); 115 + reduction_pctg(cpu) = state; 116 + 117 + /* 118 + * Update all the CPUs in the same package because they all 119 + * contribute to the temperature and often share the same 120 + * frequency. 121 + */ 122 + for_each_online_cpu(i) { 123 + if (topology_physical_package_id(i) == 124 + topology_physical_package_id(cpu)) 125 + cpufreq_update_policy(i); 126 + } 136 127 return 0; 137 128 } 138 129 139 130 void acpi_thermal_cpufreq_init(void) 140 131 { 141 132 int i; 142 - 143 - for (i = 0; i < nr_cpu_ids; i++) 144 - if (cpu_present(i)) 145 - per_cpu(cpufreq_thermal_reduction_pctg, i) = 0; 146 133 147 134 i = cpufreq_register_notifier(&acpi_thermal_cpufreq_notifier_block, 148 135 CPUFREQ_POLICY_NOTIFIER);
+2 -3
drivers/acpi/processor_throttling.c
··· 769 769 u64 *value) 770 770 { 771 771 u32 bit_width, bit_offset; 772 - u64 ptc_value; 772 + u32 ptc_value; 773 773 u64 ptc_mask; 774 774 struct acpi_processor_throttling *throttling; 775 775 int ret = -1; ··· 777 777 throttling = &pr->throttling; 778 778 switch (throttling->status_register.space_id) { 779 779 case ACPI_ADR_SPACE_SYSTEM_IO: 780 - ptc_value = 0; 781 780 bit_width = throttling->status_register.bit_width; 782 781 bit_offset = throttling->status_register.bit_offset; 783 782 784 783 acpi_os_read_port((acpi_io_address) throttling->status_register. 785 - address, (u32 *) &ptc_value, 784 + address, &ptc_value, 786 785 (u32) (bit_width + bit_offset)); 787 786 ptc_mask = (1 << bit_width) - 1; 788 787 *value = (u64) ((ptc_value >> bit_offset) & ptc_mask);
+1 -2
drivers/acpi/reboot.c
··· 23 23 /* Is the reset register supported? The spec says we should be 24 24 * checking the bit width and bit offset, but Windows ignores 25 25 * these fields */ 26 - if (!(acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER)) 27 - return; 26 + /* Ignore also acpi_gbl_FADT.flags.ACPI_FADT_RESET_REGISTER */ 28 27 29 28 reset_value = acpi_gbl_FADT.reset_value; 30 29
+8 -4
drivers/acpi/scan.c
··· 880 880 int j; 881 881 882 882 device->power.flags.power_resources = 1; 883 - ps->flags.valid = 1; 884 883 for (j = 0; j < ps->resources.count; j++) 885 884 acpi_bus_add_power_resource(ps->resources.handles[j]); 885 + } 886 + 887 + /* The exist of _PR3 indicates D3Cold support */ 888 + if (i == ACPI_STATE_D3) { 889 + status = acpi_get_handle(device->handle, object_name, &handle); 890 + if (ACPI_SUCCESS(status)) 891 + device->power.states[ACPI_STATE_D3_COLD].flags.valid = 1; 886 892 } 887 893 888 894 /* Evaluate "_PSx" to see if we can do explicit sets */ 889 895 object_name[2] = 'S'; 890 896 status = acpi_get_handle(device->handle, object_name, &handle); 891 - if (ACPI_SUCCESS(status)) { 897 + if (ACPI_SUCCESS(status)) 892 898 ps->flags.explicit_set = 1; 893 - ps->flags.valid = 1; 894 - } 895 899 896 900 /* State is valid if we have some power control */ 897 901 if (ps->resources.count || ps->flags.explicit_set)
+68 -8
drivers/acpi/sleep.c
··· 17 17 #include <linux/suspend.h> 18 18 #include <linux/reboot.h> 19 19 #include <linux/acpi.h> 20 + #include <linux/module.h> 21 + #include <linux/pm_runtime.h> 20 22 21 23 #include <asm/io.h> 22 24 ··· 27 25 28 26 #include "internal.h" 29 27 #include "sleep.h" 28 + 29 + static unsigned int gts, bfs; 30 + module_param(gts, uint, 0644); 31 + module_param(bfs, uint, 0644); 32 + MODULE_PARM_DESC(gts, "Enable evaluation of _GTS on suspend."); 33 + MODULE_PARM_DESC(bfs, "Enable evaluation of _BFS on resume".); 34 + 35 + static u8 wake_sleep_flags(void) 36 + { 37 + u8 flags = ACPI_NO_OPTIONAL_METHODS; 38 + 39 + if (gts) 40 + flags |= ACPI_EXECUTE_GTS; 41 + if (bfs) 42 + flags |= ACPI_EXECUTE_BFS; 43 + 44 + return flags; 45 + } 30 46 31 47 static u8 sleep_states[ACPI_S_STATE_COUNT]; 32 48 ··· 263 243 { 264 244 acpi_status status = AE_OK; 265 245 u32 acpi_state = acpi_target_sleep_state; 246 + u8 flags = wake_sleep_flags(); 266 247 int error; 267 248 268 249 ACPI_FLUSH_CPU_CACHE(); ··· 271 250 switch (acpi_state) { 272 251 case ACPI_STATE_S1: 273 252 barrier(); 274 - status = acpi_enter_sleep_state(acpi_state); 253 + status = acpi_enter_sleep_state(acpi_state, flags); 275 254 break; 276 255 277 256 case ACPI_STATE_S3: ··· 286 265 acpi_write_bit_register(ACPI_BITREG_SCI_ENABLE, 1); 287 266 288 267 /* Reprogram control registers and execute _BFS */ 289 - acpi_leave_sleep_state_prep(acpi_state); 268 + acpi_leave_sleep_state_prep(acpi_state, flags); 290 269 291 270 /* ACPI 3.0 specs (P62) says that it's the responsibility 292 271 * of the OSPM to clear the status bit [ implying that the ··· 550 529 551 530 static int acpi_hibernation_enter(void) 552 531 { 532 + u8 flags = wake_sleep_flags(); 553 533 acpi_status status = AE_OK; 554 534 555 535 ACPI_FLUSH_CPU_CACHE(); 556 536 557 537 /* This shouldn't return. If it returns, we have a problem */ 558 - status = acpi_enter_sleep_state(ACPI_STATE_S4); 538 + status = acpi_enter_sleep_state(ACPI_STATE_S4, flags); 559 539 /* Reprogram control registers and execute _BFS */ 560 - acpi_leave_sleep_state_prep(ACPI_STATE_S4); 540 + acpi_leave_sleep_state_prep(ACPI_STATE_S4, flags); 561 541 562 542 return ACPI_SUCCESS(status) ? 0 : -EFAULT; 563 543 } 564 544 565 545 static void acpi_hibernation_leave(void) 566 546 { 547 + u8 flags = wake_sleep_flags(); 548 + 567 549 /* 568 550 * If ACPI is not enabled by the BIOS and the boot kernel, we need to 569 551 * enable it here. 570 552 */ 571 553 acpi_enable(); 572 554 /* Reprogram control registers and execute _BFS */ 573 - acpi_leave_sleep_state_prep(ACPI_STATE_S4); 555 + acpi_leave_sleep_state_prep(ACPI_STATE_S4, flags); 574 556 /* Check the hardware signature */ 575 557 if (facs && s4_hardware_signature != facs->hardware_signature) { 576 558 printk(KERN_EMERG "ACPI: Hardware changed while hibernated, " ··· 754 730 755 731 #ifdef CONFIG_PM_SLEEP 756 732 /** 733 + * acpi_pm_device_run_wake - Enable/disable wake-up for given device. 734 + * @phys_dev: Device to enable/disable the platform to wake-up the system for. 735 + * @enable: Whether enable or disable the wake-up functionality. 736 + * 737 + * Find the ACPI device object corresponding to @pci_dev and try to 738 + * enable/disable the GPE associated with it. 739 + */ 740 + int acpi_pm_device_run_wake(struct device *phys_dev, bool enable) 741 + { 742 + struct acpi_device *dev; 743 + acpi_handle handle; 744 + 745 + if (!device_run_wake(phys_dev)) 746 + return -EINVAL; 747 + 748 + handle = DEVICE_ACPI_HANDLE(phys_dev); 749 + if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &dev))) { 750 + dev_dbg(phys_dev, "ACPI handle has no context in %s!\n", 751 + __func__); 752 + return -ENODEV; 753 + } 754 + 755 + if (enable) { 756 + acpi_enable_wakeup_device_power(dev, ACPI_STATE_S0); 757 + acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number); 758 + } else { 759 + acpi_disable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number); 760 + acpi_disable_wakeup_device_power(dev); 761 + } 762 + 763 + return 0; 764 + } 765 + 766 + /** 757 767 * acpi_pm_device_sleep_wake - enable or disable the system wake-up 758 768 * capability of given device 759 769 * @dev: device to handle ··· 828 770 829 771 static void acpi_power_off(void) 830 772 { 773 + u8 flags = wake_sleep_flags(); 774 + 831 775 /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */ 832 776 printk(KERN_DEBUG "%s called\n", __func__); 833 777 local_irq_disable(); 834 - acpi_enter_sleep_state(ACPI_STATE_S5); 778 + acpi_enter_sleep_state(ACPI_STATE_S5, flags); 835 779 } 836 780 837 781 /* ··· 848 788 { 849 789 acpi_handle dummy; 850 790 851 - if (ACPI_SUCCESS(acpi_get_handle(ACPI_ROOT_OBJECT, METHOD_NAME__GTS, &dummy))) 791 + if (ACPI_SUCCESS(acpi_get_handle(ACPI_ROOT_OBJECT, METHOD_PATHNAME__GTS, &dummy))) 852 792 { 853 793 printk(KERN_NOTICE PREFIX "BIOS offers _GTS\n"); 854 794 printk(KERN_NOTICE PREFIX "If \"acpi.gts=1\" improves suspend, " 855 795 "please notify linux-acpi@vger.kernel.org\n"); 856 796 } 857 - if (ACPI_SUCCESS(acpi_get_handle(ACPI_ROOT_OBJECT, METHOD_NAME__BFS, &dummy))) 797 + if (ACPI_SUCCESS(acpi_get_handle(ACPI_ROOT_OBJECT, METHOD_PATHNAME__BFS, &dummy))) 858 798 { 859 799 printk(KERN_NOTICE PREFIX "BIOS offers _BFS\n"); 860 800 printk(KERN_NOTICE PREFIX "If \"acpi.bfs=1\" improves resume, "
+4 -4
drivers/acpi/thermal.c
··· 941 941 if (!tz) 942 942 return -EINVAL; 943 943 944 - /* Get temperature [_TMP] (required) */ 945 - result = acpi_thermal_get_temperature(tz); 944 + /* Get trip points [_CRT, _PSV, etc.] (required) */ 945 + result = acpi_thermal_get_trip_points(tz); 946 946 if (result) 947 947 return result; 948 948 949 - /* Get trip points [_CRT, _PSV, etc.] (required) */ 950 - result = acpi_thermal_get_trip_points(tz); 949 + /* Get temperature [_TMP] (required) */ 950 + result = acpi_thermal_get_temperature(tz); 951 951 if (result) 952 952 return result; 953 953
+31 -19
drivers/acpi/video.c
··· 548 548 * 1. The system BIOS should NOT automatically control the brightness 549 549 * level of the LCD when the power changes from AC to DC. 550 550 * Return Value: 551 - * -1 wrong arg. 551 + * -EINVAL wrong arg. 552 552 */ 553 553 554 554 static int 555 555 acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag) 556 556 { 557 - u64 status = 0; 557 + acpi_status status; 558 558 union acpi_object arg0 = { ACPI_TYPE_INTEGER }; 559 559 struct acpi_object_list args = { 1, &arg0 }; 560 560 561 561 562 - if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1) { 563 - status = -1; 564 - goto Failed; 565 - } 562 + if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1) 563 + return -EINVAL; 566 564 arg0.integer.value = (lcd_flag << 2) | bios_flag; 567 565 video->dos_setting = arg0.integer.value; 568 - acpi_evaluate_object(video->device->handle, "_DOS", &args, NULL); 566 + status = acpi_evaluate_object(video->device->handle, "_DOS", 567 + &args, NULL); 568 + if (ACPI_FAILURE(status)) 569 + return -EIO; 569 570 570 - Failed: 571 - return status; 571 + return 0; 572 572 } 573 573 574 574 /* ··· 1343 1343 acpi_video_bus_get_devices(struct acpi_video_bus *video, 1344 1344 struct acpi_device *device) 1345 1345 { 1346 - int status = 0; 1346 + int status; 1347 1347 struct acpi_device *dev; 1348 1348 1349 - acpi_video_device_enumerate(video); 1349 + status = acpi_video_device_enumerate(video); 1350 + if (status) 1351 + return status; 1350 1352 1351 1353 list_for_each_entry(dev, &device->children, node) { 1352 1354 1353 1355 status = acpi_video_bus_get_one_device(dev, video); 1354 - if (ACPI_FAILURE(status)) { 1356 + if (status) { 1355 1357 printk(KERN_WARNING PREFIX 1356 1358 "Can't attach device\n"); 1357 1359 continue; ··· 1655 1653 mutex_init(&video->device_list_lock); 1656 1654 INIT_LIST_HEAD(&video->video_device_list); 1657 1655 1658 - acpi_video_bus_get_devices(video, device); 1659 - acpi_video_bus_start_devices(video); 1656 + error = acpi_video_bus_get_devices(video, device); 1657 + if (error) 1658 + goto err_free_video; 1660 1659 1661 1660 video->input = input = input_allocate_device(); 1662 1661 if (!input) { 1663 1662 error = -ENOMEM; 1664 - goto err_stop_video; 1663 + goto err_put_video; 1665 1664 } 1665 + 1666 + error = acpi_video_bus_start_devices(video); 1667 + if (error) 1668 + goto err_free_input_dev; 1666 1669 1667 1670 snprintf(video->phys, sizeof(video->phys), 1668 1671 "%s/video/input0", acpi_device_hid(video->device)); ··· 1689 1682 1690 1683 error = input_register_device(input); 1691 1684 if (error) 1692 - goto err_free_input_dev; 1685 + goto err_stop_video; 1693 1686 1694 1687 printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s rom: %s post: %s)\n", 1695 1688 ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device), ··· 1699 1692 1700 1693 video->pm_nb.notifier_call = acpi_video_resume; 1701 1694 video->pm_nb.priority = 0; 1702 - register_pm_notifier(&video->pm_nb); 1695 + error = register_pm_notifier(&video->pm_nb); 1696 + if (error) 1697 + goto err_unregister_input_dev; 1703 1698 1704 1699 return 0; 1705 1700 1706 - err_free_input_dev: 1707 - input_free_device(input); 1701 + err_unregister_input_dev: 1702 + input_unregister_device(input); 1708 1703 err_stop_video: 1709 1704 acpi_video_bus_stop_devices(video); 1705 + err_free_input_dev: 1706 + input_free_device(input); 1707 + err_put_video: 1710 1708 acpi_video_bus_put_devices(video); 1711 1709 kfree(video->attached_array); 1712 1710 err_free_video:
+89 -8
drivers/cpuidle/cpuidle.c
··· 53 53 54 54 static int __cpuidle_register_device(struct cpuidle_device *dev); 55 55 56 + static inline int cpuidle_enter(struct cpuidle_device *dev, 57 + struct cpuidle_driver *drv, int index) 58 + { 59 + struct cpuidle_state *target_state = &drv->states[index]; 60 + return target_state->enter(dev, drv, index); 61 + } 62 + 63 + static inline int cpuidle_enter_tk(struct cpuidle_device *dev, 64 + struct cpuidle_driver *drv, int index) 65 + { 66 + return cpuidle_wrap_enter(dev, drv, index, cpuidle_enter); 67 + } 68 + 69 + typedef int (*cpuidle_enter_t)(struct cpuidle_device *dev, 70 + struct cpuidle_driver *drv, int index); 71 + 72 + static cpuidle_enter_t cpuidle_enter_ops; 73 + 74 + /** 75 + * cpuidle_play_dead - cpu off-lining 76 + * 77 + * Only returns in case of an error 78 + */ 79 + int cpuidle_play_dead(void) 80 + { 81 + struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices); 82 + struct cpuidle_driver *drv = cpuidle_get_driver(); 83 + int i, dead_state = -1; 84 + int power_usage = -1; 85 + 86 + /* Find lowest-power state that supports long-term idle */ 87 + for (i = CPUIDLE_DRIVER_STATE_START; i < drv->state_count; i++) { 88 + struct cpuidle_state *s = &drv->states[i]; 89 + 90 + if (s->power_usage < power_usage && s->enter_dead) { 91 + power_usage = s->power_usage; 92 + dead_state = i; 93 + } 94 + } 95 + 96 + if (dead_state != -1) 97 + return drv->states[dead_state].enter_dead(dev, dead_state); 98 + 99 + return -ENODEV; 100 + } 101 + 56 102 /** 57 103 * cpuidle_idle_call - the main idle loop 58 104 * ··· 109 63 { 110 64 struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices); 111 65 struct cpuidle_driver *drv = cpuidle_get_driver(); 112 - struct cpuidle_state *target_state; 113 66 int next_state, entered_state; 114 67 115 68 if (off) ··· 137 92 return 0; 138 93 } 139 94 140 - target_state = &drv->states[next_state]; 141 - 142 95 trace_power_start_rcuidle(POWER_CSTATE, next_state, dev->cpu); 143 96 trace_cpu_idle_rcuidle(next_state, dev->cpu); 144 97 145 - entered_state = target_state->enter(dev, drv, next_state); 98 + entered_state = cpuidle_enter_ops(dev, drv, next_state); 146 99 147 100 trace_power_end_rcuidle(dev->cpu); 148 101 trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, dev->cpu); ··· 153 110 dev->states_usage[entered_state].time += 154 111 (unsigned long long)dev->last_residency; 155 112 dev->states_usage[entered_state].usage++; 113 + } else { 114 + dev->last_residency = 0; 156 115 } 157 116 158 117 /* give the governor an opportunity to reflect on the outcome */ ··· 209 164 210 165 EXPORT_SYMBOL_GPL(cpuidle_resume_and_unlock); 211 166 167 + /** 168 + * cpuidle_wrap_enter - performs timekeeping and irqen around enter function 169 + * @dev: pointer to a valid cpuidle_device object 170 + * @drv: pointer to a valid cpuidle_driver object 171 + * @index: index of the target cpuidle state. 172 + */ 173 + int cpuidle_wrap_enter(struct cpuidle_device *dev, 174 + struct cpuidle_driver *drv, int index, 175 + int (*enter)(struct cpuidle_device *dev, 176 + struct cpuidle_driver *drv, int index)) 177 + { 178 + ktime_t time_start, time_end; 179 + s64 diff; 180 + 181 + time_start = ktime_get(); 182 + 183 + index = enter(dev, drv, index); 184 + 185 + time_end = ktime_get(); 186 + 187 + local_irq_enable(); 188 + 189 + diff = ktime_to_us(ktime_sub(time_end, time_start)); 190 + if (diff > INT_MAX) 191 + diff = INT_MAX; 192 + 193 + dev->last_residency = (int) diff; 194 + 195 + return index; 196 + } 197 + 212 198 #ifdef CONFIG_ARCH_HAS_CPU_RELAX 213 199 static int poll_idle(struct cpuidle_device *dev, 214 200 struct cpuidle_driver *drv, int index) ··· 273 197 state->power_usage = -1; 274 198 state->flags = 0; 275 199 state->enter = poll_idle; 200 + state->disable = 0; 276 201 } 277 202 #else 278 203 static void poll_idle_init(struct cpuidle_driver *drv) {} ··· 289 212 int cpuidle_enable_device(struct cpuidle_device *dev) 290 213 { 291 214 int ret, i; 215 + struct cpuidle_driver *drv = cpuidle_get_driver(); 292 216 293 217 if (dev->enabled) 294 218 return 0; 295 - if (!cpuidle_get_driver() || !cpuidle_curr_governor) 219 + if (!drv || !cpuidle_curr_governor) 296 220 return -EIO; 297 221 if (!dev->state_count) 298 - return -EINVAL; 222 + dev->state_count = drv->state_count; 299 223 300 224 if (dev->registered == 0) { 301 225 ret = __cpuidle_register_device(dev); ··· 304 226 return ret; 305 227 } 306 228 307 - poll_idle_init(cpuidle_get_driver()); 229 + cpuidle_enter_ops = drv->en_core_tk_irqen ? 230 + cpuidle_enter_tk : cpuidle_enter; 231 + 232 + poll_idle_init(drv); 308 233 309 234 if ((ret = cpuidle_add_state_sysfs(dev))) 310 235 return ret; 311 236 312 237 if (cpuidle_curr_governor->enable && 313 - (ret = cpuidle_curr_governor->enable(cpuidle_get_driver(), dev))) 238 + (ret = cpuidle_curr_governor->enable(drv, dev))) 314 239 goto fail_sysfs; 315 240 316 241 for (i = 0; i < dev->state_count; i++) {
+1 -1
drivers/cpuidle/driver.c
··· 47 47 */ 48 48 int cpuidle_register_driver(struct cpuidle_driver *drv) 49 49 { 50 - if (!drv) 50 + if (!drv || !drv->state_count) 51 51 return -EINVAL; 52 52 53 53 if (cpuidle_disabled())
+5 -2
drivers/cpuidle/governors/menu.c
··· 236 236 { 237 237 struct menu_device *data = &__get_cpu_var(menu_devices); 238 238 int latency_req = pm_qos_request(PM_QOS_CPU_DMA_LATENCY); 239 - unsigned int power_usage = -1; 239 + int power_usage = -1; 240 240 int i; 241 241 int multiplier; 242 242 struct timespec t; ··· 280 280 * We want to default to C1 (hlt), not to busy polling 281 281 * unless the timer is happening really really soon. 282 282 */ 283 - if (data->expected_us > 5) 283 + if (data->expected_us > 5 && 284 + drv->states[CPUIDLE_DRIVER_STATE_START].disable == 0) 284 285 data->last_state_idx = CPUIDLE_DRIVER_STATE_START; 285 286 286 287 /* ··· 291 290 for (i = CPUIDLE_DRIVER_STATE_START; i < drv->state_count; i++) { 292 291 struct cpuidle_state *s = &drv->states[i]; 293 292 293 + if (s->disable) 294 + continue; 294 295 if (s->target_residency > data->predicted_us) 295 296 continue; 296 297 if (s->exit_latency > latency_req)
+40
drivers/cpuidle/sysfs.c
··· 11 11 #include <linux/sysfs.h> 12 12 #include <linux/slab.h> 13 13 #include <linux/cpu.h> 14 + #include <linux/capability.h> 14 15 15 16 #include "cpuidle.h" 16 17 ··· 223 222 #define define_one_state_ro(_name, show) \ 224 223 static struct cpuidle_state_attr attr_##_name = __ATTR(_name, 0444, show, NULL) 225 224 225 + #define define_one_state_rw(_name, show, store) \ 226 + static struct cpuidle_state_attr attr_##_name = __ATTR(_name, 0644, show, store) 227 + 226 228 #define define_show_state_function(_name) \ 227 229 static ssize_t show_state_##_name(struct cpuidle_state *state, \ 228 230 struct cpuidle_state_usage *state_usage, char *buf) \ 229 231 { \ 230 232 return sprintf(buf, "%u\n", state->_name);\ 233 + } 234 + 235 + #define define_store_state_function(_name) \ 236 + static ssize_t store_state_##_name(struct cpuidle_state *state, \ 237 + const char *buf, size_t size) \ 238 + { \ 239 + long value; \ 240 + int err; \ 241 + if (!capable(CAP_SYS_ADMIN)) \ 242 + return -EPERM; \ 243 + err = kstrtol(buf, 0, &value); \ 244 + if (err) \ 245 + return err; \ 246 + if (value) \ 247 + state->disable = 1; \ 248 + else \ 249 + state->disable = 0; \ 250 + return size; \ 231 251 } 232 252 233 253 #define define_show_state_ull_function(_name) \ ··· 273 251 define_show_state_ull_function(time) 274 252 define_show_state_str_function(name) 275 253 define_show_state_str_function(desc) 254 + define_show_state_function(disable) 255 + define_store_state_function(disable) 276 256 277 257 define_one_state_ro(name, show_state_name); 278 258 define_one_state_ro(desc, show_state_desc); ··· 282 258 define_one_state_ro(power, show_state_power_usage); 283 259 define_one_state_ro(usage, show_state_usage); 284 260 define_one_state_ro(time, show_state_time); 261 + define_one_state_rw(disable, show_state_disable, store_state_disable); 285 262 286 263 static struct attribute *cpuidle_state_default_attrs[] = { 287 264 &attr_name.attr, ··· 291 266 &attr_power.attr, 292 267 &attr_usage.attr, 293 268 &attr_time.attr, 269 + &attr_disable.attr, 294 270 NULL 295 271 }; 296 272 ··· 313 287 return ret; 314 288 } 315 289 290 + static ssize_t cpuidle_state_store(struct kobject *kobj, 291 + struct attribute *attr, const char *buf, size_t size) 292 + { 293 + int ret = -EIO; 294 + struct cpuidle_state *state = kobj_to_state(kobj); 295 + struct cpuidle_state_attr *cattr = attr_to_stateattr(attr); 296 + 297 + if (cattr->store) 298 + ret = cattr->store(state, buf, size); 299 + 300 + return ret; 301 + } 302 + 316 303 static const struct sysfs_ops cpuidle_state_sysfs_ops = { 317 304 .show = cpuidle_state_show, 305 + .store = cpuidle_state_store, 318 306 }; 319 307 320 308 static void cpuidle_state_sysfs_release(struct kobject *kobj)
+3 -37
drivers/pci/pci-acpi.c
··· 277 277 return 0; 278 278 } 279 279 280 - /** 281 - * acpi_dev_run_wake - Enable/disable wake-up for given device. 282 - * @phys_dev: Device to enable/disable the platform to wake-up the system for. 283 - * @enable: Whether enable or disable the wake-up functionality. 284 - * 285 - * Find the ACPI device object corresponding to @pci_dev and try to 286 - * enable/disable the GPE associated with it. 287 - */ 288 - static int acpi_dev_run_wake(struct device *phys_dev, bool enable) 289 - { 290 - struct acpi_device *dev; 291 - acpi_handle handle; 292 - 293 - if (!device_run_wake(phys_dev)) 294 - return -EINVAL; 295 - 296 - handle = DEVICE_ACPI_HANDLE(phys_dev); 297 - if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &dev))) { 298 - dev_dbg(phys_dev, "ACPI handle has no context in %s!\n", 299 - __func__); 300 - return -ENODEV; 301 - } 302 - 303 - if (enable) { 304 - acpi_enable_wakeup_device_power(dev, ACPI_STATE_S0); 305 - acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number); 306 - } else { 307 - acpi_disable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number); 308 - acpi_disable_wakeup_device_power(dev); 309 - } 310 - 311 - return 0; 312 - } 313 - 314 280 static void acpi_pci_propagate_run_wake(struct pci_bus *bus, bool enable) 315 281 { 316 282 while (bus->parent) { ··· 284 318 285 319 if (bridge->pme_interrupt) 286 320 return; 287 - if (!acpi_dev_run_wake(&bridge->dev, enable)) 321 + if (!acpi_pm_device_run_wake(&bridge->dev, enable)) 288 322 return; 289 323 bus = bus->parent; 290 324 } 291 325 292 326 /* We have reached the root bus. */ 293 327 if (bus->bridge) 294 - acpi_dev_run_wake(bus->bridge, enable); 328 + acpi_pm_device_run_wake(bus->bridge, enable); 295 329 } 296 330 297 331 static int acpi_pci_run_wake(struct pci_dev *dev, bool enable) ··· 299 333 if (dev->pme_interrupt) 300 334 return 0; 301 335 302 - if (!acpi_dev_run_wake(&dev->dev, enable)) 336 + if (!acpi_pm_device_run_wake(&dev->dev, enable)) 303 337 return 0; 304 338 305 339 acpi_pci_propagate_run_wake(dev->bus, enable);
+2 -11
drivers/platform/x86/intel_ips.c
··· 609 609 bool ret = false; 610 610 u32 temp_limit; 611 611 u32 avg_power; 612 - const char *msg = "MCP limit exceeded: "; 613 612 614 613 spin_lock_irqsave(&ips->turbo_status_lock, flags); 615 614 616 615 temp_limit = ips->mcp_temp_limit * 100; 617 - if (ips->mcp_avg_temp > temp_limit) { 618 - dev_info(&ips->dev->dev, 619 - "%sAvg temp %u, limit %u\n", msg, ips->mcp_avg_temp, 620 - temp_limit); 616 + if (ips->mcp_avg_temp > temp_limit) 621 617 ret = true; 622 - } 623 618 624 619 avg_power = ips->cpu_avg_power + ips->mch_avg_power; 625 - if (avg_power > ips->mcp_power_limit) { 626 - dev_info(&ips->dev->dev, 627 - "%sAvg power %u, limit %u\n", msg, avg_power, 628 - ips->mcp_power_limit); 620 + if (avg_power > ips->mcp_power_limit) 629 621 ret = true; 630 - } 631 622 632 623 spin_unlock_irqrestore(&ips->turbo_status_lock, flags); 633 624
+6 -1
drivers/pnp/pnpacpi/core.c
··· 321 321 { 322 322 struct acpi_device *acpi = to_acpi_device(dev); 323 323 struct pnp_dev *pnp = _pnp; 324 + struct device *physical_device; 325 + 326 + physical_device = acpi_get_physical_device(acpi->handle); 327 + if (physical_device) 328 + put_device(physical_device); 324 329 325 330 /* true means it matched */ 326 - return !acpi_get_physical_device(acpi->handle) 331 + return !physical_device 327 332 && compare_pnp_id(pnp->id, acpi_device_hid(acpi)); 328 333 } 329 334
+8
drivers/thermal/Kconfig
··· 18 18 depends on THERMAL 19 19 depends on HWMON=y || HWMON=THERMAL 20 20 default y 21 + 22 + config SPEAR_THERMAL 23 + bool "SPEAr thermal sensor driver" 24 + depends on THERMAL 25 + depends on PLAT_SPEAR 26 + help 27 + Enable this to plug the SPEAr thermal sensor driver into the Linux 28 + thermal framework
+1
drivers/thermal/Makefile
··· 3 3 # 4 4 5 5 obj-$(CONFIG_THERMAL) += thermal_sys.o 6 + obj-$(CONFIG_SPEAR_THERMAL) += spear_thermal.o
+206
drivers/thermal/spear_thermal.c
··· 1 + /* 2 + * SPEAr thermal driver. 3 + * 4 + * Copyright (C) 2011-2012 ST Microelectronics 5 + * Author: Vincenzo Frascino <vincenzo.frascino@st.com> 6 + * 7 + * This software is licensed under the terms of the GNU General Public 8 + * License version 2, as published by the Free Software Foundation, and 9 + * may be copied, distributed, and modified under those terms. 10 + * 11 + * This program is distributed in the hope that it will be useful, 12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 + * GNU General Public License for more details. 15 + * 16 + */ 17 + 18 + #include <linux/clk.h> 19 + #include <linux/device.h> 20 + #include <linux/err.h> 21 + #include <linux/io.h> 22 + #include <linux/kernel.h> 23 + #include <linux/module.h> 24 + #include <linux/platform_device.h> 25 + #include <linux/platform_data/spear_thermal.h> 26 + #include <linux/thermal.h> 27 + 28 + #define MD_FACTOR 1000 29 + 30 + /* SPEAr Thermal Sensor Dev Structure */ 31 + struct spear_thermal_dev { 32 + /* pointer to base address of the thermal sensor */ 33 + void __iomem *thermal_base; 34 + /* clk structure */ 35 + struct clk *clk; 36 + /* pointer to thermal flags */ 37 + unsigned int flags; 38 + }; 39 + 40 + static inline int thermal_get_temp(struct thermal_zone_device *thermal, 41 + unsigned long *temp) 42 + { 43 + struct spear_thermal_dev *stdev = thermal->devdata; 44 + 45 + /* 46 + * Data are ready to be read after 628 usec from POWERDOWN signal 47 + * (PDN) = 1 48 + */ 49 + *temp = (readl_relaxed(stdev->thermal_base) & 0x7F) * MD_FACTOR; 50 + return 0; 51 + } 52 + 53 + static struct thermal_zone_device_ops ops = { 54 + .get_temp = thermal_get_temp, 55 + }; 56 + 57 + #ifdef CONFIG_PM 58 + static int spear_thermal_suspend(struct device *dev) 59 + { 60 + struct platform_device *pdev = to_platform_device(dev); 61 + struct thermal_zone_device *spear_thermal = platform_get_drvdata(pdev); 62 + struct spear_thermal_dev *stdev = spear_thermal->devdata; 63 + unsigned int actual_mask = 0; 64 + 65 + /* Disable SPEAr Thermal Sensor */ 66 + actual_mask = readl_relaxed(stdev->thermal_base); 67 + writel_relaxed(actual_mask & ~stdev->flags, stdev->thermal_base); 68 + 69 + clk_disable(stdev->clk); 70 + dev_info(dev, "Suspended.\n"); 71 + 72 + return 0; 73 + } 74 + 75 + static int spear_thermal_resume(struct device *dev) 76 + { 77 + struct platform_device *pdev = to_platform_device(dev); 78 + struct thermal_zone_device *spear_thermal = platform_get_drvdata(pdev); 79 + struct spear_thermal_dev *stdev = spear_thermal->devdata; 80 + unsigned int actual_mask = 0; 81 + int ret = 0; 82 + 83 + ret = clk_enable(stdev->clk); 84 + if (ret) { 85 + dev_err(&pdev->dev, "Can't enable clock\n"); 86 + return ret; 87 + } 88 + 89 + /* Enable SPEAr Thermal Sensor */ 90 + actual_mask = readl_relaxed(stdev->thermal_base); 91 + writel_relaxed(actual_mask | stdev->flags, stdev->thermal_base); 92 + 93 + dev_info(dev, "Resumed.\n"); 94 + 95 + return 0; 96 + } 97 + #endif 98 + 99 + static SIMPLE_DEV_PM_OPS(spear_thermal_pm_ops, spear_thermal_suspend, 100 + spear_thermal_resume); 101 + 102 + static int spear_thermal_probe(struct platform_device *pdev) 103 + { 104 + struct thermal_zone_device *spear_thermal = NULL; 105 + struct spear_thermal_dev *stdev; 106 + struct spear_thermal_pdata *pdata; 107 + int ret = 0; 108 + struct resource *stres = platform_get_resource(pdev, IORESOURCE_MEM, 0); 109 + 110 + if (!stres) { 111 + dev_err(&pdev->dev, "memory resource missing\n"); 112 + return -ENODEV; 113 + } 114 + 115 + pdata = dev_get_platdata(&pdev->dev); 116 + if (!pdata) { 117 + dev_err(&pdev->dev, "platform data is NULL\n"); 118 + return -EINVAL; 119 + } 120 + 121 + stdev = devm_kzalloc(&pdev->dev, sizeof(*stdev), GFP_KERNEL); 122 + if (!stdev) { 123 + dev_err(&pdev->dev, "kzalloc fail\n"); 124 + return -ENOMEM; 125 + } 126 + 127 + /* Enable thermal sensor */ 128 + stdev->thermal_base = devm_ioremap(&pdev->dev, stres->start, 129 + resource_size(stres)); 130 + if (!stdev->thermal_base) { 131 + dev_err(&pdev->dev, "ioremap failed\n"); 132 + return -ENOMEM; 133 + } 134 + 135 + stdev->clk = clk_get(&pdev->dev, NULL); 136 + if (IS_ERR(stdev->clk)) { 137 + dev_err(&pdev->dev, "Can't get clock\n"); 138 + return PTR_ERR(stdev->clk); 139 + } 140 + 141 + ret = clk_enable(stdev->clk); 142 + if (ret) { 143 + dev_err(&pdev->dev, "Can't enable clock\n"); 144 + goto put_clk; 145 + } 146 + 147 + stdev->flags = pdata->thermal_flags; 148 + writel_relaxed(stdev->flags, stdev->thermal_base); 149 + 150 + spear_thermal = thermal_zone_device_register("spear_thermal", 0, 151 + stdev, &ops, 0, 0, 0, 0); 152 + if (IS_ERR(spear_thermal)) { 153 + dev_err(&pdev->dev, "thermal zone device is NULL\n"); 154 + ret = PTR_ERR(spear_thermal); 155 + goto disable_clk; 156 + } 157 + 158 + platform_set_drvdata(pdev, spear_thermal); 159 + 160 + dev_info(&spear_thermal->device, "Thermal Sensor Loaded at: 0x%p.\n", 161 + stdev->thermal_base); 162 + 163 + return 0; 164 + 165 + disable_clk: 166 + clk_disable(stdev->clk); 167 + put_clk: 168 + clk_put(stdev->clk); 169 + 170 + return ret; 171 + } 172 + 173 + static int spear_thermal_exit(struct platform_device *pdev) 174 + { 175 + unsigned int actual_mask = 0; 176 + struct thermal_zone_device *spear_thermal = platform_get_drvdata(pdev); 177 + struct spear_thermal_dev *stdev = spear_thermal->devdata; 178 + 179 + thermal_zone_device_unregister(spear_thermal); 180 + platform_set_drvdata(pdev, NULL); 181 + 182 + /* Disable SPEAr Thermal Sensor */ 183 + actual_mask = readl_relaxed(stdev->thermal_base); 184 + writel_relaxed(actual_mask & ~stdev->flags, stdev->thermal_base); 185 + 186 + clk_disable(stdev->clk); 187 + clk_put(stdev->clk); 188 + 189 + return 0; 190 + } 191 + 192 + static struct platform_driver spear_thermal_driver = { 193 + .probe = spear_thermal_probe, 194 + .remove = spear_thermal_exit, 195 + .driver = { 196 + .name = "spear_thermal", 197 + .owner = THIS_MODULE, 198 + .pm = &spear_thermal_pm_ops, 199 + }, 200 + }; 201 + 202 + module_platform_driver(spear_thermal_driver); 203 + 204 + MODULE_AUTHOR("Vincenzo Frascino <vincenzo.frascino@st.com>"); 205 + MODULE_DESCRIPTION("SPEAr thermal driver"); 206 + MODULE_LICENSE("GPL");
+39 -55
drivers/thermal/thermal_sys.c
··· 23 23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 24 24 */ 25 25 26 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 27 + 26 28 #include <linux/module.h> 27 29 #include <linux/device.h> 28 30 #include <linux/err.h> ··· 40 38 MODULE_AUTHOR("Zhang Rui"); 41 39 MODULE_DESCRIPTION("Generic thermal management sysfs support"); 42 40 MODULE_LICENSE("GPL"); 43 - 44 - #define PREFIX "Thermal: " 45 41 46 42 struct thermal_cooling_device_instance { 47 43 int id; ··· 60 60 static LIST_HEAD(thermal_cdev_list); 61 61 static DEFINE_MUTEX(thermal_list_lock); 62 62 63 - static unsigned int thermal_event_seqnum; 64 - 65 63 static int get_idr(struct idr *idr, struct mutex *lock, int *id) 66 64 { 67 65 int err; 68 66 69 - again: 67 + again: 70 68 if (unlikely(idr_pre_get(idr, GFP_KERNEL) == 0)) 71 69 return -ENOMEM; 72 70 ··· 150 152 if (!tz->ops->set_mode) 151 153 return -EPERM; 152 154 153 - if (!strncmp(buf, "enabled", sizeof("enabled"))) 155 + if (!strncmp(buf, "enabled", sizeof("enabled") - 1)) 154 156 result = tz->ops->set_mode(tz, THERMAL_DEVICE_ENABLED); 155 - else if (!strncmp(buf, "disabled", sizeof("disabled"))) 157 + else if (!strncmp(buf, "disabled", sizeof("disabled") - 1)) 156 158 result = tz->ops->set_mode(tz, THERMAL_DEVICE_DISABLED); 157 159 else 158 160 result = -EINVAL; ··· 281 283 static DEVICE_ATTR(type, 0444, type_show, NULL); 282 284 static DEVICE_ATTR(temp, 0444, temp_show, NULL); 283 285 static DEVICE_ATTR(mode, 0644, mode_show, mode_store); 284 - static DEVICE_ATTR(passive, S_IRUGO | S_IWUSR, passive_show, \ 285 - passive_store); 286 + static DEVICE_ATTR(passive, S_IRUGO | S_IWUSR, passive_show, passive_store); 286 287 287 288 static struct device_attribute trip_point_attrs[] = { 288 289 __ATTR(trip_point_0_type, 0444, trip_point_type_show, NULL), ··· 309 312 __ATTR(trip_point_11_type, 0444, trip_point_type_show, NULL), 310 313 __ATTR(trip_point_11_temp, 0444, trip_point_temp_show, NULL), 311 314 }; 312 - 313 - #define TRIP_POINT_ATTR_ADD(_dev, _index, result) \ 314 - do { \ 315 - result = device_create_file(_dev, \ 316 - &trip_point_attrs[_index * 2]); \ 317 - if (result) \ 318 - break; \ 319 - result = device_create_file(_dev, \ 320 - &trip_point_attrs[_index * 2 + 1]); \ 321 - } while (0) 322 - 323 - #define TRIP_POINT_ATTR_REMOVE(_dev, _index) \ 324 - do { \ 325 - device_remove_file(_dev, &trip_point_attrs[_index * 2]); \ 326 - device_remove_file(_dev, &trip_point_attrs[_index * 2 + 1]); \ 327 - } while (0) 328 315 329 316 /* sys I/F for cooling device */ 330 317 #define to_cooling_device(_dev) \ ··· 816 835 return 0; 817 836 818 837 device_remove_file(&tz->device, &dev->attr); 819 - remove_symbol_link: 838 + remove_symbol_link: 820 839 sysfs_remove_link(&tz->device.kobj, dev->name); 821 - release_idr: 840 + release_idr: 822 841 release_idr(&tz->idr, &tz->lock, dev->id); 823 - free_mem: 842 + free_mem: 824 843 kfree(dev); 825 844 return result; 826 845 } 827 - 828 846 EXPORT_SYMBOL(thermal_zone_bind_cooling_device); 829 847 830 848 /** ··· 853 873 854 874 return -ENODEV; 855 875 856 - unbind: 876 + unbind: 857 877 device_remove_file(&tz->device, &pos->attr); 858 878 sysfs_remove_link(&tz->device.kobj, pos->name); 859 879 release_idr(&tz->idr, &tz->lock, pos->id); 860 880 kfree(pos); 861 881 return 0; 862 882 } 863 - 864 883 EXPORT_SYMBOL(thermal_zone_unbind_cooling_device); 865 884 866 885 static void thermal_release(struct device *dev) ··· 867 888 struct thermal_zone_device *tz; 868 889 struct thermal_cooling_device *cdev; 869 890 870 - if (!strncmp(dev_name(dev), "thermal_zone", sizeof "thermal_zone" - 1)) { 891 + if (!strncmp(dev_name(dev), "thermal_zone", 892 + sizeof("thermal_zone") - 1)) { 871 893 tz = to_thermal_zone(dev); 872 894 kfree(tz); 873 895 } else { ··· 888 908 * @devdata: device private data. 889 909 * @ops: standard thermal cooling devices callbacks. 890 910 */ 891 - struct thermal_cooling_device *thermal_cooling_device_register( 892 - char *type, void *devdata, const struct thermal_cooling_device_ops *ops) 911 + struct thermal_cooling_device * 912 + thermal_cooling_device_register(char *type, void *devdata, 913 + const struct thermal_cooling_device_ops *ops) 893 914 { 894 915 struct thermal_cooling_device *cdev; 895 916 struct thermal_zone_device *pos; ··· 955 974 if (!result) 956 975 return cdev; 957 976 958 - unregister: 977 + unregister: 959 978 release_idr(&thermal_cdev_idr, &thermal_idr_lock, cdev->id); 960 979 device_unregister(&cdev->device); 961 980 return ERR_PTR(result); 962 981 } 963 - 964 982 EXPORT_SYMBOL(thermal_cooling_device_register); 965 983 966 984 /** ··· 1004 1024 device_unregister(&cdev->device); 1005 1025 return; 1006 1026 } 1007 - 1008 1027 EXPORT_SYMBOL(thermal_cooling_device_unregister); 1009 1028 1010 1029 /** ··· 1023 1044 1024 1045 if (tz->ops->get_temp(tz, &temp)) { 1025 1046 /* get_temp failed - retry it later */ 1026 - printk(KERN_WARNING PREFIX "failed to read out thermal zone " 1027 - "%d\n", tz->id); 1047 + pr_warn("failed to read out thermal zone %d\n", tz->id); 1028 1048 goto leave; 1029 1049 } 1030 1050 ··· 1038 1060 ret = tz->ops->notify(tz, count, 1039 1061 trip_type); 1040 1062 if (!ret) { 1041 - printk(KERN_EMERG 1042 - "Critical temperature reached (%ld C), shutting down.\n", 1043 - temp/1000); 1063 + pr_emerg("Critical temperature reached (%ld C), shutting down\n", 1064 + temp/1000); 1044 1065 orderly_poweroff(true); 1045 1066 } 1046 1067 } ··· 1077 1100 1078 1101 tz->last_temperature = temp; 1079 1102 1080 - leave: 1103 + leave: 1081 1104 if (tz->passive) 1082 1105 thermal_zone_device_set_polling(tz, tz->passive_delay); 1083 1106 else if (tz->polling_delay) ··· 1176 1199 } 1177 1200 1178 1201 for (count = 0; count < trips; count++) { 1179 - TRIP_POINT_ATTR_ADD(&tz->device, count, result); 1202 + result = device_create_file(&tz->device, 1203 + &trip_point_attrs[count * 2]); 1204 + if (result) 1205 + break; 1206 + result = device_create_file(&tz->device, 1207 + &trip_point_attrs[count * 2 + 1]); 1180 1208 if (result) 1181 1209 goto unregister; 1182 1210 tz->ops->get_trip_type(tz, count, &trip_type); ··· 1217 1235 if (!result) 1218 1236 return tz; 1219 1237 1220 - unregister: 1238 + unregister: 1221 1239 release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id); 1222 1240 device_unregister(&tz->device); 1223 1241 return ERR_PTR(result); 1224 1242 } 1225 - 1226 1243 EXPORT_SYMBOL(thermal_zone_device_register); 1227 1244 1228 1245 /** ··· 1260 1279 if (tz->ops->get_mode) 1261 1280 device_remove_file(&tz->device, &dev_attr_mode); 1262 1281 1263 - for (count = 0; count < tz->trips; count++) 1264 - TRIP_POINT_ATTR_REMOVE(&tz->device, count); 1265 - 1282 + for (count = 0; count < tz->trips; count++) { 1283 + device_remove_file(&tz->device, 1284 + &trip_point_attrs[count * 2]); 1285 + device_remove_file(&tz->device, 1286 + &trip_point_attrs[count * 2 + 1]); 1287 + } 1266 1288 thermal_remove_hwmon_sysfs(tz); 1267 1289 release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id); 1268 1290 idr_destroy(&tz->idr); ··· 1273 1289 device_unregister(&tz->device); 1274 1290 return; 1275 1291 } 1276 - 1277 1292 EXPORT_SYMBOL(thermal_zone_device_unregister); 1278 1293 1279 1294 #ifdef CONFIG_NET ··· 1295 1312 void *msg_header; 1296 1313 int size; 1297 1314 int result; 1315 + static unsigned int thermal_event_seqnum; 1298 1316 1299 1317 /* allocate memory */ 1300 - size = nla_total_size(sizeof(struct thermal_genl_event)) + \ 1301 - nla_total_size(0); 1318 + size = nla_total_size(sizeof(struct thermal_genl_event)) + 1319 + nla_total_size(0); 1302 1320 1303 1321 skb = genlmsg_new(size, GFP_ATOMIC); 1304 1322 if (!skb) ··· 1315 1331 } 1316 1332 1317 1333 /* fill the data */ 1318 - attr = nla_reserve(skb, THERMAL_GENL_ATTR_EVENT, \ 1319 - sizeof(struct thermal_genl_event)); 1334 + attr = nla_reserve(skb, THERMAL_GENL_ATTR_EVENT, 1335 + sizeof(struct thermal_genl_event)); 1320 1336 1321 1337 if (!attr) { 1322 1338 nlmsg_free(skb); ··· 1343 1359 1344 1360 result = genlmsg_multicast(skb, 0, thermal_event_mcgrp.id, GFP_ATOMIC); 1345 1361 if (result) 1346 - printk(KERN_INFO "failed to send netlink event:%d", result); 1362 + pr_info("failed to send netlink event:%d\n", result); 1347 1363 1348 1364 return result; 1349 1365 }
+5 -2
include/acpi/acexcep.h
··· 57 57 #define ACPI_SUCCESS(a) (!(a)) 58 58 #define ACPI_FAILURE(a) (a) 59 59 60 + #define ACPI_SKIP(a) (a == AE_CTRL_SKIP) 60 61 #define AE_OK (acpi_status) 0x0000 61 62 62 63 /* ··· 90 89 #define AE_SAME_HANDLER (acpi_status) (0x0019 | AE_CODE_ENVIRONMENTAL) 91 90 #define AE_NO_HANDLER (acpi_status) (0x001A | AE_CODE_ENVIRONMENTAL) 92 91 #define AE_OWNER_ID_LIMIT (acpi_status) (0x001B | AE_CODE_ENVIRONMENTAL) 92 + #define AE_NOT_CONFIGURED (acpi_status) (0x001C | AE_CODE_ENVIRONMENTAL) 93 93 94 - #define AE_CODE_ENV_MAX 0x001B 94 + #define AE_CODE_ENV_MAX 0x001C 95 95 96 96 /* 97 97 * Programmer exceptions ··· 215 213 "AE_ABORT_METHOD", 216 214 "AE_SAME_HANDLER", 217 215 "AE_NO_HANDLER", 218 - "AE_OWNER_ID_LIMIT" 216 + "AE_OWNER_ID_LIMIT", 217 + "AE_NOT_CONFIGURED" 219 218 }; 220 219 221 220 char const *acpi_gbl_exception_names_pgm[] = {
+6 -6
include/acpi/acnames.h
··· 46 46 47 47 /* Method names - these methods can appear anywhere in the namespace */ 48 48 49 + #define METHOD_NAME__SB_ "_SB_" 49 50 #define METHOD_NAME__HID "_HID" 50 51 #define METHOD_NAME__CID "_CID" 51 52 #define METHOD_NAME__UID "_UID" ··· 65 64 66 65 /* Method names - these methods must appear at the namespace root */ 67 66 68 - #define METHOD_NAME__BFS "\\_BFS" 69 - #define METHOD_NAME__GTS "\\_GTS" 70 - #define METHOD_NAME__PTS "\\_PTS" 71 - #define METHOD_NAME__SST "\\_SI._SST" 72 - #define METHOD_NAME__WAK "\\_WAK" 67 + #define METHOD_PATHNAME__BFS "\\_BFS" 68 + #define METHOD_PATHNAME__GTS "\\_GTS" 69 + #define METHOD_PATHNAME__PTS "\\_PTS" 70 + #define METHOD_PATHNAME__SST "\\_SI._SST" 71 + #define METHOD_PATHNAME__WAK "\\_WAK" 73 72 74 73 /* Definitions of the predefined namespace names */ 75 74 ··· 80 79 #define ACPI_PREFIX_LOWER (u32) 0x69706361 /* "acpi" */ 81 80 82 81 #define ACPI_NS_ROOT_PATH "\\" 83 - #define ACPI_NS_SYSTEM_BUS "_SB_" 84 82 85 83 #endif /* __ACNAMES_H__ */
+7
include/acpi/acpi_bus.h
··· 323 323 int acpi_bus_update_power(acpi_handle handle, int *state_p); 324 324 bool acpi_bus_power_manageable(acpi_handle handle); 325 325 bool acpi_bus_can_wakeup(acpi_handle handle); 326 + int acpi_power_resource_register_device(struct device *dev, acpi_handle handle); 327 + void acpi_power_resource_unregister_device(struct device *dev, acpi_handle handle); 326 328 #ifdef CONFIG_ACPI_PROC_EVENT 327 329 int acpi_bus_generate_proc_event(struct acpi_device *device, u8 type, int data); 328 330 int acpi_bus_generate_proc_event4(const char *class, const char *bid, u8 type, int data); ··· 394 392 #endif 395 393 396 394 #ifdef CONFIG_PM_SLEEP 395 + int acpi_pm_device_run_wake(struct device *, bool); 397 396 int acpi_pm_device_sleep_wake(struct device *, bool); 398 397 #else 398 + static inline int acpi_pm_device_run_wake(struct device *dev, bool enable) 399 + { 400 + return -ENODEV; 401 + } 399 402 static inline int acpi_pm_device_sleep_wake(struct device *dev, bool enable) 400 403 { 401 404 return -ENODEV;
+7 -6
include/acpi/acpiosxf.h
··· 95 95 acpi_os_table_override(struct acpi_table_header *existing_table, 96 96 struct acpi_table_header **new_table); 97 97 98 + acpi_status 99 + acpi_os_physical_table_override(struct acpi_table_header *existing_table, 100 + acpi_physical_address * new_address, 101 + u32 *new_table_length); 102 + 98 103 /* 99 104 * Spinlock primitives 100 105 */ ··· 222 217 * Platform and hardware-independent physical memory interfaces 223 218 */ 224 219 acpi_status 225 - acpi_os_read_memory(acpi_physical_address address, u32 * value, u32 width); 226 - acpi_status 227 - acpi_os_read_memory64(acpi_physical_address address, u64 *value, u32 width); 220 + acpi_os_read_memory(acpi_physical_address address, u64 *value, u32 width); 228 221 229 222 acpi_status 230 - acpi_os_write_memory(acpi_physical_address address, u32 value, u32 width); 231 - acpi_status 232 - acpi_os_write_memory64(acpi_physical_address address, u64 value, u32 width); 223 + acpi_os_write_memory(acpi_physical_address address, u64 value, u32 width); 233 224 234 225 /* 235 226 * Platform and hardware-independent PCI configuration space access
+149 -58
include/acpi/acpixf.h
··· 47 47 48 48 /* Current ACPICA subsystem version in YYYYMMDD format */ 49 49 50 - #define ACPI_CA_VERSION 0x20120111 50 + #define ACPI_CA_VERSION 0x20120320 51 51 52 + #include "acconfig.h" 52 53 #include "actypes.h" 53 54 #include "actbl.h" 54 55 ··· 71 70 extern u8 acpi_gbl_copy_dsdt_locally; 72 71 extern u8 acpi_gbl_truncate_io_addresses; 73 72 extern u8 acpi_gbl_disable_auto_repair; 73 + 74 + /* 75 + * Hardware-reduced prototypes. All interfaces that use these macros will 76 + * be configured out of the ACPICA build if the ACPI_REDUCED_HARDWARE flag 77 + * is set to TRUE. 78 + */ 79 + #if (!ACPI_REDUCED_HARDWARE) 80 + #define ACPI_HW_DEPENDENT_RETURN_STATUS(prototype) \ 81 + prototype; 82 + 83 + #define ACPI_HW_DEPENDENT_RETURN_OK(prototype) \ 84 + prototype; 85 + 86 + #define ACPI_HW_DEPENDENT_RETURN_VOID(prototype) \ 87 + prototype; 88 + 89 + #else 90 + #define ACPI_HW_DEPENDENT_RETURN_STATUS(prototype) \ 91 + static ACPI_INLINE prototype {return(AE_NOT_CONFIGURED);} 92 + 93 + #define ACPI_HW_DEPENDENT_RETURN_OK(prototype) \ 94 + static ACPI_INLINE prototype {return(AE_OK);} 95 + 96 + #define ACPI_HW_DEPENDENT_RETURN_VOID(prototype) \ 97 + static ACPI_INLINE prototype {} 98 + 99 + #endif /* !ACPI_REDUCED_HARDWARE */ 74 100 75 101 extern u32 acpi_current_gpe_count; 76 102 extern struct acpi_table_fadt acpi_gbl_FADT; ··· 124 96 acpi_status acpi_subsystem_status(void); 125 97 #endif 126 98 127 - acpi_status acpi_enable(void); 128 - 129 - acpi_status acpi_disable(void); 99 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable(void)) 100 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_disable(void)) 130 101 131 102 #ifdef ACPI_FUTURE_USAGE 132 103 acpi_status acpi_get_system_info(struct acpi_buffer *ret_buffer); ··· 262 235 acpi_status 263 236 acpi_install_initialization_handler(acpi_init_handler handler, u32 function); 264 237 265 - acpi_status 266 - acpi_install_global_event_handler(ACPI_GBL_EVENT_HANDLER handler, 267 - void *context); 238 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 239 + acpi_install_global_event_handler 240 + (ACPI_GBL_EVENT_HANDLER handler, void *context)) 268 241 269 - acpi_status 270 - acpi_install_fixed_event_handler(u32 acpi_event, 271 - acpi_event_handler handler, void *context); 272 - 273 - acpi_status 274 - acpi_remove_fixed_event_handler(u32 acpi_event, acpi_event_handler handler); 275 - 242 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 243 + acpi_install_fixed_event_handler(u32 244 + acpi_event, 245 + acpi_event_handler 246 + handler, 247 + void 248 + *context)) 249 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 250 + acpi_remove_fixed_event_handler(u32 acpi_event, 251 + acpi_event_handler 252 + handler)) 253 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 254 + acpi_install_gpe_handler(acpi_handle 255 + gpe_device, 256 + u32 gpe_number, 257 + u32 type, 258 + acpi_gpe_handler 259 + address, 260 + void *context)) 261 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 262 + acpi_remove_gpe_handler(acpi_handle gpe_device, 263 + u32 gpe_number, 264 + acpi_gpe_handler 265 + address)) 276 266 acpi_status 277 267 acpi_install_notify_handler(acpi_handle device, 278 268 u32 handler_type, ··· 310 266 acpi_adr_space_type space_id, 311 267 acpi_adr_space_handler handler); 312 268 313 - acpi_status 314 - acpi_install_gpe_handler(acpi_handle gpe_device, 315 - u32 gpe_number, 316 - u32 type, acpi_gpe_handler address, void *context); 317 - 318 - acpi_status 319 - acpi_remove_gpe_handler(acpi_handle gpe_device, 320 - u32 gpe_number, acpi_gpe_handler address); 321 - 322 269 #ifdef ACPI_FUTURE_USAGE 323 270 acpi_status acpi_install_exception_handler(acpi_exception_handler handler); 324 271 #endif ··· 319 284 /* 320 285 * Global Lock interfaces 321 286 */ 322 - acpi_status acpi_acquire_global_lock(u16 timeout, u32 * handle); 323 - 324 - acpi_status acpi_release_global_lock(u32 handle); 287 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 288 + acpi_acquire_global_lock(u16 timeout, 289 + u32 *handle)) 290 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 291 + acpi_release_global_lock(u32 handle)) 325 292 326 293 /* 327 294 * Interfaces to AML mutex objects ··· 336 299 /* 337 300 * Fixed Event interfaces 338 301 */ 339 - acpi_status acpi_enable_event(u32 event, u32 flags); 302 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 303 + acpi_enable_event(u32 event, u32 flags)) 340 304 341 - acpi_status acpi_disable_event(u32 event, u32 flags); 305 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 306 + acpi_disable_event(u32 event, u32 flags)) 342 307 343 - acpi_status acpi_clear_event(u32 event); 308 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_clear_event(u32 event)) 344 309 345 - acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status); 346 - 310 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 311 + acpi_get_event_status(u32 event, 312 + acpi_event_status 313 + *event_status)) 347 314 /* 348 315 * General Purpose Event (GPE) Interfaces 349 316 */ 350 - acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number); 317 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_update_all_gpes(void)) 351 318 352 - acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number); 319 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 320 + acpi_enable_gpe(acpi_handle gpe_device, 321 + u32 gpe_number)) 353 322 354 - acpi_status acpi_clear_gpe(acpi_handle gpe_device, u32 gpe_number); 323 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 324 + acpi_disable_gpe(acpi_handle gpe_device, 325 + u32 gpe_number)) 355 326 356 - acpi_status 357 - acpi_setup_gpe_for_wake(acpi_handle parent_device, 358 - acpi_handle gpe_device, u32 gpe_number); 327 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 328 + acpi_clear_gpe(acpi_handle gpe_device, 329 + u32 gpe_number)) 359 330 360 - acpi_status acpi_set_gpe_wake_mask(acpi_handle gpe_device, u32 gpe_number, u8 action); 331 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 332 + acpi_set_gpe(acpi_handle gpe_device, 333 + u32 gpe_number, u8 action)) 361 334 362 - acpi_status 363 - acpi_get_gpe_status(acpi_handle gpe_device, 364 - u32 gpe_number, acpi_event_status *event_status); 335 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 336 + acpi_finish_gpe(acpi_handle gpe_device, 337 + u32 gpe_number)) 365 338 366 - acpi_status acpi_disable_all_gpes(void); 339 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 340 + acpi_setup_gpe_for_wake(acpi_handle 341 + parent_device, 342 + acpi_handle gpe_device, 343 + u32 gpe_number)) 344 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 345 + acpi_set_gpe_wake_mask(acpi_handle gpe_device, 346 + u32 gpe_number, 347 + u8 action)) 348 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 349 + acpi_get_gpe_status(acpi_handle gpe_device, 350 + u32 gpe_number, 351 + acpi_event_status 352 + *event_status)) 367 353 368 - acpi_status acpi_enable_all_runtime_gpes(void); 354 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_disable_all_gpes(void)) 369 355 370 - acpi_status acpi_get_gpe_device(u32 gpe_index, acpi_handle *gpe_device); 356 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable_all_runtime_gpes(void)) 371 357 372 - acpi_status 373 - acpi_install_gpe_block(acpi_handle gpe_device, 374 - struct acpi_generic_address *gpe_block_address, 375 - u32 register_count, u32 interrupt_number); 358 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 359 + acpi_get_gpe_device(u32 gpe_index, 360 + acpi_handle * gpe_device)) 376 361 377 - acpi_status acpi_remove_gpe_block(acpi_handle gpe_device); 378 - 379 - acpi_status acpi_update_all_gpes(void); 362 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 363 + acpi_install_gpe_block(acpi_handle gpe_device, 364 + struct 365 + acpi_generic_address 366 + *gpe_block_address, 367 + u32 register_count, 368 + u32 interrupt_number)) 369 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 370 + acpi_remove_gpe_block(acpi_handle gpe_device)) 380 371 381 372 /* 382 373 * Resource interfaces ··· 456 391 */ 457 392 acpi_status acpi_reset(void); 458 393 459 - acpi_status acpi_read_bit_register(u32 register_id, u32 *return_value); 394 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 395 + acpi_read_bit_register(u32 register_id, 396 + u32 *return_value)) 460 397 461 - acpi_status acpi_write_bit_register(u32 register_id, u32 value); 398 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 399 + acpi_write_bit_register(u32 register_id, 400 + u32 value)) 462 401 463 - acpi_status acpi_set_firmware_waking_vector(u32 physical_address); 402 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 403 + acpi_set_firmware_waking_vector(u32 404 + physical_address)) 464 405 465 406 #if ACPI_MACHINE_WIDTH == 64 466 - acpi_status acpi_set_firmware_waking_vector64(u64 physical_address); 407 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 408 + acpi_set_firmware_waking_vector64(u64 409 + physical_address)) 467 410 #endif 468 411 469 412 acpi_status acpi_read(u64 *value, struct acpi_generic_address *reg); 470 413 471 414 acpi_status acpi_write(u64 value, struct acpi_generic_address *reg); 472 415 416 + /* 417 + * Sleep/Wake interfaces 418 + */ 473 419 acpi_status 474 420 acpi_get_sleep_type_data(u8 sleep_state, u8 * slp_typ_a, u8 * slp_typ_b); 475 421 476 422 acpi_status acpi_enter_sleep_state_prep(u8 sleep_state); 477 423 478 - acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state); 424 + acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state, u8 flags); 479 425 480 - acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void); 426 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void)) 481 427 482 - acpi_status acpi_leave_sleep_state_prep(u8 sleep_state); 428 + acpi_status acpi_leave_sleep_state_prep(u8 sleep_state, u8 flags); 483 429 484 430 acpi_status acpi_leave_sleep_state(u8 sleep_state); 431 + 432 + /* 433 + * ACPI Timer interfaces 434 + */ 435 + #ifdef ACPI_FUTURE_USAGE 436 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 437 + acpi_get_timer_resolution(u32 *resolution)) 438 + 439 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_get_timer(u32 *ticks)) 440 + 441 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 442 + acpi_get_timer_duration(u32 start_ticks, 443 + u32 end_ticks, 444 + u32 *time_elapsed)) 445 + #endif /* ACPI_FUTURE_USAGE */ 485 446 486 447 /* 487 448 * Error/Warning output
+7
include/acpi/actbl.h
··· 309 309 PM_TABLET = 8 310 310 }; 311 311 312 + /* Values for sleep_status and sleep_control registers (V5 FADT) */ 313 + 314 + #define ACPI_X_WAKE_STATUS 0x80 315 + #define ACPI_X_SLEEP_TYPE_MASK 0x1C 316 + #define ACPI_X_SLEEP_TYPE_POSITION 0x02 317 + #define ACPI_X_SLEEP_ENABLE 0x20 318 + 312 319 /* Reset to default packing */ 313 320 314 321 #pragma pack()
+20 -2
include/acpi/actypes.h
··· 518 518 #define ACPI_SLEEP_TYPE_INVALID 0xFF 519 519 520 520 /* 521 + * Sleep/Wake flags 522 + */ 523 + #define ACPI_NO_OPTIONAL_METHODS 0x00 /* Do not execute any optional methods */ 524 + #define ACPI_EXECUTE_GTS 0x01 /* For enter sleep interface */ 525 + #define ACPI_EXECUTE_BFS 0x02 /* For leave sleep prep interface */ 526 + 527 + /* 521 528 * Standard notify values 522 529 */ 523 530 #define ACPI_NOTIFY_BUS_CHECK (u8) 0x00 ··· 539 532 #define ACPI_NOTIFY_DEVICE_PLD_CHECK (u8) 0x09 540 533 #define ACPI_NOTIFY_RESERVED (u8) 0x0A 541 534 #define ACPI_NOTIFY_LOCALITY_UPDATE (u8) 0x0B 535 + #define ACPI_NOTIFY_SHUTDOWN_REQUEST (u8) 0x0C 542 536 543 - #define ACPI_NOTIFY_MAX 0x0B 537 + #define ACPI_NOTIFY_MAX 0x0C 544 538 545 539 /* 546 540 * Types associated with ACPI names and objects. The first group of ··· 706 698 #define ACPI_ALL_NOTIFY (ACPI_SYSTEM_NOTIFY | ACPI_DEVICE_NOTIFY) 707 699 #define ACPI_MAX_NOTIFY_HANDLER_TYPE 0x3 708 700 709 - #define ACPI_MAX_SYS_NOTIFY 0x7f 701 + #define ACPI_MAX_SYS_NOTIFY 0x7F 702 + #define ACPI_MAX_DEVICE_SPECIFIC_NOTIFY 0xBF 710 703 711 704 /* Address Space (Operation Region) Types */ 712 705 ··· 794 785 795 786 #define ACPI_ENABLE_EVENT 1 796 787 #define ACPI_DISABLE_EVENT 0 788 + 789 + /* Sleep function dispatch */ 790 + 791 + typedef acpi_status(*ACPI_SLEEP_FUNCTION) (u8 sleep_state, u8 flags); 792 + 793 + struct acpi_sleep_functions { 794 + ACPI_SLEEP_FUNCTION legacy_function; 795 + ACPI_SLEEP_FUNCTION extended_function; 796 + }; 797 797 798 798 /* 799 799 * External ACPI object definition
+10
include/linux/acpi.h
··· 372 372 373 373 #endif /* !CONFIG_ACPI */ 374 374 375 + #ifdef CONFIG_ACPI 376 + void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state, 377 + u32 pm1a_ctrl, u32 pm1b_ctrl)); 378 + 379 + acpi_status acpi_os_prepare_sleep(u8 sleep_state, 380 + u32 pm1a_control, u32 pm1b_control); 381 + #else 382 + #define acpi_os_set_prepare_sleep(func, pm1a_ctrl, pm1b_ctrl) do { } while (0) 383 + #endif 384 + 375 385 #endif /*_LINUX_ACPI_H*/
+19 -3
include/linux/cpuidle.h
··· 15 15 #include <linux/list.h> 16 16 #include <linux/kobject.h> 17 17 #include <linux/completion.h> 18 + #include <linux/hrtimer.h> 18 19 19 20 #define CPUIDLE_STATE_MAX 8 20 21 #define CPUIDLE_NAME_LEN 16 ··· 44 43 45 44 unsigned int flags; 46 45 unsigned int exit_latency; /* in US */ 47 - unsigned int power_usage; /* in mW */ 46 + int power_usage; /* in mW */ 48 47 unsigned int target_residency; /* in US */ 48 + unsigned int disable; 49 49 50 50 int (*enter) (struct cpuidle_device *dev, 51 51 struct cpuidle_driver *drv, 52 52 int index); 53 + 54 + int (*enter_dead) (struct cpuidle_device *dev, int index); 53 55 }; 54 56 55 57 /* Idle State Flags */ ··· 100 96 struct list_head device_list; 101 97 struct kobject kobj; 102 98 struct completion kobj_unregister; 103 - void *governor_data; 104 99 }; 105 100 106 101 DECLARE_PER_CPU(struct cpuidle_device *, cpuidle_devices); ··· 121 118 ****************************/ 122 119 123 120 struct cpuidle_driver { 124 - char name[CPUIDLE_NAME_LEN]; 121 + const char *name; 125 122 struct module *owner; 126 123 127 124 unsigned int power_specified:1; 125 + /* set to 1 to use the core cpuidle time keeping (for all states). */ 126 + unsigned int en_core_tk_irqen:1; 128 127 struct cpuidle_state states[CPUIDLE_STATE_MAX]; 129 128 int state_count; 130 129 int safe_state_index; ··· 145 140 extern void cpuidle_resume_and_unlock(void); 146 141 extern int cpuidle_enable_device(struct cpuidle_device *dev); 147 142 extern void cpuidle_disable_device(struct cpuidle_device *dev); 143 + extern int cpuidle_wrap_enter(struct cpuidle_device *dev, 144 + struct cpuidle_driver *drv, int index, 145 + int (*enter)(struct cpuidle_device *dev, 146 + struct cpuidle_driver *drv, int index)); 147 + extern int cpuidle_play_dead(void); 148 148 149 149 #else 150 150 static inline void disable_cpuidle(void) { } ··· 167 157 static inline int cpuidle_enable_device(struct cpuidle_device *dev) 168 158 {return -ENODEV; } 169 159 static inline void cpuidle_disable_device(struct cpuidle_device *dev) { } 160 + static inline int cpuidle_wrap_enter(struct cpuidle_device *dev, 161 + struct cpuidle_driver *drv, int index, 162 + int (*enter)(struct cpuidle_device *dev, 163 + struct cpuidle_driver *drv, int index)) 164 + { return -ENODEV; } 165 + static inline int cpuidle_play_dead(void) {return -ENODEV; } 170 166 171 167 #endif 172 168
+26
include/linux/platform_data/spear_thermal.h
··· 1 + /* 2 + * SPEAr thermal driver platform data. 3 + * 4 + * Copyright (C) 2011-2012 ST Microelectronics 5 + * Author: Vincenzo Frascino <vincenzo.frascino@st.com> 6 + * 7 + * This software is licensed under the terms of the GNU General Public 8 + * License version 2, as published by the Free Software Foundation, and 9 + * may be copied, distributed, and modified under those terms. 10 + * 11 + * This program is distributed in the hope that it will be useful, 12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 + * GNU General Public License for more details. 15 + * 16 + */ 17 + #ifndef SPEAR_THERMAL_H 18 + #define SPEAR_THERMAL_H 19 + 20 + /* SPEAr Thermal Sensor Platform Data */ 21 + struct spear_thermal_pdata { 22 + /* flags used to enable thermal sensor */ 23 + unsigned int thermal_flags; 24 + }; 25 + 26 + #endif /* SPEAR_THERMAL_H */
-1
include/linux/tboot.h
··· 143 143 144 144 extern void tboot_probe(void); 145 145 extern void tboot_shutdown(u32 shutdown_type); 146 - extern void tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control); 147 146 extern struct acpi_table_header *tboot_get_dmar_table( 148 147 struct acpi_table_header *dmar_tbl); 149 148 extern int tboot_force_iommu(void);
+58 -41
tools/power/x86/turbostat/turbostat.8
··· 4 4 .SH SYNOPSIS 5 5 .ft B 6 6 .B turbostat 7 + .RB [ "\-s" ] 7 8 .RB [ "\-v" ] 8 9 .RB [ "\-M MSR#" ] 9 10 .RB command 10 11 .br 11 12 .B turbostat 13 + .RB [ "\-s" ] 12 14 .RB [ "\-v" ] 13 15 .RB [ "\-M MSR#" ] 14 16 .RB [ "\-i interval_sec" ] ··· 27 25 on processors that additionally support C-state residency counters. 28 26 29 27 .SS Options 28 + The \fB-s\fP option prints only a 1-line summary for each sample interval. 29 + .PP 30 30 The \fB-v\fP option increases verbosity. 31 31 .PP 32 32 The \fB-M MSR#\fP option dumps the specified MSR, ··· 43 39 .SH FIELD DESCRIPTIONS 44 40 .nf 45 41 \fBpk\fP processor package number. 46 - \fBcr\fP processor core number. 42 + \fBcor\fP processor core number. 47 43 \fBCPU\fP Linux CPU (logical processor) number. 44 + Note that multiple CPUs per core indicate support for Intel(R) Hyper-Threading Technology. 48 45 \fB%c0\fP percent of the interval that the CPU retired instructions. 49 46 \fBGHz\fP average clock rate while the CPU was in c0 state. 50 47 \fBTSC\fP average GHz that the TSC ran during the entire interval. 51 - \fB%c1, %c3, %c6\fP show the percentage residency in hardware core idle states. 52 - \fB%pc3, %pc6\fP percentage residency in hardware package idle states. 48 + \fB%c1, %c3, %c6, %c7\fP show the percentage residency in hardware core idle states. 49 + \fB%pc2, %pc3, %pc6, %pc7\fP percentage residency in hardware package idle states. 53 50 .fi 54 51 .PP 55 52 .SH EXAMPLE ··· 58 53 (override interval with "-i sec" option, or specify a command 59 54 for turbostat to fork). 60 55 61 - The first row of statistics reflect the average for the entire system. 56 + The first row of statistics is a summary for the entire system. 57 + Note that the summary is a weighted average. 62 58 Subsequent rows show per-CPU statistics. 63 59 64 60 .nf 65 61 [root@x980]# ./turbostat 66 - cr CPU %c0 GHz TSC %c1 %c3 %c6 %pc3 %pc6 67 - 0.04 1.62 3.38 0.11 0.00 99.85 0.00 95.07 68 - 0 0 0.04 1.62 3.38 0.06 0.00 99.90 0.00 95.07 69 - 0 6 0.02 1.62 3.38 0.08 0.00 99.90 0.00 95.07 70 - 1 2 0.10 1.62 3.38 0.29 0.00 99.61 0.00 95.07 71 - 1 8 0.11 1.62 3.38 0.28 0.00 99.61 0.00 95.07 72 - 2 4 0.01 1.62 3.38 0.01 0.00 99.98 0.00 95.07 73 - 2 10 0.01 1.61 3.38 0.02 0.00 99.98 0.00 95.07 74 - 8 1 0.07 1.62 3.38 0.15 0.00 99.78 0.00 95.07 75 - 8 7 0.03 1.62 3.38 0.19 0.00 99.78 0.00 95.07 76 - 9 3 0.01 1.62 3.38 0.02 0.00 99.98 0.00 95.07 77 - 9 9 0.01 1.62 3.38 0.02 0.00 99.98 0.00 95.07 78 - 10 5 0.01 1.62 3.38 0.13 0.00 99.86 0.00 95.07 79 - 10 11 0.08 1.62 3.38 0.05 0.00 99.86 0.00 95.07 62 + cor CPU %c0 GHz TSC %c1 %c3 %c6 %pc3 %pc6 63 + 0.60 1.63 3.38 2.91 0.00 96.49 0.00 76.64 64 + 0 0 0.59 1.62 3.38 4.51 0.00 94.90 0.00 76.64 65 + 0 6 1.13 1.64 3.38 3.97 0.00 94.90 0.00 76.64 66 + 1 2 0.08 1.62 3.38 0.07 0.00 99.85 0.00 76.64 67 + 1 8 0.03 1.62 3.38 0.12 0.00 99.85 0.00 76.64 68 + 2 4 0.01 1.62 3.38 0.06 0.00 99.93 0.00 76.64 69 + 2 10 0.04 1.62 3.38 0.02 0.00 99.93 0.00 76.64 70 + 8 1 2.85 1.62 3.38 11.71 0.00 85.44 0.00 76.64 71 + 8 7 1.98 1.62 3.38 12.58 0.00 85.44 0.00 76.64 72 + 9 3 0.36 1.62 3.38 0.71 0.00 98.93 0.00 76.64 73 + 9 9 0.09 1.62 3.38 0.98 0.00 98.93 0.00 76.64 74 + 10 5 0.03 1.62 3.38 0.09 0.00 99.87 0.00 76.64 75 + 10 11 0.07 1.62 3.38 0.06 0.00 99.87 0.00 76.64 76 + .fi 77 + .SH SUMMARY EXAMPLE 78 + The "-s" option prints the column headers just once, 79 + and then the one line system summary for each sample interval. 80 + 81 + .nf 82 + [root@x980]# ./turbostat -s 83 + %c0 GHz TSC %c1 %c3 %c6 %pc3 %pc6 84 + 0.61 1.89 3.38 5.95 0.00 93.44 0.00 66.33 85 + 0.52 1.62 3.38 6.83 0.00 92.65 0.00 61.11 86 + 0.62 1.92 3.38 5.47 0.00 93.91 0.00 67.31 80 87 .fi 81 88 .SH VERBOSE EXAMPLE 82 89 The "-v" option adds verbosity to the output: ··· 118 101 119 102 .nf 120 103 [root@x980 lenb]# ./turbostat cat /dev/zero > /dev/null 121 - 122 - ^Ccr CPU %c0 GHz TSC %c1 %c3 %c6 %pc3 %pc6 123 - 8.49 3.63 3.38 16.23 0.66 74.63 0.00 0.00 124 - 0 0 1.22 3.62 3.38 32.18 0.00 66.60 0.00 0.00 125 - 0 6 0.40 3.61 3.38 33.00 0.00 66.60 0.00 0.00 126 - 1 2 0.11 3.14 3.38 0.19 3.95 95.75 0.00 0.00 127 - 1 8 0.05 2.88 3.38 0.25 3.95 95.75 0.00 0.00 128 - 2 4 0.00 3.13 3.38 0.02 0.00 99.98 0.00 0.00 129 - 2 10 0.00 3.09 3.38 0.02 0.00 99.98 0.00 0.00 130 - 8 1 0.04 3.50 3.38 14.43 0.00 85.54 0.00 0.00 131 - 8 7 0.03 2.98 3.38 14.43 0.00 85.54 0.00 0.00 132 - 9 3 0.00 3.16 3.38 100.00 0.00 0.00 0.00 0.00 133 - 9 9 99.93 3.63 3.38 0.06 0.00 0.00 0.00 0.00 134 - 10 5 0.01 2.82 3.38 0.08 0.00 99.91 0.00 0.00 135 - 10 11 0.02 3.36 3.38 0.06 0.00 99.91 0.00 0.00 136 - 6.950866 sec 104 + ^C 105 + cor CPU %c0 GHz TSC %c1 %c3 %c6 %pc3 %pc6 106 + 8.63 3.64 3.38 14.46 0.49 76.42 0.00 0.00 107 + 0 0 0.34 3.36 3.38 99.66 0.00 0.00 0.00 0.00 108 + 0 6 99.96 3.64 3.38 0.04 0.00 0.00 0.00 0.00 109 + 1 2 0.14 3.50 3.38 1.75 2.04 96.07 0.00 0.00 110 + 1 8 0.38 3.57 3.38 1.51 2.04 96.07 0.00 0.00 111 + 2 4 0.01 2.65 3.38 0.06 0.00 99.93 0.00 0.00 112 + 2 10 0.03 2.12 3.38 0.04 0.00 99.93 0.00 0.00 113 + 8 1 0.91 3.59 3.38 35.27 0.92 62.90 0.00 0.00 114 + 8 7 1.61 3.63 3.38 34.57 0.92 62.90 0.00 0.00 115 + 9 3 0.04 3.38 3.38 0.20 0.00 99.76 0.00 0.00 116 + 9 9 0.04 3.29 3.38 0.20 0.00 99.76 0.00 0.00 117 + 10 5 0.03 3.08 3.38 0.12 0.00 99.85 0.00 0.00 118 + 10 11 0.05 3.07 3.38 0.10 0.00 99.85 0.00 0.00 119 + 4.907015 sec 137 120 138 121 .fi 139 - Above the cycle soaker drives cpu9 up 3.6 Ghz turbo limit 122 + Above the cycle soaker drives cpu6 up 3.6 Ghz turbo limit 140 123 while the other processors are generally in various states of idle. 141 124 142 - Note that cpu3 is an HT sibling sharing core9 143 - with cpu9, and thus it is unable to get to an idle state 144 - deeper than c1 while cpu9 is busy. 125 + Note that cpu0 is an HT sibling sharing core0 126 + with cpu6, and thus it is unable to get to an idle state 127 + deeper than c1 while cpu6 is busy. 145 128 146 - Note that turbostat reports average GHz of 3.61, while 147 - the arithmetic average of the GHz column above is 3.24. 129 + Note that turbostat reports average GHz of 3.64, while 130 + the arithmetic average of the GHz column above is lower. 148 131 This is a weighted average, where the weight is %c0. ie. it is the total number of 149 132 un-halted cycles elapsed per time divided by the number of CPUs. 150 133 .SH NOTES ··· 184 167 .SH "SEE ALSO" 185 168 msr(4), vmstat(8) 186 169 .PP 187 - .SH AUTHORS 170 + .SH AUTHOR 188 171 .nf 189 172 Written by Len Brown <len.brown@intel.com>
+166 -79
tools/power/x86/turbostat/turbostat.c
··· 2 2 * turbostat -- show CPU frequency and C-state residency 3 3 * on modern Intel turbo-capable processors. 4 4 * 5 - * Copyright (c) 2010, Intel Corporation. 5 + * Copyright (c) 2012 Intel Corporation. 6 6 * Len Brown <len.brown@intel.com> 7 7 * 8 8 * This program is free software; you can redistribute it and/or modify it ··· 19 19 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 20 20 */ 21 21 22 + #define _GNU_SOURCE 22 23 #include <stdio.h> 23 24 #include <unistd.h> 24 25 #include <sys/types.h> ··· 33 32 #include <dirent.h> 34 33 #include <string.h> 35 34 #include <ctype.h> 35 + #include <sched.h> 36 36 37 37 #define MSR_TSC 0x10 38 38 #define MSR_NEHALEM_PLATFORM_INFO 0xCE ··· 51 49 char *proc_stat = "/proc/stat"; 52 50 unsigned int interval_sec = 5; /* set with -i interval_sec */ 53 51 unsigned int verbose; /* set with -v */ 52 + unsigned int summary_only; /* set with -s */ 54 53 unsigned int skip_c0; 55 54 unsigned int skip_c1; 56 55 unsigned int do_nhm_cstates; ··· 71 68 int aperf_mperf_unstable; 72 69 int backwards_count; 73 70 char *progname; 74 - int need_reinitialize; 75 71 76 72 int num_cpus; 73 + cpu_set_t *cpu_mask; 74 + size_t cpu_mask_size; 77 75 78 76 struct counters { 79 77 unsigned long long tsc; /* per thread */ ··· 103 99 struct timeval tv_odd; 104 100 struct timeval tv_delta; 105 101 106 - unsigned long long get_msr(int cpu, off_t offset) 102 + /* 103 + * cpu_mask_init(ncpus) 104 + * 105 + * allocate and clear cpu_mask 106 + * set cpu_mask_size 107 + */ 108 + void cpu_mask_init(int ncpus) 109 + { 110 + cpu_mask = CPU_ALLOC(ncpus); 111 + if (cpu_mask == NULL) { 112 + perror("CPU_ALLOC"); 113 + exit(3); 114 + } 115 + cpu_mask_size = CPU_ALLOC_SIZE(ncpus); 116 + CPU_ZERO_S(cpu_mask_size, cpu_mask); 117 + } 118 + 119 + void cpu_mask_uninit() 120 + { 121 + CPU_FREE(cpu_mask); 122 + cpu_mask = NULL; 123 + cpu_mask_size = 0; 124 + } 125 + 126 + int cpu_migrate(int cpu) 127 + { 128 + CPU_ZERO_S(cpu_mask_size, cpu_mask); 129 + CPU_SET_S(cpu, cpu_mask_size, cpu_mask); 130 + if (sched_setaffinity(0, cpu_mask_size, cpu_mask) == -1) 131 + return -1; 132 + else 133 + return 0; 134 + } 135 + 136 + int get_msr(int cpu, off_t offset, unsigned long long *msr) 107 137 { 108 138 ssize_t retval; 109 - unsigned long long msr; 110 139 char pathname[32]; 111 140 int fd; 112 141 113 142 sprintf(pathname, "/dev/cpu/%d/msr", cpu); 114 143 fd = open(pathname, O_RDONLY); 115 - if (fd < 0) { 116 - perror(pathname); 117 - need_reinitialize = 1; 118 - return 0; 119 - } 144 + if (fd < 0) 145 + return -1; 120 146 121 - retval = pread(fd, &msr, sizeof msr, offset); 122 - if (retval != sizeof msr) { 123 - fprintf(stderr, "cpu%d pread(..., 0x%zx) = %jd\n", 124 - cpu, offset, retval); 125 - exit(-2); 126 - } 127 - 147 + retval = pread(fd, msr, sizeof *msr, offset); 128 148 close(fd); 129 - return msr; 149 + 150 + if (retval != sizeof *msr) 151 + return -1; 152 + 153 + return 0; 130 154 } 131 155 132 156 void print_header(void) 133 157 { 134 158 if (show_pkg) 135 159 fprintf(stderr, "pk"); 160 + if (show_pkg) 161 + fprintf(stderr, " "); 136 162 if (show_core) 137 - fprintf(stderr, " cr"); 163 + fprintf(stderr, "cor"); 138 164 if (show_cpu) 139 165 fprintf(stderr, " CPU"); 166 + if (show_pkg || show_core || show_cpu) 167 + fprintf(stderr, " "); 140 168 if (do_nhm_cstates) 141 - fprintf(stderr, " %%c0 "); 169 + fprintf(stderr, " %%c0"); 142 170 if (has_aperf) 143 - fprintf(stderr, " GHz"); 171 + fprintf(stderr, " GHz"); 144 172 fprintf(stderr, " TSC"); 145 173 if (do_nhm_cstates) 146 174 fprintf(stderr, " %%c1"); ··· 183 147 if (do_snb_cstates) 184 148 fprintf(stderr, " %%c7"); 185 149 if (do_snb_cstates) 186 - fprintf(stderr, " %%pc2"); 150 + fprintf(stderr, " %%pc2"); 187 151 if (do_nhm_cstates) 188 - fprintf(stderr, " %%pc3"); 152 + fprintf(stderr, " %%pc3"); 189 153 if (do_nhm_cstates) 190 - fprintf(stderr, " %%pc6"); 154 + fprintf(stderr, " %%pc6"); 191 155 if (do_snb_cstates) 192 - fprintf(stderr, " %%pc7"); 156 + fprintf(stderr, " %%pc7"); 193 157 if (extra_msr_offset) 194 158 fprintf(stderr, " MSR 0x%x ", extra_msr_offset); 195 159 ··· 223 187 dump_cnt(cnt); 224 188 } 225 189 190 + /* 191 + * column formatting convention & formats 192 + * package: "pk" 2 columns %2d 193 + * core: "cor" 3 columns %3d 194 + * CPU: "CPU" 3 columns %3d 195 + * GHz: "GHz" 3 columns %3.2 196 + * TSC: "TSC" 3 columns %3.2 197 + * percentage " %pc3" %6.2 198 + */ 226 199 void print_cnt(struct counters *p) 227 200 { 228 201 double interval_float; ··· 241 196 /* topology columns, print blanks on 1st (average) line */ 242 197 if (p == cnt_average) { 243 198 if (show_pkg) 199 + fprintf(stderr, " "); 200 + if (show_pkg && show_core) 244 201 fprintf(stderr, " "); 245 202 if (show_core) 246 - fprintf(stderr, " "); 203 + fprintf(stderr, " "); 247 204 if (show_cpu) 248 - fprintf(stderr, " "); 205 + fprintf(stderr, " " " "); 249 206 } else { 250 207 if (show_pkg) 251 - fprintf(stderr, "%d", p->pkg); 208 + fprintf(stderr, "%2d", p->pkg); 209 + if (show_pkg && show_core) 210 + fprintf(stderr, " "); 252 211 if (show_core) 253 - fprintf(stderr, "%4d", p->core); 212 + fprintf(stderr, "%3d", p->core); 254 213 if (show_cpu) 255 - fprintf(stderr, "%4d", p->cpu); 214 + fprintf(stderr, " %3d", p->cpu); 256 215 } 257 216 258 217 /* %c0 */ 259 218 if (do_nhm_cstates) { 219 + if (show_pkg || show_core || show_cpu) 220 + fprintf(stderr, " "); 260 221 if (!skip_c0) 261 - fprintf(stderr, "%7.2f", 100.0 * p->mperf/p->tsc); 222 + fprintf(stderr, "%6.2f", 100.0 * p->mperf/p->tsc); 262 223 else 263 - fprintf(stderr, " ****"); 224 + fprintf(stderr, " ****"); 264 225 } 265 226 266 227 /* GHz */ 267 228 if (has_aperf) { 268 229 if (!aperf_mperf_unstable) { 269 - fprintf(stderr, "%5.2f", 230 + fprintf(stderr, " %3.2f", 270 231 1.0 * p->tsc / units * p->aperf / 271 232 p->mperf / interval_float); 272 233 } else { 273 234 if (p->aperf > p->tsc || p->mperf > p->tsc) { 274 - fprintf(stderr, " ****"); 235 + fprintf(stderr, " ***"); 275 236 } else { 276 - fprintf(stderr, "%4.1f*", 237 + fprintf(stderr, "%3.1f*", 277 238 1.0 * p->tsc / 278 239 units * p->aperf / 279 240 p->mperf / interval_float); ··· 292 241 293 242 if (do_nhm_cstates) { 294 243 if (!skip_c1) 295 - fprintf(stderr, "%7.2f", 100.0 * p->c1/p->tsc); 244 + fprintf(stderr, " %6.2f", 100.0 * p->c1/p->tsc); 296 245 else 297 246 fprintf(stderr, " ****"); 298 247 } ··· 303 252 if (do_snb_cstates) 304 253 fprintf(stderr, " %6.2f", 100.0 * p->c7/p->tsc); 305 254 if (do_snb_cstates) 306 - fprintf(stderr, " %5.2f", 100.0 * p->pc2/p->tsc); 255 + fprintf(stderr, " %6.2f", 100.0 * p->pc2/p->tsc); 307 256 if (do_nhm_cstates) 308 - fprintf(stderr, " %5.2f", 100.0 * p->pc3/p->tsc); 257 + fprintf(stderr, " %6.2f", 100.0 * p->pc3/p->tsc); 309 258 if (do_nhm_cstates) 310 - fprintf(stderr, " %5.2f", 100.0 * p->pc6/p->tsc); 259 + fprintf(stderr, " %6.2f", 100.0 * p->pc6/p->tsc); 311 260 if (do_snb_cstates) 312 - fprintf(stderr, " %5.2f", 100.0 * p->pc7/p->tsc); 261 + fprintf(stderr, " %6.2f", 100.0 * p->pc7/p->tsc); 313 262 if (extra_msr_offset) 314 263 fprintf(stderr, " 0x%016llx", p->extra_msr); 315 264 putc('\n', stderr); ··· 318 267 void print_counters(struct counters *counters) 319 268 { 320 269 struct counters *cnt; 270 + static int printed; 321 271 322 - print_header(); 272 + 273 + if (!printed || !summary_only) 274 + print_header(); 323 275 324 276 if (num_cpus > 1) 325 277 print_cnt(cnt_average); 278 + 279 + printed = 1; 280 + 281 + if (summary_only) 282 + return; 326 283 327 284 for (cnt = counters; cnt != NULL; cnt = cnt->next) 328 285 print_cnt(cnt); ··· 499 440 free(sum); 500 441 } 501 442 502 - void get_counters(struct counters *cnt) 443 + int get_counters(struct counters *cnt) 503 444 { 504 445 for ( ; cnt; cnt = cnt->next) { 505 - cnt->tsc = get_msr(cnt->cpu, MSR_TSC); 506 - if (do_nhm_cstates) 507 - cnt->c3 = get_msr(cnt->cpu, MSR_CORE_C3_RESIDENCY); 508 - if (do_nhm_cstates) 509 - cnt->c6 = get_msr(cnt->cpu, MSR_CORE_C6_RESIDENCY); 446 + 447 + if (cpu_migrate(cnt->cpu)) 448 + return -1; 449 + 450 + if (get_msr(cnt->cpu, MSR_TSC, &cnt->tsc)) 451 + return -1; 452 + 453 + if (has_aperf) { 454 + if (get_msr(cnt->cpu, MSR_APERF, &cnt->aperf)) 455 + return -1; 456 + if (get_msr(cnt->cpu, MSR_MPERF, &cnt->mperf)) 457 + return -1; 458 + } 459 + 460 + if (do_nhm_cstates) { 461 + if (get_msr(cnt->cpu, MSR_CORE_C3_RESIDENCY, &cnt->c3)) 462 + return -1; 463 + if (get_msr(cnt->cpu, MSR_CORE_C6_RESIDENCY, &cnt->c6)) 464 + return -1; 465 + } 466 + 510 467 if (do_snb_cstates) 511 - cnt->c7 = get_msr(cnt->cpu, MSR_CORE_C7_RESIDENCY); 512 - if (has_aperf) 513 - cnt->aperf = get_msr(cnt->cpu, MSR_APERF); 514 - if (has_aperf) 515 - cnt->mperf = get_msr(cnt->cpu, MSR_MPERF); 516 - if (do_snb_cstates) 517 - cnt->pc2 = get_msr(cnt->cpu, MSR_PKG_C2_RESIDENCY); 518 - if (do_nhm_cstates) 519 - cnt->pc3 = get_msr(cnt->cpu, MSR_PKG_C3_RESIDENCY); 520 - if (do_nhm_cstates) 521 - cnt->pc6 = get_msr(cnt->cpu, MSR_PKG_C6_RESIDENCY); 522 - if (do_snb_cstates) 523 - cnt->pc7 = get_msr(cnt->cpu, MSR_PKG_C7_RESIDENCY); 468 + if (get_msr(cnt->cpu, MSR_CORE_C7_RESIDENCY, &cnt->c7)) 469 + return -1; 470 + 471 + if (do_nhm_cstates) { 472 + if (get_msr(cnt->cpu, MSR_PKG_C3_RESIDENCY, &cnt->pc3)) 473 + return -1; 474 + if (get_msr(cnt->cpu, MSR_PKG_C6_RESIDENCY, &cnt->pc6)) 475 + return -1; 476 + } 477 + if (do_snb_cstates) { 478 + if (get_msr(cnt->cpu, MSR_PKG_C2_RESIDENCY, &cnt->pc2)) 479 + return -1; 480 + if (get_msr(cnt->cpu, MSR_PKG_C7_RESIDENCY, &cnt->pc7)) 481 + return -1; 482 + } 524 483 if (extra_msr_offset) 525 - cnt->extra_msr = get_msr(cnt->cpu, extra_msr_offset); 484 + if (get_msr(cnt->cpu, extra_msr_offset, &cnt->extra_msr)) 485 + return -1; 526 486 } 487 + return 0; 527 488 } 528 489 529 490 void print_nehalem_info(void) ··· 554 475 if (!do_nehalem_platform_info) 555 476 return; 556 477 557 - msr = get_msr(0, MSR_NEHALEM_PLATFORM_INFO); 478 + get_msr(0, MSR_NEHALEM_PLATFORM_INFO, &msr); 558 479 559 480 ratio = (msr >> 40) & 0xFF; 560 481 fprintf(stderr, "%d * %.0f = %.0f MHz max efficiency\n", ··· 570 491 if (!do_nehalem_turbo_ratio_limit) 571 492 return; 572 493 573 - msr = get_msr(0, MSR_NEHALEM_TURBO_RATIO_LIMIT); 494 + get_msr(0, MSR_NEHALEM_TURBO_RATIO_LIMIT, &msr); 574 495 575 496 ratio = (msr >> 24) & 0xFF; 576 497 if (ratio) ··· 636 557 return; 637 558 } 638 559 639 - show_cpu = 1; /* there is more than one CPU */ 560 + if (!summary_only) 561 + show_cpu = 1; /* there is more than one CPU */ 640 562 641 563 /* 642 564 * insert on front of list. ··· 655 575 656 576 while (prev->next && (prev->next->pkg < new->pkg)) { 657 577 prev = prev->next; 658 - show_pkg = 1; /* there is more than 1 package */ 578 + if (!summary_only) 579 + show_pkg = 1; /* there is more than 1 package */ 659 580 } 660 581 661 582 while (prev->next && (prev->next->pkg == new->pkg) 662 583 && (prev->next->core < new->core)) { 663 584 prev = prev->next; 664 - show_core = 1; /* there is more than 1 core */ 585 + if (!summary_only) 586 + show_core = 1; /* there is more than 1 core */ 665 587 } 666 588 667 589 while (prev->next && (prev->next->pkg == new->pkg) ··· 763 681 } 764 682 765 683 /* 766 - * run func(index, cpu) on every cpu in /proc/stat 684 + * run func(pkg, core, cpu) on every cpu in /proc/stat 767 685 */ 768 686 769 687 int for_all_cpus(void (func)(int, int, int)) ··· 799 717 800 718 void re_initialize(void) 801 719 { 802 - printf("turbostat: topology changed, re-initializing.\n"); 803 720 free_all_counters(); 804 721 num_cpus = for_all_cpus(alloc_new_counters); 805 - need_reinitialize = 0; 806 - printf("num_cpus is now %d\n", num_cpus); 722 + cpu_mask_uninit(); 723 + cpu_mask_init(num_cpus); 724 + printf("turbostat: re-initialized with num_cpus %d\n", num_cpus); 807 725 } 808 726 809 727 void dummy(int pkg, int core, int cpu) { return; } 810 728 /* 811 729 * check to see if a cpu came on-line 812 730 */ 813 - void verify_num_cpus(void) 731 + int verify_num_cpus(void) 814 732 { 815 733 int new_num_cpus; 816 734 ··· 820 738 if (verbose) 821 739 printf("num_cpus was %d, is now %d\n", 822 740 num_cpus, new_num_cpus); 823 - need_reinitialize = 1; 741 + return -1; 824 742 } 743 + return 0; 825 744 } 826 745 827 746 void turbostat_loop() ··· 832 749 gettimeofday(&tv_even, (struct timezone *)NULL); 833 750 834 751 while (1) { 835 - verify_num_cpus(); 836 - if (need_reinitialize) { 752 + if (verify_num_cpus()) { 837 753 re_initialize(); 838 754 goto restart; 839 755 } 840 756 sleep(interval_sec); 841 - get_counters(cnt_odd); 757 + if (get_counters(cnt_odd)) { 758 + re_initialize(); 759 + goto restart; 760 + } 842 761 gettimeofday(&tv_odd, (struct timezone *)NULL); 843 - 844 762 compute_delta(cnt_odd, cnt_even, cnt_delta); 845 763 timersub(&tv_odd, &tv_even, &tv_delta); 846 764 compute_average(cnt_delta, cnt_average); 847 765 print_counters(cnt_delta); 848 - if (need_reinitialize) { 766 + sleep(interval_sec); 767 + if (get_counters(cnt_even)) { 849 768 re_initialize(); 850 769 goto restart; 851 770 } 852 - sleep(interval_sec); 853 - get_counters(cnt_even); 854 771 gettimeofday(&tv_even, (struct timezone *)NULL); 855 772 compute_delta(cnt_even, cnt_odd, cnt_delta); 856 773 timersub(&tv_even, &tv_odd, &tv_delta); ··· 1036 953 check_super_user(); 1037 954 1038 955 num_cpus = for_all_cpus(alloc_new_counters); 956 + cpu_mask_init(num_cpus); 1039 957 1040 958 if (verbose) 1041 959 print_nehalem_info(); ··· 1089 1005 1090 1006 progname = argv[0]; 1091 1007 1092 - while ((opt = getopt(argc, argv, "+vi:M:")) != -1) { 1008 + while ((opt = getopt(argc, argv, "+svi:M:")) != -1) { 1093 1009 switch (opt) { 1010 + case 's': 1011 + summary_only++; 1012 + break; 1094 1013 case 'v': 1095 1014 verbose++; 1096 1015 break;