aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/powerpc/platforms/pseries/hotplug-cpu.c70
1 files changed, 39 insertions, 31 deletions
diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c
index 66d8c2c64aa9..6fb28cf229e7 100644
--- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
+++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
@@ -335,8 +335,6 @@ static void pseries_remove_processor(struct device_node *np)
335 cpu_maps_update_done(); 335 cpu_maps_update_done();
336} 336}
337 337
338#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
339
340static int dlpar_online_cpu(struct device_node *dn) 338static int dlpar_online_cpu(struct device_node *dn)
341{ 339{
342 int rc = 0; 340 int rc = 0;
@@ -404,16 +402,11 @@ static bool dlpar_cpu_exists(struct device_node *parent, u32 drc_index)
404 return found; 402 return found;
405} 403}
406 404
407static ssize_t dlpar_cpu_probe(const char *buf, size_t count) 405static ssize_t dlpar_cpu_add(u32 drc_index)
408{ 406{
409 struct device_node *dn, *parent; 407 struct device_node *dn, *parent;
410 u32 drc_index;
411 int rc; 408 int rc;
412 409
413 rc = kstrtou32(buf, 0, &drc_index);
414 if (rc)
415 return -EINVAL;
416
417 parent = of_find_node_by_path("/cpus"); 410 parent = of_find_node_by_path("/cpus");
499static ssize_t dlpar_cpu_remove(struct device_node *dn, u32 drc_index)
500{
501 int rc;
502
503 rc = dlpar_offline_cpu(dn);
504 if (rc)
505 return -EINVAL;
506
507 rc = dlpar_release_drc(drc_index);
508 if (rc)
509 return rc;
510
511 rc = dlpar_detach_node(dn);
512 if (rc)
513 dlpar_acquire_drc(drc_index);
514
515 return rc;
516}
517
518#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
519
520static ssize_t dlpar_cpu_probe(const char *buf, size_t count)
521{
522 u32 drc_index;
523 int rc;
524
525 rc = kstrtou32(buf, 0, &drc_index);
526 if (rc)
527 return -EINVAL;
528
529 rc = dlpar_cpu_add(drc_index);
530
531 return rc ? rc : count;
532}
533
509static ssize_t dlpar_cpu_release(const char *buf, size_t count) 534static ssize_t dlpar_cpu_release(const char *buf, size_t count)
510{ 535{
511 struct device_node *dn; 536 struct device_node *dn;
@@ -522,27 +547,10 @@ static ssize_t dlpar_cpu_release(const char *buf, size_t count)
522 return -EINVAL; 547 return -EINVAL;
523 } 548 }
524 549
525 rc = dlpar_offline_cpu(dn); 550 rc = dlpar_cpu_remove(dn, drc_index);
526 if (rc) {
527 of_node_put(dn);
528 return -EINVAL;
529 }
530
531 rc = dlpar_release_drc(drc_index);
532 if (rc) {
533 of_node_put(dn);
534 return rc;
535 }
536
537 rc = dlpar_detach_node(dn);
538 if (rc) {
539 dlpar_acquire_drc(drc_index);
540 return rc;
541 }
542
543 of_node_put(dn); 551 of_node_put(dn);
544 552
545 return count; 553 return rc ? rc : count;
546} 554}
547 555
548#endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */ 556#endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */