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

Merge tag 'pm+acpi-2-3.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull more ACPI and power management updates from Rafael Wysocki:

- ACPI-based device hotplug fixes for issues introduced recently and a
fix for an older error code path bug in the ACPI PCI host bridge
driver

- Fix for recently broken OMAP cpufreq build from Viresh Kumar

- Fix for a recent hibernation regression related to s2disk

- Fix for a locking-related regression in the ACPI EC driver from
Puneet Kumar

- System suspend error code path fix related to runtime PM and runtime
PM documentation update from Ulf Hansson

- cpufreq's conservative governor fix from Xiaoguang Chen

- New processor IDs for intel_idle and turbostat and removal of an
obsolete Kconfig option from Len Brown

- New device IDs for the ACPI LPSS (Low-Power Subsystem) driver and
ACPI-based PCI hotplug (ACPIPHP) cleanup from Mika Westerberg

- Removal of several ACPI video DMI blacklist entries that are not
necessary any more from Aaron Lu

- Rework of the ACPI companion representation in struct device and code
cleanup related to that change from Rafael J Wysocki, Lan Tianyu and
Jarkko Nikula

- Fixes for assigning names to ACPI-enumerated I2C and SPI devices from
Jarkko Nikula

* tag 'pm+acpi-2-3.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (24 commits)
PCI / hotplug / ACPI: Drop unused acpiphp_debug declaration
ACPI / scan: Set flags.match_driver in acpi_bus_scan_fixed()
ACPI / PCI root: Clear driver_data before failing enumeration
ACPI / hotplug: Fix PCI host bridge hot removal
ACPI / hotplug: Fix acpi_bus_get_device() return value check
cpufreq: governor: Remove fossil comment in the cpufreq_governor_dbs()
ACPI / video: clean up DMI table for initial black screen problem
ACPI / EC: Ensure lock is acquired before accessing ec struct members
PM / Hibernate: Do not crash kernel in free_basic_memory_bitmaps()
ACPI / AC: Remove struct acpi_device pointer from struct acpi_ac
spi: Use stable dev_name for ACPI enumerated SPI slaves
i2c: Use stable dev_name for ACPI enumerated I2C slaves
ACPI: Provide acpi_dev_name accessor for struct acpi_device device name
ACPI / bind: Use (put|get)_device() on ACPI device objects too
ACPI: Eliminate the DEVICE_ACPI_HANDLE() macro
ACPI / driver core: Store an ACPI device pointer in struct acpi_dev_node
cpufreq: OMAP: Fix compilation error 'r & ret undeclared'
PM / Runtime: Fix error path for prepare
PM / Runtime: Update documentation around probe|remove|suspend
cpufreq: conservative: set requested_freq to policy max when it is over policy max
...

