From: rabin.vincent@stericsson.com (Rabin Vincent)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: perf_event: support dual-core with single PMU IRQ
Date: Fri, 4 Feb 2011 11:59:26 +0530 [thread overview]
Message-ID: <mailman.137.1297057779.1530.linux-arm-kernel@lists.infradead.org> (raw)
DB8500 (dual-core) has the PMU interrupts of both cores ORed into one. Support
this by setting the affinity of the interrupt to the other core when the
current core finds that its counter has not overflowed when an interrupt
occurred.
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
---
arch/arm/kernel/perf_event.c | 33 ++++++++++++++++++++++++++++++++-
1 files changed, 32 insertions(+), 1 deletions(-)
diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c
index 5efa264..d07990e 100644
--- a/arch/arm/kernel/perf_event.c
+++ b/arch/arm/kernel/perf_event.c
@@ -377,9 +377,27 @@ validate_group(struct perf_event *event)
return 0;
}
+static irqreturn_t armpmu_bounce_interrupt(int irq, void *dev)
+{
+ irqreturn_t ret = armpmu->handle_irq(irq, dev);
+
+ if (ret == IRQ_NONE) {
+ int other = !smp_processor_id();
+ irq_set_affinity(irq, cpumask_of(other));
+ }
+
+ /*
+ * We should be able to get away with the amount of IRQ_NONEs we give,
+ * while still having the spurious IRQ detection code kick in if the
+ * interrupt really starts hitting spuriously.
+ */
+ return ret;
+}
+
static int
armpmu_reserve_hardware(void)
{
+ irq_handler_t irq_handler = armpmu->handle_irq;
int i, err = -ENODEV, irq;
pmu_device = reserve_pmu(ARM_PMU_DEVICE_CPU);
@@ -395,12 +413,25 @@ armpmu_reserve_hardware(void)
return -ENODEV;
}
+ /*
+ * Some SoCs have the PMU IRQ lines of two cores wired together into a
+ * single interrupt.
+ */
+ if (pmu_device->num_resources < num_online_cpus()) {
+ if (num_online_cpus() > 2) {
+ pr_err(">2 cpus not supported for single-irq workaround");
+ return -ENODEV;
+ }
+
+ irq_handler = armpmu_bounce_interrupt;
+ }
+
for (i = 0; i < pmu_device->num_resources; ++i) {
irq = platform_get_irq(pmu_device, i);
if (irq < 0)
continue;
- err = request_irq(irq, armpmu->handle_irq,
+ err = request_irq(irq, irq_handler,
IRQF_DISABLED | IRQF_NOBALANCING,
"armpmu", NULL);
if (err) {
--001636c5aa55c3c736049baacb0b
Content-Type: application/octet-stream;
name="0001-ARM-perf_event-support-dual-core-with-single-PMU-IRQ.patch"
Content-Disposition: attachment;
filename="0001-ARM-perf_event-support-dual-core-with-single-PMU-IRQ.patch"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_gjuykx4u0
RnJvbSA0MTBlZTgzMWRkNjk2OWVjMDQ3YmE5OGIxY2QzMmFjMjA0NGYxNWNlIE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiBSYWJpbiBWaW5jZW50IDxyYWJpbi52aW5jZW50QHN0ZXJpY3Nz
b24uY29tPgpEYXRlOiBGcmksIDQgRmViIDIwMTEgMTE6NTk6MjYgKzA1MzAKU3ViamVjdDogW1BB
VENIXSBBUk06IHBlcmZfZXZlbnQ6IHN1cHBvcnQgZHVhbC1jb3JlIHdpdGggc2luZ2xlIFBNVSBJ
UlEKCkRCODUwMCAoZHVhbC1jb3JlKSBoYXMgdGhlIFBNVSBpbnRlcnJ1cHRzIG9mIGJvdGggY29y
ZXMgT1JlZCBpbnRvIG9uZS4gIFN1cHBvcnQKdGhpcyBieSBzZXR0aW5nIHRoZSBhZmZpbml0eSBv
ZiB0aGUgaW50ZXJydXB0IHRvIHRoZSBvdGhlciBjb3JlIHdoZW4gdGhlCmN1cnJlbnQgY29yZSBm
aW5kcyB0aGF0IGl0cyBjb3VudGVyIGhhcyBub3Qgb3ZlcmZsb3dlZCB3aGVuIGFuIGludGVycnVw
dApvY2N1cnJlZC4KClNpZ25lZC1vZmYtYnk6IFJhYmluIFZpbmNlbnQgPHJhYmluLnZpbmNlbnRA
c3Rlcmljc3Nvbi5jb20+Ci0tLQogYXJjaC9hcm0va2VybmVsL3BlcmZfZXZlbnQuYyB8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fCBJUlFGX05PQkFMQU5DSU5HLAogCQkJCSAgImFybXBtdSIsIE5VTEwpOwog
CQlpZiAoZXJyKSB7Ci0tIAoxLjcuMi5kaXJ0eQoK
--001636c5aa55c3c736049baacb0b--
next reply other threads:[~2011-02-04 6:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-04 6:29 Rabin Vincent [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-02-04 6:29 [PATCH] ARM: perf_event: support dual-core with single PMU IRQ Rabin Vincent
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=mailman.137.1297057779.1530.linux-arm-kernel@lists.infradead.org \
--to=rabin.vincent@stericsson.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).