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

Merge branch 'acpi-hotplug'

* acpi-hotplug:
ACPI / memhotplug: Use defined marco METHOD_NAME__STA
ACPI / hotplug: Use kobject_init_and_add() instead of _init() and _add()
ACPI / hotplug: Don't set kobject parent pointer explicitly
ACPI / hotplug: Set kobject name via kobject_add(), not kobject_set_name()
hotplug, powerpc, x86: Remove cpu_hotplug_driver_lock()
hotplug / x86: Disable ARCH_CPU_PROBE_RELEASE on x86
hotplug / x86: Add hotplug lock to missing places
hotplug / x86: Fix online state in cpu0 debug interface

+53 -104
-12
arch/powerpc/kernel/smp.c
··· 844 844 smp_ops->cpu_die(cpu); 845 845 } 846 846 847 - static DEFINE_MUTEX(powerpc_cpu_hotplug_driver_mutex); 848 - 849 - void cpu_hotplug_driver_lock() 850 - { 851 - mutex_lock(&powerpc_cpu_hotplug_driver_mutex); 852 - } 853 - 854 - void cpu_hotplug_driver_unlock() 855 - { 856 - mutex_unlock(&powerpc_cpu_hotplug_driver_mutex); 857 - } 858 - 859 847 void cpu_die(void) 860 848 { 861 849 if (ppc_md.cpu_die)
+16 -27
arch/powerpc/platforms/pseries/dlpar.c
··· 404 404 unsigned long drc_index; 405 405 int rc; 406 406 407 - cpu_hotplug_driver_lock(); 408 407 rc = strict_strtoul(buf, 0, &drc_index); 409 - if (rc) { 410 - rc = -EINVAL; 411 - goto out; 412 - } 408 + if (rc) 409 + return -EINVAL; 413 410 414 411 parent = of_find_node_by_path("/cpus"); 415 - if (!parent) { 416 - rc = -ENODEV; 417 - goto out; 418 - } 412 + if (!parent) 413 + return -ENODEV; 419 414 420 415 dn = dlpar_configure_connector(drc_index, parent); 421 - if (!dn) { 422 - rc = -EINVAL; 423 - goto out; 424 - } 416 + if (!dn) 417 + return -EINVAL; 425 418 426 419 of_node_put(parent); 427 420 428 421 rc = dlpar_acquire_drc(drc_index); 429 422 if (rc) { 430 423 dlpar_free_cc_nodes(dn); 431 - rc = -EINVAL; 432 - goto out; 424 + return -EINVAL; 433 425 } 434 426 435 427 rc = dlpar_attach_node(dn); 436 428 if (rc) { 437 429 dlpar_release_drc(drc_index); 438 430 dlpar_free_cc_nodes(dn); 439 - goto out; 431 + return rc; 440 432 } 441 433 442 434 rc = dlpar_online_cpu(dn); 443 - out: 444 - cpu_hotplug_driver_unlock(); 435 + if (rc) 436 + return rc; 445 437 446 - return rc ? rc : count; 438 + return count; 447 439 } 448 440 449 441 static int dlpar_offline_cpu(struct device_node *dn) ··· 508 516 return -EINVAL; 509 517 } 510 518 511 - cpu_hotplug_driver_lock(); 512 519 rc = dlpar_offline_cpu(dn); 513 520 if (rc) { 514 521 of_node_put(dn); 515 - rc = -EINVAL; 516 - goto out; 522 + return -EINVAL; 517 523 } 518 524 519 525 rc = dlpar_release_drc(*drc_index); 520 526 if (rc) { 521 527 of_node_put(dn); 522 - goto out; 528 + return rc; 523 529 } 524 530 525 531 rc = dlpar_detach_node(dn); 526 532 if (rc) { 527 533 dlpar_acquire_drc(*drc_index); 528 - goto out; 534 + return rc; 529 535 } 530 536 531 537 of_node_put(dn); 532 - out: 533 - cpu_hotplug_driver_unlock(); 534 - return rc ? rc : count; 538 + 539 + return count; 535 540 } 536 541 537 542 static int __init pseries_dlpar_init(void)
-4
arch/x86/Kconfig
··· 254 254 default "-fcall-saved-ecx -fcall-saved-edx" if X86_32 255 255 default "-fcall-saved-rdi -fcall-saved-rsi -fcall-saved-rdx -fcall-saved-rcx -fcall-saved-r8 -fcall-saved-r9 -fcall-saved-r10 -fcall-saved-r11" if X86_64 256 256 257 - config ARCH_CPU_PROBE_RELEASE 258 - def_bool y 259 - depends on HOTPLUG_CPU 260 - 261 257 config ARCH_SUPPORTS_UPROBES 262 258 def_bool y 263 259
-21
arch/x86/kernel/smpboot.c
··· 82 82 /* State of each CPU */ 83 83 DEFINE_PER_CPU(int, cpu_state) = { 0 }; 84 84 85 - #ifdef CONFIG_HOTPLUG_CPU 86 - /* 87 - * We need this for trampoline_base protection from concurrent accesses when 88 - * off- and onlining cores wildly. 89 - */ 90 - static DEFINE_MUTEX(x86_cpu_hotplug_driver_mutex); 91 - 92 - void cpu_hotplug_driver_lock(void) 93 - { 94 - mutex_lock(&x86_cpu_hotplug_driver_mutex); 95 - } 96 - 97 - void cpu_hotplug_driver_unlock(void) 98 - { 99 - mutex_unlock(&x86_cpu_hotplug_driver_mutex); 100 - } 101 - 102 - ssize_t arch_cpu_probe(const char *buf, size_t count) { return -1; } 103 - ssize_t arch_cpu_release(const char *buf, size_t count) { return -1; } 104 - #endif 105 - 106 85 /* Number of siblings per CPU package */ 107 86 int smp_num_siblings = 1; 108 87 EXPORT_SYMBOL(smp_num_siblings);
+7 -4
arch/x86/kernel/topology.c
··· 65 65 if (!cpu_is_hotpluggable(cpu)) 66 66 return -EINVAL; 67 67 68 - cpu_hotplug_driver_lock(); 68 + lock_device_hotplug(); 69 69 70 70 switch (action) { 71 71 case 0: 72 72 ret = cpu_down(cpu); 73 73 if (!ret) { 74 74 pr_info("CPU %u is now offline\n", cpu); 75 + dev->offline = true; 75 76 kobject_uevent(&dev->kobj, KOBJ_OFFLINE); 76 77 } else 77 78 pr_debug("Can't offline CPU%d.\n", cpu); 78 79 break; 79 80 case 1: 80 81 ret = cpu_up(cpu); 81 - if (!ret) 82 + if (!ret) { 83 + dev->offline = false; 82 84 kobject_uevent(&dev->kobj, KOBJ_ONLINE); 83 - else 85 + } else { 84 86 pr_debug("Can't online CPU%d.\n", cpu); 87 + } 85 88 break; 86 89 default: 87 90 ret = -EINVAL; 88 91 } 89 92 90 - cpu_hotplug_driver_unlock(); 93 + unlock_device_hotplug(); 91 94 92 95 return ret; 93 96 }
+3 -2
drivers/acpi/acpi_memhotplug.c
··· 152 152 unsigned long long current_status; 153 153 154 154 /* Get device present/absent information from the _STA */ 155 - if (ACPI_FAILURE(acpi_evaluate_integer(mem_device->device->handle, "_STA", 156 - NULL, &current_status))) 155 + if (ACPI_FAILURE(acpi_evaluate_integer(mem_device->device->handle, 156 + METHOD_NAME__STA, NULL, 157 + &current_status))) 157 158 return -ENODEV; 158 159 /* 159 160 * Check for device status. Device should be
+2 -7
drivers/acpi/sysfs.c
··· 762 762 if (!hotplug_kobj) 763 763 goto err_out; 764 764 765 - kobject_init(&hotplug->kobj, &acpi_hotplug_profile_ktype); 766 - error = kobject_set_name(&hotplug->kobj, "%s", name); 767 - if (error) 768 - goto err_out; 769 - 770 - hotplug->kobj.parent = hotplug_kobj; 771 - error = kobject_add(&hotplug->kobj, hotplug_kobj, NULL); 765 + error = kobject_init_and_add(&hotplug->kobj, 766 + &acpi_hotplug_profile_ktype, hotplug_kobj, "%s", name); 772 767 if (error) 773 768 goto err_out; 774 769
+25 -14
drivers/base/cpu.c
··· 44 44 struct cpu *cpu = container_of(dev, struct cpu, dev); 45 45 int cpuid = dev->id; 46 46 int from_nid, to_nid; 47 - int ret = -ENODEV; 48 - 49 - cpu_hotplug_driver_lock(); 47 + int ret; 50 48 51 49 from_nid = cpu_to_node(cpuid); 52 50 if (from_nid == NUMA_NO_NODE) 53 - goto out; 51 + return -ENODEV; 54 52 55 53 ret = cpu_up(cpuid); 56 54 /* ··· 59 61 if (from_nid != to_nid) 60 62 change_cpu_under_node(cpu, from_nid, to_nid); 61 63 62 - out: 63 - cpu_hotplug_driver_unlock(); 64 64 return ret; 65 65 } 66 66 67 67 static int cpu_subsys_offline(struct device *dev) 68 68 { 69 - int ret; 70 - 71 - cpu_hotplug_driver_lock(); 72 - ret = cpu_down(dev->id); 73 - cpu_hotplug_driver_unlock(); 74 - return ret; 69 + return cpu_down(dev->id); 75 70 } 76 71 77 72 void unregister_cpu(struct cpu *cpu) ··· 84 93 const char *buf, 85 94 size_t count) 86 95 { 87 - return arch_cpu_probe(buf, count); 96 + ssize_t cnt; 97 + int ret; 98 + 99 + ret = lock_device_hotplug_sysfs(); 100 + if (ret) 101 + return ret; 102 + 103 + cnt = arch_cpu_probe(buf, count); 104 + 105 + unlock_device_hotplug(); 106 + return cnt; 88 107 } 89 108 90 109 static ssize_t cpu_release_store(struct device *dev, ··· 102 101 const char *buf, 103 102 size_t count) 104 103 { 105 - return arch_cpu_release(buf, count); 104 + ssize_t cnt; 105 + int ret; 106 + 107 + ret = lock_device_hotplug_sysfs(); 108 + if (ret) 109 + return ret; 110 + 111 + cnt = arch_cpu_release(buf, count); 112 + 113 + unlock_device_hotplug(); 114 + return cnt; 106 115 } 107 116 108 117 static DEVICE_ATTR(probe, S_IWUSR, NULL, cpu_probe_store);
-13
include/linux/cpu.h
··· 185 185 void clear_tasks_mm_cpumask(int cpu); 186 186 int cpu_down(unsigned int cpu); 187 187 188 - #ifdef CONFIG_ARCH_CPU_PROBE_RELEASE 189 - extern void cpu_hotplug_driver_lock(void); 190 - extern void cpu_hotplug_driver_unlock(void); 191 - #else 192 - static inline void cpu_hotplug_driver_lock(void) 193 - { 194 - } 195 - 196 - static inline void cpu_hotplug_driver_unlock(void) 197 - { 198 - } 199 - #endif 200 - 201 188 #else /* CONFIG_HOTPLUG_CPU */ 202 189 203 190 static inline void cpu_hotplug_begin(void) {}