Commit 28c94843 authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Ingo Molnar

bus/arm-cci: Convert to hotplug statemachine

Install the callbacks via the state machine and let the core invoke
the callbacks on the already online CPUs.
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarAnna-Maria Gleixner <anna-maria@linutronix.de>
Cc: Andrzej Hajda <a.hajda@samsung.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Olof Johansson <olof@lixom.net>
Cc: Pawel Moll <pawel.moll@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Punit Agrawal <punit.agrawal@arm.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Suzuki K. Poulose <suzuki.poulose@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will.deacon@arm.com>
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160713153334.679142601@linutronix.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent e3cfce17
...@@ -144,12 +144,15 @@ struct cci_pmu { ...@@ -144,12 +144,15 @@ struct cci_pmu {
int num_cntrs; int num_cntrs;
atomic_t active_events; atomic_t active_events;
struct mutex reserve_mutex; struct mutex reserve_mutex;
struct notifier_block cpu_nb; struct list_head entry;
cpumask_t cpus; cpumask_t cpus;
}; };
#define to_cci_pmu(c) (container_of(c, struct cci_pmu, pmu)) #define to_cci_pmu(c) (container_of(c, struct cci_pmu, pmu))
static DEFINE_MUTEX(cci_pmu_mutex);
static LIST_HEAD(cci_pmu_list);
enum cci_models { enum cci_models {
#ifdef CONFIG_ARM_CCI400_PMU #ifdef CONFIG_ARM_CCI400_PMU
CCI400_R0, CCI400_R0,
...@@ -1503,31 +1506,26 @@ static int cci_pmu_init(struct cci_pmu *cci_pmu, struct platform_device *pdev) ...@@ -1503,31 +1506,26 @@ static int cci_pmu_init(struct cci_pmu *cci_pmu, struct platform_device *pdev)
return perf_pmu_register(&cci_pmu->pmu, name, -1); return perf_pmu_register(&cci_pmu->pmu, name, -1);
} }
static int cci_pmu_cpu_notifier(struct notifier_block *self, static int cci_pmu_offline_cpu(unsigned int cpu)
unsigned long action, void *hcpu)
{ {
struct cci_pmu *cci_pmu = container_of(self, struct cci_pmu *cci_pmu;
struct cci_pmu, cpu_nb);
unsigned int cpu = (long)hcpu;
unsigned int target; unsigned int target;
switch (action & ~CPU_TASKS_FROZEN) { mutex_lock(&cci_pmu_mutex);
case CPU_DOWN_PREPARE: list_for_each_entry(cci_pmu, &cci_pmu_list, entry) {
if (!cpumask_test_and_clear_cpu(cpu, &cci_pmu->cpus)) if (!cpumask_test_and_clear_cpu(cpu, &cci_pmu->cpus))
break; continue;
target = cpumask_any_but(cpu_online_mask, cpu); target = cpumask_any_but(cpu_online_mask, cpu);
if (target >= nr_cpu_ids) // UP, last CPU if (target >= nr_cpu_ids)
break; continue;
/* /*
* TODO: migrate context once core races on event->ctx have * TODO: migrate context once core races on event->ctx have
* been fixed. * been fixed.
*/ */
cpumask_set_cpu(target, &cci_pmu->cpus); cpumask_set_cpu(target, &cci_pmu->cpus);
default:
break;
} }
mutex_unlock(&cci_pmu_mutex);
return NOTIFY_OK; return 0;
} }
static struct cci_pmu_model cci_pmu_models[] = { static struct cci_pmu_model cci_pmu_models[] = {
...@@ -1766,24 +1764,13 @@ static int cci_pmu_probe(struct platform_device *pdev) ...@@ -1766,24 +1764,13 @@ static int cci_pmu_probe(struct platform_device *pdev)
atomic_set(&cci_pmu->active_events, 0); atomic_set(&cci_pmu->active_events, 0);
cpumask_set_cpu(smp_processor_id(), &cci_pmu->cpus); cpumask_set_cpu(smp_processor_id(), &cci_pmu->cpus);
cci_pmu->cpu_nb = (struct notifier_block) { ret = cci_pmu_init(cci_pmu, pdev);
.notifier_call = cci_pmu_cpu_notifier,
/*
* to migrate uncore events, our notifier should be executed
* before perf core's notifier.
*/
.priority = CPU_PRI_PERF + 1,
};
ret = register_cpu_notifier(&cci_pmu->cpu_nb);
if (ret) if (ret)
return ret; return ret;
ret = cci_pmu_init(cci_pmu, pdev); mutex_lock(&cci_pmu_mutex);
if (ret) { list_add(&cci_pmu->entry, &cci_pmu_list);
unregister_cpu_notifier(&cci_pmu->cpu_nb); mutex_unlock(&cci_pmu_mutex);
return ret;
}
pr_info("ARM %s PMU driver probed", cci_pmu->model->name); pr_info("ARM %s PMU driver probed", cci_pmu->model->name);
return 0; return 0;
...@@ -1817,6 +1804,12 @@ static int __init cci_platform_init(void) ...@@ -1817,6 +1804,12 @@ static int __init cci_platform_init(void)
{ {
int ret; int ret;
ret = cpuhp_setup_state_nocalls(CPUHP_AP_PERF_ARM_CCI_ONLINE,
"AP_PERF_ARM_CCI_ONLINE", NULL,
cci_pmu_offline_cpu);
if (ret)
return ret;
ret = platform_driver_register(&cci_pmu_driver); ret = platform_driver_register(&cci_pmu_driver);
if (ret) if (ret)
return ret; return ret;
......
...@@ -45,6 +45,7 @@ enum cpuhp_state { ...@@ -45,6 +45,7 @@ enum cpuhp_state {
CPUHP_AP_PERF_X86_CSTATE_ONLINE, CPUHP_AP_PERF_X86_CSTATE_ONLINE,
CPUHP_AP_PERF_S390_CF_ONLINE, CPUHP_AP_PERF_S390_CF_ONLINE,
CPUHP_AP_PERF_S390_SF_ONLINE, CPUHP_AP_PERF_S390_SF_ONLINE,
CPUHP_AP_PERF_ARM_CCI_ONLINE,
CPUHP_AP_NOTIFY_ONLINE, CPUHP_AP_NOTIFY_ONLINE,
CPUHP_AP_ONLINE_DYN, CPUHP_AP_ONLINE_DYN,
CPUHP_AP_ONLINE_DYN_END = CPUHP_AP_ONLINE_DYN + 30, CPUHP_AP_ONLINE_DYN_END = CPUHP_AP_ONLINE_DYN + 30,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment