From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv2 2/4] ARM: pmu: reject duplicate PMU registrations
Date: Wed, 15 Jun 2011 15:40:02 +0100 [thread overview]
Message-ID: <1308148804-5518-3-git-send-email-mark.rutland@arm.com> (raw)
In-Reply-To: <1308148804-5518-1-git-send-email-mark.rutland@arm.com>
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>
---
arch/arm/kernel/pmu.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/arch/arm/kernel/pmu.c b/arch/arm/kernel/pmu.c
index 87942b9..de6b1b0 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,
return -EINVAL;
}
- if (pmu_devices[type])
- pr_warning("registering new PMU device type %d overwrites "
- "previous registration!\n", type);
- else
- pr_info("registered new PMU device of type %d\n",
- type);
+ if (pmu_devices[type]) {
+ pr_warning("rejecting duplicate registration of PMU device "
+ "type %d.", type);
+ return -ENOSPC;
+ }
+ pr_info("registered new PMU device of type %d\n", type);
pmu_devices[type] = pdev;
return 0;
}
--
1.7.0.4
next prev parent reply other threads:[~2011-06-15 14:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-15 14:40 [PATCHv2 0/4] ARM: pmu: improve PMU type identification Mark Rutland
2011-06-15 14:40 ` [PATCHv2 1/4] ARM: pmu: refactor reservation Mark Rutland
2011-06-15 14:40 ` Mark Rutland [this message]
2011-06-15 14:40 ` [PATCHv2 3/4] ARM: pmu: add OF probing support Mark Rutland
2011-06-15 14:40 ` [PATCHv2 4/4] ARM: pmu: add platform_device_id table support Mark Rutland
2011-06-15 14:45 ` [PATCHv2 0/4] ARM: pmu: improve PMU type identification Jamie Iles
2011-06-15 15:01 ` Rob Herring
2011-06-29 9:26 ` Russell King - ARM Linux
2011-06-29 9:36 ` Will Deacon
2011-06-29 10:42 ` Jamie Iles
2011-06-29 13:32 ` Jean Pihet
2011-06-29 15:29 ` Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1308148804-5518-3-git-send-email-mark.rutland@arm.com \
--to=mark.rutland@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).