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

Configure Feed

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

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

* 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux:
cpuidle: Single/Global registration of idle states
cpuidle: Split cpuidle_state structure and move per-cpu statistics fields
cpuidle: Remove CPUIDLE_FLAG_IGNORE and dev->prepare()
cpuidle: Move dev->last_residency update to driver enter routine; remove dev->last_state
ACPI: Fix CONFIG_ACPI_DOCK=n compiler warning
ACPI: Export FADT pm_profile integer value to userspace
thermal: Prevent polling from happening during system suspend
ACPI: Drop ACPI_NO_HARDWARE_INIT
ACPI atomicio: Convert width in bits to bytes in __acpi_ioremap_fast()
PNPACPI: Simplify disabled resource registration
ACPI: Fix possible recursive locking in hwregs.c
ACPI: use kstrdup()
mrst pmu: update comment
tools/power turbostat: less verbose debugging

+732 -415
+22
Documentation/ABI/stable/sysfs-acpi-pmprofile
··· 1 + What: /sys/firmware/acpi/pm_profile 2 + Date: 03-Nov-2011 3 + KernelVersion: v3.2 4 + Contact: linux-acpi@vger.kernel.org 5 + Description: The ACPI pm_profile sysfs interface exports the platform 6 + power management (and performance) requirement expectations 7 + as provided by BIOS. The integer value is directly passed as 8 + retrieved from the FADT ACPI table. 9 + Values: For possible values see ACPI specification: 10 + 5.2.9 Fixed ACPI Description Table (FADT) 11 + Field: Preferred_PM_Profile 12 + 13 + Currently these values are defined by spec: 14 + 0 Unspecified 15 + 1 Desktop 16 + 2 Mobile 17 + 3 Workstation 18 + 4 Enterprise Server 19 + 5 SOHO Server 20 + 6 Appliance PC 21 + 7 Performance Server 22 + >7 Reserved
+23 -18
arch/arm/mach-at91/cpuidle.c
··· 34 34 35 35 /* Actual code that puts the SoC in different idle states */ 36 36 static int at91_enter_idle(struct cpuidle_device *dev, 37 - struct cpuidle_state *state) 37 + struct cpuidle_driver *drv, 38 + int index) 38 39 { 39 40 struct timeval before, after; 40 41 int idle_time; ··· 43 42 44 43 local_irq_disable(); 45 44 do_gettimeofday(&before); 46 - if (state == &dev->states[0]) 45 + if (index == 0) 47 46 /* Wait for interrupt state */ 48 47 cpu_do_idle(); 49 - else if (state == &dev->states[1]) { 48 + else if (index == 1) { 50 49 asm("b 1f; .align 5; 1:"); 51 50 asm("mcr p15, 0, r0, c7, c10, 4"); /* drain write buffer */ 52 51 saved_lpr = sdram_selfrefresh_enable(); ··· 57 56 local_irq_enable(); 58 57 idle_time = (after.tv_sec - before.tv_sec) * USEC_PER_SEC + 59 58 (after.tv_usec - before.tv_usec); 60 - return idle_time; 59 + 60 + dev->last_residency = idle_time; 61 + return index; 61 62 } 62 63 63 64 /* Initialize CPU idle by registering the idle states */ 64 65 static int at91_init_cpuidle(void) 65 66 { 66 67 struct cpuidle_device *device; 67 - 68 - cpuidle_register_driver(&at91_idle_driver); 68 + struct cpuidle_driver *driver = &at91_idle_driver; 69 69 70 70 device = &per_cpu(at91_cpuidle_device, smp_processor_id()); 71 71 device->state_count = AT91_MAX_STATES; 72 + driver->state_count = AT91_MAX_STATES; 72 73 73 74 /* Wait for interrupt state */ 74 - device->states[0].enter = at91_enter_idle; 75 - device->states[0].exit_latency = 1; 76 - device->states[0].target_residency = 10000; 77 - device->states[0].flags = CPUIDLE_FLAG_TIME_VALID; 78 - strcpy(device->states[0].name, "WFI"); 79 - strcpy(device->states[0].desc, "Wait for interrupt"); 75 + driver->states[0].enter = at91_enter_idle; 76 + driver->states[0].exit_latency = 1; 77 + driver->states[0].target_residency = 10000; 78 + driver->states[0].flags = CPUIDLE_FLAG_TIME_VALID; 79 + strcpy(driver->states[0].name, "WFI"); 80 + strcpy(driver->states[0].desc, "Wait for interrupt"); 80 81 81 82 /* Wait for interrupt and RAM self refresh state */ 82 - device->states[1].enter = at91_enter_idle; 83 - device->states[1].exit_latency = 10; 84 - device->states[1].target_residency = 10000; 85 - device->states[1].flags = CPUIDLE_FLAG_TIME_VALID; 86 - strcpy(device->states[1].name, "RAM_SR"); 87 - strcpy(device->states[1].desc, "WFI and RAM Self Refresh"); 83 + driver->states[1].enter = at91_enter_idle; 84 + driver->states[1].exit_latency = 10; 85 + driver->states[1].target_residency = 10000; 86 + driver->states[1].flags = CPUIDLE_FLAG_TIME_VALID; 87 + strcpy(driver->states[1].name, "RAM_SR"); 88 + strcpy(driver->states[1].desc, "WFI and RAM Self Refresh"); 89 + 90 + cpuidle_register_driver(&at91_idle_driver); 88 91 89 92 if (cpuidle_register_device(device)) { 90 93 printk(KERN_ERR "at91_init_cpuidle: Failed registering\n");
+31 -24
arch/arm/mach-davinci/cpuidle.c
··· 79 79 80 80 /* Actual code that puts the SoC in different idle states */ 81 81 static int davinci_enter_idle(struct cpuidle_device *dev, 82 - struct cpuidle_state *state) 82 + struct cpuidle_driver *drv, 83 + int index) 83 84 { 84 - struct davinci_ops *ops = cpuidle_get_statedata(state); 85 + struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; 86 + struct davinci_ops *ops = cpuidle_get_statedata(state_usage); 85 87 struct timeval before, after; 86 88 int idle_time; 87 89 ··· 101 99 local_irq_enable(); 102 100 idle_time = (after.tv_sec - before.tv_sec) * USEC_PER_SEC + 103 101 (after.tv_usec - before.tv_usec); 104 - return idle_time; 102 + 103 + dev->last_residency = idle_time; 104 + 105 + return index; 105 106 } 106 107 107 108 static int __init davinci_cpuidle_probe(struct platform_device *pdev) 108 109 { 109 110 int ret; 110 111 struct cpuidle_device *device; 112 + struct cpuidle_driver *driver = &davinci_idle_driver; 111 113 struct davinci_cpuidle_config *pdata = pdev->dev.platform_data; 112 114 113 115 device = &per_cpu(davinci_cpuidle_device, smp_processor_id()); ··· 123 117 124 118 ddr2_reg_base = pdata->ddr2_ctlr_base; 125 119 120 + /* Wait for interrupt state */ 121 + driver->states[0].enter = davinci_enter_idle; 122 + driver->states[0].exit_latency = 1; 123 + driver->states[0].target_residency = 10000; 124 + driver->states[0].flags = CPUIDLE_FLAG_TIME_VALID; 125 + strcpy(driver->states[0].name, "WFI"); 126 + strcpy(driver->states[0].desc, "Wait for interrupt"); 127 + 128 + /* Wait for interrupt and DDR self refresh state */ 129 + driver->states[1].enter = davinci_enter_idle; 130 + driver->states[1].exit_latency = 10; 131 + driver->states[1].target_residency = 10000; 132 + driver->states[1].flags = CPUIDLE_FLAG_TIME_VALID; 133 + strcpy(driver->states[1].name, "DDR SR"); 134 + strcpy(driver->states[1].desc, "WFI and DDR Self Refresh"); 135 + if (pdata->ddr2_pdown) 136 + davinci_states[1].flags |= DAVINCI_CPUIDLE_FLAGS_DDR2_PWDN; 137 + cpuidle_set_statedata(&device->states_usage[1], &davinci_states[1]); 138 + 139 + device->state_count = DAVINCI_CPUIDLE_MAX_STATES; 140 + driver->state_count = DAVINCI_CPUIDLE_MAX_STATES; 141 + 126 142 ret = cpuidle_register_driver(&davinci_idle_driver); 127 143 if (ret) { 128 144 dev_err(&pdev->dev, "failed to register driver\n"); 129 145 return ret; 130 146 } 131 - 132 - /* Wait for interrupt state */ 133 - device->states[0].enter = davinci_enter_idle; 134 - device->states[0].exit_latency = 1; 135 - device->states[0].target_residency = 10000; 136 - device->states[0].flags = CPUIDLE_FLAG_TIME_VALID; 137 - strcpy(device->states[0].name, "WFI"); 138 - strcpy(device->states[0].desc, "Wait for interrupt"); 139 - 140 - /* Wait for interrupt and DDR self refresh state */ 141 - device->states[1].enter = davinci_enter_idle; 142 - device->states[1].exit_latency = 10; 143 - device->states[1].target_residency = 10000; 144 - device->states[1].flags = CPUIDLE_FLAG_TIME_VALID; 145 - strcpy(device->states[1].name, "DDR SR"); 146 - strcpy(device->states[1].desc, "WFI and DDR Self Refresh"); 147 - if (pdata->ddr2_pdown) 148 - davinci_states[1].flags |= DAVINCI_CPUIDLE_FLAGS_DDR2_PWDN; 149 - cpuidle_set_statedata(&device->states[1], &davinci_states[1]); 150 - 151 - device->state_count = DAVINCI_CPUIDLE_MAX_STATES; 152 147 153 148 ret = cpuidle_register_device(device); 154 149 if (ret) {
+16 -12
arch/arm/mach-exynos/cpuidle.c
··· 16 16 #include <asm/proc-fns.h> 17 17 18 18 static int exynos4_enter_idle(struct cpuidle_device *dev, 19 - struct cpuidle_state *state); 19 + struct cpuidle_driver *drv, 20 + int index); 20 21 21 22 static struct cpuidle_state exynos4_cpuidle_set[] = { 22 23 [0] = { ··· 38 37 }; 39 38 40 39 static int exynos4_enter_idle(struct cpuidle_device *dev, 41 - struct cpuidle_state *state) 40 + struct cpuidle_driver *drv, 41 + int index) 42 42 { 43 43 struct timeval before, after; 44 44 int idle_time; ··· 54 52 idle_time = (after.tv_sec - before.tv_sec) * USEC_PER_SEC + 55 53 (after.tv_usec - before.tv_usec); 56 54 57 - return idle_time; 55 + dev->last_residency = idle_time; 56 + return index; 58 57 } 59 58 60 59 static int __init exynos4_init_cpuidle(void) 61 60 { 62 61 int i, max_cpuidle_state, cpu_id; 63 62 struct cpuidle_device *device; 63 + struct cpuidle_driver *drv = &exynos4_idle_driver; 64 64 65 + /* Setup cpuidle driver */ 66 + drv->state_count = (sizeof(exynos4_cpuidle_set) / 67 + sizeof(struct cpuidle_state)); 68 + max_cpuidle_state = drv->state_count; 69 + for (i = 0; i < max_cpuidle_state; i++) { 70 + memcpy(&drv->states[i], &exynos4_cpuidle_set[i], 71 + sizeof(struct cpuidle_state)); 72 + } 65 73 cpuidle_register_driver(&exynos4_idle_driver); 66 74 67 75 for_each_cpu(cpu_id, cpu_online_mask) { 68 76 device = &per_cpu(exynos4_cpuidle_device, cpu_id); 69 77 device->cpu = cpu_id; 70 78 71 - device->state_count = (sizeof(exynos4_cpuidle_set) / 72 - sizeof(struct cpuidle_state)); 73 - 74 - max_cpuidle_state = device->state_count; 75 - 76 - for (i = 0; i < max_cpuidle_state; i++) { 77 - memcpy(&device->states[i], &exynos4_cpuidle_set[i], 78 - sizeof(struct cpuidle_state)); 79 - } 79 + device->state_count = drv->state_count; 80 80 81 81 if (cpuidle_register_device(device)) { 82 82 printk(KERN_ERR "CPUidle register device failed\n,");
+24 -18
arch/arm/mach-kirkwood/cpuidle.c
··· 33 33 34 34 /* Actual code that puts the SoC in different idle states */ 35 35 static int kirkwood_enter_idle(struct cpuidle_device *dev, 36 - struct cpuidle_state *state) 36 + struct cpuidle_driver *drv, 37 + int index) 37 38 { 38 39 struct timeval before, after; 39 40 int idle_time; 40 41 41 42 local_irq_disable(); 42 43 do_gettimeofday(&before); 43 - if (state == &dev->states[0]) 44 + if (index == 0) 44 45 /* Wait for interrupt state */ 45 46 cpu_do_idle(); 46 - else if (state == &dev->states[1]) { 47 + else if (index == 1) { 47 48 /* 48 49 * Following write will put DDR in self refresh. 49 50 * Note that we have 256 cycles before DDR puts it ··· 59 58 local_irq_enable(); 60 59 idle_time = (after.tv_sec - before.tv_sec) * USEC_PER_SEC + 61 60 (after.tv_usec - before.tv_usec); 62 - return idle_time; 61 + 62 + /* Update last residency */ 63 + dev->last_residency = idle_time; 64 + 65 + return index; 63 66 } 64 67 65 68 /* Initialize CPU idle by registering the idle states */ 66 69 static int kirkwood_init_cpuidle(void) 67 70 { 68 71 struct cpuidle_device *device; 69 - 70 - cpuidle_register_driver(&kirkwood_idle_driver); 72 + struct cpuidle_driver *driver = &kirkwood_idle_driver; 71 73 72 74 device = &per_cpu(kirkwood_cpuidle_device, smp_processor_id()); 73 75 device->state_count = KIRKWOOD_MAX_STATES; 76 + driver->state_count = KIRKWOOD_MAX_STATES; 74 77 75 78 /* Wait for interrupt state */ 76 - device->states[0].enter = kirkwood_enter_idle; 77 - device->states[0].exit_latency = 1; 78 - device->states[0].target_residency = 10000; 79 - device->states[0].flags = CPUIDLE_FLAG_TIME_VALID; 80 - strcpy(device->states[0].name, "WFI"); 81 - strcpy(device->states[0].desc, "Wait for interrupt"); 79 + driver->states[0].enter = kirkwood_enter_idle; 80 + driver->states[0].exit_latency = 1; 81 + driver->states[0].target_residency = 10000; 82 + driver->states[0].flags = CPUIDLE_FLAG_TIME_VALID; 83 + strcpy(driver->states[0].name, "WFI"); 84 + strcpy(driver->states[0].desc, "Wait for interrupt"); 82 85 83 86 /* Wait for interrupt and DDR self refresh state */ 84 - device->states[1].enter = kirkwood_enter_idle; 85 - device->states[1].exit_latency = 10; 86 - device->states[1].target_residency = 10000; 87 - device->states[1].flags = CPUIDLE_FLAG_TIME_VALID; 88 - strcpy(device->states[1].name, "DDR SR"); 89 - strcpy(device->states[1].desc, "WFI and DDR Self Refresh"); 87 + driver->states[1].enter = kirkwood_enter_idle; 88 + driver->states[1].exit_latency = 10; 89 + driver->states[1].target_residency = 10000; 90 + driver->states[1].flags = CPUIDLE_FLAG_TIME_VALID; 91 + strcpy(driver->states[1].name, "DDR SR"); 92 + strcpy(driver->states[1].desc, "WFI and DDR Self Refresh"); 90 93 94 + cpuidle_register_driver(&kirkwood_idle_driver); 91 95 if (cpuidle_register_device(device)) { 92 96 printk(KERN_ERR "kirkwood_init_cpuidle: Failed registering\n"); 93 97 return -EIO;
+85 -48
arch/arm/mach-omap2/cpuidle34xx.c
··· 88 88 /** 89 89 * omap3_enter_idle - Programs OMAP3 to enter the specified state 90 90 * @dev: cpuidle device 91 - * @state: The target state to be programmed 91 + * @drv: cpuidle driver 92 + * @index: the index of state to be entered 92 93 * 93 94 * Called from the CPUidle framework to program the device to the 94 95 * specified target state selected by the governor. 95 96 */ 96 97 static int omap3_enter_idle(struct cpuidle_device *dev, 97 - struct cpuidle_state *state) 98 + struct cpuidle_driver *drv, 99 + int index) 98 100 { 99 - struct omap3_idle_statedata *cx = cpuidle_get_statedata(state); 101 + struct omap3_idle_statedata *cx = 102 + cpuidle_get_statedata(&dev->states_usage[index]); 100 103 struct timespec ts_preidle, ts_postidle, ts_idle; 101 104 u32 mpu_state = cx->mpu_state, core_state = cx->core_state; 105 + int idle_time; 102 106 103 107 /* Used to keep track of the total time in idle */ 104 108 getnstimeofday(&ts_preidle); ··· 117 113 goto return_sleep_time; 118 114 119 115 /* Deny idle for C1 */ 120 - if (state == &dev->states[0]) { 116 + if (index == 0) { 121 117 pwrdm_for_each_clkdm(mpu_pd, _cpuidle_deny_idle); 122 118 pwrdm_for_each_clkdm(core_pd, _cpuidle_deny_idle); 123 119 } ··· 126 122 omap_sram_idle(); 127 123 128 124 /* Re-allow idle for C1 */ 129 - if (state == &dev->states[0]) { 125 + if (index == 0) { 130 126 pwrdm_for_each_clkdm(mpu_pd, _cpuidle_allow_idle); 131 127 pwrdm_for_each_clkdm(core_pd, _cpuidle_allow_idle); 132 128 } ··· 138 134 local_irq_enable(); 139 135 local_fiq_enable(); 140 136 141 - return ts_idle.tv_nsec / NSEC_PER_USEC + ts_idle.tv_sec * USEC_PER_SEC; 137 + idle_time = ts_idle.tv_nsec / NSEC_PER_USEC + ts_idle.tv_sec * \ 138 + USEC_PER_SEC; 139 + 140 + /* Update cpuidle counters */ 141 + dev->last_residency = idle_time; 142 + 143 + return index; 142 144 } 143 145 144 146 /** 145 147 * next_valid_state - Find next valid C-state 146 148 * @dev: cpuidle device 147 - * @state: Currently selected C-state 149 + * @drv: cpuidle driver 150 + * @index: Index of currently selected c-state 148 151 * 149 - * If the current state is valid, it is returned back to the caller. 150 - * Else, this function searches for a lower c-state which is still 151 - * valid. 152 + * If the state corresponding to index is valid, index is returned back 153 + * to the caller. Else, this function searches for a lower c-state which is 154 + * still valid (as defined in omap3_power_states[]) and returns its index. 152 155 * 153 156 * A state is valid if the 'valid' field is enabled and 154 157 * if it satisfies the enable_off_mode condition. 155 158 */ 156 - static struct cpuidle_state *next_valid_state(struct cpuidle_device *dev, 157 - struct cpuidle_state *curr) 159 + static int next_valid_state(struct cpuidle_device *dev, 160 + struct cpuidle_driver *drv, 161 + int index) 158 162 { 159 - struct cpuidle_state *next = NULL; 160 - struct omap3_idle_statedata *cx = cpuidle_get_statedata(curr); 163 + struct cpuidle_state_usage *curr_usage = &dev->states_usage[index]; 164 + struct cpuidle_state *curr = &drv->states[index]; 165 + struct omap3_idle_statedata *cx = cpuidle_get_statedata(curr_usage); 161 166 u32 mpu_deepest_state = PWRDM_POWER_RET; 162 167 u32 core_deepest_state = PWRDM_POWER_RET; 168 + int next_index = -1; 163 169 164 170 if (enable_off_mode) { 165 171 mpu_deepest_state = PWRDM_POWER_OFF; ··· 186 172 if ((cx->valid) && 187 173 (cx->mpu_state >= mpu_deepest_state) && 188 174 (cx->core_state >= core_deepest_state)) { 189 - return curr; 175 + return index; 190 176 } else { 191 177 int idx = OMAP3_NUM_STATES - 1; 192 178 193 179 /* Reach the current state starting at highest C-state */ 194 180 for (; idx >= 0; idx--) { 195 - if (&dev->states[idx] == curr) { 196 - next = &dev->states[idx]; 181 + if (&drv->states[idx] == curr) { 182 + next_index = idx; 197 183 break; 198 184 } 199 185 } 200 186 201 187 /* Should never hit this condition */ 202 - WARN_ON(next == NULL); 188 + WARN_ON(next_index == -1); 203 189 204 190 /* 205 191 * Drop to next valid state. ··· 207 193 */ 208 194 idx--; 209 195 for (; idx >= 0; idx--) { 210 - cx = cpuidle_get_statedata(&dev->states[idx]); 196 + cx = cpuidle_get_statedata(&dev->states_usage[idx]); 211 197 if ((cx->valid) && 212 198 (cx->mpu_state >= mpu_deepest_state) && 213 199 (cx->core_state >= core_deepest_state)) { 214 - next = &dev->states[idx]; 200 + next_index = idx; 215 201 break; 216 202 } 217 203 } 218 204 /* 219 205 * C1 is always valid. 220 - * So, no need to check for 'next==NULL' outside this loop. 206 + * So, no need to check for 'next_index == -1' outside 207 + * this loop. 221 208 */ 222 209 } 223 210 224 - return next; 211 + return next_index; 225 212 } 226 213 227 214 /** 228 215 * omap3_enter_idle_bm - Checks for any bus activity 229 216 * @dev: cpuidle device 230 - * @state: The target state to be programmed 217 + * @drv: cpuidle driver 218 + * @index: array index of target state to be programmed 231 219 * 232 220 * This function checks for any pending activity and then programs 233 221 * the device to the specified or a safer state. 234 222 */ 235 223 static int omap3_enter_idle_bm(struct cpuidle_device *dev, 236 - struct cpuidle_state *state) 224 + struct cpuidle_driver *drv, 225 + int index) 237 226 { 238 - struct cpuidle_state *new_state; 227 + int new_state_idx; 239 228 u32 core_next_state, per_next_state = 0, per_saved_state = 0, cam_state; 240 229 struct omap3_idle_statedata *cx; 241 230 int ret; 242 231 243 232 if (!omap3_can_sleep()) { 244 - new_state = dev->safe_state; 233 + new_state_idx = drv->safe_state_index; 245 234 goto select_state; 246 235 } 247 236 ··· 254 237 */ 255 238 cam_state = pwrdm_read_pwrst(cam_pd); 256 239 if (cam_state == PWRDM_POWER_ON) { 257 - new_state = dev->safe_state; 240 + new_state_idx = drv->safe_state_index; 258 241 goto select_state; 259 242 } 260 243 ··· 270 253 * Prevent PER off if CORE is not in retention or off as this 271 254 * would disable PER wakeups completely. 272 255 */ 273 - cx = cpuidle_get_statedata(state); 256 + cx = cpuidle_get_statedata(&dev->states_usage[index]); 274 257 core_next_state = cx->core_state; 275 258 per_next_state = per_saved_state = pwrdm_read_next_pwrst(per_pd); 276 259 if ((per_next_state == PWRDM_POWER_OFF) && ··· 281 264 if (per_next_state != per_saved_state) 282 265 pwrdm_set_next_pwrst(per_pd, per_next_state); 283 266 284 - new_state = next_valid_state(dev, state); 267 + new_state_idx = next_valid_state(dev, drv, index); 285 268 286 269 select_state: 287 - dev->last_state = new_state; 288 - ret = omap3_enter_idle(dev, new_state); 270 + ret = omap3_enter_idle(dev, drv, new_state_idx); 289 271 290 272 /* Restore original PER state if it was modified */ 291 273 if (per_next_state != per_saved_state) ··· 317 301 .owner = THIS_MODULE, 318 302 }; 319 303 320 - /* Helper to fill the C-state common data and register the driver_data */ 321 - static inline struct omap3_idle_statedata *_fill_cstate( 322 - struct cpuidle_device *dev, 304 + /* Helper to fill the C-state common data*/ 305 + static inline void _fill_cstate(struct cpuidle_driver *drv, 323 306 int idx, const char *descr) 324 307 { 325 - struct omap3_idle_statedata *cx = &omap3_idle_data[idx]; 326 - struct cpuidle_state *state = &dev->states[idx]; 308 + struct cpuidle_state *state = &drv->states[idx]; 327 309 328 310 state->exit_latency = cpuidle_params_table[idx].exit_latency; 329 311 state->target_residency = cpuidle_params_table[idx].target_residency; 330 312 state->flags = CPUIDLE_FLAG_TIME_VALID; 331 313 state->enter = omap3_enter_idle_bm; 332 - cx->valid = cpuidle_params_table[idx].valid; 333 314 sprintf(state->name, "C%d", idx + 1); 334 315 strncpy(state->desc, descr, CPUIDLE_DESC_LEN); 335 - cpuidle_set_statedata(state, cx); 316 + 317 + } 318 + 319 + /* Helper to register the driver_data */ 320 + static inline struct omap3_idle_statedata *_fill_cstate_usage( 321 + struct cpuidle_device *dev, 322 + int idx) 323 + { 324 + struct omap3_idle_statedata *cx = &omap3_idle_data[idx]; 325 + struct cpuidle_state_usage *state_usage = &dev->states_usage[idx]; 326 + 327 + cx->valid = cpuidle_params_table[idx].valid; 328 + cpuidle_set_statedata(state_usage, cx); 336 329 337 330 return cx; 338 331 } ··· 355 330 int __init omap3_idle_init(void) 356 331 { 357 332 struct cpuidle_device *dev; 333 + struct cpuidle_driver *drv = &omap3_idle_driver; 358 334 struct omap3_idle_statedata *cx; 359 335 360 336 mpu_pd = pwrdm_lookup("mpu_pwrdm"); ··· 363 337 per_pd = pwrdm_lookup("per_pwrdm"); 364 338 cam_pd = pwrdm_lookup("cam_pwrdm"); 365 339 366 - cpuidle_register_driver(&omap3_idle_driver); 340 + 341 + drv->safe_state_index = -1; 367 342 dev = &per_cpu(omap3_idle_dev, smp_processor_id()); 368 343 369 344 /* C1 . MPU WFI + Core active */ 370 - cx = _fill_cstate(dev, 0, "MPU ON + CORE ON"); 371 - (&dev->states[0])->enter = omap3_enter_idle; 372 - dev->safe_state = &dev->states[0]; 345 + _fill_cstate(drv, 0, "MPU ON + CORE ON"); 346 + (&drv->states[0])->enter = omap3_enter_idle; 347 + drv->safe_state_index = 0; 348 + cx = _fill_cstate_usage(dev, 0); 373 349 cx->valid = 1; /* C1 is always valid */ 374 350 cx->mpu_state = PWRDM_POWER_ON; 375 351 cx->core_state = PWRDM_POWER_ON; 376 352 377 353 /* C2 . MPU WFI + Core inactive */ 378 - cx = _fill_cstate(dev, 1, "MPU ON + CORE ON"); 354 + _fill_cstate(drv, 1, "MPU ON + CORE ON"); 355 + cx = _fill_cstate_usage(dev, 1); 379 356 cx->mpu_state = PWRDM_POWER_ON; 380 357 cx->core_state = PWRDM_POWER_ON; 381 358 382 359 /* C3 . MPU CSWR + Core inactive */ 383 - cx = _fill_cstate(dev, 2, "MPU RET + CORE ON"); 360 + _fill_cstate(drv, 2, "MPU RET + CORE ON"); 361 + cx = _fill_cstate_usage(dev, 2); 384 362 cx->mpu_state = PWRDM_POWER_RET; 385 363 cx->core_state = PWRDM_POWER_ON; 386 364 387 365 /* C4 . MPU OFF + Core inactive */ 388 - cx = _fill_cstate(dev, 3, "MPU OFF + CORE ON"); 366 + _fill_cstate(drv, 3, "MPU OFF + CORE ON"); 367 + cx = _fill_cstate_usage(dev, 3); 389 368 cx->mpu_state = PWRDM_POWER_OFF; 390 369 cx->core_state = PWRDM_POWER_ON; 391 370 392 371 /* C5 . MPU RET + Core RET */ 393 - cx = _fill_cstate(dev, 4, "MPU RET + CORE RET"); 372 + _fill_cstate(drv, 4, "MPU RET + CORE RET"); 373 + cx = _fill_cstate_usage(dev, 4); 394 374 cx->mpu_state = PWRDM_POWER_RET; 395 375 cx->core_state = PWRDM_POWER_RET; 396 376 397 377 /* C6 . MPU OFF + Core RET */ 398 - cx = _fill_cstate(dev, 5, "MPU OFF + CORE RET"); 378 + _fill_cstate(drv, 5, "MPU OFF + CORE RET"); 379 + cx = _fill_cstate_usage(dev, 5); 399 380 cx->mpu_state = PWRDM_POWER_OFF; 400 381 cx->core_state = PWRDM_POWER_RET; 401 382 402 383 /* C7 . MPU OFF + Core OFF */ 403 - cx = _fill_cstate(dev, 6, "MPU OFF + CORE OFF"); 384 + _fill_cstate(drv, 6, "MPU OFF + CORE OFF"); 385 + cx = _fill_cstate_usage(dev, 6); 404 386 /* 405 387 * Erratum i583: implementation for ES rev < Es1.2 on 3630. We cannot 406 388 * enable OFF mode in a stable form for previous revisions. ··· 421 387 } 422 388 cx->mpu_state = PWRDM_POWER_OFF; 423 389 cx->core_state = PWRDM_POWER_OFF; 390 + 391 + drv->state_count = OMAP3_NUM_STATES; 392 + cpuidle_register_driver(&omap3_idle_driver); 424 393 425 394 dev->state_count = OMAP3_NUM_STATES; 426 395 if (cpuidle_register_device(dev)) {
+17 -11
arch/sh/kernel/cpu/shmobile/cpuidle.c
··· 26 26 }; 27 27 28 28 static int cpuidle_sleep_enter(struct cpuidle_device *dev, 29 - struct cpuidle_state *state) 29 + struct cpuidle_driver *drv, 30 + int index) 30 31 { 31 32 unsigned long allowed_mode = arch_hwblk_sleep_mode(); 32 33 ktime_t before, after; 33 - int requested_state = state - &dev->states[0]; 34 + int requested_state = index; 34 35 int allowed_state; 35 36 int k; 36 37 ··· 48 47 */ 49 48 k = min_t(int, allowed_state, requested_state); 50 49 51 - dev->last_state = &dev->states[k]; 52 50 before = ktime_get(); 53 51 sh_mobile_call_standby(cpuidle_mode[k]); 54 52 after = ktime_get(); 55 - return ktime_to_ns(ktime_sub(after, before)) >> 10; 53 + 54 + dev->last_residency = (int)ktime_to_ns(ktime_sub(after, before)) >> 10; 55 + 56 + return k; 56 57 } 57 58 58 59 static struct cpuidle_device cpuidle_dev; ··· 66 63 void sh_mobile_setup_cpuidle(void) 67 64 { 68 65 struct cpuidle_device *dev = &cpuidle_dev; 66 + struct cpuidle_driver *drv = &cpuidle_driver; 69 67 struct cpuidle_state *state; 70 68 int i; 71 69 72 - cpuidle_register_driver(&cpuidle_driver); 73 70 74 71 for (i = 0; i < CPUIDLE_STATE_MAX; i++) { 75 - dev->states[i].name[0] = '\0'; 76 - dev->states[i].desc[0] = '\0'; 72 + drv->states[i].name[0] = '\0'; 73 + drv->states[i].desc[0] = '\0'; 77 74 } 78 75 79 76 i = CPUIDLE_DRIVER_STATE_START; 80 77 81 - state = &dev->states[i++]; 78 + state = &drv->states[i++]; 82 79 snprintf(state->name, CPUIDLE_NAME_LEN, "C1"); 83 80 strncpy(state->desc, "SuperH Sleep Mode", CPUIDLE_DESC_LEN); 84 81 state->exit_latency = 1; ··· 88 85 state->flags |= CPUIDLE_FLAG_TIME_VALID; 89 86 state->enter = cpuidle_sleep_enter; 90 87 91 - dev->safe_state = state; 88 + drv->safe_state_index = i-1; 92 89 93 90 if (sh_mobile_sleep_supported & SUSP_SH_SF) { 94 - state = &dev->states[i++]; 91 + state = &drv->states[i++]; 95 92 snprintf(state->name, CPUIDLE_NAME_LEN, "C2"); 96 93 strncpy(state->desc, "SuperH Sleep Mode [SF]", 97 94 CPUIDLE_DESC_LEN); ··· 104 101 } 105 102 106 103 if (sh_mobile_sleep_supported & SUSP_SH_STANDBY) { 107 - state = &dev->states[i++]; 104 + state = &drv->states[i++]; 108 105 snprintf(state->name, CPUIDLE_NAME_LEN, "C3"); 109 106 strncpy(state->desc, "SuperH Mobile Standby Mode [SF]", 110 107 CPUIDLE_DESC_LEN); ··· 116 113 state->enter = cpuidle_sleep_enter; 117 114 } 118 115 116 + drv->state_count = i; 119 117 dev->state_count = i; 118 + 119 + cpuidle_register_driver(&cpuidle_driver); 120 120 121 121 cpuidle_register_device(dev); 122 122 }
+1 -1
arch/x86/platform/mrst/pmu.c
··· 70 70 /* 24 */ { 0x4110, 0 }, /* Lincroft */ 71 71 }; 72 72 73 - /* n.b. We ignore PCI-id 0x815 in LSS9 b/c MeeGo has no driver for it */ 73 + /* n.b. We ignore PCI-id 0x815 in LSS9 b/c Linux has no driver for it */ 74 74 static u16 mrst_lss9_pci_ids[] = {0x080a, 0x0814, 0}; 75 75 static u16 mrst_lss10_pci_ids[] = {0x0800, 0x0801, 0x0802, 0x0803, 76 76 0x0804, 0x0805, 0x080f, 0};
+6 -5
drivers/acpi/acpica/hwregs.c
··· 269 269 270 270 status = acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS, 271 271 ACPI_BITMASK_ALL_FIXED_STATUS); 272 - if (ACPI_FAILURE(status)) { 273 - goto unlock_and_exit; 274 - } 272 + 273 + acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags); 274 + 275 + if (ACPI_FAILURE(status)) 276 + goto exit; 275 277 276 278 /* Clear the GPE Bits in all GPE registers in all GPE blocks */ 277 279 278 280 status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block, NULL); 279 281 280 - unlock_and_exit: 281 - acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags); 282 + exit: 282 283 return_ACPI_STATUS(status); 283 284 } 284 285
+1 -1
drivers/acpi/atomicio.c
··· 76 76 { 77 77 struct acpi_iomap *map; 78 78 79 - map = __acpi_find_iomap(paddr, size); 79 + map = __acpi_find_iomap(paddr, size/8); 80 80 if (map) 81 81 return map->vaddr + (paddr - map->paddr); 82 82 else
+2 -6
drivers/acpi/bus.c
··· 911 911 } 912 912 #endif 913 913 914 - status = 915 - acpi_enable_subsystem(~ 916 - (ACPI_NO_HARDWARE_INIT | 917 - ACPI_NO_ACPI_ENABLE)); 914 + status = acpi_enable_subsystem(~ACPI_NO_ACPI_ENABLE); 918 915 if (ACPI_FAILURE(status)) { 919 916 printk(KERN_ERR PREFIX "Unable to enable ACPI\n"); 920 917 goto error0; ··· 932 935 933 936 acpi_os_initialize1(); 934 937 935 - status = 936 - acpi_enable_subsystem(ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE); 938 + status = acpi_enable_subsystem(ACPI_NO_ACPI_ENABLE); 937 939 if (ACPI_FAILURE(status)) { 938 940 printk(KERN_ERR PREFIX 939 941 "Unable to start the ACPI Interpreter\n");
+3 -17
drivers/acpi/processor_driver.c
··· 426 426 427 427 if (action == CPU_ONLINE && pr) { 428 428 acpi_processor_ppc_has_changed(pr, 0); 429 - acpi_processor_cst_has_changed(pr); 429 + acpi_processor_hotplug(pr); 430 430 acpi_processor_reevaluate_tstate(pr, action); 431 431 acpi_processor_tstate_has_changed(pr); 432 432 } ··· 503 503 acpi_processor_get_throttling_info(pr); 504 504 acpi_processor_get_limit_info(pr); 505 505 506 - 507 - if (cpuidle_get_driver() == &acpi_idle_driver) 506 + if (!cpuidle_get_driver() || cpuidle_get_driver() == &acpi_idle_driver) 508 507 acpi_processor_power_init(pr, device); 509 508 510 509 pr->cdev = thermal_cooling_device_register("Processor", device, ··· 799 800 800 801 memset(&errata, 0, sizeof(errata)); 801 802 802 - if (!cpuidle_register_driver(&acpi_idle_driver)) { 803 - printk(KERN_DEBUG "ACPI: %s registered with cpuidle\n", 804 - acpi_idle_driver.name); 805 - } else { 806 - printk(KERN_DEBUG "ACPI: acpi_idle yielding to %s\n", 807 - cpuidle_get_driver()->name); 808 - } 809 - 810 803 result = acpi_bus_register_driver(&acpi_processor_driver); 811 804 if (result < 0) 812 - goto out_cpuidle; 805 + return result; 813 806 814 807 acpi_processor_install_hotplug_notify(); 815 808 ··· 812 821 acpi_processor_throttling_init(); 813 822 814 823 return 0; 815 - 816 - out_cpuidle: 817 - cpuidle_unregister_driver(&acpi_idle_driver); 818 - 819 - return result; 820 824 } 821 825 822 826 static void __exit acpi_processor_exit(void)
+209 -46
drivers/acpi/processor_idle.c
··· 741 741 /** 742 742 * acpi_idle_enter_c1 - enters an ACPI C1 state-type 743 743 * @dev: the target CPU 744 - * @state: the state data 744 + * @drv: cpuidle driver containing cpuidle state info 745 + * @index: index of target state 745 746 * 746 747 * This is equivalent to the HALT instruction. 747 748 */ 748 749 static int acpi_idle_enter_c1(struct cpuidle_device *dev, 749 - struct cpuidle_state *state) 750 + struct cpuidle_driver *drv, int index) 750 751 { 751 752 ktime_t kt1, kt2; 752 753 s64 idle_time; 753 754 struct acpi_processor *pr; 754 - struct acpi_processor_cx *cx = cpuidle_get_statedata(state); 755 + struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; 756 + struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage); 755 757 756 758 pr = __this_cpu_read(processors); 759 + dev->last_residency = 0; 757 760 758 761 if (unlikely(!pr)) 759 - return 0; 762 + return -EINVAL; 760 763 761 764 local_irq_disable(); 762 765 ··· 767 764 if (acpi_idle_suspend) { 768 765 local_irq_enable(); 769 766 cpu_relax(); 770 - return 0; 767 + return -EINVAL; 771 768 } 772 769 773 770 lapic_timer_state_broadcast(pr, cx, 1); ··· 776 773 kt2 = ktime_get_real(); 777 774 idle_time = ktime_to_us(ktime_sub(kt2, kt1)); 778 775 776 + /* Update device last_residency*/ 777 + dev->last_residency = (int)idle_time; 778 + 779 779 local_irq_enable(); 780 780 cx->usage++; 781 781 lapic_timer_state_broadcast(pr, cx, 0); 782 782 783 - return idle_time; 783 + return index; 784 784 } 785 785 786 786 /** 787 787 * acpi_idle_enter_simple - enters an ACPI state without BM handling 788 788 * @dev: the target CPU 789 - * @state: the state data 789 + * @drv: cpuidle driver with cpuidle state information 790 + * @index: the index of suggested state 790 791 */ 791 792 static int acpi_idle_enter_simple(struct cpuidle_device *dev, 792 - struct cpuidle_state *state) 793 + struct cpuidle_driver *drv, int index) 793 794 { 794 795 struct acpi_processor *pr; 795 - struct acpi_processor_cx *cx = cpuidle_get_statedata(state); 796 + struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; 797 + struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage); 796 798 ktime_t kt1, kt2; 797 799 s64 idle_time_ns; 798 800 s64 idle_time; 799 801 800 802 pr = __this_cpu_read(processors); 803 + dev->last_residency = 0; 801 804 802 805 if (unlikely(!pr)) 803 - return 0; 804 - 805 - if (acpi_idle_suspend) 806 - return(acpi_idle_enter_c1(dev, state)); 806 + return -EINVAL; 807 807 808 808 local_irq_disable(); 809 + 810 + if (acpi_idle_suspend) { 811 + local_irq_enable(); 812 + cpu_relax(); 813 + return -EINVAL; 814 + } 815 + 809 816 810 817 if (cx->entry_method != ACPI_CSTATE_FFH) { 811 818 current_thread_info()->status &= ~TS_POLLING; ··· 828 815 if (unlikely(need_resched())) { 829 816 current_thread_info()->status |= TS_POLLING; 830 817 local_irq_enable(); 831 - return 0; 818 + return -EINVAL; 832 819 } 833 820 } 834 821 ··· 850 837 idle_time = idle_time_ns; 851 838 do_div(idle_time, NSEC_PER_USEC); 852 839 840 + /* Update device last_residency*/ 841 + dev->last_residency = (int)idle_time; 842 + 853 843 /* Tell the scheduler how much we idled: */ 854 844 sched_clock_idle_wakeup_event(idle_time_ns); 855 845 ··· 864 848 865 849 lapic_timer_state_broadcast(pr, cx, 0); 866 850 cx->time += idle_time; 867 - return idle_time; 851 + return index; 868 852 } 869 853 870 854 static int c3_cpu_count; ··· 873 857 /** 874 858 * acpi_idle_enter_bm - enters C3 with proper BM handling 875 859 * @dev: the target CPU 876 - * @state: the state data 860 + * @drv: cpuidle driver containing state data 861 + * @index: the index of suggested state 877 862 * 878 863 * If BM is detected, the deepest non-C3 idle state is entered instead. 879 864 */ 880 865 static int acpi_idle_enter_bm(struct cpuidle_device *dev, 881 - struct cpuidle_state *state) 866 + struct cpuidle_driver *drv, int index) 882 867 { 883 868 struct acpi_processor *pr; 884 - struct acpi_processor_cx *cx = cpuidle_get_statedata(state); 869 + struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; 870 + struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage); 885 871 ktime_t kt1, kt2; 886 872 s64 idle_time_ns; 887 873 s64 idle_time; 888 874 889 875 890 876 pr = __this_cpu_read(processors); 877 + dev->last_residency = 0; 891 878 892 879 if (unlikely(!pr)) 893 - return 0; 880 + return -EINVAL; 894 881 895 - if (acpi_idle_suspend) 896 - return(acpi_idle_enter_c1(dev, state)); 882 + 883 + if (acpi_idle_suspend) { 884 + cpu_relax(); 885 + return -EINVAL; 886 + } 897 887 898 888 if (!cx->bm_sts_skip && acpi_idle_bm_check()) { 899 - if (dev->safe_state) { 900 - dev->last_state = dev->safe_state; 901 - return dev->safe_state->enter(dev, dev->safe_state); 889 + if (drv->safe_state_index >= 0) { 890 + return drv->states[drv->safe_state_index].enter(dev, 891 + drv, drv->safe_state_index); 902 892 } else { 903 893 local_irq_disable(); 904 894 acpi_safe_halt(); 905 895 local_irq_enable(); 906 - return 0; 896 + return -EINVAL; 907 897 } 908 898 } 909 899 ··· 926 904 if (unlikely(need_resched())) { 927 905 current_thread_info()->status |= TS_POLLING; 928 906 local_irq_enable(); 929 - return 0; 907 + return -EINVAL; 930 908 } 931 909 } 932 910 ··· 976 954 idle_time = idle_time_ns; 977 955 do_div(idle_time, NSEC_PER_USEC); 978 956 957 + /* Update device last_residency*/ 958 + dev->last_residency = (int)idle_time; 959 + 979 960 /* Tell the scheduler how much we idled: */ 980 961 sched_clock_idle_wakeup_event(idle_time_ns); 981 962 ··· 990 965 991 966 lapic_timer_state_broadcast(pr, cx, 0); 992 967 cx->time += idle_time; 993 - return idle_time; 968 + return index; 994 969 } 995 970 996 971 struct cpuidle_driver acpi_idle_driver = { ··· 999 974 }; 1000 975 1001 976 /** 1002 - * acpi_processor_setup_cpuidle - prepares and configures CPUIDLE 977 + * acpi_processor_setup_cpuidle_cx - prepares and configures CPUIDLE 978 + * device i.e. per-cpu data 979 + * 1003 980 * @pr: the ACPI processor 1004 981 */ 1005 - static int acpi_processor_setup_cpuidle(struct acpi_processor *pr) 982 + static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr) 1006 983 { 1007 984 int i, count = CPUIDLE_DRIVER_STATE_START; 1008 985 struct acpi_processor_cx *cx; 1009 - struct cpuidle_state *state; 986 + struct cpuidle_state_usage *state_usage; 1010 987 struct cpuidle_device *dev = &pr->power.dev; 1011 988 1012 989 if (!pr->flags.power_setup_done) ··· 1019 992 } 1020 993 1021 994 dev->cpu = pr->id; 1022 - for (i = 0; i < CPUIDLE_STATE_MAX; i++) { 1023 - dev->states[i].name[0] = '\0'; 1024 - dev->states[i].desc[0] = '\0'; 1025 - } 1026 995 1027 996 if (max_cstate == 0) 1028 997 max_cstate = 1; 1029 998 1030 999 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) { 1031 1000 cx = &pr->power.states[i]; 1032 - state = &dev->states[count]; 1001 + state_usage = &dev->states_usage[count]; 1033 1002 1034 1003 if (!cx->valid) 1035 1004 continue; ··· 1036 1013 !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED)) 1037 1014 continue; 1038 1015 #endif 1039 - cpuidle_set_statedata(state, cx); 1040 1016 1017 + cpuidle_set_statedata(state_usage, cx); 1018 + 1019 + count++; 1020 + if (count == CPUIDLE_STATE_MAX) 1021 + break; 1022 + } 1023 + 1024 + dev->state_count = count; 1025 + 1026 + if (!count) 1027 + return -EINVAL; 1028 + 1029 + return 0; 1030 + } 1031 + 1032 + /** 1033 + * acpi_processor_setup_cpuidle states- prepares and configures cpuidle 1034 + * global state data i.e. idle routines 1035 + * 1036 + * @pr: the ACPI processor 1037 + */ 1038 + static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr) 1039 + { 1040 + int i, count = CPUIDLE_DRIVER_STATE_START; 1041 + struct acpi_processor_cx *cx; 1042 + struct cpuidle_state *state; 1043 + struct cpuidle_driver *drv = &acpi_idle_driver; 1044 + 1045 + if (!pr->flags.power_setup_done) 1046 + return -EINVAL; 1047 + 1048 + if (pr->flags.power == 0) 1049 + return -EINVAL; 1050 + 1051 + drv->safe_state_index = -1; 1052 + for (i = 0; i < CPUIDLE_STATE_MAX; i++) { 1053 + drv->states[i].name[0] = '\0'; 1054 + drv->states[i].desc[0] = '\0'; 1055 + } 1056 + 1057 + if (max_cstate == 0) 1058 + max_cstate = 1; 1059 + 1060 + for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) { 1061 + cx = &pr->power.states[i]; 1062 + 1063 + if (!cx->valid) 1064 + continue; 1065 + 1066 + #ifdef CONFIG_HOTPLUG_CPU 1067 + if ((cx->type != ACPI_STATE_C1) && (num_online_cpus() > 1) && 1068 + !pr->flags.has_cst && 1069 + !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED)) 1070 + continue; 1071 + #endif 1072 + 1073 + state = &drv->states[count]; 1041 1074 snprintf(state->name, CPUIDLE_NAME_LEN, "C%d", i); 1042 1075 strncpy(state->desc, cx->desc, CPUIDLE_DESC_LEN); 1043 1076 state->exit_latency = cx->latency; ··· 1106 1027 state->flags |= CPUIDLE_FLAG_TIME_VALID; 1107 1028 1108 1029 state->enter = acpi_idle_enter_c1; 1109 - dev->safe_state = state; 1030 + drv->safe_state_index = count; 1110 1031 break; 1111 1032 1112 1033 case ACPI_STATE_C2: 1113 1034 state->flags |= CPUIDLE_FLAG_TIME_VALID; 1114 1035 state->enter = acpi_idle_enter_simple; 1115 - dev->safe_state = state; 1036 + drv->safe_state_index = count; 1116 1037 break; 1117 1038 1118 1039 case ACPI_STATE_C3: ··· 1128 1049 break; 1129 1050 } 1130 1051 1131 - dev->state_count = count; 1052 + drv->state_count = count; 1132 1053 1133 1054 if (!count) 1134 1055 return -EINVAL; ··· 1136 1057 return 0; 1137 1058 } 1138 1059 1139 - int acpi_processor_cst_has_changed(struct acpi_processor *pr) 1060 + int acpi_processor_hotplug(struct acpi_processor *pr) 1140 1061 { 1141 1062 int ret = 0; 1142 1063 ··· 1157 1078 cpuidle_disable_device(&pr->power.dev); 1158 1079 acpi_processor_get_power_info(pr); 1159 1080 if (pr->flags.power) { 1160 - acpi_processor_setup_cpuidle(pr); 1081 + acpi_processor_setup_cpuidle_cx(pr); 1161 1082 ret = cpuidle_enable_device(&pr->power.dev); 1162 1083 } 1163 1084 cpuidle_resume_and_unlock(); ··· 1165 1086 return ret; 1166 1087 } 1167 1088 1089 + int acpi_processor_cst_has_changed(struct acpi_processor *pr) 1090 + { 1091 + int cpu; 1092 + struct acpi_processor *_pr; 1093 + 1094 + if (disabled_by_idle_boot_param()) 1095 + return 0; 1096 + 1097 + if (!pr) 1098 + return -EINVAL; 1099 + 1100 + if (nocst) 1101 + return -ENODEV; 1102 + 1103 + if (!pr->flags.power_setup_done) 1104 + return -ENODEV; 1105 + 1106 + /* 1107 + * FIXME: Design the ACPI notification to make it once per 1108 + * system instead of once per-cpu. This condition is a hack 1109 + * to make the code that updates C-States be called once. 1110 + */ 1111 + 1112 + if (smp_processor_id() == 0 && 1113 + cpuidle_get_driver() == &acpi_idle_driver) { 1114 + 1115 + cpuidle_pause_and_lock(); 1116 + /* Protect against cpu-hotplug */ 1117 + get_online_cpus(); 1118 + 1119 + /* Disable all cpuidle devices */ 1120 + for_each_online_cpu(cpu) { 1121 + _pr = per_cpu(processors, cpu); 1122 + if (!_pr || !_pr->flags.power_setup_done) 1123 + continue; 1124 + cpuidle_disable_device(&_pr->power.dev); 1125 + } 1126 + 1127 + /* Populate Updated C-state information */ 1128 + acpi_processor_setup_cpuidle_states(pr); 1129 + 1130 + /* Enable all cpuidle devices */ 1131 + for_each_online_cpu(cpu) { 1132 + _pr = per_cpu(processors, cpu); 1133 + if (!_pr || !_pr->flags.power_setup_done) 1134 + continue; 1135 + acpi_processor_get_power_info(_pr); 1136 + if (_pr->flags.power) { 1137 + acpi_processor_setup_cpuidle_cx(_pr); 1138 + cpuidle_enable_device(&_pr->power.dev); 1139 + } 1140 + } 1141 + put_online_cpus(); 1142 + cpuidle_resume_and_unlock(); 1143 + } 1144 + 1145 + return 0; 1146 + } 1147 + 1148 + static int acpi_processor_registered; 1149 + 1168 1150 int __cpuinit acpi_processor_power_init(struct acpi_processor *pr, 1169 1151 struct acpi_device *device) 1170 1152 { 1171 1153 acpi_status status = 0; 1154 + int retval; 1172 1155 static int first_run; 1173 1156 1174 1157 if (disabled_by_idle_boot_param()) ··· 1267 1126 * platforms that only support C1. 1268 1127 */ 1269 1128 if (pr->flags.power) { 1270 - acpi_processor_setup_cpuidle(pr); 1271 - if (cpuidle_register_device(&pr->power.dev)) 1272 - return -EIO; 1129 + /* Register acpi_idle_driver if not already registered */ 1130 + if (!acpi_processor_registered) { 1131 + acpi_processor_setup_cpuidle_states(pr); 1132 + retval = cpuidle_register_driver(&acpi_idle_driver); 1133 + if (retval) 1134 + return retval; 1135 + printk(KERN_DEBUG "ACPI: %s registered with cpuidle\n", 1136 + acpi_idle_driver.name); 1137 + } 1138 + /* Register per-cpu cpuidle_device. Cpuidle driver 1139 + * must already be registered before registering device 1140 + */ 1141 + acpi_processor_setup_cpuidle_cx(pr); 1142 + retval = cpuidle_register_device(&pr->power.dev); 1143 + if (retval) { 1144 + if (acpi_processor_registered == 0) 1145 + cpuidle_unregister_driver(&acpi_idle_driver); 1146 + return retval; 1147 + } 1148 + acpi_processor_registered++; 1273 1149 } 1274 1150 return 0; 1275 1151 } ··· 1297 1139 if (disabled_by_idle_boot_param()) 1298 1140 return 0; 1299 1141 1300 - cpuidle_unregister_device(&pr->power.dev); 1301 - pr->flags.power_setup_done = 0; 1142 + if (pr->flags.power) { 1143 + cpuidle_unregister_device(&pr->power.dev); 1144 + acpi_processor_registered--; 1145 + if (acpi_processor_registered == 0) 1146 + cpuidle_unregister_driver(&acpi_idle_driver); 1147 + } 1302 1148 1149 + pr->flags.power_setup_done = 0; 1303 1150 return 0; 1304 1151 }
+1 -2
drivers/acpi/scan.c
··· 1062 1062 if (!id) 1063 1063 return; 1064 1064 1065 - id->id = kmalloc(strlen(dev_id) + 1, GFP_KERNEL); 1065 + id->id = kstrdup(dev_id, GFP_KERNEL); 1066 1066 if (!id->id) { 1067 1067 kfree(id); 1068 1068 return; 1069 1069 } 1070 1070 1071 - strcpy(id->id, dev_id); 1072 1071 list_add_tail(&id->list, &device->pnp.ids); 1073 1072 } 1074 1073
+13 -1
drivers/acpi/sysfs.c
··· 706 706 return; 707 707 } 708 708 709 + static ssize_t 710 + acpi_show_profile(struct device *dev, struct device_attribute *attr, 711 + char *buf) 712 + { 713 + return sprintf(buf, "%d\n", acpi_gbl_FADT.preferred_profile); 714 + } 715 + 716 + static const struct device_attribute pm_profile_attr = 717 + __ATTR(pm_profile, S_IRUGO, acpi_show_profile, NULL); 718 + 709 719 int __init acpi_sysfs_init(void) 710 720 { 711 721 int result; 712 722 713 723 result = acpi_tables_sysfs_init(); 714 - 724 + if (result) 725 + return result; 726 + result = sysfs_create_file(acpi_kobj, &pm_profile_attr.attr); 715 727 return result; 716 728 }
+28 -58
drivers/cpuidle/cpuidle.c
··· 62 62 int cpuidle_idle_call(void) 63 63 { 64 64 struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices); 65 + struct cpuidle_driver *drv = cpuidle_get_driver(); 65 66 struct cpuidle_state *target_state; 66 - int next_state; 67 + int next_state, entered_state; 67 68 68 69 if (off) 69 70 return -ENODEV; ··· 85 84 hrtimer_peek_ahead_timers(); 86 85 #endif 87 86 88 - /* 89 - * Call the device's prepare function before calling the 90 - * governor's select function. ->prepare gives the device's 91 - * cpuidle driver a chance to update any dynamic information 92 - * of its cpuidle states for the current idle period, e.g. 93 - * state availability, latencies, residencies, etc. 94 - */ 95 - if (dev->prepare) 96 - dev->prepare(dev); 97 - 98 87 /* ask the governor for the next state */ 99 - next_state = cpuidle_curr_governor->select(dev); 88 + next_state = cpuidle_curr_governor->select(drv, dev); 100 89 if (need_resched()) { 101 90 local_irq_enable(); 102 91 return 0; 103 92 } 104 93 105 - target_state = &dev->states[next_state]; 106 - 107 - /* enter the state and update stats */ 108 - dev->last_state = target_state; 94 + target_state = &drv->states[next_state]; 109 95 110 96 trace_power_start(POWER_CSTATE, next_state, dev->cpu); 111 97 trace_cpu_idle(next_state, dev->cpu); 112 98 113 - dev->last_residency = target_state->enter(dev, target_state); 99 + entered_state = target_state->enter(dev, drv, next_state); 114 100 115 101 trace_power_end(dev->cpu); 116 102 trace_cpu_idle(PWR_EVENT_EXIT, dev->cpu); 117 103 118 - if (dev->last_state) 119 - target_state = dev->last_state; 120 - 121 - target_state->time += (unsigned long long)dev->last_residency; 122 - target_state->usage++; 104 + if (entered_state >= 0) { 105 + /* Update cpuidle counters */ 106 + /* This can be moved to within driver enter routine 107 + * but that results in multiple copies of same code. 108 + */ 109 + dev->states_usage[entered_state].time += 110 + (unsigned long long)dev->last_residency; 111 + dev->states_usage[entered_state].usage++; 112 + } 123 113 124 114 /* give the governor an opportunity to reflect on the outcome */ 125 115 if (cpuidle_curr_governor->reflect) 126 - cpuidle_curr_governor->reflect(dev); 116 + cpuidle_curr_governor->reflect(dev, entered_state); 127 117 128 118 return 0; 129 119 } ··· 165 173 EXPORT_SYMBOL_GPL(cpuidle_resume_and_unlock); 166 174 167 175 #ifdef CONFIG_ARCH_HAS_CPU_RELAX 168 - static int poll_idle(struct cpuidle_device *dev, struct cpuidle_state *st) 176 + static int poll_idle(struct cpuidle_device *dev, 177 + struct cpuidle_driver *drv, int index) 169 178 { 170 179 ktime_t t1, t2; 171 180 s64 diff; 172 - int ret; 173 181 174 182 t1 = ktime_get(); 175 183 local_irq_enable(); ··· 181 189 if (diff > INT_MAX) 182 190 diff = INT_MAX; 183 191 184 - ret = (int) diff; 185 - return ret; 192 + dev->last_residency = (int) diff; 193 + 194 + return index; 186 195 } 187 196 188 - static void poll_idle_init(struct cpuidle_device *dev) 197 + static void poll_idle_init(struct cpuidle_driver *drv) 189 198 { 190 - struct cpuidle_state *state = &dev->states[0]; 191 - 192 - cpuidle_set_statedata(state, NULL); 199 + struct cpuidle_state *state = &drv->states[0]; 193 200 194 201 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL"); 195 202 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE"); ··· 199 208 state->enter = poll_idle; 200 209 } 201 210 #else 202 - static void poll_idle_init(struct cpuidle_device *dev) {} 211 + static void poll_idle_init(struct cpuidle_driver *drv) {} 203 212 #endif /* CONFIG_ARCH_HAS_CPU_RELAX */ 204 213 205 214 /** ··· 226 235 return ret; 227 236 } 228 237 229 - poll_idle_init(dev); 238 + poll_idle_init(cpuidle_get_driver()); 230 239 231 240 if ((ret = cpuidle_add_state_sysfs(dev))) 232 241 return ret; 233 242 234 243 if (cpuidle_curr_governor->enable && 235 - (ret = cpuidle_curr_governor->enable(dev))) 244 + (ret = cpuidle_curr_governor->enable(cpuidle_get_driver(), dev))) 236 245 goto fail_sysfs; 237 246 238 247 for (i = 0; i < dev->state_count; i++) { 239 - dev->states[i].usage = 0; 240 - dev->states[i].time = 0; 248 + dev->states_usage[i].usage = 0; 249 + dev->states_usage[i].time = 0; 241 250 } 242 251 dev->last_residency = 0; 243 - dev->last_state = NULL; 244 252 245 253 smp_wmb(); 246 254 ··· 273 283 dev->enabled = 0; 274 284 275 285 if (cpuidle_curr_governor->disable) 276 - cpuidle_curr_governor->disable(dev); 286 + cpuidle_curr_governor->disable(cpuidle_get_driver(), dev); 277 287 278 288 cpuidle_remove_state_sysfs(dev); 279 289 enabled_devices--; ··· 300 310 return -EINVAL; 301 311 302 312 init_completion(&dev->kobj_unregister); 303 - 304 - /* 305 - * cpuidle driver should set the dev->power_specified bit 306 - * before registering the device if the driver provides 307 - * power_usage numbers. 308 - * 309 - * For those devices whose ->power_specified is not set, 310 - * we fill in power_usage with decreasing values as the 311 - * cpuidle code has an implicit assumption that state Cn 312 - * uses less power than C(n-1). 313 - * 314 - * With CONFIG_ARCH_HAS_CPU_RELAX, C0 is already assigned 315 - * an power value of -1. So we use -2, -3, etc, for other 316 - * c-states. 317 - */ 318 - if (!dev->power_specified) { 319 - int i; 320 - for (i = CPUIDLE_DRIVER_STATE_START; i < dev->state_count; i++) 321 - dev->states[i].power_usage = -1 - i; 322 - } 323 313 324 314 per_cpu(cpuidle_devices, dev->cpu) = dev; 325 315 list_add(&dev->device_list, &cpuidle_detected_devices);
+25
drivers/cpuidle/driver.c
··· 17 17 static struct cpuidle_driver *cpuidle_curr_driver; 18 18 DEFINE_SPINLOCK(cpuidle_driver_lock); 19 19 20 + static void __cpuidle_register_driver(struct cpuidle_driver *drv) 21 + { 22 + int i; 23 + /* 24 + * cpuidle driver should set the drv->power_specified bit 25 + * before registering if the driver provides 26 + * power_usage numbers. 27 + * 28 + * If power_specified is not set, 29 + * we fill in power_usage with decreasing values as the 30 + * cpuidle code has an implicit assumption that state Cn 31 + * uses less power than C(n-1). 32 + * 33 + * With CONFIG_ARCH_HAS_CPU_RELAX, C0 is already assigned 34 + * an power value of -1. So we use -2, -3, etc, for other 35 + * c-states. 36 + */ 37 + if (!drv->power_specified) { 38 + for (i = CPUIDLE_DRIVER_STATE_START; i < drv->state_count; i++) 39 + drv->states[i].power_usage = -1 - i; 40 + } 41 + } 42 + 43 + 20 44 /** 21 45 * cpuidle_register_driver - registers a driver 22 46 * @drv: the driver ··· 58 34 spin_unlock(&cpuidle_driver_lock); 59 35 return -EBUSY; 60 36 } 37 + __cpuidle_register_driver(drv); 61 38 cpuidle_curr_driver = drv; 62 39 spin_unlock(&cpuidle_driver_lock); 63 40
+30 -11
drivers/cpuidle/governors/ladder.c
··· 60 60 61 61 /** 62 62 * ladder_select_state - selects the next state to enter 63 + * @drv: cpuidle driver 63 64 * @dev: the CPU 64 65 */ 65 - static int ladder_select_state(struct cpuidle_device *dev) 66 + static int ladder_select_state(struct cpuidle_driver *drv, 67 + struct cpuidle_device *dev) 66 68 { 67 69 struct ladder_device *ldev = &__get_cpu_var(ladder_devices); 68 70 struct ladder_device_state *last_state; ··· 79 77 80 78 last_state = &ldev->states[last_idx]; 81 79 82 - if (dev->states[last_idx].flags & CPUIDLE_FLAG_TIME_VALID) 83 - last_residency = cpuidle_get_last_residency(dev) - dev->states[last_idx].exit_latency; 80 + if (drv->states[last_idx].flags & CPUIDLE_FLAG_TIME_VALID) { 81 + last_residency = cpuidle_get_last_residency(dev) - \ 82 + drv->states[last_idx].exit_latency; 83 + } 84 84 else 85 85 last_residency = last_state->threshold.promotion_time + 1; 86 86 87 87 /* consider promotion */ 88 - if (last_idx < dev->state_count - 1 && 88 + if (last_idx < drv->state_count - 1 && 89 89 last_residency > last_state->threshold.promotion_time && 90 - dev->states[last_idx + 1].exit_latency <= latency_req) { 90 + drv->states[last_idx + 1].exit_latency <= latency_req) { 91 91 last_state->stats.promotion_count++; 92 92 last_state->stats.demotion_count = 0; 93 93 if (last_state->stats.promotion_count >= last_state->threshold.promotion_count) { ··· 100 96 101 97 /* consider demotion */ 102 98 if (last_idx > CPUIDLE_DRIVER_STATE_START && 103 - dev->states[last_idx].exit_latency > latency_req) { 99 + drv->states[last_idx].exit_latency > latency_req) { 104 100 int i; 105 101 106 102 for (i = last_idx - 1; i > CPUIDLE_DRIVER_STATE_START; i--) { 107 - if (dev->states[i].exit_latency <= latency_req) 103 + if (drv->states[i].exit_latency <= latency_req) 108 104 break; 109 105 } 110 106 ladder_do_selection(ldev, last_idx, i); ··· 127 123 128 124 /** 129 125 * ladder_enable_device - setup for the governor 126 + * @drv: cpuidle driver 130 127 * @dev: the CPU 131 128 */ 132 - static int ladder_enable_device(struct cpuidle_device *dev) 129 + static int ladder_enable_device(struct cpuidle_driver *drv, 130 + struct cpuidle_device *dev) 133 131 { 134 132 int i; 135 133 struct ladder_device *ldev = &per_cpu(ladder_devices, dev->cpu); ··· 140 134 141 135 ldev->last_state_idx = CPUIDLE_DRIVER_STATE_START; 142 136 143 - for (i = 0; i < dev->state_count; i++) { 144 - state = &dev->states[i]; 137 + for (i = 0; i < drv->state_count; i++) { 138 + state = &drv->states[i]; 145 139 lstate = &ldev->states[i]; 146 140 147 141 lstate->stats.promotion_count = 0; ··· 150 144 lstate->threshold.promotion_count = PROMOTION_COUNT; 151 145 lstate->threshold.demotion_count = DEMOTION_COUNT; 152 146 153 - if (i < dev->state_count - 1) 147 + if (i < drv->state_count - 1) 154 148 lstate->threshold.promotion_time = state->exit_latency; 155 149 if (i > 0) 156 150 lstate->threshold.demotion_time = state->exit_latency; ··· 159 153 return 0; 160 154 } 161 155 156 + /** 157 + * ladder_reflect - update the correct last_state_idx 158 + * @dev: the CPU 159 + * @index: the index of actual state entered 160 + */ 161 + static void ladder_reflect(struct cpuidle_device *dev, int index) 162 + { 163 + struct ladder_device *ldev = &__get_cpu_var(ladder_devices); 164 + if (index > 0) 165 + ldev->last_state_idx = index; 166 + } 167 + 162 168 static struct cpuidle_governor ladder_governor = { 163 169 .name = "ladder", 164 170 .rating = 10, 165 171 .enable = ladder_enable_device, 166 172 .select = ladder_select_state, 173 + .reflect = ladder_reflect, 167 174 .owner = THIS_MODULE, 168 175 }; 169 176
+17 -12
drivers/cpuidle/governors/menu.c
··· 183 183 184 184 static DEFINE_PER_CPU(struct menu_device, menu_devices); 185 185 186 - static void menu_update(struct cpuidle_device *dev); 186 + static void menu_update(struct cpuidle_driver *drv, struct cpuidle_device *dev); 187 187 188 188 /* This implements DIV_ROUND_CLOSEST but avoids 64 bit division */ 189 189 static u64 div_round64(u64 dividend, u32 divisor) ··· 229 229 230 230 /** 231 231 * menu_select - selects the next idle state to enter 232 + * @drv: cpuidle driver containing state data 232 233 * @dev: the CPU 233 234 */ 234 - static int menu_select(struct cpuidle_device *dev) 235 + static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev) 235 236 { 236 237 struct menu_device *data = &__get_cpu_var(menu_devices); 237 238 int latency_req = pm_qos_request(PM_QOS_CPU_DMA_LATENCY); ··· 242 241 struct timespec t; 243 242 244 243 if (data->needs_update) { 245 - menu_update(dev); 244 + menu_update(drv, dev); 246 245 data->needs_update = 0; 247 246 } 248 247 ··· 287 286 * Find the idle state with the lowest power while satisfying 288 287 * our constraints. 289 288 */ 290 - for (i = CPUIDLE_DRIVER_STATE_START; i < dev->state_count; i++) { 291 - struct cpuidle_state *s = &dev->states[i]; 289 + for (i = CPUIDLE_DRIVER_STATE_START; i < drv->state_count; i++) { 290 + struct cpuidle_state *s = &drv->states[i]; 292 291 293 - if (s->flags & CPUIDLE_FLAG_IGNORE) 294 - continue; 295 292 if (s->target_residency > data->predicted_us) 296 293 continue; 297 294 if (s->exit_latency > latency_req) ··· 310 311 /** 311 312 * menu_reflect - records that data structures need update 312 313 * @dev: the CPU 314 + * @index: the index of actual entered state 313 315 * 314 316 * NOTE: it's important to be fast here because this operation will add to 315 317 * the overall exit latency. 316 318 */ 317 - static void menu_reflect(struct cpuidle_device *dev) 319 + static void menu_reflect(struct cpuidle_device *dev, int index) 318 320 { 319 321 struct menu_device *data = &__get_cpu_var(menu_devices); 320 - data->needs_update = 1; 322 + data->last_state_idx = index; 323 + if (index >= 0) 324 + data->needs_update = 1; 321 325 } 322 326 323 327 /** 324 328 * menu_update - attempts to guess what happened after entry 329 + * @drv: cpuidle driver containing state data 325 330 * @dev: the CPU 326 331 */ 327 - static void menu_update(struct cpuidle_device *dev) 332 + static void menu_update(struct cpuidle_driver *drv, struct cpuidle_device *dev) 328 333 { 329 334 struct menu_device *data = &__get_cpu_var(menu_devices); 330 335 int last_idx = data->last_state_idx; 331 336 unsigned int last_idle_us = cpuidle_get_last_residency(dev); 332 - struct cpuidle_state *target = &dev->states[last_idx]; 337 + struct cpuidle_state *target = &drv->states[last_idx]; 333 338 unsigned int measured_us; 334 339 u64 new_factor; 335 340 ··· 387 384 388 385 /** 389 386 * menu_enable_device - scans a CPU's states and does setup 387 + * @drv: cpuidle driver 390 388 * @dev: the CPU 391 389 */ 392 - static int menu_enable_device(struct cpuidle_device *dev) 390 + static int menu_enable_device(struct cpuidle_driver *drv, 391 + struct cpuidle_device *dev) 393 392 { 394 393 struct menu_device *data = &per_cpu(menu_devices, dev->cpu); 395 394
+15 -7
drivers/cpuidle/sysfs.c
··· 216 216 217 217 struct cpuidle_state_attr { 218 218 struct attribute attr; 219 - ssize_t (*show)(struct cpuidle_state *, char *); 219 + ssize_t (*show)(struct cpuidle_state *, \ 220 + struct cpuidle_state_usage *, char *); 220 221 ssize_t (*store)(struct cpuidle_state *, const char *, size_t); 221 222 }; 222 223 ··· 225 224 static struct cpuidle_state_attr attr_##_name = __ATTR(_name, 0444, show, NULL) 226 225 227 226 #define define_show_state_function(_name) \ 228 - static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ 227 + static ssize_t show_state_##_name(struct cpuidle_state *state, \ 228 + struct cpuidle_state_usage *state_usage, char *buf) \ 229 229 { \ 230 230 return sprintf(buf, "%u\n", state->_name);\ 231 231 } 232 232 233 233 #define define_show_state_ull_function(_name) \ 234 - static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ 234 + static ssize_t show_state_##_name(struct cpuidle_state *state, \ 235 + struct cpuidle_state_usage *state_usage, char *buf) \ 235 236 { \ 236 - return sprintf(buf, "%llu\n", state->_name);\ 237 + return sprintf(buf, "%llu\n", state_usage->_name);\ 237 238 } 238 239 239 240 #define define_show_state_str_function(_name) \ 240 - static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ 241 + static ssize_t show_state_##_name(struct cpuidle_state *state, \ 242 + struct cpuidle_state_usage *state_usage, char *buf) \ 241 243 { \ 242 244 if (state->_name[0] == '\0')\ 243 245 return sprintf(buf, "<null>\n");\ ··· 273 269 274 270 #define kobj_to_state_obj(k) container_of(k, struct cpuidle_state_kobj, kobj) 275 271 #define kobj_to_state(k) (kobj_to_state_obj(k)->state) 272 + #define kobj_to_state_usage(k) (kobj_to_state_obj(k)->state_usage) 276 273 #define attr_to_stateattr(a) container_of(a, struct cpuidle_state_attr, attr) 277 274 static ssize_t cpuidle_state_show(struct kobject * kobj, 278 275 struct attribute * attr ,char * buf) 279 276 { 280 277 int ret = -EIO; 281 278 struct cpuidle_state *state = kobj_to_state(kobj); 279 + struct cpuidle_state_usage *state_usage = kobj_to_state_usage(kobj); 282 280 struct cpuidle_state_attr * cattr = attr_to_stateattr(attr); 283 281 284 282 if (cattr->show) 285 - ret = cattr->show(state, buf); 283 + ret = cattr->show(state, state_usage, buf); 286 284 287 285 return ret; 288 286 } ··· 322 316 { 323 317 int i, ret = -ENOMEM; 324 318 struct cpuidle_state_kobj *kobj; 319 + struct cpuidle_driver *drv = cpuidle_get_driver(); 325 320 326 321 /* state statistics */ 327 322 for (i = 0; i < device->state_count; i++) { 328 323 kobj = kzalloc(sizeof(struct cpuidle_state_kobj), GFP_KERNEL); 329 324 if (!kobj) 330 325 goto error_state; 331 - kobj->state = &device->states[i]; 326 + kobj->state = &drv->states[i]; 327 + kobj->state_usage = &device->states_usage[i]; 332 328 init_completion(&kobj->kobj_unregister); 333 329 334 330 ret = kobject_init_and_add(&kobj->kobj, &ktype_state_cpuidle, &device->kobj,
+99 -31
drivers/idle/intel_idle.c
··· 82 82 static unsigned int lapic_timer_reliable_states = (1 << 1); /* Default to only C1 */ 83 83 84 84 static struct cpuidle_device __percpu *intel_idle_cpuidle_devices; 85 - static int intel_idle(struct cpuidle_device *dev, struct cpuidle_state *state); 85 + static int intel_idle(struct cpuidle_device *dev, 86 + struct cpuidle_driver *drv, int index); 86 87 87 88 static struct cpuidle_state *cpuidle_state_table; 88 89 ··· 111 110 { /* MWAIT C1 */ 112 111 .name = "C1-NHM", 113 112 .desc = "MWAIT 0x00", 114 - .driver_data = (void *) 0x00, 115 113 .flags = CPUIDLE_FLAG_TIME_VALID, 116 114 .exit_latency = 3, 117 115 .target_residency = 6, ··· 118 118 { /* MWAIT C2 */ 119 119 .name = "C3-NHM", 120 120 .desc = "MWAIT 0x10", 121 - .driver_data = (void *) 0x10, 122 121 .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 123 122 .exit_latency = 20, 124 123 .target_residency = 80, ··· 125 126 { /* MWAIT C3 */ 126 127 .name = "C6-NHM", 127 128 .desc = "MWAIT 0x20", 128 - .driver_data = (void *) 0x20, 129 129 .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 130 130 .exit_latency = 200, 131 131 .target_residency = 800, ··· 136 138 { /* MWAIT C1 */ 137 139 .name = "C1-SNB", 138 140 .desc = "MWAIT 0x00", 139 - .driver_data = (void *) 0x00, 140 141 .flags = CPUIDLE_FLAG_TIME_VALID, 141 142 .exit_latency = 1, 142 143 .target_residency = 1, ··· 143 146 { /* MWAIT C2 */ 144 147 .name = "C3-SNB", 145 148 .desc = "MWAIT 0x10", 146 - .driver_data = (void *) 0x10, 147 149 .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 148 150 .exit_latency = 80, 149 151 .target_residency = 211, ··· 150 154 { /* MWAIT C3 */ 151 155 .name = "C6-SNB", 152 156 .desc = "MWAIT 0x20", 153 - .driver_data = (void *) 0x20, 154 157 .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 155 158 .exit_latency = 104, 156 159 .target_residency = 345, ··· 157 162 { /* MWAIT C4 */ 158 163 .name = "C7-SNB", 159 164 .desc = "MWAIT 0x30", 160 - .driver_data = (void *) 0x30, 161 165 .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 162 166 .exit_latency = 109, 163 167 .target_residency = 345, ··· 168 174 { /* MWAIT C1 */ 169 175 .name = "C1-ATM", 170 176 .desc = "MWAIT 0x00", 171 - .driver_data = (void *) 0x00, 172 177 .flags = CPUIDLE_FLAG_TIME_VALID, 173 178 .exit_latency = 1, 174 179 .target_residency = 4, ··· 175 182 { /* MWAIT C2 */ 176 183 .name = "C2-ATM", 177 184 .desc = "MWAIT 0x10", 178 - .driver_data = (void *) 0x10, 179 185 .flags = CPUIDLE_FLAG_TIME_VALID, 180 186 .exit_latency = 20, 181 187 .target_residency = 80, ··· 183 191 { /* MWAIT C4 */ 184 192 .name = "C4-ATM", 185 193 .desc = "MWAIT 0x30", 186 - .driver_data = (void *) 0x30, 187 194 .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 188 195 .exit_latency = 100, 189 196 .target_residency = 400, ··· 191 200 { /* MWAIT C6 */ 192 201 .name = "C6-ATM", 193 202 .desc = "MWAIT 0x52", 194 - .driver_data = (void *) 0x52, 195 203 .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 196 204 .exit_latency = 140, 197 205 .target_residency = 560, 198 206 .enter = &intel_idle }, 199 207 }; 200 208 209 + static int get_driver_data(int cstate) 210 + { 211 + int driver_data; 212 + switch (cstate) { 213 + 214 + case 1: /* MWAIT C1 */ 215 + driver_data = 0x00; 216 + break; 217 + case 2: /* MWAIT C2 */ 218 + driver_data = 0x10; 219 + break; 220 + case 3: /* MWAIT C3 */ 221 + driver_data = 0x20; 222 + break; 223 + case 4: /* MWAIT C4 */ 224 + driver_data = 0x30; 225 + break; 226 + case 5: /* MWAIT C5 */ 227 + driver_data = 0x40; 228 + break; 229 + case 6: /* MWAIT C6 */ 230 + driver_data = 0x52; 231 + break; 232 + default: 233 + driver_data = 0x00; 234 + } 235 + return driver_data; 236 + } 237 + 201 238 /** 202 239 * intel_idle 203 240 * @dev: cpuidle_device 204 - * @state: cpuidle state 241 + * @drv: cpuidle driver 242 + * @index: index of cpuidle state 205 243 * 206 244 */ 207 - static int intel_idle(struct cpuidle_device *dev, struct cpuidle_state *state) 245 + static int intel_idle(struct cpuidle_device *dev, 246 + struct cpuidle_driver *drv, int index) 208 247 { 209 248 unsigned long ecx = 1; /* break on interrupt flag */ 210 - unsigned long eax = (unsigned long)cpuidle_get_statedata(state); 249 + struct cpuidle_state *state = &drv->states[index]; 250 + struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; 251 + unsigned long eax = (unsigned long)cpuidle_get_statedata(state_usage); 211 252 unsigned int cstate; 212 253 ktime_t kt_before, kt_after; 213 254 s64 usec_delta; ··· 280 257 if (!(lapic_timer_reliable_states & (1 << (cstate)))) 281 258 clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &cpu); 282 259 283 - return usec_delta; 260 + /* Update cpuidle counters */ 261 + dev->last_residency = (int)usec_delta; 262 + 263 + return index; 284 264 } 285 265 286 266 static void __setup_broadcast_timer(void *arg) ··· 424 398 return; 425 399 } 426 400 /* 401 + * intel_idle_cpuidle_driver_init() 402 + * allocate, initialize cpuidle_states 403 + */ 404 + static int intel_idle_cpuidle_driver_init(void) 405 + { 406 + int cstate; 407 + struct cpuidle_driver *drv = &intel_idle_driver; 408 + 409 + drv->state_count = 1; 410 + 411 + for (cstate = 1; cstate < MWAIT_MAX_NUM_CSTATES; ++cstate) { 412 + int num_substates; 413 + 414 + if (cstate > max_cstate) { 415 + printk(PREFIX "max_cstate %d reached\n", 416 + max_cstate); 417 + break; 418 + } 419 + 420 + /* does the state exist in CPUID.MWAIT? */ 421 + num_substates = (mwait_substates >> ((cstate) * 4)) 422 + & MWAIT_SUBSTATE_MASK; 423 + if (num_substates == 0) 424 + continue; 425 + /* is the state not enabled? */ 426 + if (cpuidle_state_table[cstate].enter == NULL) { 427 + /* does the driver not know about the state? */ 428 + if (*cpuidle_state_table[cstate].name == '\0') 429 + pr_debug(PREFIX "unaware of model 0x%x" 430 + " MWAIT %d please" 431 + " contact lenb@kernel.org", 432 + boot_cpu_data.x86_model, cstate); 433 + continue; 434 + } 435 + 436 + if ((cstate > 2) && 437 + !boot_cpu_has(X86_FEATURE_NONSTOP_TSC)) 438 + mark_tsc_unstable("TSC halts in idle" 439 + " states deeper than C2"); 440 + 441 + drv->states[drv->state_count] = /* structure copy */ 442 + cpuidle_state_table[cstate]; 443 + 444 + drv->state_count += 1; 445 + } 446 + 447 + if (auto_demotion_disable_flags) 448 + smp_call_function(auto_demotion_disable, NULL, 1); 449 + 450 + return 0; 451 + } 452 + 453 + 454 + /* 427 455 * intel_idle_cpuidle_devices_init() 428 456 * allocate, initialize, register cpuidle_devices 429 457 */ ··· 511 431 continue; 512 432 /* is the state not enabled? */ 513 433 if (cpuidle_state_table[cstate].enter == NULL) { 514 - /* does the driver not know about the state? */ 515 - if (*cpuidle_state_table[cstate].name == '\0') 516 - pr_debug(PREFIX "unaware of model 0x%x" 517 - " MWAIT %d please" 518 - " contact lenb@kernel.org", 519 - boot_cpu_data.x86_model, cstate); 520 434 continue; 521 435 } 522 436 523 - if ((cstate > 2) && 524 - !boot_cpu_has(X86_FEATURE_NONSTOP_TSC)) 525 - mark_tsc_unstable("TSC halts in idle" 526 - " states deeper than C2"); 527 - 528 - dev->states[dev->state_count] = /* structure copy */ 529 - cpuidle_state_table[cstate]; 437 + dev->states_usage[dev->state_count].driver_data = 438 + (void *)get_driver_data(cstate); 530 439 531 440 dev->state_count += 1; 532 441 } ··· 528 459 return -EIO; 529 460 } 530 461 } 531 - if (auto_demotion_disable_flags) 532 - smp_call_function(auto_demotion_disable, NULL, 1); 533 462 534 463 return 0; 535 464 } ··· 545 478 if (retval) 546 479 return retval; 547 480 481 + intel_idle_cpuidle_driver_init(); 548 482 retval = cpuidle_register_driver(&intel_idle_driver); 549 483 if (retval) { 550 484 printk(KERN_DEBUG PREFIX "intel_idle yielding to %s",
+15 -47
drivers/pnp/pnpacpi/rsparser.c
··· 509 509 struct acpi_resource_dma *p) 510 510 { 511 511 int i; 512 - unsigned char map = 0, flags = 0; 513 - 514 - if (p->channel_count == 0) 515 - flags |= IORESOURCE_DISABLED; 512 + unsigned char map = 0, flags; 516 513 517 514 for (i = 0; i < p->channel_count; i++) 518 515 map |= 1 << p->channels[i]; 519 516 520 - flags |= dma_flags(dev, p->type, p->bus_master, p->transfer); 517 + flags = dma_flags(dev, p->type, p->bus_master, p->transfer); 521 518 pnp_register_dma_resource(dev, option_flags, map, flags); 522 519 } 523 520 ··· 524 527 { 525 528 int i; 526 529 pnp_irq_mask_t map; 527 - unsigned char flags = 0; 528 - 529 - if (p->interrupt_count == 0) 530 - flags |= IORESOURCE_DISABLED; 530 + unsigned char flags; 531 531 532 532 bitmap_zero(map.bits, PNP_IRQ_NR); 533 533 for (i = 0; i < p->interrupt_count; i++) 534 534 if (p->interrupts[i]) 535 535 __set_bit(p->interrupts[i], map.bits); 536 536 537 - flags |= irq_flags(p->triggering, p->polarity, p->sharable); 537 + flags = irq_flags(p->triggering, p->polarity, p->sharable); 538 538 pnp_register_irq_resource(dev, option_flags, &map, flags); 539 539 } 540 540 ··· 541 547 { 542 548 int i; 543 549 pnp_irq_mask_t map; 544 - unsigned char flags = 0; 545 - 546 - if (p->interrupt_count == 0) 547 - flags |= IORESOURCE_DISABLED; 550 + unsigned char flags; 548 551 549 552 bitmap_zero(map.bits, PNP_IRQ_NR); 550 553 for (i = 0; i < p->interrupt_count; i++) { ··· 555 564 } 556 565 } 557 566 558 - flags |= irq_flags(p->triggering, p->polarity, p->sharable); 567 + flags = irq_flags(p->triggering, p->polarity, p->sharable); 559 568 pnp_register_irq_resource(dev, option_flags, &map, flags); 560 569 } 561 570 ··· 565 574 { 566 575 unsigned char flags = 0; 567 576 568 - if (io->address_length == 0) 569 - flags |= IORESOURCE_DISABLED; 570 - 571 577 if (io->io_decode == ACPI_DECODE_16) 572 - flags |= IORESOURCE_IO_16BIT_ADDR; 578 + flags = IORESOURCE_IO_16BIT_ADDR; 573 579 pnp_register_port_resource(dev, option_flags, io->minimum, io->maximum, 574 580 io->alignment, io->address_length, flags); 575 581 } ··· 575 587 unsigned int option_flags, 576 588 struct acpi_resource_fixed_io *io) 577 589 { 578 - unsigned char flags = 0; 579 - 580 - if (io->address_length == 0) 581 - flags |= IORESOURCE_DISABLED; 582 - 583 590 pnp_register_port_resource(dev, option_flags, io->address, io->address, 584 - 0, io->address_length, flags | IORESOURCE_IO_FIXED); 591 + 0, io->address_length, IORESOURCE_IO_FIXED); 585 592 } 586 593 587 594 static __init void pnpacpi_parse_mem24_option(struct pnp_dev *dev, ··· 585 602 { 586 603 unsigned char flags = 0; 587 604 588 - if (p->address_length == 0) 589 - flags |= IORESOURCE_DISABLED; 590 - 591 605 if (p->write_protect == ACPI_READ_WRITE_MEMORY) 592 - flags |= IORESOURCE_MEM_WRITEABLE; 606 + flags = IORESOURCE_MEM_WRITEABLE; 593 607 pnp_register_mem_resource(dev, option_flags, p->minimum, p->maximum, 594 608 p->alignment, p->address_length, flags); 595 609 } ··· 597 617 { 598 618 unsigned char flags = 0; 599 619 600 - if (p->address_length == 0) 601 - flags |= IORESOURCE_DISABLED; 602 - 603 620 if (p->write_protect == ACPI_READ_WRITE_MEMORY) 604 - flags |= IORESOURCE_MEM_WRITEABLE; 621 + flags = IORESOURCE_MEM_WRITEABLE; 605 622 pnp_register_mem_resource(dev, option_flags, p->minimum, p->maximum, 606 623 p->alignment, p->address_length, flags); 607 624 } ··· 609 632 { 610 633 unsigned char flags = 0; 611 634 612 - if (p->address_length == 0) 613 - flags |= IORESOURCE_DISABLED; 614 - 615 635 if (p->write_protect == ACPI_READ_WRITE_MEMORY) 616 - flags |= IORESOURCE_MEM_WRITEABLE; 636 + flags = IORESOURCE_MEM_WRITEABLE; 617 637 pnp_register_mem_resource(dev, option_flags, p->address, p->address, 618 638 0, p->address_length, flags); 619 639 } ··· 630 656 return; 631 657 } 632 658 633 - if (p->address_length == 0) 634 - flags |= IORESOURCE_DISABLED; 635 - 636 659 if (p->resource_type == ACPI_MEMORY_RANGE) { 637 660 if (p->info.mem.write_protect == ACPI_READ_WRITE_MEMORY) 638 - flags |= IORESOURCE_MEM_WRITEABLE; 661 + flags = IORESOURCE_MEM_WRITEABLE; 639 662 pnp_register_mem_resource(dev, option_flags, p->minimum, 640 663 p->minimum, 0, p->address_length, 641 664 flags); 642 665 } else if (p->resource_type == ACPI_IO_RANGE) 643 666 pnp_register_port_resource(dev, option_flags, p->minimum, 644 667 p->minimum, 0, p->address_length, 645 - flags | IORESOURCE_IO_FIXED); 668 + IORESOURCE_IO_FIXED); 646 669 } 647 670 648 671 static __init void pnpacpi_parse_ext_address_option(struct pnp_dev *dev, ··· 649 678 struct acpi_resource_extended_address64 *p = &r->data.ext_address64; 650 679 unsigned char flags = 0; 651 680 652 - if (p->address_length == 0) 653 - flags |= IORESOURCE_DISABLED; 654 - 655 681 if (p->resource_type == ACPI_MEMORY_RANGE) { 656 682 if (p->info.mem.write_protect == ACPI_READ_WRITE_MEMORY) 657 - flags |= IORESOURCE_MEM_WRITEABLE; 683 + flags = IORESOURCE_MEM_WRITEABLE; 658 684 pnp_register_mem_resource(dev, option_flags, p->minimum, 659 685 p->minimum, 0, p->address_length, 660 686 flags); 661 687 } else if (p->resource_type == ACPI_IO_RANGE) 662 688 pnp_register_port_resource(dev, option_flags, p->minimum, 663 689 p->minimum, 0, p->address_length, 664 - flags | IORESOURCE_IO_FIXED); 690 + IORESOURCE_IO_FIXED); 665 691 } 666 692 667 693 struct acpipnp_parse_option_s {
+2 -2
drivers/thermal/thermal_sys.c
··· 678 678 return; 679 679 680 680 if (delay > 1000) 681 - schedule_delayed_work(&(tz->poll_queue), 681 + queue_delayed_work(system_freezable_wq, &(tz->poll_queue), 682 682 round_jiffies(msecs_to_jiffies(delay))); 683 683 else 684 - schedule_delayed_work(&(tz->poll_queue), 684 + queue_delayed_work(system_freezable_wq, &(tz->poll_queue), 685 685 msecs_to_jiffies(delay)); 686 686 } 687 687
+1 -1
include/acpi/acpi_drivers.h
··· 144 144 { 145 145 } 146 146 static inline int register_hotplug_dock_device(acpi_handle handle, 147 - struct acpi_dock_ops *ops, 147 + const struct acpi_dock_ops *ops, 148 148 void *context) 149 149 { 150 150 return -ENODEV;
-1
include/acpi/actypes.h
··· 470 470 */ 471 471 #define ACPI_FULL_INITIALIZATION 0x00 472 472 #define ACPI_NO_ADDRESS_SPACE_INIT 0x01 473 - #define ACPI_NO_HARDWARE_INIT 0x02 474 473 #define ACPI_NO_EVENT_INIT 0x04 475 474 #define ACPI_NO_HANDLER_INIT 0x08 476 475 #define ACPI_NO_ACPI_ENABLE 0x10
+1
include/acpi/processor.h
··· 329 329 int acpi_processor_power_init(struct acpi_processor *pr, 330 330 struct acpi_device *device); 331 331 int acpi_processor_cst_has_changed(struct acpi_processor *pr); 332 + int acpi_processor_hotplug(struct acpi_processor *pr); 332 333 int acpi_processor_power_exit(struct acpi_processor *pr, 333 334 struct acpi_device *device); 334 335 int acpi_processor_suspend(struct acpi_device * device, pm_message_t state);
+30 -22
include/linux/cpuidle.h
··· 23 23 struct module; 24 24 25 25 struct cpuidle_device; 26 + struct cpuidle_driver; 26 27 27 28 28 29 /**************************** 29 30 * CPUIDLE DEVICE INTERFACE * 30 31 ****************************/ 31 32 33 + struct cpuidle_state_usage { 34 + void *driver_data; 35 + 36 + unsigned long long usage; 37 + unsigned long long time; /* in US */ 38 + }; 39 + 32 40 struct cpuidle_state { 33 41 char name[CPUIDLE_NAME_LEN]; 34 42 char desc[CPUIDLE_DESC_LEN]; 35 - void *driver_data; 36 43 37 44 unsigned int flags; 38 45 unsigned int exit_latency; /* in US */ 39 46 unsigned int power_usage; /* in mW */ 40 47 unsigned int target_residency; /* in US */ 41 48 42 - unsigned long long usage; 43 - unsigned long long time; /* in US */ 44 - 45 49 int (*enter) (struct cpuidle_device *dev, 46 - struct cpuidle_state *state); 50 + struct cpuidle_driver *drv, 51 + int index); 47 52 }; 48 53 49 54 /* Idle State Flags */ 50 55 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */ 51 - #define CPUIDLE_FLAG_IGNORE (0x100) /* ignore during this idle period */ 52 56 53 57 #define CPUIDLE_DRIVER_FLAGS_MASK (0xFFFF0000) 54 58 55 59 /** 56 60 * cpuidle_get_statedata - retrieves private driver state data 57 - * @state: the state 61 + * @st_usage: the state usage statistics 58 62 */ 59 - static inline void * cpuidle_get_statedata(struct cpuidle_state *state) 63 + static inline void *cpuidle_get_statedata(struct cpuidle_state_usage *st_usage) 60 64 { 61 - return state->driver_data; 65 + return st_usage->driver_data; 62 66 } 63 67 64 68 /** 65 69 * cpuidle_set_statedata - stores private driver state data 66 - * @state: the state 70 + * @st_usage: the state usage statistics 67 71 * @data: the private data 68 72 */ 69 73 static inline void 70 - cpuidle_set_statedata(struct cpuidle_state *state, void *data) 74 + cpuidle_set_statedata(struct cpuidle_state_usage *st_usage, void *data) 71 75 { 72 - state->driver_data = data; 76 + st_usage->driver_data = data; 73 77 } 74 78 75 79 struct cpuidle_state_kobj { 76 80 struct cpuidle_state *state; 81 + struct cpuidle_state_usage *state_usage; 77 82 struct completion kobj_unregister; 78 83 struct kobject kobj; 79 84 }; ··· 86 81 struct cpuidle_device { 87 82 unsigned int registered:1; 88 83 unsigned int enabled:1; 89 - unsigned int power_specified:1; 90 84 unsigned int cpu; 91 85 92 86 int last_residency; 93 87 int state_count; 94 - struct cpuidle_state states[CPUIDLE_STATE_MAX]; 88 + struct cpuidle_state_usage states_usage[CPUIDLE_STATE_MAX]; 95 89 struct cpuidle_state_kobj *kobjs[CPUIDLE_STATE_MAX]; 96 - struct cpuidle_state *last_state; 97 90 98 91 struct list_head device_list; 99 92 struct kobject kobj; 100 93 struct completion kobj_unregister; 101 94 void *governor_data; 102 - struct cpuidle_state *safe_state; 103 - 104 - int (*prepare) (struct cpuidle_device *dev); 105 95 }; 106 96 107 97 DECLARE_PER_CPU(struct cpuidle_device *, cpuidle_devices); ··· 120 120 struct cpuidle_driver { 121 121 char name[CPUIDLE_NAME_LEN]; 122 122 struct module *owner; 123 + 124 + unsigned int power_specified:1; 125 + struct cpuidle_state states[CPUIDLE_STATE_MAX]; 126 + int state_count; 127 + int safe_state_index; 123 128 }; 124 129 125 130 #ifdef CONFIG_CPU_IDLE ··· 171 166 struct list_head governor_list; 172 167 unsigned int rating; 173 168 174 - int (*enable) (struct cpuidle_device *dev); 175 - void (*disable) (struct cpuidle_device *dev); 169 + int (*enable) (struct cpuidle_driver *drv, 170 + struct cpuidle_device *dev); 171 + void (*disable) (struct cpuidle_driver *drv, 172 + struct cpuidle_device *dev); 176 173 177 - int (*select) (struct cpuidle_device *dev); 178 - void (*reflect) (struct cpuidle_device *dev); 174 + int (*select) (struct cpuidle_driver *drv, 175 + struct cpuidle_device *dev); 176 + void (*reflect) (struct cpuidle_device *dev, int index); 179 177 180 178 struct module *owner; 181 179 };
+15 -13
tools/power/x86/turbostat/turbostat.c
··· 162 162 163 163 void dump_cnt(struct counters *cnt) 164 164 { 165 - fprintf(stderr, "package: %d ", cnt->pkg); 166 - fprintf(stderr, "core:: %d ", cnt->core); 167 - fprintf(stderr, "CPU: %d ", cnt->cpu); 168 - fprintf(stderr, "TSC: %016llX\n", cnt->tsc); 169 - fprintf(stderr, "c3: %016llX\n", cnt->c3); 170 - fprintf(stderr, "c6: %016llX\n", cnt->c6); 171 - fprintf(stderr, "c7: %016llX\n", cnt->c7); 172 - fprintf(stderr, "aperf: %016llX\n", cnt->aperf); 173 - fprintf(stderr, "pc2: %016llX\n", cnt->pc2); 174 - fprintf(stderr, "pc3: %016llX\n", cnt->pc3); 175 - fprintf(stderr, "pc6: %016llX\n", cnt->pc6); 176 - fprintf(stderr, "pc7: %016llX\n", cnt->pc7); 177 - fprintf(stderr, "msr0x%x: %016llX\n", extra_msr_offset, cnt->extra_msr); 165 + if (!cnt) 166 + return; 167 + if (cnt->pkg) fprintf(stderr, "package: %d ", cnt->pkg); 168 + if (cnt->core) fprintf(stderr, "core:: %d ", cnt->core); 169 + if (cnt->cpu) fprintf(stderr, "CPU: %d ", cnt->cpu); 170 + if (cnt->tsc) fprintf(stderr, "TSC: %016llX\n", cnt->tsc); 171 + if (cnt->c3) fprintf(stderr, "c3: %016llX\n", cnt->c3); 172 + if (cnt->c6) fprintf(stderr, "c6: %016llX\n", cnt->c6); 173 + if (cnt->c7) fprintf(stderr, "c7: %016llX\n", cnt->c7); 174 + if (cnt->aperf) fprintf(stderr, "aperf: %016llX\n", cnt->aperf); 175 + if (cnt->pc2) fprintf(stderr, "pc2: %016llX\n", cnt->pc2); 176 + if (cnt->pc3) fprintf(stderr, "pc3: %016llX\n", cnt->pc3); 177 + if (cnt->pc6) fprintf(stderr, "pc6: %016llX\n", cnt->pc6); 178 + if (cnt->pc7) fprintf(stderr, "pc7: %016llX\n", cnt->pc7); 179 + if (cnt->extra_msr) fprintf(stderr, "msr0x%x: %016llX\n", extra_msr_offset, cnt->extra_msr); 178 180 } 179 181 180 182 void dump_list(struct counters *cnt)