Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7cc277b4 authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Thomas Gleixner
Browse files

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: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarThomas 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: default avatarThomas Gleixner <tglx@linutronix.de>
parent dfbbd86a
Loading
Loading
Loading
Loading
+16 −43
Original line number Original line Diff line number Diff line
@@ -498,57 +498,30 @@ static int cache_add_dev(unsigned int cpu)
	return rc;
	return rc;
}
}


static void cache_remove_dev(unsigned int cpu)
static int cacheinfo_cpu_online(unsigned int cpu)
{
{
	if (!cpumask_test_cpu(cpu, &cache_dev_map))
	int rc = detect_cache_attributes(cpu);
		return;
	cpumask_clear_cpu(cpu, &cache_dev_map);

	cpu_cache_sysfs_exit(cpu);
}

static int cacheinfo_cpu_callback(struct notifier_block *nfb,
				  unsigned long action, void *hcpu)
{
	unsigned int cpu = (unsigned long)hcpu;
	int rc = 0;


	switch (action & ~CPU_TASKS_FROZEN) {
	if (rc)
	case CPU_ONLINE:
		return rc;
		rc = detect_cache_attributes(cpu);
		if (!rc)
	rc = cache_add_dev(cpu);
	rc = cache_add_dev(cpu);
		break;
	if (rc)
	case CPU_DEAD:
		cache_remove_dev(cpu);
		free_cache_attributes(cpu);
		free_cache_attributes(cpu);
		break;
	return rc;
	}
	return notifier_from_errno(rc);
}
}


static int __init cacheinfo_sysfs_init(void)
static int cacheinfo_cpu_pre_down(unsigned int cpu)
{
{
	int cpu, rc = 0;
	if (cpumask_test_and_clear_cpu(cpu, &cache_dev_map))

		cpu_cache_sysfs_exit(cpu);
	cpu_notifier_register_begin();


	for_each_online_cpu(cpu) {
		rc = detect_cache_attributes(cpu);
		if (rc)
			goto out;
		rc = cache_add_dev(cpu);
		if (rc) {
	free_cache_attributes(cpu);
	free_cache_attributes(cpu);
			pr_err("error populating cacheinfo..cpu%d\n", cpu);
	return 0;
			goto out;
		}
}
}
	__hotcpu_notifier(cacheinfo_cpu_callback, 0);


out:
static int __init cacheinfo_sysfs_init(void)
	cpu_notifier_register_done();
{
	return rc;
	return cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "base/cacheinfo:online",
				 cacheinfo_cpu_online, cacheinfo_cpu_pre_down);
}
}

device_initcall(cacheinfo_sysfs_init);
device_initcall(cacheinfo_sysfs_init);