diff options
author | Nathan Fontenot <nfont@linux.vnet.ibm.com> | 2015-12-16 15:51:26 -0500 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2015-12-17 06:41:01 -0500 |
commit | d98389f375329b7a37d0e9211a1216d9141d7a5f (patch) | |
tree | 06f70c905f414156eb6f1b6bd94c02cad39417f1 | |
parent | 183deeea5871a6f750ec64ab1cff85fb089d38df (diff) |
powerpc/pseries: Factor out common cpu hotplug code
Re-factor the cpu hotplug code to support doing cpu hotplug completely in
the kernel and using the existing sysfs probe/release interfaces. This
patch pulls out pieces of existing cpu hotplug code into common routines,
dlpar_cpu_add() and dlpar_cpu_remove(), to be used by both interfaces.
There are no functional changes introduced.
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r-- | arch/powerpc/platforms/pseries/hotplug-cpu.c | 70 |
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 | |||
340 | static int dlpar_online_cpu(struct device_node *dn) | 338 | static 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 | ||
407 | static ssize_t dlpar_cpu_probe(const char *buf, size_t count) | 405 | static 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"); |
418 | if (!parent) | 411 | if (!parent) |
419 | return -ENODEV; | 412 | return -ENODEV; |
@@ -444,10 +437,7 @@ static ssize_t dlpar_cpu_probe(const char *buf, size_t count) | |||
444 | } | 437 | } |
445 | 438 | ||
446 | rc = dlpar_online_cpu(dn); | 439 | rc = dlpar_online_cpu(dn); |
447 | if (rc) | 440 | return rc; |
448 | return rc; | ||
449 | |||
450 | return count; | ||
451 | } | 441 | } |
452 | 442 | ||
453 | static int dlpar_offline_cpu(struct device_node *dn) | 443 | static int dlpar_offline_cpu(struct device_node *dn) |
@@ -506,6 +496,41 @@ out: | |||
506 | 496 | ||
507 | } | 497 | } |
508 | 498 | ||
499 | static 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 | |||
520 | static 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 | |||
509 | static ssize_t dlpar_cpu_release(const char *buf, size_t count) | 534 | static 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 */ |