aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Rutland <mark.rutland@arm.com>2011-06-22 10:32:48 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2011-06-29 05:27:08 -0400
commitae0c3751ab08d3fe039d48935e9ad2c46711b23b (patch)
tree7159b91bd55eb6e64032c84644a932a5cf35d9e8
parentf12482c9393da2c1f5cb3217f29aa79c653dd980 (diff)
ARM: 6975/1: pmu: reject duplicate PMU registrations
Currently, the PMU reservation framework allows for multiple PMUs of the same type to register themselves. This can lead to a bug with the sequence: register_pmu(pmu1); reserve_pmu(pmu_type); register_pmu(pmu2); release_pmu(pmu1); Here, pmu1 cannot be released, and pmu2 cannot be reserved. This patch modifies register_pmu to reject registrations where a PMU is already present, preventing this problem. PMUs which can have multiple instances should not use the PMU reservation framework. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Acked-by: Jamie Iles <jamie@jamieiles.com> Acked-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/kernel/pmu.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/arch/arm/kernel/pmu.c b/arch/arm/kernel/pmu.c
index 87942b931c6..de6b1b0860c 100644
--- a/arch/arm/kernel/pmu.c
+++ b/arch/arm/kernel/pmu.c
@@ -34,13 +34,13 @@ static int __devinit pmu_register(struct platform_device *pdev,
34 return -EINVAL; 34 return -EINVAL;
35 } 35 }
36 36
37 if (pmu_devices[type]) 37 if (pmu_devices[type]) {
38 pr_warning("registering new PMU device type %d overwrites " 38 pr_warning("rejecting duplicate registration of PMU device "
39 "previous registration!\n", type); 39 "type %d.", type);
40 else 40 return -ENOSPC;
41 pr_info("registered new PMU device of type %d\n", 41 }
42 type);
43 42
43 pr_info("registered new PMU device of type %d\n", type);
44 pmu_devices[type] = pdev; 44 pmu_devices[type] = pdev;
45 return 0; 45 return 0;
46} 46}