diff options
| author | Sudeep KarkadaNagesha <Sudeep.KarkadaNagesha@arm.com> | 2012-07-31 10:11:23 +0100 | 
|---|---|---|
| committer | Will Deacon <will.deacon@arm.com> | 2012-11-09 11:37:25 +0000 | 
| commit | 513c99ce4e64245be1f83f56039ec4891b451955 (patch) | |
| tree | 5f322c568433b855fede78276e9dd7ce06188025 /arch/arm/kernel/perf_event_cpu.c | |
| parent | e50c54189f7c6211a99539156e3978474f0b1a0b (diff) | |
| download | olio-linux-3.10-513c99ce4e64245be1f83f56039ec4891b451955.tar.xz olio-linux-3.10-513c99ce4e64245be1f83f56039ec4891b451955.zip  | |
ARM: perf: allocate CPU PMU dynamically at probe time
Supporting multiple, heterogeneous CPU PMUs requires us to allocate the
arm_pmu structures dynamically as the devices are probed.
This patch removes the static structure definitions for each CPU PMU
type and instead passes pointers to the PMU-specific init functions.
Signed-off-by: Sudeep KarkadaNagesha <Sudeep.KarkadaNagesha@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'arch/arm/kernel/perf_event_cpu.c')
| -rw-r--r-- | arch/arm/kernel/perf_event_cpu.c | 47 | 
1 files changed, 30 insertions, 17 deletions
diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c index 8d7d8d4de9d..3863fd405fa 100644 --- a/arch/arm/kernel/perf_event_cpu.c +++ b/arch/arm/kernel/perf_event_cpu.c @@ -23,6 +23,7 @@  #include <linux/kernel.h>  #include <linux/of.h>  #include <linux/platform_device.h> +#include <linux/slab.h>  #include <linux/spinlock.h>  #include <asm/cputype.h> @@ -195,13 +196,13 @@ static struct platform_device_id __devinitdata cpu_pmu_plat_device_ids[] = {  /*   * CPU PMU identification and probing.   */ -static struct arm_pmu *__devinit probe_current_pmu(void) +static int __devinit probe_current_pmu(struct arm_pmu *pmu)  { -	struct arm_pmu *pmu = NULL;  	int cpu = get_cpu();  	unsigned long cpuid = read_cpuid_id();  	unsigned long implementor = (cpuid & 0xFF000000) >> 24;  	unsigned long part_number = (cpuid & 0xFFF0); +	int ret = -ENODEV;  	pr_info("probing PMU on CPU %d\n", cpu); @@ -211,25 +212,25 @@ static struct arm_pmu *__devinit probe_current_pmu(void)  		case 0xB360:	/* ARM1136 */  		case 0xB560:	/* ARM1156 */  		case 0xB760:	/* ARM1176 */ -			pmu = armv6pmu_init(); +			ret = armv6pmu_init(pmu);  			break;  		case 0xB020:	/* ARM11mpcore */ -			pmu = armv6mpcore_pmu_init(); +			ret = armv6mpcore_pmu_init(pmu);  			break;  		case 0xC080:	/* Cortex-A8 */ -			pmu = armv7_a8_pmu_init(); +			ret = armv7_a8_pmu_init(pmu);  			break;  		case 0xC090:	/* Cortex-A9 */ -			pmu = armv7_a9_pmu_init(); +			ret = armv7_a9_pmu_init(pmu);  			break;  		case 0xC050:	/* Cortex-A5 */ -			pmu = armv7_a5_pmu_init(); +			ret = armv7_a5_pmu_init(pmu);  			break;  		case 0xC0F0:	/* Cortex-A15 */ -			pmu = armv7_a15_pmu_init(); +			ret = armv7_a15_pmu_init(pmu);  			break;  		case 0xC070:	/* Cortex-A7 */ -			pmu = armv7_a7_pmu_init(); +			ret = armv7_a7_pmu_init(pmu);  			break;  		}  	/* Intel CPUs [xscale]. */ @@ -237,39 +238,51 @@ static struct arm_pmu *__devinit probe_current_pmu(void)  		part_number = (cpuid >> 13) & 0x7;  		switch (part_number) {  		case 1: -			pmu = xscale1pmu_init(); +			ret = xscale1pmu_init(pmu);  			break;  		case 2: -			pmu = xscale2pmu_init(); +			ret = xscale2pmu_init(pmu);  			break;  		}  	}  	put_cpu(); -	return pmu; +	return ret;  }  static int __devinit cpu_pmu_device_probe(struct platform_device *pdev)  {  	const struct of_device_id *of_id; -	struct arm_pmu *(*init_fn)(void); +	int (*init_fn)(struct arm_pmu *);  	struct device_node *node = pdev->dev.of_node; +	struct arm_pmu *pmu; +	int ret = -ENODEV;  	if (cpu_pmu) {  		pr_info("attempt to register multiple PMU devices!");  		return -ENOSPC;  	} +	pmu = kzalloc(sizeof(struct arm_pmu), GFP_KERNEL); +	if (!pmu) { +		pr_info("failed to allocate PMU device!"); +		return -ENOMEM; +	} +  	if (node && (of_id = of_match_node(cpu_pmu_of_device_ids, pdev->dev.of_node))) {  		init_fn = of_id->data; -		cpu_pmu = init_fn(); +		ret = init_fn(pmu);  	} else { -		cpu_pmu = probe_current_pmu(); +		ret = probe_current_pmu(pmu);  	} -	if (!cpu_pmu) -		return -ENODEV; +	if (ret) { +		pr_info("failed to register PMU devices!"); +		kfree(pmu); +		return ret; +	} +	cpu_pmu = pmu;  	cpu_pmu->plat_device = pdev;  	cpu_pmu_init(cpu_pmu);  	register_cpu_notifier(&cpu_pmu_hotplug_notifier);  |