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

Pull ACPI and PM fixes and new device IDs from Rafael Wysocki:
"These commits, except for one, are regression fixes and the remaining
one fixes a divide error leading to a kernel panic. The majority of
the regressions fixed here were introduced during the 3.12 cycle, one
of them is from this cycle and one is older.

Specifics:

- VGA switcheroo was broken for some users as a result of the
ACPI-based PCI hotplug (ACPIPHP) changes in 3.12, because some
previously ignored hotplug events started to be handled. The fix
causes them to be ignored again.

- There are two more issues related to cpufreq's suspend/resume
handling changes from the 3.12 cycle addressed by Viresh Kumar's
fixes.

- intel_pstate triggers a divide error in a timer function if the
P-state information it needs is missing during initialization.
This leads to kernel panics on nested KVM clients and is fixed by
failing the initialization cleanly in those cases.

- PCI initalization code changes during the 3.9 cycle uncovered BIOS
issues related to ACPI wakeup notifications (some BIOSes send them
for devices that aren't supposed to support ACPI wakeup). Work
around them by installing an ACPI wakeup notify handler for all PCI
devices with ACPI support.

- The Calxeda cpuilde driver's probe function is tagged as __init,
which is incorrect and causes a section mismatch to occur during
build. Fix from Andre Przywara removes the __init tag from there.

- During the 3.12 cycle ACPIPHP started to print warnings about
missing _ADR for devices that legitimately don't have it. Fix from
Toshi Kani makes it only print the warnings where they make sense"

* tag 'pm+acpi-3.13-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
ACPIPHP / radeon / nouveau: Fix VGA switcheroo problem related to hotplug
intel_pstate: Fail initialization if P-state information is missing
ARM/cpuidle: remove __init tag from Calxeda cpuidle probe function
PCI / ACPI: Install wakeup notify handlers for all PCI devs with ACPI
cpufreq: preserve user_policy across suspend/resume
cpufreq: Clean up after a failing light-weight initialization
ACPI / PCI / hotplug: Avoid warning when _ADR not present

Changed files
+108 -33
drivers
include
acpi
+10
drivers/acpi/bus.c
··· 156 156 } 157 157 EXPORT_SYMBOL(acpi_bus_get_private_data); 158 158 159 + void acpi_bus_no_hotplug(acpi_handle handle) 160 + { 161 + struct acpi_device *adev = NULL; 162 + 163 + acpi_bus_get_device(handle, &adev); 164 + if (adev) 165 + adev->flags.no_hotplug = true; 166 + } 167 + EXPORT_SYMBOL_GPL(acpi_bus_no_hotplug); 168 + 159 169 static void acpi_print_osc_error(acpi_handle handle, 160 170 struct acpi_osc_context *context, char *error) 161 171 {
+23 -14
drivers/cpufreq/cpufreq.c
··· 839 839 840 840 /* set default policy */ 841 841 ret = cpufreq_set_policy(policy, &new_policy); 842 - policy->user_policy.policy = policy->policy; 843 - policy->user_policy.governor = policy->governor; 844 - 845 842 if (ret) { 846 843 pr_debug("setting policy failed\n"); 847 844 if (cpufreq_driver->exit) ··· 1013 1016 read_unlock_irqrestore(&cpufreq_driver_lock, flags); 1014 1017 #endif 1015 1018 1016 - if (frozen) 1017 - /* Restore the saved policy when doing light-weight init */ 1018 - policy = cpufreq_policy_restore(cpu); 1019 - else 1019 + /* 1020 + * Restore the saved policy when doing light-weight init and fall back 1021 + * to the full init if that fails. 1022 + */ 1023 + policy = frozen ? cpufreq_policy_restore(cpu) : NULL; 1024 + if (!policy) { 1025 + frozen = false; 1020 1026 policy = cpufreq_policy_alloc(); 1021 - 1022 - if (!policy) 1023 - goto nomem_out; 1024 - 1027 + if (!policy) 1028 + goto nomem_out; 1029 + } 1025 1030 1026 1031 /* 1027 1032 * In the resume path, since we restore a saved policy, the assignment ··· 1068 1069 */ 1069 1070 cpumask_and(policy->cpus, policy->cpus, cpu_online_mask); 1070 1071 1071 - policy->user_policy.min = policy->min; 1072 - policy->user_policy.max = policy->max; 1072 + if (!frozen) { 1073 + policy->user_policy.min = policy->min; 1074 + policy->user_policy.max = policy->max; 1075 + } 1073 1076 1074 1077 blocking_notifier_call_chain(&cpufreq_policy_notifier_list, 1075 1078 CPUFREQ_START, policy); ··· 1102 1101 1103 1102 cpufreq_init_policy(policy); 1104 1103 1104 + if (!frozen) { 1105 + policy->user_policy.policy = policy->policy; 1106 + policy->user_policy.governor = policy->governor; 1107 + } 1108 + 1105 1109 kobject_uevent(&policy->kobj, KOBJ_ADD); 1106 1110 up_read(&cpufreq_rwsem); 1107 1111 ··· 1124 1118 if (cpufreq_driver->exit) 1125 1119 cpufreq_driver->exit(policy); 1126 1120 err_set_policy_cpu: 1127 - if (frozen) 1121 + if (frozen) { 1122 + /* Do not leave stale fallback data behind. */ 1123 + per_cpu(cpufreq_cpu_data_fallback, cpu) = NULL; 1128 1124 cpufreq_policy_put_kobj(policy); 1125 + } 1129 1126 cpufreq_policy_free(policy); 1130 1127 1131 1128 nomem_out:
+5
drivers/cpufreq/intel_pstate.c
··· 614 614 cpu = all_cpu_data[cpunum]; 615 615 616 616 intel_pstate_get_cpu_pstates(cpu); 617 + if (!cpu->pstate.current_pstate) { 618 + all_cpu_data[cpunum] = NULL; 619 + kfree(cpu); 620 + return -ENODATA; 621 + } 617 622 618 623 cpu->cpu = cpunum; 619 624
+1 -1
drivers/cpuidle/cpuidle-calxeda.c
··· 65 65 .state_count = 2, 66 66 }; 67 67 68 - static int __init calxeda_cpuidle_probe(struct platform_device *pdev) 68 + static int calxeda_cpuidle_probe(struct platform_device *pdev) 69 69 { 70 70 return cpuidle_register(&calxeda_idle_driver, NULL); 71 71 }
+14 -2
drivers/gpu/drm/nouveau/nouveau_acpi.c
··· 51 51 bool dsm_detected; 52 52 bool optimus_detected; 53 53 acpi_handle dhandle; 54 + acpi_handle other_handle; 54 55 acpi_handle rom_handle; 55 56 } nouveau_dsm_priv; 56 57 ··· 261 260 if (!dhandle) 262 261 return false; 263 262 264 - if (!acpi_has_method(dhandle, "_DSM")) 263 + if (!acpi_has_method(dhandle, "_DSM")) { 264 + nouveau_dsm_priv.other_handle = dhandle; 265 265 return false; 266 - 266 + } 267 267 if (nouveau_test_dsm(dhandle, nouveau_dsm, NOUVEAU_DSM_POWER)) 268 268 retval |= NOUVEAU_DSM_HAS_MUX; 269 269 ··· 340 338 printk(KERN_INFO "VGA switcheroo: detected DSM switching method %s handle\n", 341 339 acpi_method_name); 342 340 nouveau_dsm_priv.dsm_detected = true; 341 + /* 342 + * On some systems hotplug events are generated for the device 343 + * being switched off when _DSM is executed. They cause ACPI 344 + * hotplug to trigger and attempt to remove the device from 345 + * the system, which causes it to break down. Prevent that from 346 + * happening by setting the no_hotplug flag for the involved 347 + * ACPI device objects. 348 + */ 349 + acpi_bus_no_hotplug(nouveau_dsm_priv.dhandle); 350 + acpi_bus_no_hotplug(nouveau_dsm_priv.other_handle); 343 351 ret = true; 344 352 } 345 353
+14 -2
drivers/gpu/drm/radeon/radeon_atpx_handler.c
··· 33 33 bool atpx_detected; 34 34 /* handle for device - and atpx */ 35 35 acpi_handle dhandle; 36 + acpi_handle other_handle; 36 37 struct radeon_atpx atpx; 37 38 } radeon_atpx_priv; 38 39 ··· 452 451 return false; 453 452 454 453 status = acpi_get_handle(dhandle, "ATPX", &atpx_handle); 455 - if (ACPI_FAILURE(status)) 454 + if (ACPI_FAILURE(status)) { 455 + radeon_atpx_priv.other_handle = dhandle; 456 456 return false; 457 - 457 + } 458 458 radeon_atpx_priv.dhandle = dhandle; 459 459 radeon_atpx_priv.atpx.handle = atpx_handle; 460 460 return true; ··· 532 530 printk(KERN_INFO "VGA switcheroo: detected switching method %s handle\n", 533 531 acpi_method_name); 534 532 radeon_atpx_priv.atpx_detected = true; 533 + /* 534 + * On some systems hotplug events are generated for the device 535 + * being switched off when ATPX is executed. They cause ACPI 536 + * hotplug to trigger and attempt to remove the device from 537 + * the system, which causes it to break down. Prevent that from 538 + * happening by setting the no_hotplug flag for the involved 539 + * ACPI device objects. 540 + */ 541 + acpi_bus_no_hotplug(radeon_atpx_priv.dhandle); 542 + acpi_bus_no_hotplug(radeon_atpx_priv.other_handle); 535 543 return true; 536 544 } 537 545 return false;
+26 -4
drivers/pci/hotplug/acpiphp_glue.c
··· 279 279 280 280 status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr); 281 281 if (ACPI_FAILURE(status)) { 282 - acpi_handle_warn(handle, "can't evaluate _ADR (%#x)\n", status); 282 + if (status != AE_NOT_FOUND) 283 + acpi_handle_warn(handle, 284 + "can't evaluate _ADR (%#x)\n", status); 283 285 return AE_OK; 284 286 } 285 287 ··· 645 643 slot->flags &= (~SLOT_ENABLED); 646 644 } 647 645 646 + static bool acpiphp_no_hotplug(acpi_handle handle) 647 + { 648 + struct acpi_device *adev = NULL; 649 + 650 + acpi_bus_get_device(handle, &adev); 651 + return adev && adev->flags.no_hotplug; 652 + } 653 + 654 + static bool slot_no_hotplug(struct acpiphp_slot *slot) 655 + { 656 + struct acpiphp_func *func; 657 + 658 + list_for_each_entry(func, &slot->funcs, sibling) 659 + if (acpiphp_no_hotplug(func_to_handle(func))) 660 + return true; 661 + 662 + return false; 663 + } 648 664 649 665 /** 650 666 * get_slot_status - get ACPI slot status ··· 721 701 unsigned long long sta; 722 702 723 703 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); 724 - alive = ACPI_SUCCESS(status) && sta == ACPI_STA_ALL; 704 + alive = (ACPI_SUCCESS(status) && sta == ACPI_STA_ALL) 705 + || acpiphp_no_hotplug(handle); 725 706 } 726 707 if (!alive) { 727 708 u32 v; ··· 762 741 struct pci_dev *dev, *tmp; 763 742 764 743 mutex_lock(&slot->crit_sect); 765 - /* wake up all functions */ 766 - if (get_slot_status(slot) == ACPI_STA_ALL) { 744 + if (slot_no_hotplug(slot)) { 745 + ; /* do nothing */ 746 + } else if (get_slot_status(slot) == ACPI_STA_ALL) { 767 747 /* remove stale devices if any */ 768 748 list_for_each_entry_safe(dev, tmp, &bus->devices, 769 749 bus_list)
+12 -9
drivers/pci/pci-acpi.c
··· 330 330 static void pci_acpi_setup(struct device *dev) 331 331 { 332 332 struct pci_dev *pci_dev = to_pci_dev(dev); 333 - acpi_handle handle = ACPI_HANDLE(dev); 334 - struct acpi_device *adev; 333 + struct acpi_device *adev = ACPI_COMPANION(dev); 335 334 336 - if (acpi_bus_get_device(handle, &adev) || !adev->wakeup.flags.valid) 335 + if (!adev) 336 + return; 337 + 338 + pci_acpi_add_pm_notifier(adev, pci_dev); 339 + if (!adev->wakeup.flags.valid) 337 340 return; 338 341 339 342 device_set_wakeup_capable(dev, true); 340 343 acpi_pci_sleep_wake(pci_dev, false); 341 - 342 - pci_acpi_add_pm_notifier(adev, pci_dev); 343 344 if (adev->wakeup.flags.run_wake) 344 345 device_set_run_wake(dev, true); 345 346 } 346 347 347 348 static void pci_acpi_cleanup(struct device *dev) 348 349 { 349 - acpi_handle handle = ACPI_HANDLE(dev); 350 - struct acpi_device *adev; 350 + struct acpi_device *adev = ACPI_COMPANION(dev); 351 351 352 - if (!acpi_bus_get_device(handle, &adev) && adev->wakeup.flags.valid) { 352 + if (!adev) 353 + return; 354 + 355 + pci_acpi_remove_pm_notifier(adev); 356 + if (adev->wakeup.flags.valid) { 353 357 device_set_wakeup_capable(dev, false); 354 358 device_set_run_wake(dev, false); 355 - pci_acpi_remove_pm_notifier(adev); 356 359 } 357 360 } 358 361
+3 -1
include/acpi/acpi_bus.h
··· 169 169 u32 ejectable:1; 170 170 u32 power_manageable:1; 171 171 u32 match_driver:1; 172 - u32 reserved:27; 172 + u32 no_hotplug:1; 173 + u32 reserved:26; 173 174 }; 174 175 175 176 /* File System */ ··· 345 344 extern int acpi_bus_generate_netlink_event(const char*, const char*, u8, int); 346 345 void acpi_bus_private_data_handler(acpi_handle, void *); 347 346 int acpi_bus_get_private_data(acpi_handle, void **); 347 + void acpi_bus_no_hotplug(acpi_handle handle); 348 348 extern int acpi_notifier_call_chain(struct acpi_device *, u32, u32); 349 349 extern int register_acpi_notifier(struct notifier_block *); 350 350 extern int unregister_acpi_notifier(struct notifier_block *);