+374 -328
+6 -8
Documentation/power/runtime_pm.txt
··· 547 547 should be used. Of course, for this purpose the device's runtime PM has to be 548 548 enabled earlier by calling pm_runtime_enable(). 549 549 550 - If the device bus type's or driver's ->probe() callback runs 551 - pm_runtime_suspend() or pm_runtime_idle() or their asynchronous counterparts, 552 - they will fail returning -EAGAIN, because the device's usage counter is 553 - incremented by the driver core before executing ->probe(). Still, it may be 554 - desirable to suspend the device as soon as ->probe() has finished, so the driver 555 - core uses pm_runtime_put_sync() to invoke the subsystem-level idle callback for 556 - the device at that time. 550 + It may be desirable to suspend the device once ->probe() has finished. 551 + Therefore the driver core uses the asyncronous pm_request_idle() to submit a 552 + request to execute the subsystem-level idle callback for the device at that 553 + time. A driver that makes use of the runtime autosuspend feature, may want to 554 + update the last busy mark before returning from ->probe(). 557 555 558 556 Moreover, the driver core prevents runtime PM callbacks from racing with the bus 559 557 notifier callback in __device_release_driver(), which is necessary, because the ··· 654 656 __pm_runtime_disable() with 'false' as the second argument for every device 655 657 right before executing the subsystem-level .suspend_late() callback for it. 656 658 657 - * During system resume it calls pm_runtime_enable() and pm_runtime_put_sync() 659 + * During system resume it calls pm_runtime_enable() and pm_runtime_put() 658 660 for every device right after executing the subsystem-level .resume_early() 659 661 callback and right after executing the subsystem-level .resume() callback 660 662 for it, respectively.
+1 -1
arch/ia64/hp/common/sba_iommu.c
··· 1992 1992 if (PCI_CONTROLLER(bus)->iommu) 1993 1993 return; 1994 1994 1995 - handle = PCI_CONTROLLER(bus)->acpi_handle; 1995 + handle = acpi_device_handle(PCI_CONTROLLER(bus)->companion); 1996 1996 if (!handle) 1997 1997 return; 1998 1998
+1 -1
arch/ia64/include/asm/pci.h
··· 95 95 }; 96 96 97 97 struct pci_controller { 98 - void *acpi_handle; 98 + struct acpi_device *companion; 99 99 void *iommu; 100 100 int segment; 101 101 int node; /* nearest node with memory or -1 for global allocation */
+3 -3
arch/ia64/pci/pci.c
··· 436 436 if (!controller) 437 437 return NULL; 438 438 439 - controller->acpi_handle = device->handle; 439 + controller->companion = device; 440 440 441 - pxm = acpi_get_pxm(controller->acpi_handle); 441 + pxm = acpi_get_pxm(device->handle); 442 442 #ifdef CONFIG_NUMA 443 443 if (pxm >= 0) 444 444 controller->node = pxm_to_node(pxm); ··· 489 489 { 490 490 struct pci_controller *controller = bridge->bus->sysdata; 491 491 492 - ACPI_HANDLE_SET(&bridge->dev, controller->acpi_handle); 492 + ACPI_COMPANION_SET(&bridge->dev, controller->companion); 493 493 return 0; 494 494 } 495 495
+2 -2
arch/ia64/sn/kernel/io_acpi_init.c
··· 132 132 struct acpi_resource_vendor_typed *vendor; 133 133 134 134 135 - handle = PCI_CONTROLLER(bus)->acpi_handle; 135 + handle = acpi_device_handle(PCI_CONTROLLER(bus)->companion); 136 136 status = acpi_get_vendor_resource(handle, METHOD_NAME__CRS, 137 137 &sn_uuid, &buffer); 138 138 if (ACPI_FAILURE(status)) { ··· 360 360 acpi_status status; 361 361 struct acpi_buffer name_buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 362 362 363 - rootbus_handle = PCI_CONTROLLER(dev)->acpi_handle; 363 + rootbus_handle = acpi_device_handle(PCI_CONTROLLER(dev)->companion); 364 364 status = acpi_evaluate_integer(rootbus_handle, METHOD_NAME__SEG, NULL, 365 365 &segment); 366 366 if (ACPI_SUCCESS(status)) {
+1 -1
arch/x86/include/asm/pci.h
··· 15 15 int domain; /* PCI domain */ 16 16 int node; /* NUMA node */ 17 17 #ifdef CONFIG_ACPI 18 - void *acpi; /* ACPI-specific data */ 18 + struct acpi_device *companion; /* ACPI companion device */ 19 19 #endif 20 20 #ifdef CONFIG_X86_64 21 21 void *iommu; /* IOMMU private data */
+2
arch/x86/include/uapi/asm/msr-index.h
··· 147 147 #define MSR_PP1_ENERGY_STATUS 0x00000641 148 148 #define MSR_PP1_POLICY 0x00000642 149 149 150 + #define MSR_CORE_C1_RES 0x00000660 151 + 150 152 #define MSR_AMD64_MC0_MASK 0xc0010044 151 153 152 154 #define MSR_IA32_MCx_CTL(x) (MSR_IA32_MC0_CTL + 4*(x))
+2 -2
arch/x86/pci/acpi.c
··· 518 518 sd = &info->sd; 519 519 sd->domain = domain; 520 520 sd->node = node; 521 - sd->acpi = device->handle; 521 + sd->companion = device; 522 522 /* 523 523 * Maybe the desired pci bus has been already scanned. In such case 524 524 * it is unnecessary to scan the pci bus with the given domain,busnum. ··· 589 589 { 590 590 struct pci_sysdata *sd = bridge->bus->sysdata; 591 591 592 - ACPI_HANDLE_SET(&bridge->dev, sd->acpi); 592 + ACPI_COMPANION_SET(&bridge->dev, sd->companion); 593 593 return 0; 594 594 } 595 595
-11
drivers/acpi/Kconfig
··· 235 235 initrd, therefore it's safe to say Y. 236 236 See Documentation/acpi/initrd_table_override.txt for details 237 237 238 - config ACPI_BLACKLIST_YEAR 239 - int "Disable ACPI for systems before Jan 1st this year" if X86_32 240 - default 0 241 - help 242 - Enter a 4-digit year, e.g., 2001, to disable ACPI by default 243 - on platforms with DMI BIOS date before January 1st that year. 244 - "acpi=force" can be used to override this mechanism. 245 - 246 - Enter 0 to disable this mechanism and allow ACPI to 247 - run by default no matter what the year. (default) 248 - 249 238 config ACPI_DEBUG 250 239 bool "Debug Statements" 251 240 default n
+8 -7
drivers/acpi/ac.c
··· 56 56 57 57 struct acpi_ac { 58 58 struct power_supply charger; 59 - struct acpi_device *adev; 60 59 struct platform_device *pdev; 61 60 unsigned long long state; 62 61 }; ··· 69 70 static int acpi_ac_get_state(struct acpi_ac *ac) 70 71 { 71 72 acpi_status status; 73 + acpi_handle handle = ACPI_HANDLE(&ac->pdev->dev); 72 74 73 - status = acpi_evaluate_integer(ac->adev->handle, "_PSR", NULL, 75 + status = acpi_evaluate_integer(handle, "_PSR", NULL, 74 76 &ac->state); 75 77 if (ACPI_FAILURE(status)) { 76 78 ACPI_EXCEPTION((AE_INFO, status, ··· 119 119 static void acpi_ac_notify_handler(acpi_handle handle, u32 event, void *data) 120 120 { 121 121 struct acpi_ac *ac = data; 122 + struct acpi_device *adev; 122 123 123 124 if (!ac) 124 125 return; ··· 142 141 msleep(ac_sleep_before_get_state_ms); 143 142 144 143 acpi_ac_get_state(ac); 145 - acpi_bus_generate_netlink_event(ac->adev->pnp.device_class, 144 + adev = ACPI_COMPANION(&ac->pdev->dev); 145 + acpi_bus_generate_netlink_event(adev->pnp.device_class, 146 146 dev_name(&ac->pdev->dev), 147 147 event, (u32) ac->state); 148 - acpi_notifier_call_chain(ac->adev, event, (u32) ac->state); 148 + acpi_notifier_call_chain(adev, event, (u32) ac->state); 149 149 kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE); 150 150 } 151 151 ··· 180 178 if (!pdev) 181 179 return -EINVAL; 182 180 183 - result = acpi_bus_get_device(ACPI_HANDLE(&pdev->dev), &adev); 184 - if (result) 181 + adev = ACPI_COMPANION(&pdev->dev); 182 + if (!adev) 185 183 return -ENODEV; 186 184 187 185 ac = kzalloc(sizeof(struct acpi_ac), GFP_KERNEL); ··· 190 188 191 189 strcpy(acpi_device_name(adev), ACPI_AC_DEVICE_NAME); 192 190 strcpy(acpi_device_class(adev), ACPI_AC_CLASS); 193 - ac->adev = adev; 194 191 ac->pdev = pdev; 195 192 platform_set_drvdata(pdev, ac); 196 193
+9
drivers/acpi/acpi_lpss.c
··· 163 163 { "80860F41", (unsigned long)&byt_i2c_dev_desc }, 164 164 { "INT33B2", }, 165 165 166 + { "INT3430", (unsigned long)&lpt_dev_desc }, 167 + { "INT3431", (unsigned long)&lpt_dev_desc }, 168 + { "INT3432", (unsigned long)&lpt_dev_desc }, 169 + { "INT3433", (unsigned long)&lpt_dev_desc }, 170 + { "INT3434", (unsigned long)&lpt_uart_dev_desc }, 171 + { "INT3435", (unsigned long)&lpt_uart_dev_desc }, 172 + { "INT3436", (unsigned long)&lpt_sdio_dev_desc }, 173 + { "INT3437", }, 174 + 166 175 { } 167 176 }; 168 177
+1 -1
drivers/acpi/acpi_platform.c
··· 111 111 pdevinfo.id = -1; 112 112 pdevinfo.res = resources; 113 113 pdevinfo.num_res = count; 114 - pdevinfo.acpi_node.handle = adev->handle; 114 + pdevinfo.acpi_node.companion = adev; 115 115 pdev = platform_device_register_full(&pdevinfo); 116 116 if (IS_ERR(pdev)) { 117 117 dev_err(&adev->dev, "platform device creation failed: %ld\n",
-35
drivers/acpi/blacklist.c
··· 75 75 {""} 76 76 }; 77 77 78 - #if CONFIG_ACPI_BLACKLIST_YEAR 79 - 80 - static int __init blacklist_by_year(void) 81 - { 82 - int year; 83 - 84 - /* Doesn't exist? Likely an old system */ 85 - if (!dmi_get_date(DMI_BIOS_DATE, &year, NULL, NULL)) { 86 - printk(KERN_ERR PREFIX "no DMI BIOS year, " 87 - "acpi=force is required to enable ACPI\n" ); 88 - return 1; 89 - } 90 - /* 0? Likely a buggy new BIOS */ 91 - if (year == 0) { 92 - printk(KERN_ERR PREFIX "DMI BIOS year==0, " 93 - "assuming ACPI-capable machine\n" ); 94 - return 0; 95 - } 96 - if (year < CONFIG_ACPI_BLACKLIST_YEAR) { 97 - printk(KERN_ERR PREFIX "BIOS age (%d) fails cutoff (%d), " 98 - "acpi=force is required to enable ACPI\n", 99 - year, CONFIG_ACPI_BLACKLIST_YEAR); 100 - return 1; 101 - } 102 - return 0; 103 - } 104 - #else 105 - static inline int blacklist_by_year(void) 106 - { 107 - return 0; 108 - } 109 - #endif 110 - 111 78 int __init acpi_blacklisted(void) 112 79 { 113 80 int i = 0; ··· 132 165 i++; 133 166 } 134 167 } 135 - 136 - blacklisted += blacklist_by_year(); 137 168 138 169 dmi_check_system(acpi_osi_dmi_table); 139 170
+5 -9
drivers/acpi/device_pm.c
··· 22 22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 23 23 */ 24 24 25 - #include <linux/device.h> 25 + #include <linux/acpi.h> 26 26 #include <linux/export.h> 27 27 #include <linux/mutex.h> 28 28 #include <linux/pm_qos.h> 29 29 #include <linux/pm_runtime.h> 30 - 31 - #include <acpi/acpi.h> 32 - #include <acpi/acpi_bus.h> 33 - #include <acpi/acpi_drivers.h> 34 30 35 31 #include "internal.h" 36 32 ··· 544 548 */ 545 549 int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in) 546 550 { 547 - acpi_handle handle = DEVICE_ACPI_HANDLE(dev); 551 + acpi_handle handle = ACPI_HANDLE(dev); 548 552 struct acpi_device *adev; 549 553 int ret, d_min, d_max; 550 554 ··· 652 656 if (!device_run_wake(phys_dev)) 653 657 return -EINVAL; 654 658 655 - handle = DEVICE_ACPI_HANDLE(phys_dev); 659 + handle = ACPI_HANDLE(phys_dev); 656 660 if (!handle || acpi_bus_get_device(handle, &adev)) { 657 661 dev_dbg(phys_dev, "ACPI handle without context in %s!\n", 658 662 __func__); ··· 696 700 if (!device_can_wakeup(dev)) 697 701 return -EINVAL; 698 702 699 - handle = DEVICE_ACPI_HANDLE(dev); 703 + handle = ACPI_HANDLE(dev); 700 704 if (!handle || acpi_bus_get_device(handle, &adev)) { 701 705 dev_dbg(dev, "ACPI handle without context in %s!\n", __func__); 702 706 return -ENODEV; ··· 718 722 */ 719 723 struct acpi_device *acpi_dev_pm_get_node(struct device *dev) 720 724 { 721 - acpi_handle handle = DEVICE_ACPI_HANDLE(dev); 725 + acpi_handle handle = ACPI_HANDLE(dev); 722 726 struct acpi_device *adev; 723 727 724 728 return handle && !acpi_bus_get_device(handle, &adev) ? adev : NULL;
+2 -1
drivers/acpi/ec.c
··· 173 173 static void advance_transaction(struct acpi_ec *ec, u8 status) 174 174 { 175 175 unsigned long flags; 176 - struct transaction *t = ec->curr; 176 + struct transaction *t; 177 177 178 178 spin_lock_irqsave(&ec->lock, flags); 179 + t = ec->curr; 179 180 if (!t) 180 181 goto unlock; 181 182 if (t->wlen > t->wi) {
+28 -25
drivers/acpi/glue.c
··· 197 197 198 198 int acpi_bind_one(struct device *dev, acpi_handle handle) 199 199 { 200 - struct acpi_device *acpi_dev; 201 - acpi_status status; 200 + struct acpi_device *acpi_dev = NULL; 202 201 struct acpi_device_physical_node *physical_node, *pn; 203 202 char physical_node_name[PHYSICAL_NODE_NAME_SIZE]; 204 203 struct list_head *physnode_list; 205 204 unsigned int node_id; 206 205 int retval = -EINVAL; 207 206 208 - if (ACPI_HANDLE(dev)) { 207 + if (ACPI_COMPANION(dev)) { 209 208 if (handle) { 210 - dev_warn(dev, "ACPI handle is already set\n"); 209 + dev_warn(dev, "ACPI companion already set\n"); 211 210 return -EINVAL; 212 211 } else { 213 - handle = ACPI_HANDLE(dev); 212 + acpi_dev = ACPI_COMPANION(dev); 214 213 } 214 + } else { 215 + acpi_bus_get_device(handle, &acpi_dev); 215 216 } 216 - if (!handle) 217 + if (!acpi_dev) 217 218 return -EINVAL; 218 219 220 + get_device(&acpi_dev->dev); 219 221 get_device(dev); 220 - status = acpi_bus_get_device(handle, &acpi_dev); 221 - if (ACPI_FAILURE(status)) 222 - goto err; 223 - 224 222 physical_node = kzalloc(sizeof(*physical_node), GFP_KERNEL); 225 223 if (!physical_node) { 226 224 retval = -ENOMEM; ··· 240 242 241 243 dev_warn(dev, "Already associated with ACPI node\n"); 242 244 kfree(physical_node); 243 - if (ACPI_HANDLE(dev) != handle) 245 + if (ACPI_COMPANION(dev) != acpi_dev) 244 246 goto err; 245 247 246 248 put_device(dev); 249 + put_device(&acpi_dev->dev); 247 250 return 0; 248 251 } 249 252 if (pn->node_id == node_id) { ··· 258 259 list_add(&physical_node->node, physnode_list); 259 260 acpi_dev->physical_node_count++; 260 261 261 - if (!ACPI_HANDLE(dev)) 262 - ACPI_HANDLE_SET(dev, acpi_dev->handle); 262 + if (!ACPI_COMPANION(dev)) 263 + ACPI_COMPANION_SET(dev, acpi_dev); 263 264 264 265 acpi_physnode_link_name(physical_node_name, node_id); 265 266 retval = sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj, ··· 282 283 return 0; 283 284 284 285 err: 285 - ACPI_HANDLE_SET(dev, NULL); 286 + ACPI_COMPANION_SET(dev, NULL); 286 287 put_device(dev); 288 + put_device(&acpi_dev->dev); 287 289 return retval; 288 290 } 289 291 EXPORT_SYMBOL_GPL(acpi_bind_one); 290 292 291 293 int acpi_unbind_one(struct device *dev) 292 294 { 295 + struct acpi_device *acpi_dev = ACPI_COMPANION(dev); 293 296 struct acpi_device_physical_node *entry; 294 - struct acpi_device *acpi_dev; 295 - acpi_status status; 296 297 297 - if (!ACPI_HANDLE(dev)) 298 + if (!acpi_dev) 298 299 return 0; 299 - 300 - status = acpi_bus_get_device(ACPI_HANDLE(dev), &acpi_dev); 301 - if (ACPI_FAILURE(status)) { 302 - dev_err(dev, "Oops, ACPI handle corrupt in %s()\n", __func__); 303 - return -EINVAL; 304 - } 305 300 306 301 mutex_lock(&acpi_dev->physical_node_lock); 307 302 ··· 309 316 acpi_physnode_link_name(physnode_name, entry->node_id); 310 317 sysfs_remove_link(&acpi_dev->dev.kobj, physnode_name); 311 318 sysfs_remove_link(&dev->kobj, "firmware_node"); 312 - ACPI_HANDLE_SET(dev, NULL); 313 - /* acpi_bind_one() increase refcnt by one. */ 319 + ACPI_COMPANION_SET(dev, NULL); 320 + /* Drop references taken by acpi_bind_one(). */ 314 321 put_device(dev); 322 + put_device(&acpi_dev->dev); 315 323 kfree(entry); 316 324 break; 317 325 } ··· 321 327 return 0; 322 328 } 323 329 EXPORT_SYMBOL_GPL(acpi_unbind_one); 330 + 331 + void acpi_preset_companion(struct device *dev, acpi_handle parent, u64 addr) 332 + { 333 + struct acpi_device *adev; 334 + 335 + if (!acpi_bus_get_device(acpi_get_child(parent, addr), &adev)) 336 + ACPI_COMPANION_SET(dev, adev); 337 + } 338 + EXPORT_SYMBOL_GPL(acpi_preset_companion); 324 339 325 340 static int acpi_platform_notify(struct device *dev) 326 341 {
+1
drivers/acpi/pci_root.c
··· 575 575 dev_err(&device->dev, 576 576 "Bus %04x:%02x not present in PCI namespace\n", 577 577 root->segment, (unsigned int)root->secondary.start); 578 + device->driver_data = NULL; 578 579 result = -ENODEV; 579 580 goto end; 580 581 }
+4 -10
drivers/acpi/scan.c
··· 289 289 { 290 290 struct acpi_device *device = data; 291 291 acpi_handle handle = device->handle; 292 - struct acpi_scan_handler *handler; 293 292 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; 294 293 int error; 295 294 296 295 lock_device_hotplug(); 297 296 mutex_lock(&acpi_scan_lock); 298 297 299 - handler = device->handler; 300 - if (!handler || !handler->hotplug.enabled) { 301 - put_device(&device->dev); 302 - goto err_support; 303 - } 304 - 305 298 if (ost_src == ACPI_NOTIFY_EJECT_REQUEST) 306 299 acpi_evaluate_hotplug_ost(handle, ACPI_NOTIFY_EJECT_REQUEST, 307 300 ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); 308 301 309 - if (handler->hotplug.mode == AHM_CONTAINER) 302 + if (device->handler && device->handler->hotplug.mode == AHM_CONTAINER) 310 303 kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE); 311 304 312 305 error = acpi_scan_hot_remove(device); ··· 404 411 break; 405 412 case ACPI_NOTIFY_EJECT_REQUEST: 406 413 acpi_handle_debug(handle, "ACPI_NOTIFY_EJECT_REQUEST event\n"); 407 - status = acpi_bus_get_device(handle, &adev); 408 - if (ACPI_FAILURE(status)) 414 + if (acpi_bus_get_device(handle, &adev)) 409 415 goto err_out; 410 416 411 417 get_device(&adev->dev); ··· 1989 1997 if (result) 1990 1998 return result; 1991 1999 2000 + device->flags.match_driver = true; 1992 2001 result = device_attach(&device->dev); 1993 2002 if (result < 0) 1994 2003 return result; ··· 2006 2013 if (result) 2007 2014 return result; 2008 2015 2016 + device->flags.match_driver = true; 2009 2017 result = device_attach(&device->dev); 2010 2018 } 2011 2019
+12 -75
drivers/acpi/video.c
··· 82 82 module_param(allow_duplicates, bool, 0644); 83 83 84 84 /* 85 - * Some BIOSes claim they use minimum backlight at boot, 86 - * and this may bring dimming screen after boot 87 - */ 88 - static bool use_bios_initial_backlight = 1; 89 - module_param(use_bios_initial_backlight, bool, 0644); 90 - 91 - /* 92 85 * For Windows 8 systems: if set ture and the GPU driver has 93 86 * registered a backlight interface, skip registering ACPI video's. 94 87 */ ··· 399 406 return 0; 400 407 } 401 408 402 - static int video_ignore_initial_backlight(const struct dmi_system_id *d) 403 - { 404 - use_bios_initial_backlight = 0; 405 - return 0; 406 - } 407 - 408 409 static struct dmi_system_id video_dmi_table[] __initdata = { 409 410 /* 410 411 * Broken _BQC workaround http://bugzilla.kernel.org/show_bug.cgi?id=13121 ··· 441 454 .matches = { 442 455 DMI_MATCH(DMI_BOARD_VENDOR, "Acer"), 443 456 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 7720"), 444 - }, 445 - }, 446 - { 447 - .callback = video_ignore_initial_backlight, 448 - .ident = "HP Folio 13-2000", 449 - .matches = { 450 - DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"), 451 - DMI_MATCH(DMI_PRODUCT_NAME, "HP Folio 13 - 2000 Notebook PC"), 452 - }, 453 - }, 454 - { 455 - .callback = video_ignore_initial_backlight, 456 - .ident = "Fujitsu E753", 457 - .matches = { 458 - DMI_MATCH(DMI_BOARD_VENDOR, "FUJITSU"), 459 - DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E753"), 460 - }, 461 - }, 462 - { 463 - .callback = video_ignore_initial_backlight, 464 - .ident = "HP Pavilion dm4", 465 - .matches = { 466 - DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"), 467 - DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dm4 Notebook PC"), 468 - }, 469 - }, 470 - { 471 - .callback = video_ignore_initial_backlight, 472 - .ident = "HP Pavilion g6 Notebook PC", 473 - .matches = { 474 - DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"), 475 - DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion g6 Notebook PC"), 476 - }, 477 - }, 478 - { 479 - .callback = video_ignore_initial_backlight, 480 - .ident = "HP 1000 Notebook PC", 481 - .matches = { 482 - DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"), 483 - DMI_MATCH(DMI_PRODUCT_NAME, "HP 1000 Notebook PC"), 484 - }, 485 - }, 486 - { 487 - .callback = video_ignore_initial_backlight, 488 - .ident = "HP Pavilion m4", 489 - .matches = { 490 - DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"), 491 - DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion m4 Notebook PC"), 492 457 }, 493 458 }, 494 459 {} ··· 778 839 if (!device->cap._BQC) 779 840 goto set_level; 780 841 781 - if (use_bios_initial_backlight) { 782 - level = acpi_video_bqc_value_to_level(device, level_old); 783 - /* 784 - * On some buggy laptops, _BQC returns an uninitialized 785 - * value when invoked for the first time, i.e. 786 - * level_old is invalid (no matter whether it's a level 787 - * or an index). Set the backlight to max_level in this case. 788 - */ 789 - for (i = 2; i < br->count; i++) 790 - if (level == br->levels[i]) 791 - break; 792 - if (i == br->count || !level) 793 - level = max_level; 794 - } 842 + level = acpi_video_bqc_value_to_level(device, level_old); 843 + /* 844 + * On some buggy laptops, _BQC returns an uninitialized 845 + * value when invoked for the first time, i.e. 846 + * level_old is invalid (no matter whether it's a level 847 + * or an index). Set the backlight to max_level in this case. 848 + */ 849 + for (i = 2; i < br->count; i++) 850 + if (level == br->levels[i]) 851 + break; 852 + if (i == br->count || !level) 853 + level = max_level; 795 854 796 855 set_level: 797 856 result = acpi_video_device_lcd_set_level(device, level);
+2 -2
drivers/ata/libata-acpi.c
··· 185 185 if (libata_noacpi || ap->flags & ATA_FLAG_ACPI_SATA || !host_handle) 186 186 return; 187 187 188 - ACPI_HANDLE_SET(&ap->tdev, acpi_get_child(host_handle, ap->port_no)); 188 + acpi_preset_companion(&ap->tdev, host_handle, ap->port_no); 189 189 190 190 if (ata_acpi_gtm(ap, &ap->__acpi_init_gtm) == 0) 191 191 ap->pflags |= ATA_PFLAG_INIT_GTM_VALID; ··· 222 222 parent_handle = port_handle; 223 223 } 224 224 225 - ACPI_HANDLE_SET(&dev->tdev, acpi_get_child(parent_handle, adr)); 225 + acpi_preset_companion(&dev->tdev, parent_handle, adr); 226 226 227 227 register_hotplug_dock_device(ata_dev_acpi_handle(dev), 228 228 &ata_acpi_dev_dock_ops, dev, NULL, NULL);
+2 -2
drivers/base/platform.c
··· 432 432 goto err_alloc; 433 433 434 434 pdev->dev.parent = pdevinfo->parent; 435 - ACPI_HANDLE_SET(&pdev->dev, pdevinfo->acpi_node.handle); 435 + ACPI_COMPANION_SET(&pdev->dev, pdevinfo->acpi_node.companion); 436 436 437 437 if (pdevinfo->dma_mask) { 438 438 /* ··· 463 463 ret = platform_device_add(pdev); 464 464 if (ret) { 465 465 err: 466 - ACPI_HANDLE_SET(&pdev->dev, NULL); 466 + ACPI_COMPANION_SET(&pdev->dev, NULL); 467 467 kfree(pdev->dev.dma_mask); 468 468 469 469 err_alloc:
+3
drivers/base/power/main.c
··· 1350 1350 1351 1351 device_unlock(dev); 1352 1352 1353 + if (error) 1354 + pm_runtime_put(dev); 1355 + 1353 1356 return error; 1354 1357 } 1355 1358
+3
drivers/cpufreq/cpufreq_conservative.c
··· 68 68 69 69 dbs_info->requested_freq += get_freq_target(cs_tuners, policy); 70 70 71 + if (dbs_info->requested_freq > policy->max) 72 + dbs_info->requested_freq = policy->max; 73 + 71 74 __cpufreq_driver_target(policy, dbs_info->requested_freq, 72 75 CPUFREQ_RELATION_H); 73 76 return;
-4
drivers/cpufreq/cpufreq_governor.c
··· 328 328 dbs_data->cdata->gov_dbs_timer); 329 329 } 330 330 331 - /* 332 - * conservative does not implement micro like ondemand 333 - * governor, thus we are bound to jiffes/HZ 334 - */ 335 331 if (dbs_data->cdata->governor == GOV_CONSERVATIVE) { 336 332 cs_dbs_info->down_skip = 0; 337 333 cs_dbs_info->enable = 1;
+1
drivers/cpufreq/omap-cpufreq.c
··· 53 53 54 54 static int omap_target(struct cpufreq_policy *policy, unsigned int index) 55 55 { 56 + int r, ret; 56 57 struct dev_pm_opp *opp; 57 58 unsigned long freq, volt = 0, volt_old = 0, tol = 0; 58 59 unsigned int old_freq, new_freq;
+1
drivers/gpio/gpiolib.c
··· 13 13 #include <linux/acpi_gpio.h> 14 14 #include <linux/idr.h> 15 15 #include <linux/slab.h> 16 + #include <linux/acpi.h> 16 17 17 18 #define CREATE_TRACE_POINTS 18 19 #include <trace/events/gpio.h>
+1 -1
drivers/gpu/drm/i915/intel_acpi.c
··· 196 196 acpi_handle dhandle; 197 197 int ret; 198 198 199 - dhandle = DEVICE_ACPI_HANDLE(&pdev->dev); 199 + dhandle = ACPI_HANDLE(&pdev->dev); 200 200 if (!dhandle) 201 201 return false; 202 202
+1 -1
drivers/gpu/drm/i915/intel_opregion.c
··· 638 638 u32 temp; 639 639 int i = 0; 640 640 641 - handle = DEVICE_ACPI_HANDLE(&dev->pdev->dev); 641 + handle = ACPI_HANDLE(&dev->pdev->dev); 642 642 if (!handle || acpi_bus_get_device(handle, &acpi_dev)) 643 643 return; 644 644
+1 -1
drivers/gpu/drm/nouveau/core/subdev/mxm/base.c
··· 116 116 acpi_handle handle; 117 117 int ret; 118 118 119 - handle = DEVICE_ACPI_HANDLE(&device->pdev->dev); 119 + handle = ACPI_HANDLE(&device->pdev->dev); 120 120 if (!handle) 121 121 return false; 122 122
+3 -3
drivers/gpu/drm/nouveau/nouveau_acpi.c
··· 256 256 acpi_handle dhandle; 257 257 int retval = 0; 258 258 259 - dhandle = DEVICE_ACPI_HANDLE(&pdev->dev); 259 + dhandle = ACPI_HANDLE(&pdev->dev); 260 260 if (!dhandle) 261 261 return false; 262 262 ··· 414 414 if (!nouveau_dsm_priv.dsm_detected && !nouveau_dsm_priv.optimus_detected) 415 415 return false; 416 416 417 - dhandle = DEVICE_ACPI_HANDLE(&pdev->dev); 417 + dhandle = ACPI_HANDLE(&pdev->dev); 418 418 if (!dhandle) 419 419 return false; 420 420 ··· 448 448 return NULL; 449 449 } 450 450 451 - handle = DEVICE_ACPI_HANDLE(&dev->pdev->dev); 451 + handle = ACPI_HANDLE(&dev->pdev->dev); 452 452 if (!handle) 453 453 return NULL; 454 454
+4 -4
drivers/gpu/drm/radeon/radeon_acpi.c
··· 369 369 return NOTIFY_DONE; 370 370 371 371 /* Check pending SBIOS requests */ 372 - handle = DEVICE_ACPI_HANDLE(&rdev->pdev->dev); 372 + handle = ACPI_HANDLE(&rdev->pdev->dev); 373 373 count = radeon_atif_get_sbios_requests(handle, &req); 374 374 375 375 if (count <= 0) ··· 556 556 struct radeon_atcs *atcs = &rdev->atcs; 557 557 558 558 /* Get the device handle */ 559 - handle = DEVICE_ACPI_HANDLE(&rdev->pdev->dev); 559 + handle = ACPI_HANDLE(&rdev->pdev->dev); 560 560 if (!handle) 561 561 return -EINVAL; 562 562 ··· 596 596 u32 retry = 3; 597 597 598 598 /* Get the device handle */ 599 - handle = DEVICE_ACPI_HANDLE(&rdev->pdev->dev); 599 + handle = ACPI_HANDLE(&rdev->pdev->dev); 600 600 if (!handle) 601 601 return -EINVAL; 602 602 ··· 699 699 int ret; 700 700 701 701 /* Get the device handle */ 702 - handle = DEVICE_ACPI_HANDLE(&rdev->pdev->dev); 702 + handle = ACPI_HANDLE(&rdev->pdev->dev); 703 703 704 704 /* No need to proceed if we're sure that ATIF is not supported */ 705 705 if (!ASIC_IS_AVIVO(rdev) || !rdev->bios || !handle)
+3 -4
drivers/gpu/drm/radeon/radeon_atpx_handler.c
··· 8 8 */ 9 9 #include <linux/vga_switcheroo.h> 10 10 #include <linux/slab.h> 11 - #include <acpi/acpi.h> 12 - #include <acpi/acpi_bus.h> 11 + #include <linux/acpi.h> 13 12 #include <linux/pci.h> 14 13 15 14 #include "radeon_acpi.h" ··· 446 447 acpi_handle dhandle, atpx_handle; 447 448 acpi_status status; 448 449 449 - dhandle = DEVICE_ACPI_HANDLE(&pdev->dev); 450 + dhandle = ACPI_HANDLE(&pdev->dev); 450 451 if (!dhandle) 451 452 return false; 452 453 ··· 492 493 */ 493 494 static int radeon_atpx_get_client_id(struct pci_dev *pdev) 494 495 { 495 - if (radeon_atpx_priv.dhandle == DEVICE_ACPI_HANDLE(&pdev->dev)) 496 + if (radeon_atpx_priv.dhandle == ACPI_HANDLE(&pdev->dev)) 496 497 return VGA_SWITCHEROO_IGD; 497 498 else 498 499 return VGA_SWITCHEROO_DIS;
+1 -1
drivers/gpu/drm/radeon/radeon_bios.c
··· 185 185 return false; 186 186 187 187 while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) { 188 - dhandle = DEVICE_ACPI_HANDLE(&pdev->dev); 188 + dhandle = ACPI_HANDLE(&pdev->dev); 189 189 if (!dhandle) 190 190 continue; 191 191
+1 -1
drivers/hid/i2c-hid/i2c-hid.c
··· 1008 1008 hid->hid_get_raw_report = i2c_hid_get_raw_report; 1009 1009 hid->hid_output_raw_report = i2c_hid_output_raw_report; 1010 1010 hid->dev.parent = &client->dev; 1011 - ACPI_HANDLE_SET(&hid->dev, ACPI_HANDLE(&client->dev)); 1011 + ACPI_COMPANION_SET(&hid->dev, ACPI_COMPANION(&client->dev)); 1012 1012 hid->bus = BUS_I2C; 1013 1013 hid->version = le16_to_cpu(ihid->hdesc.bcdVersion); 1014 1014 hid->vendor = le16_to_cpu(ihid->hdesc.wVendorID);
+19 -6
drivers/i2c/i2c-core.c
··· 615 615 } 616 616 EXPORT_SYMBOL_GPL(i2c_unlock_adapter); 617 617 618 + static void i2c_dev_set_name(struct i2c_adapter *adap, 619 + struct i2c_client *client) 620 + { 621 + struct acpi_device *adev = ACPI_COMPANION(&client->dev); 622 + 623 + if (adev) { 624 + dev_set_name(&client->dev, "i2c-%s", acpi_dev_name(adev)); 625 + return; 626 + } 627 + 628 + /* For 10-bit clients, add an arbitrary offset to avoid collisions */ 629 + dev_set_name(&client->dev, "%d-%04x", i2c_adapter_id(adap), 630 + client->addr | ((client->flags & I2C_CLIENT_TEN) 631 + ? 0xa000 : 0)); 632 + } 633 + 618 634 /** 619 635 * i2c_new_device - instantiate an i2c device 620 636 * @adap: the adapter managing the device ··· 687 671 client->dev.bus = &i2c_bus_type; 688 672 client->dev.type = &i2c_client_type; 689 673 client->dev.of_node = info->of_node; 690 - ACPI_HANDLE_SET(&client->dev, info->acpi_node.handle); 674 + ACPI_COMPANION_SET(&client->dev, info->acpi_node.companion); 691 675 692 - /* For 10-bit clients, add an arbitrary offset to avoid collisions */ 693 - dev_set_name(&client->dev, "%d-%04x", i2c_adapter_id(adap), 694 - client->addr | ((client->flags & I2C_CLIENT_TEN) 695 - ? 0xa000 : 0)); 676 + i2c_dev_set_name(adap, client); 696 677 status = device_register(&client->dev); 697 678 if (status) 698 679 goto out_err; ··· 1113 1100 return AE_OK; 1114 1101 1115 1102 memset(&info, 0, sizeof(info)); 1116 - info.acpi_node.handle = handle; 1103 + info.acpi_node.companion = adev; 1117 1104 info.irq = -1; 1118 1105 1119 1106 INIT_LIST_HEAD(&resource_list);
+2 -3
drivers/ide/ide-acpi.c
··· 7 7 * Copyright (C) 2006 Hannes Reinecke 8 8 */ 9 9 10 + #include <linux/acpi.h> 10 11 #include <linux/ata.h> 11 12 #include <linux/delay.h> 12 13 #include <linux/device.h> ··· 19 18 #include <linux/pci.h> 20 19 #include <linux/dmi.h> 21 20 #include <linux/module.h> 22 - 23 - #include <acpi/acpi_bus.h> 24 21 25 22 #define REGS_PER_GTF 7 26 23 ··· 127 128 128 129 DEBPRINT("ENTER: pci %02x:%02x.%01x\n", bus, devnum, func); 129 130 130 - dev_handle = DEVICE_ACPI_HANDLE(dev); 131 + dev_handle = ACPI_HANDLE(dev); 131 132 if (!dev_handle) { 132 133 DEBPRINT("no acpi handle for device\n"); 133 134 goto err;
+23 -1
drivers/idle/intel_idle.c
··· 1 1 /* 2 2 * intel_idle.c - native hardware idle loop for modern Intel processors 3 3 * 4 - * Copyright (c) 2010, Intel Corporation. 4 + * Copyright (c) 2013, Intel Corporation. 5 5 * Len Brown <len.brown@intel.com> 6 6 * 7 7 * This program is free software; you can redistribute it and/or modify it ··· 329 329 { 330 330 .enter = NULL } 331 331 }; 332 + static struct cpuidle_state avn_cstates[CPUIDLE_STATE_MAX] = { 333 + { 334 + .name = "C1-AVN", 335 + .desc = "MWAIT 0x00", 336 + .flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_TIME_VALID, 337 + .exit_latency = 2, 338 + .target_residency = 2, 339 + .enter = &intel_idle }, 340 + { 341 + .name = "C6-AVN", 342 + .desc = "MWAIT 0x51", 343 + .flags = MWAIT2flg(0x58) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 344 + .exit_latency = 15, 345 + .target_residency = 45, 346 + .enter = &intel_idle }, 347 + }; 332 348 333 349 /** 334 350 * intel_idle ··· 478 462 .disable_promotion_to_c1e = true, 479 463 }; 480 464 465 + static const struct idle_cpu idle_cpu_avn = { 466 + .state_table = avn_cstates, 467 + .disable_promotion_to_c1e = true, 468 + }; 469 + 481 470 #define ICPU(model, cpu) \ 482 471 { X86_VENDOR_INTEL, 6, model, X86_FEATURE_MWAIT, (unsigned long)&cpu } 483 472 ··· 504 483 ICPU(0x3f, idle_cpu_hsw), 505 484 ICPU(0x45, idle_cpu_hsw), 506 485 ICPU(0x46, idle_cpu_hsw), 486 + ICPU(0x4D, idle_cpu_avn), 507 487 {} 508 488 }; 509 489 MODULE_DEVICE_TABLE(x86cpu, intel_idle_ids);
+1 -2
drivers/mmc/core/sdio_bus.c
··· 308 308 struct mmc_host *host = func->card->host; 309 309 u64 addr = (host->slotno << 16) | func->num; 310 310 311 - ACPI_HANDLE_SET(&func->dev, 312 - acpi_get_child(ACPI_HANDLE(host->parent), addr)); 311 + acpi_preset_companion(&func->dev, ACPI_HANDLE(host->parent), addr); 313 312 } 314 313 #else 315 314 static inline void sdio_acpi_set_handle(struct sdio_func *func) {}
+1 -1
drivers/pci/hotplug/acpi_pcihp.c
··· 367 367 string = (struct acpi_buffer){ ACPI_ALLOCATE_BUFFER, NULL }; 368 368 } 369 369 370 - handle = DEVICE_ACPI_HANDLE(&pdev->dev); 370 + handle = ACPI_HANDLE(&pdev->dev); 371 371 if (!handle) { 372 372 /* 373 373 * This hotplug controller was not listed in the ACPI name
-1
drivers/pci/hotplug/acpiphp.h
··· 176 176 u8 acpiphp_get_adapter_status(struct acpiphp_slot *slot); 177 177 178 178 /* variables */ 179 - extern bool acpiphp_debug; 180 179 extern bool acpiphp_disabled; 181 180 182 181 #endif /* _ACPIPHP_H */
+2 -2
drivers/pci/hotplug/pciehp_acpi.c
··· 54 54 { 55 55 if (slot_detection_mode != PCIEHP_DETECT_ACPI) 56 56 return 0; 57 - if (acpi_pci_detect_ejectable(DEVICE_ACPI_HANDLE(&dev->dev))) 57 + if (acpi_pci_detect_ejectable(ACPI_HANDLE(&dev->dev))) 58 58 return 0; 59 59 return -ENODEV; 60 60 } ··· 96 96 dup_slot_id++; 97 97 } 98 98 list_add_tail(&slot->list, &dummy_slots); 99 - handle = DEVICE_ACPI_HANDLE(&pdev->dev); 99 + handle = ACPI_HANDLE(&pdev->dev); 100 100 if (!acpi_slot_detected && acpi_pci_detect_ejectable(handle)) 101 101 acpi_slot_detected = 1; 102 102 return -ENODEV; /* dummy driver always returns error */
+4 -4
drivers/pci/hotplug/sgi_hotplug.c
··· 9 9 * Work to add BIOS PROM support was completed by Mike Habeck. 10 10 */ 11 11 12 + #include <linux/acpi.h> 12 13 #include <linux/init.h> 13 14 #include <linux/kernel.h> 14 15 #include <linux/module.h> ··· 30 29 #include <asm/sn/sn_feature_sets.h> 31 30 #include <asm/sn/sn_sal.h> 32 31 #include <asm/sn/types.h> 33 - #include <linux/acpi.h> 34 32 #include <asm/sn/acpi.h> 35 33 36 34 #include "../pci.h" ··· 414 414 acpi_handle rethandle; 415 415 acpi_status ret; 416 416 417 - phandle = PCI_CONTROLLER(slot->pci_bus)->acpi_handle; 417 + phandle = acpi_device_handle(PCI_CONTROLLER(slot->pci_bus)->companion); 418 418 419 419 if (acpi_bus_get_device(phandle, &pdevice)) { 420 420 dev_dbg(&slot->pci_bus->self->dev, ··· 495 495 496 496 /* free the ACPI resources for the slot */ 497 497 if (SN_ACPI_BASE_SUPPORT() && 498 - PCI_CONTROLLER(slot->pci_bus)->acpi_handle) { 498 + PCI_CONTROLLER(slot->pci_bus)->companion) { 499 499 unsigned long long adr; 500 500 struct acpi_device *device; 501 501 acpi_handle phandle; ··· 504 504 acpi_status ret; 505 505 506 506 /* Get the rootbus node pointer */ 507 - phandle = PCI_CONTROLLER(slot->pci_bus)->acpi_handle; 507 + phandle = acpi_device_handle(PCI_CONTROLLER(slot->pci_bus)->companion); 508 508 509 509 acpi_scan_lock_acquire(); 510 510 /*
+1 -1
drivers/pci/ioapic.c
··· 37 37 char *type; 38 38 struct resource *res; 39 39 40 - handle = DEVICE_ACPI_HANDLE(&dev->dev); 40 + handle = ACPI_HANDLE(&dev->dev); 41 41 if (!handle) 42 42 return -EINVAL; 43 43
+3 -3
drivers/pci/pci-acpi.c
··· 173 173 174 174 static bool acpi_pci_power_manageable(struct pci_dev *dev) 175 175 { 176 - acpi_handle handle = DEVICE_ACPI_HANDLE(&dev->dev); 176 + acpi_handle handle = ACPI_HANDLE(&dev->dev); 177 177 178 178 return handle ? acpi_bus_power_manageable(handle) : false; 179 179 } 180 180 181 181 static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state) 182 182 { 183 - acpi_handle handle = DEVICE_ACPI_HANDLE(&dev->dev); 183 + acpi_handle handle = ACPI_HANDLE(&dev->dev); 184 184 static const u8 state_conv[] = { 185 185 [PCI_D0] = ACPI_STATE_D0, 186 186 [PCI_D1] = ACPI_STATE_D1, ··· 217 217 218 218 static bool acpi_pci_can_wakeup(struct pci_dev *dev) 219 219 { 220 - acpi_handle handle = DEVICE_ACPI_HANDLE(&dev->dev); 220 + acpi_handle handle = ACPI_HANDLE(&dev->dev); 221 221 222 222 return handle ? acpi_bus_can_wakeup(handle) : false; 223 223 }
+3 -3
drivers/pci/pci-label.c
··· 263 263 acpi_handle handle; 264 264 struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL}; 265 265 266 - handle = DEVICE_ACPI_HANDLE(dev); 266 + handle = ACPI_HANDLE(dev); 267 267 268 268 if (!handle) 269 269 return FALSE; ··· 295 295 acpi_handle handle; 296 296 int length; 297 297 298 - handle = DEVICE_ACPI_HANDLE(dev); 298 + handle = ACPI_HANDLE(dev); 299 299 300 300 if (!handle) 301 301 return -1; ··· 316 316 acpi_handle handle; 317 317 int length; 318 318 319 - handle = DEVICE_ACPI_HANDLE(dev); 319 + handle = ACPI_HANDLE(dev); 320 320 321 321 if (!handle) 322 322 return -1;
+1 -1
drivers/platform/x86/apple-gmux.c
··· 519 519 520 520 gmux_data->power_state = VGA_SWITCHEROO_ON; 521 521 522 - gmux_data->dhandle = DEVICE_ACPI_HANDLE(&pnp->dev); 522 + gmux_data->dhandle = ACPI_HANDLE(&pnp->dev); 523 523 if (!gmux_data->dhandle) { 524 524 pr_err("Cannot find acpi handle for pnp device %s\n", 525 525 dev_name(&pnp->dev));
+5 -5
drivers/pnp/pnpacpi/core.c
··· 89 89 90 90 pnp_dbg(&dev->dev, "set resources\n"); 91 91 92 - handle = DEVICE_ACPI_HANDLE(&dev->dev); 92 + handle = ACPI_HANDLE(&dev->dev); 93 93 if (!handle || acpi_bus_get_device(handle, &acpi_dev)) { 94 94 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__); 95 95 return -ENODEV; ··· 122 122 123 123 dev_dbg(&dev->dev, "disable resources\n"); 124 124 125 - handle = DEVICE_ACPI_HANDLE(&dev->dev); 125 + handle = ACPI_HANDLE(&dev->dev); 126 126 if (!handle || acpi_bus_get_device(handle, &acpi_dev)) { 127 127 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__); 128 128 return 0; ··· 144 144 struct acpi_device *acpi_dev; 145 145 acpi_handle handle; 146 146 147 - handle = DEVICE_ACPI_HANDLE(&dev->dev); 147 + handle = ACPI_HANDLE(&dev->dev); 148 148 if (!handle || acpi_bus_get_device(handle, &acpi_dev)) { 149 149 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__); 150 150 return false; ··· 159 159 acpi_handle handle; 160 160 int error = 0; 161 161 162 - handle = DEVICE_ACPI_HANDLE(&dev->dev); 162 + handle = ACPI_HANDLE(&dev->dev); 163 163 if (!handle || acpi_bus_get_device(handle, &acpi_dev)) { 164 164 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__); 165 165 return 0; ··· 194 194 static int pnpacpi_resume(struct pnp_dev *dev) 195 195 { 196 196 struct acpi_device *acpi_dev; 197 - acpi_handle handle = DEVICE_ACPI_HANDLE(&dev->dev); 197 + acpi_handle handle = ACPI_HANDLE(&dev->dev); 198 198 int error = 0; 199 199 200 200 if (!handle || acpi_bus_get_device(handle, &acpi_dev)) {
+15 -4
drivers/spi/spi.c
··· 357 357 } 358 358 EXPORT_SYMBOL_GPL(spi_alloc_device); 359 359 360 + static void spi_dev_set_name(struct spi_device *spi) 361 + { 362 + struct acpi_device *adev = ACPI_COMPANION(&spi->dev); 363 + 364 + if (adev) { 365 + dev_set_name(&spi->dev, "spi-%s", acpi_dev_name(adev)); 366 + return; 367 + } 368 + 369 + dev_set_name(&spi->dev, "%s.%u", dev_name(&spi->master->dev), 370 + spi->chip_select); 371 + } 372 + 360 373 /** 361 374 * spi_add_device - Add spi_device allocated with spi_alloc_device 362 375 * @spi: spi_device to register ··· 396 383 } 397 384 398 385 /* Set the bus ID string */ 399 - dev_set_name(&spi->dev, "%s.%u", dev_name(&spi->master->dev), 400 - spi->chip_select); 401 - 386 + spi_dev_set_name(spi); 402 387 403 388 /* We need to make sure there's no other device with this 404 389 * chipselect **BEFORE** we call setup(), else we'll trash ··· 1155 1144 return AE_NO_MEMORY; 1156 1145 } 1157 1146 1158 - ACPI_HANDLE_SET(&spi->dev, handle); 1147 + ACPI_COMPANION_SET(&spi->dev, adev); 1159 1148 spi->irq = -1; 1160 1149 1161 1150 INIT_LIST_HEAD(&resource_list);
+1 -1
drivers/usb/core/hub.c
··· 5501 5501 if (!hub) 5502 5502 return NULL; 5503 5503 5504 - return DEVICE_ACPI_HANDLE(&hub->ports[port1 - 1]->dev); 5504 + return ACPI_HANDLE(&hub->ports[port1 - 1]->dev); 5505 5505 } 5506 5506 #endif
+2 -2
drivers/usb/core/usb-acpi.c
··· 173 173 } 174 174 175 175 /* root hub's parent is the usb hcd. */ 176 - parent_handle = DEVICE_ACPI_HANDLE(dev->parent); 176 + parent_handle = ACPI_HANDLE(dev->parent); 177 177 *handle = acpi_get_child(parent_handle, udev->portnum); 178 178 if (!*handle) 179 179 return -ENODEV; ··· 194 194 195 195 raw_port_num = usb_hcd_find_raw_port_number(hcd, 196 196 port_num); 197 - *handle = acpi_get_child(DEVICE_ACPI_HANDLE(&udev->dev), 197 + *handle = acpi_get_child(ACPI_HANDLE(&udev->dev), 198 198 raw_port_num); 199 199 if (!*handle) 200 200 return -ENODEV;
+3 -3
drivers/xen/pci.c
··· 59 59 add.flags = XEN_PCI_DEV_EXTFN; 60 60 61 61 #ifdef CONFIG_ACPI 62 - handle = DEVICE_ACPI_HANDLE(&pci_dev->dev); 62 + handle = ACPI_HANDLE(&pci_dev->dev); 63 63 if (!handle && pci_dev->bus->bridge) 64 - handle = DEVICE_ACPI_HANDLE(pci_dev->bus->bridge); 64 + handle = ACPI_HANDLE(pci_dev->bus->bridge); 65 65 #ifdef CONFIG_PCI_IOV 66 66 if (!handle && pci_dev->is_virtfn) 67 - handle = DEVICE_ACPI_HANDLE(physfn->bus->bridge); 67 + handle = ACPI_HANDLE(physfn->bus->bridge); 68 68 #endif 69 69 if (handle) { 70 70 acpi_status status;
+1 -1
include/acpi/acpi_bus.h
··· 431 431 { 432 432 return acpi_find_child(handle, addr, false); 433 433 } 434 + void acpi_preset_companion(struct device *dev, acpi_handle parent, u64 addr); 434 435 int acpi_is_root_bridge(acpi_handle); 435 436 struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle); 436 - #define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)ACPI_HANDLE(dev)) 437 437 438 438 int acpi_enable_wakeup_device_power(struct acpi_device *dev, int state); 439 439 int acpi_disable_wakeup_device_power(struct acpi_device *dev);
+23
include/linux/acpi.h
··· 44 44 #include <acpi/acpi_numa.h> 45 45 #include <asm/acpi.h> 46 46 47 + static inline acpi_handle acpi_device_handle(struct acpi_device *adev) 48 + { 49 + return adev ? adev->handle : NULL; 50 + } 51 + 52 + #define ACPI_COMPANION(dev) ((dev)->acpi_node.companion) 53 + #define ACPI_COMPANION_SET(dev, adev) ACPI_COMPANION(dev) = (adev) 54 + #define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev)) 55 + 56 + static inline const char *acpi_dev_name(struct acpi_device *adev) 57 + { 58 + return dev_name(&adev->dev); 59 + } 60 + 47 61 enum acpi_irq_model_id { 48 62 ACPI_IRQ_MODEL_PIC = 0, 49 63 ACPI_IRQ_MODEL_IOAPIC, ··· 414 400 #else /* !CONFIG_ACPI */ 415 401 416 402 #define acpi_disabled 1 403 + 404 + #define ACPI_COMPANION(dev) (NULL) 405 + #define ACPI_COMPANION_SET(dev, adev) do { } while (0) 406 + #define ACPI_HANDLE(dev) (NULL) 407 + 408 + static inline const char *acpi_dev_name(struct acpi_device *adev) 409 + { 410 + return NULL; 411 + } 417 412 418 413 static inline void acpi_early_init(void) { } 419 414
+3 -9
include/linux/device.h
··· 644 644 unsigned long segment_boundary_mask; 645 645 }; 646 646 647 + struct acpi_device; 648 + 647 649 struct acpi_dev_node { 648 650 #ifdef CONFIG_ACPI 649 - void *handle; 651 + struct acpi_device *companion; 650 652 #endif 651 653 }; 652 654 ··· 791 789 { 792 790 return container_of(kobj, struct device, kobj); 793 791 } 794 - 795 - #ifdef CONFIG_ACPI 796 - #define ACPI_HANDLE(dev) ((dev)->acpi_node.handle) 797 - #define ACPI_HANDLE_SET(dev, _handle_) (dev)->acpi_node.handle = (_handle_) 798 - #else 799 - #define ACPI_HANDLE(dev) (NULL) 800 - #define ACPI_HANDLE_SET(dev, _handle_) do { } while (0) 801 - #endif 802 792 803 793 /* Get the wakeup routines, which depend on struct device */ 804 794 #include <linux/pm_wakeup.h>
+2 -2
include/linux/pci-acpi.h
··· 27 27 while (!pci_is_root_bus(pbus)) 28 28 pbus = pbus->parent; 29 29 30 - return DEVICE_ACPI_HANDLE(pbus->bridge); 30 + return ACPI_HANDLE(pbus->bridge); 31 31 } 32 32 33 33 static inline acpi_handle acpi_pci_get_bridge_handle(struct pci_bus *pbus) ··· 39 39 else 40 40 dev = &pbus->self->dev; 41 41 42 - return DEVICE_ACPI_HANDLE(dev); 42 + return ACPI_HANDLE(dev); 43 43 } 44 44 45 45 void acpi_pci_add_bus(struct pci_bus *bus);
+2 -1
kernel/power/snapshot.c
··· 792 792 { 793 793 struct memory_bitmap *bm1, *bm2; 794 794 795 - BUG_ON(!(forbidden_pages_map && free_pages_map)); 795 + if (WARN_ON(!(forbidden_pages_map && free_pages_map))) 796 + return; 796 797 797 798 bm1 = forbidden_pages_map; 798 799 bm2 = free_pages_map;
+1
kernel/power/user.c
··· 70 70 data->swap = swsusp_resume_device ? 71 71 swap_type_of(swsusp_resume_device, 0, NULL) : -1; 72 72 data->mode = O_RDONLY; 73 + data->free_bitmaps = false; 73 74 error = pm_notifier_call_chain(PM_HIBERNATION_PREPARE); 74 75 if (error) 75 76 pm_notifier_call_chain(PM_POST_HIBERNATION);
+141 -56
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) 2012 Intel Corporation. 5 + * Copyright (c) 2013 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 ··· 47 47 unsigned int do_nhm_cstates; 48 48 unsigned int do_snb_cstates; 49 49 unsigned int do_c8_c9_c10; 50 + unsigned int do_slm_cstates; 51 + unsigned int use_c1_residency_msr; 50 52 unsigned int has_aperf; 51 53 unsigned int has_epb; 52 54 unsigned int units = 1000000000; /* Ghz etc */ ··· 83 81 #define RAPL_DRAM (1 << 3) 84 82 #define RAPL_PKG_PERF_STATUS (1 << 4) 85 83 #define RAPL_DRAM_PERF_STATUS (1 << 5) 84 + #define RAPL_PKG_POWER_INFO (1 << 6) 85 + #define RAPL_CORE_POLICY (1 << 7) 86 86 #define TJMAX_DEFAULT 100 87 87 88 88 #define MAX(a, b) ((a) > (b) ? (a) : (b)) ··· 100 96 unsigned long long tsc; 101 97 unsigned long long aperf; 102 98 unsigned long long mperf; 103 - unsigned long long c1; /* derived */ 99 + unsigned long long c1; 104 100 unsigned long long extra_msr64; 105 101 unsigned long long extra_delta64; 106 102 unsigned long long extra_msr32; ··· 270 266 outp += sprintf(outp, " MSR 0x%03X", extra_msr_offset64); 271 267 if (do_nhm_cstates) 272 268 outp += sprintf(outp, " %%c1"); 273 - if (do_nhm_cstates) 269 + if (do_nhm_cstates && !do_slm_cstates) 274 270 outp += sprintf(outp, " %%c3"); 275 271 if (do_nhm_cstates) 276 272 outp += sprintf(outp, " %%c6"); ··· 284 280 285 281 if (do_snb_cstates) 286 282 outp += sprintf(outp, " %%pc2"); 287 - if (do_nhm_cstates) 283 + if (do_nhm_cstates && !do_slm_cstates) 288 284 outp += sprintf(outp, " %%pc3"); 289 - if (do_nhm_cstates) 285 + if (do_nhm_cstates && !do_slm_cstates) 290 286 outp += sprintf(outp, " %%pc6"); 291 287 if (do_snb_cstates) 292 288 outp += sprintf(outp, " %%pc7"); ··· 484 480 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) 485 481 goto done; 486 482 487 - if (do_nhm_cstates) 483 + if (do_nhm_cstates && !do_slm_cstates) 488 484 outp += sprintf(outp, " %6.2f", 100.0 * c->c3/t->tsc); 489 485 if (do_nhm_cstates) 490 486 outp += sprintf(outp, " %6.2f", 100.0 * c->c6/t->tsc); ··· 503 499 504 500 if (do_snb_cstates) 505 501 outp += sprintf(outp, " %6.2f", 100.0 * p->pc2/t->tsc); 506 - if (do_nhm_cstates) 502 + if (do_nhm_cstates && !do_slm_cstates) 507 503 outp += sprintf(outp, " %6.2f", 100.0 * p->pc3/t->tsc); 508 - if (do_nhm_cstates) 504 + if (do_nhm_cstates && !do_slm_cstates) 509 505 outp += sprintf(outp, " %6.2f", 100.0 * p->pc6/t->tsc); 510 506 if (do_snb_cstates) 511 507 outp += sprintf(outp, " %6.2f", 100.0 * p->pc7/t->tsc); ··· 652 648 } 653 649 654 650 655 - /* 656 - * As counter collection is not atomic, 657 - * it is possible for mperf's non-halted cycles + idle states 658 - * to exceed TSC's all cycles: show c1 = 0% in that case. 659 - */ 660 - if ((old->mperf + core_delta->c3 + core_delta->c6 + core_delta->c7) > old->tsc) 661 - old->c1 = 0; 662 - else { 663 - /* normal case, derive c1 */ 664 - old->c1 = old->tsc - old->mperf - core_delta->c3 651 + if (use_c1_residency_msr) { 652 + /* 653 + * Some models have a dedicated C1 residency MSR, 654 + * which should be more accurate than the derivation below. 655 + */ 656 + } else { 657 + /* 658 + * As counter collection is not atomic, 659 + * it is possible for mperf's non-halted cycles + idle states 660 + * to exceed TSC's all cycles: show c1 = 0% in that case. 661 + */ 662 + if ((old->mperf + core_delta->c3 + core_delta->c6 + core_delta->c7) > old->tsc) 663 + old->c1 = 0; 664 + else { 665 + /* normal case, derive c1 */ 666 + old->c1 = old->tsc - old->mperf - core_delta->c3 665 667 - core_delta->c6 - core_delta->c7; 668 + } 666 669 } 667 670 668 671 if (old->mperf == 0) { ··· 883 872 if (get_msr(cpu, extra_msr_offset64, &t->extra_msr64)) 884 873 return -5; 885 874 875 + if (use_c1_residency_msr) { 876 + if (get_msr(cpu, MSR_CORE_C1_RES, &t->c1)) 877 + return -6; 878 + } 879 + 886 880 /* collect core counters only for 1st thread in core */ 887 881 if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE)) 888 882 return 0; 889 883 890 - if (do_nhm_cstates) { 884 + if (do_nhm_cstates && !do_slm_cstates) { 891 885 if (get_msr(cpu, MSR_CORE_C3_RESIDENCY, &c->c3)) 892 886 return -6; 887 + } 888 + 889 + if (do_nhm_cstates) { 893 890 if (get_msr(cpu, MSR_CORE_C6_RESIDENCY, &c->c6)) 894 891 return -7; 895 892 } ··· 917 898 if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) 918 899 return 0; 919 900 920 - if (do_nhm_cstates) { 901 + if (do_nhm_cstates && !do_slm_cstates) { 921 902 if (get_msr(cpu, MSR_PKG_C3_RESIDENCY, &p->pc3)) 922 903 return -9; 923 904 if (get_msr(cpu, MSR_PKG_C6_RESIDENCY, &p->pc6)) ··· 996 977 ratio, bclk, ratio * bclk); 997 978 998 979 get_msr(0, MSR_IA32_POWER_CTL, &msr); 999 - fprintf(stderr, "cpu0: MSR_IA32_POWER_CTL: 0x%08llx (C1E: %sabled)\n", 980 + fprintf(stderr, "cpu0: MSR_IA32_POWER_CTL: 0x%08llx (C1E auto-promotion: %sabled)\n", 1000 981 msr, msr & 0x2 ? "EN" : "DIS"); 1001 982 1002 983 if (!do_ivt_turbo_ratio_limit) ··· 1065 1046 1066 1047 switch(msr & 0x7) { 1067 1048 case 0: 1068 - fprintf(stderr, "pc0"); 1049 + fprintf(stderr, do_slm_cstates ? "no pkg states" : "pc0"); 1069 1050 break; 1070 1051 case 1: 1071 - fprintf(stderr, do_snb_cstates ? "pc2" : "pc0"); 1052 + fprintf(stderr, do_slm_cstates ? "no pkg states" : do_snb_cstates ? "pc2" : "pc0"); 1072 1053 break; 1073 1054 case 2: 1074 - fprintf(stderr, do_snb_cstates ? "pc6-noret" : "pc3"); 1055 + fprintf(stderr, do_slm_cstates ? "invalid" : do_snb_cstates ? "pc6-noret" : "pc3"); 1075 1056 break; 1076 1057 case 3: 1077 - fprintf(stderr, "pc6"); 1058 + fprintf(stderr, do_slm_cstates ? "invalid" : "pc6"); 1078 1059 break; 1079 1060 case 4: 1080 - fprintf(stderr, "pc7"); 1061 + fprintf(stderr, do_slm_cstates ? "pc4" : "pc7"); 1081 1062 break; 1082 1063 case 5: 1083 - fprintf(stderr, do_snb_cstates ? "pc7s" : "invalid"); 1064 + fprintf(stderr, do_slm_cstates ? "invalid" : do_snb_cstates ? "pc7s" : "invalid"); 1065 + break; 1066 + case 6: 1067 + fprintf(stderr, do_slm_cstates ? "pc6" : "invalid"); 1084 1068 break; 1085 1069 case 7: 1086 - fprintf(stderr, "unlimited"); 1070 + fprintf(stderr, do_slm_cstates ? "pc7" : "unlimited"); 1087 1071 break; 1088 1072 default: 1089 1073 fprintf(stderr, "invalid"); ··· 1482 1460 case 0x3F: /* HSW */ 1483 1461 case 0x45: /* HSW */ 1484 1462 case 0x46: /* HSW */ 1463 + case 0x37: /* BYT */ 1464 + case 0x4D: /* AVN */ 1485 1465 return 1; 1486 1466 case 0x2E: /* Nehalem-EX Xeon - Beckton */ 1487 1467 case 0x2F: /* Westmere-EX Xeon - Eagleton */ ··· 1556 1532 #define RAPL_POWER_GRANULARITY 0x7FFF /* 15 bit power granularity */ 1557 1533 #define RAPL_TIME_GRANULARITY 0x3F /* 6 bit time granularity */ 1558 1534 1535 + double get_tdp(model) 1536 + { 1537 + unsigned long long msr; 1538 + 1539 + if (do_rapl & RAPL_PKG_POWER_INFO) 1540 + if (!get_msr(0, MSR_PKG_POWER_INFO, &msr)) 1541 + return ((msr >> 0) & RAPL_POWER_GRANULARITY) * rapl_power_units; 1542 + 1543 + switch (model) { 1544 + case 0x37: 1545 + case 0x4D: 1546 + return 30.0; 1547 + default: 1548 + return 135.0; 1549 + } 1550 + } 1551 + 1552 + 1559 1553 /* 1560 1554 * rapl_probe() 1561 1555 * 1562 - * sets do_rapl 1556 + * sets do_rapl, rapl_power_units, rapl_energy_units, rapl_time_units 1563 1557 */ 1564 1558 void rapl_probe(unsigned int family, unsigned int model) 1565 1559 { 1566 1560 unsigned long long msr; 1561 + unsigned int time_unit; 1567 1562 double tdp; 1568 1563 1569 1564 if (!genuine_intel) ··· 1598 1555 case 0x3F: /* HSW */ 1599 1556 case 0x45: /* HSW */ 1600 1557 case 0x46: /* HSW */ 1601 - do_rapl = RAPL_PKG | RAPL_CORES | RAPL_GFX; 1558 + do_rapl = RAPL_PKG | RAPL_CORES | RAPL_CORE_POLICY | RAPL_GFX | RAPL_PKG_POWER_INFO; 1602 1559 break; 1603 1560 case 0x2D: 1604 1561 case 0x3E: 1605 - do_rapl = RAPL_PKG | RAPL_CORES | RAPL_DRAM | RAPL_PKG_PERF_STATUS | RAPL_DRAM_PERF_STATUS; 1562 + do_rapl = RAPL_PKG | RAPL_CORES | RAPL_CORE_POLICY | RAPL_DRAM | RAPL_PKG_PERF_STATUS | RAPL_DRAM_PERF_STATUS | RAPL_PKG_POWER_INFO; 1563 + break; 1564 + case 0x37: /* BYT */ 1565 + case 0x4D: /* AVN */ 1566 + do_rapl = RAPL_PKG | RAPL_CORES ; 1606 1567 break; 1607 1568 default: 1608 1569 return; ··· 1617 1570 return; 1618 1571 1619 1572 rapl_power_units = 1.0 / (1 << (msr & 0xF)); 1620 - rapl_energy_units = 1.0 / (1 << (msr >> 8 & 0x1F)); 1621 - rapl_time_units = 1.0 / (1 << (msr >> 16 & 0xF)); 1573 + if (model == 0x37) 1574 + rapl_energy_units = 1.0 * (1 << (msr >> 8 & 0x1F)) / 1000000; 1575 + else 1576 + rapl_energy_units = 1.0 / (1 << (msr >> 8 & 0x1F)); 1622 1577 1623 - /* get TDP to determine energy counter range */ 1624 - if (get_msr(0, MSR_PKG_POWER_INFO, &msr)) 1625 - return; 1578 + time_unit = msr >> 16 & 0xF; 1579 + if (time_unit == 0) 1580 + time_unit = 0xA; 1626 1581 1627 - tdp = ((msr >> 0) & RAPL_POWER_GRANULARITY) * rapl_power_units; 1582 + rapl_time_units = 1.0 / (1 << (time_unit)); 1583 + 1584 + tdp = get_tdp(model); 1628 1585 1629 1586 rapl_joule_counter_range = 0xFFFFFFFF * rapl_energy_units / tdp; 1630 - 1631 1587 if (verbose) 1632 - fprintf(stderr, "RAPL: %.0f sec. Joule Counter Range\n", rapl_joule_counter_range); 1588 + fprintf(stderr, "RAPL: %.0f sec. Joule Counter Range, at %.0f Watts\n", rapl_joule_counter_range, tdp); 1633 1589 1634 1590 return; 1635 1591 } ··· 1718 1668 { 1719 1669 unsigned long long msr; 1720 1670 int cpu; 1721 - double local_rapl_power_units, local_rapl_energy_units, local_rapl_time_units; 1722 1671 1723 1672 if (!do_rapl) 1724 1673 return 0; ··· 1735 1686 if (get_msr(cpu, MSR_RAPL_POWER_UNIT, &msr)) 1736 1687 return -1; 1737 1688 1738 - local_rapl_power_units = 1.0 / (1 << (msr & 0xF)); 1739 - local_rapl_energy_units = 1.0 / (1 << (msr >> 8 & 0x1F)); 1740 - local_rapl_time_units = 1.0 / (1 << (msr >> 16 & 0xF)); 1741 - 1742 - if (local_rapl_power_units != rapl_power_units) 1743 - fprintf(stderr, "cpu%d, ERROR: Power units mis-match\n", cpu); 1744 - if (local_rapl_energy_units != rapl_energy_units) 1745 - fprintf(stderr, "cpu%d, ERROR: Energy units mis-match\n", cpu); 1746 - if (local_rapl_time_units != rapl_time_units) 1747 - fprintf(stderr, "cpu%d, ERROR: Time units mis-match\n", cpu); 1748 - 1749 1689 if (verbose) { 1750 1690 fprintf(stderr, "cpu%d: MSR_RAPL_POWER_UNIT: 0x%08llx " 1751 1691 "(%f Watts, %f Joules, %f sec.)\n", cpu, msr, 1752 - local_rapl_power_units, local_rapl_energy_units, local_rapl_time_units); 1692 + rapl_power_units, rapl_energy_units, rapl_time_units); 1753 1693 } 1754 - if (do_rapl & RAPL_PKG) { 1694 + if (do_rapl & RAPL_PKG_POWER_INFO) { 1695 + 1755 1696 if (get_msr(cpu, MSR_PKG_POWER_INFO, &msr)) 1756 1697 return -5; 1757 1698 ··· 1752 1713 ((msr >> 16) & RAPL_POWER_GRANULARITY) * rapl_power_units, 1753 1714 ((msr >> 32) & RAPL_POWER_GRANULARITY) * rapl_power_units, 1754 1715 ((msr >> 48) & RAPL_TIME_GRANULARITY) * rapl_time_units); 1716 + 1717 + } 1718 + if (do_rapl & RAPL_PKG) { 1755 1719 1756 1720 if (get_msr(cpu, MSR_PKG_POWER_LIMIT, &msr)) 1757 1721 return -9; ··· 1791 1749 1792 1750 print_power_limit_msr(cpu, msr, "DRAM Limit"); 1793 1751 } 1794 - if (do_rapl & RAPL_CORES) { 1752 + if (do_rapl & RAPL_CORE_POLICY) { 1795 1753 if (verbose) { 1796 1754 if (get_msr(cpu, MSR_PP0_POLICY, &msr)) 1797 1755 return -7; 1798 1756 1799 1757 fprintf(stderr, "cpu%d: MSR_PP0_POLICY: %lld\n", cpu, msr & 0xF); 1758 + } 1759 + } 1760 + if (do_rapl & RAPL_CORES) { 1761 + if (verbose) { 1800 1762 1801 1763 if (get_msr(cpu, MSR_PP0_POWER_LIMIT, &msr)) 1802 1764 return -9; ··· 1859 1813 } 1860 1814 1861 1815 1816 + int is_slm(unsigned int family, unsigned int model) 1817 + { 1818 + if (!genuine_intel) 1819 + return 0; 1820 + switch (model) { 1821 + case 0x37: /* BYT */ 1822 + case 0x4D: /* AVN */ 1823 + return 1; 1824 + } 1825 + return 0; 1826 + } 1827 + 1828 + #define SLM_BCLK_FREQS 5 1829 + double slm_freq_table[SLM_BCLK_FREQS] = { 83.3, 100.0, 133.3, 116.7, 80.0}; 1830 + 1831 + double slm_bclk(void) 1832 + { 1833 + unsigned long long msr = 3; 1834 + unsigned int i; 1835 + double freq; 1836 + 1837 + if (get_msr(0, MSR_FSB_FREQ, &msr)) 1838 + fprintf(stderr, "SLM BCLK: unknown\n"); 1839 + 1840 + i = msr & 0xf; 1841 + if (i >= SLM_BCLK_FREQS) { 1842 + fprintf(stderr, "SLM BCLK[%d] invalid\n", i); 1843 + msr = 3; 1844 + } 1845 + freq = slm_freq_table[i]; 1846 + 1847 + fprintf(stderr, "SLM BCLK: %.1f Mhz\n", freq); 1848 + 1849 + return freq; 1850 + } 1851 + 1862 1852 double discover_bclk(unsigned int family, unsigned int model) 1863 1853 { 1864 1854 if (is_snb(family, model)) 1865 1855 return 100.00; 1856 + else if (is_slm(family, model)) 1857 + return slm_bclk(); 1866 1858 else 1867 1859 return 133.33; 1868 1860 } ··· 1957 1873 fprintf(stderr, "cpu%d: MSR_IA32_TEMPERATURE_TARGET: 0x%08llx (%d C)\n", 1958 1874 cpu, msr, target_c_local); 1959 1875 1960 - if (target_c_local < 85 || target_c_local > 120) 1876 + if (target_c_local < 85 || target_c_local > 127) 1961 1877 goto guess; 1962 1878 1963 1879 tcc_activation_temp = target_c_local; ··· 2054 1970 do_smi = do_nhm_cstates; 2055 1971 do_snb_cstates = is_snb(family, model); 2056 1972 do_c8_c9_c10 = has_c8_c9_c10(family, model); 1973 + do_slm_cstates = is_slm(family, model); 2057 1974 bclk = discover_bclk(family, model); 2058 1975 2059 1976 do_nehalem_turbo_ratio_limit = has_nehalem_turbo_ratio_limit(family, model); ··· 2416 2331 cmdline(argc, argv); 2417 2332 2418 2333 if (verbose) 2419 - fprintf(stderr, "turbostat v3.4 April 17, 2013" 2334 + fprintf(stderr, "turbostat v3.5 April 26, 2013" 2420 2335 " - Len Brown <lenb@kernel.org>\n"); 2421 2336 2422 2337 turbostat_init();