diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2016-11-03 10:50:08 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2016-11-09 17:45:29 -0500 |
commit | 7cc277b489b4fe91f42eb596b282879c2d13152e (patch) | |
tree | fb36ccbad2bd772cbc963a7236fbd776e8c2b687 | |
parent | dfbbd86a0f1c3ceec15b64c8f2149a903806ed8c (diff) |
drivers base/cacheinfo: Convert to hotplug state machine
Install the callbacks via the state machine and let the core invoke
the callbacks on the already online CPUs. No functional change.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20161103145021.28528-13-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | drivers/base/cacheinfo.c | 59 |
1 files changed, 16 insertions, 43 deletions
diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index e9fd32e91668..47983a2ba621 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c | |||
@@ -498,57 +498,30 @@ err: | |||
498 | return rc; | 498 | return rc; |
499 | } | 499 | } |
500 | 500 | ||
501 | static void cache_remove_dev(unsigned int cpu) | 501 | static int cacheinfo_cpu_online(unsigned int cpu) |
502 | { | 502 | { |
503 | if (!cpumask_test_cpu(cpu, &cache_dev_map)) | 503 | int rc = detect_cache_attributes(cpu); |
504 | return; | ||
505 | cpumask_clear_cpu(cpu, &cache_dev_map); | ||
506 | 504 | ||
507 | cpu_cache_sysfs_exit(cpu); | 505 | if (rc) |
506 | return rc; | ||
507 | rc = cache_add_dev(cpu); | ||
508 | if (rc) | ||
509 | free_cache_attributes(cpu); | ||
510 | return rc; | ||
508 | } | 511 | } |
509 | 512 | ||
510 | static int cacheinfo_cpu_callback(struct notifier_block *nfb, | 513 | static int cacheinfo_cpu_pre_down(unsigned int cpu) |
511 | unsigned long action, void *hcpu) | ||
512 | { | 514 | { |
513 | unsigned int cpu = (unsigned long)hcpu; | 515 | if (cpumask_test_and_clear_cpu(cpu, &cache_dev_map)) |
514 | int rc = 0; | 516 | cpu_cache_sysfs_exit(cpu); |
515 | 517 | ||
516 | switch (action & ~CPU_TASKS_FROZEN) { | 518 | free_cache_attributes(cpu); |
517 | case CPU_ONLINE: | 519 | return 0; |
518 | rc = detect_cache_attributes(cpu); | ||
519 | if (!rc) | ||
520 | rc = cache_add_dev(cpu); | ||
521 | break; | ||
522 | case CPU_DEAD: | ||
523 | cache_remove_dev(cpu); | ||
524 | free_cache_attributes(cpu); | ||
525 | break; | ||
526 | } | ||
527 | return notifier_from_errno(rc); | ||
528 | } | 520 | } |
529 | 521 | ||
530 | static int __init cacheinfo_sysfs_init(void) | 522 | static int __init cacheinfo_sysfs_init(void) |
531 | { | 523 | { |
532 | int cpu, rc = 0; | 524 | return cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "base/cacheinfo:online", |
533 | 525 | cacheinfo_cpu_online, cacheinfo_cpu_pre_down); | |
534 | cpu_notifier_register_begin(); | ||
535 | |||
536 | for_each_online_cpu(cpu) { | ||
537 | rc = detect_cache_attributes(cpu); | ||
538 | if (rc) | ||
539 | goto out; | ||
540 | rc = cache_add_dev(cpu); | ||
541 | if (rc) { | ||
542 | free_cache_attributes(cpu); | ||
543 | pr_err("error populating cacheinfo..cpu%d\n", cpu); | ||
544 | goto out; | ||
545 | } | ||
546 | } | ||
547 | __hotcpu_notifier(cacheinfo_cpu_callback, 0); | ||
548 | |||
549 | out: | ||
550 | cpu_notifier_register_done(); | ||
551 | return rc; | ||
552 | } | 526 | } |
553 | |||
554 | device_initcall(cacheinfo_sysfs_init); | 527 | device_initcall(cacheinfo_sysfs_init); |