aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorToshi Kani <toshi.kani@hp.com>2013-09-25 17:08:27 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-09-30 13:55:51 -0400
commit6dedcca610c6d6189b4a54d32118d1654adb73d2 (patch)
tree981de5689216d41a594a1aea945fc48ab0fc888f
parent1cad5e9a3978d182aa9b0e909fb0379da5ba45af (diff)
hotplug, powerpc, x86: Remove cpu_hotplug_driver_lock()
cpu_hotplug_driver_lock() serializes CPU online/offline operations when ARCH_CPU_PROBE_RELEASE is set. This lock interface is no longer necessary with the following reason: - lock_device_hotplug() now protects CPU online/offline operations, including the probe & release interfaces enabled by ARCH_CPU_PROBE_RELEASE. The use of cpu_hotplug_driver_lock() is redundant. - cpu_hotplug_driver_lock() is only valid when ARCH_CPU_PROBE_RELEASE is defined, which is misleading and is only enabled on powerpc. This patch removes the cpu_hotplug_driver_lock() interface. As a result, ARCH_CPU_PROBE_RELEASE only enables / disables the cpu probe & release interface as intended. There is no functional change in this patch. Signed-off-by: Toshi Kani <toshi.kani@hp.com> Reviewed-by: Nathan Fontenot <nfont@linux.vnet.ibm.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--arch/powerpc/kernel/smp.c12
-rw-r--r--arch/powerpc/platforms/pseries/dlpar.c43
-rw-r--r--arch/x86/kernel/topology.c2
-rw-r--r--drivers/base/cpu.c15
-rw-r--r--include/linux/cpu.h13
5 files changed, 19 insertions, 66 deletions
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 8e59abc237d7..930cd8af3503 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -844,18 +844,6 @@ void __cpu_die(unsigned int cpu)
844 smp_ops->cpu_die(cpu); 844 smp_ops->cpu_die(cpu);
845} 845}
846 846
847static DEFINE_MUTEX(powerpc_cpu_hotplug_driver_mutex);
848
849void cpu_hotplug_driver_lock()
850{
851 mutex_lock(&powerpc_cpu_hotplug_driver_mutex);
852}
853
854void cpu_hotplug_driver_unlock()
855{
856 mutex_unlock(&powerpc_cpu_hotplug_driver_mutex);
857}
858
859void cpu_die(void) 847void cpu_die(void)
860{ 848{
861 if (ppc_md.cpu_die) 849 if (ppc_md.cpu_die)
diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
index 7cfdaae1721a..a8fe5aa3d34f 100644
--- a/arch/powerpc/platforms/pseries/dlpar.c
+++ b/arch/powerpc/platforms/pseries/dlpar.c
@@ -404,46 +404,38 @@ static ssize_t dlpar_cpu_probe(const char *buf, size_t count)
404 unsigned long drc_index; 404 unsigned long drc_index;
405 int rc; 405 int rc;
406 406
407 cpu_hotplug_driver_lock();
408 rc = strict_strtoul(buf, 0, &drc_index); 407 rc = strict_strtoul(buf, 0, &drc_index);
409 if (rc) { 408 if (rc)
410 rc = -EINVAL; 409 return -EINVAL;
411 goto out;
412 }
413 410
414 parent = of_find_node_by_path("/cpus"); 411 parent = of_find_node_by_path("/cpus");
415 if (!parent) { 412 if (!parent)
416 rc = -ENODEV; 413 return -ENODEV;
417 goto out;
418 }
419 414
420 dn = dlpar_configure_connector(drc_index, parent); 415 dn = dlpar_configure_connector(drc_index, parent);
421 if (!dn) { 416 if (!dn)
422 rc = -EINVAL; 417 return -EINVAL;
423 goto out;
424 }
425 418
426 of_node_put(parent); 419 of_node_put(parent);
427 420
428 rc = dlpar_acquire_drc(drc_index); 421 rc = dlpar_acquire_drc(drc_index);
429 if (rc) { 422 if (rc) {
430 dlpar_free_cc_nodes(dn); 423 dlpar_free_cc_nodes(dn);
431 rc = -EINVAL; 424 return -EINVAL;
432 goto out;
433 } 425 }
434 426
435 rc = dlpar_attach_node(dn); 427 rc = dlpar_attach_node(dn);
436 if (rc) { 428 if (rc) {
437 dlpar_release_drc(drc_index); 429 dlpar_release_drc(drc_index);
438 dlpar_free_cc_nodes(dn); 430 dlpar_free_cc_nodes(dn);
439 goto out; 431 return rc;
440 } 432 }
441 433
442 rc = dlpar_online_cpu(dn); 434 rc = dlpar_online_cpu(dn);
443out: 435 if (rc)
444 cpu_hotplug_driver_unlock(); 436 return rc;
445 437
446 return rc ? rc : count; 438 return count;
447} 439}
448 440
449static int dlpar_offline_cpu(struct device_node *dn) 441static int dlpar_offline_cpu(struct device_node *dn)
@@ -516,30 +508,27 @@ static ssize_t dlpar_cpu_release(const char *buf, size_t count)
516 return -EINVAL; 508 return -EINVAL;
517 } 509 }
518 510
519 cpu_hotplug_driver_lock();
520 rc = dlpar_offline_cpu(dn); 511 rc = dlpar_offline_cpu(dn);
521 if (rc) { 512 if (rc) {
522 of_node_put(dn); 513 of_node_put(dn);
523 rc = -EINVAL; 514 return -EINVAL;
524 goto out;
525 } 515 }
526 516
527 rc = dlpar_release_drc(*drc_index); 517 rc = dlpar_release_drc(*drc_index);
528 if (rc) { 518 if (rc) {
529 of_node_put(dn); 519 of_node_put(dn);
530 goto out; 520 return rc;
531 } 521 }
532 522
533 rc = dlpar_detach_node(dn); 523 rc = dlpar_detach_node(dn);
534 if (rc) { 524 if (rc) {
535 dlpar_acquire_drc(*drc_index); 525 dlpar_acquire_drc(*drc_index);
536 goto out; 526 return rc;
537 } 527 }
538 528
539 of_node_put(dn); 529 of_node_put(dn);
540out: 530
541 cpu_hotplug_driver_unlock(); 531 return count;
542 return rc ? rc : count;
543} 532}
544 533
545static int __init pseries_dlpar_init(void) 534static int __init pseries_dlpar_init(void)
diff --git a/arch/x86/kernel/topology.c b/arch/x86/kernel/topology.c
index a3f35ebb3b52..649b010da00b 100644
--- a/arch/x86/kernel/topology.c
+++ b/arch/x86/kernel/topology.c
@@ -66,7 +66,6 @@ int __ref _debug_hotplug_cpu(int cpu, int action)
66 return -EINVAL; 66 return -EINVAL;
67 67
68 lock_device_hotplug(); 68 lock_device_hotplug();
69 cpu_hotplug_driver_lock();
70 69
71 switch (action) { 70 switch (action) {
72 case 0: 71 case 0:
@@ -91,7 +90,6 @@ int __ref _debug_hotplug_cpu(int cpu, int action)
91 ret = -EINVAL; 90 ret = -EINVAL;
92 } 91 }
93 92
94 cpu_hotplug_driver_unlock();
95 unlock_device_hotplug(); 93 unlock_device_hotplug();
96 94
97 return ret; 95 return ret;
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 51f5d7fe2f0b..f48370dfc908 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -44,13 +44,11 @@ static int __ref cpu_subsys_online(struct device *dev)
44 struct cpu *cpu = container_of(dev, struct cpu, dev); 44 struct cpu *cpu = container_of(dev, struct cpu, dev);
45 int cpuid = dev->id; 45 int cpuid = dev->id;
46 int from_nid, to_nid; 46 int from_nid, to_nid;
47 int ret = -ENODEV; 47 int ret;
48
49 cpu_hotplug_driver_lock();
50 48
51 from_nid = cpu_to_node(cpuid); 49 from_nid = cpu_to_node(cpuid);
52 if (from_nid == NUMA_NO_NODE) 50 if (from_nid == NUMA_NO_NODE)
53 goto out; 51 return -ENODEV;
54 52
55 ret = cpu_up(cpuid); 53 ret = cpu_up(cpuid);
56 /* 54 /*
@@ -61,19 +59,12 @@ static int __ref cpu_subsys_online(struct device *dev)
61 if (from_nid != to_nid) 59 if (from_nid != to_nid)
62 change_cpu_under_node(cpu, from_nid, to_nid); 60 change_cpu_under_node(cpu, from_nid, to_nid);
63 61
64 out:
65 cpu_hotplug_driver_unlock();
66 return ret; 62 return ret;
67} 63}
68 64
69static int cpu_subsys_offline(struct device *dev) 65static int cpu_subsys_offline(struct device *dev)
70{ 66{
71 int ret; 67 return cpu_down(dev->id);
72
73 cpu_hotplug_driver_lock();
74 ret = cpu_down(dev->id);
75 cpu_hotplug_driver_unlock();
76 return ret;
77} 68}
78 69
79void unregister_cpu(struct cpu *cpu) 70void unregister_cpu(struct cpu *cpu)
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 801ff9e73679..3434ef7de017 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -185,19 +185,6 @@ extern void cpu_hotplug_enable(void);
185void clear_tasks_mm_cpumask(int cpu); 185void clear_tasks_mm_cpumask(int cpu);
186int cpu_down(unsigned int cpu); 186int cpu_down(unsigned int cpu);
187 187
188#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
189extern void cpu_hotplug_driver_lock(void);
190extern void cpu_hotplug_driver_unlock(void);
191#else
192static inline void cpu_hotplug_driver_lock(void)
193{
194}
195
196static inline void cpu_hotplug_driver_unlock(void)
197{
198}
199#endif
200
201#else /* CONFIG_HOTPLUG_CPU */ 188#else /* CONFIG_HOTPLUG_CPU */
202 189
203static inline void cpu_hotplug_begin(void) {} 190static inline void cpu_hotplug_begin(void) {}