powerpc/perf: increase the perf HW events to 6
authorCatalin Udma <catalin.udma@freescale.com>
Wed, 5 Jun 2013 20:22:08 +0000 (15:22 -0500)
committerScott Wood <scottwood@freescale.com>
Wed, 7 Aug 2013 23:38:03 +0000 (18:38 -0500)
This change is required after the e6500 perf support has been added.
There are 6 counters in e6500 core instead of 4 in e500 core and
the MAX_HWEVENTS counter should be changed accordingly from 4 to 6.
Added also runtime check for counters overflow.

Signed-off-by: Catalin Udma <catalin.udma@freescale.com>
Signed-off-by: Lijun Pan <Lijun.Pan@freescale.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
arch/powerpc/include/asm/perf_event_fsl_emb.h
arch/powerpc/perf/core-fsl-emb.c

index 718a9fa94e68eebafec29bcaa4f0214b55db9846..a58165450f6fa659cbd261624855c7791a4c3fc5 100644 (file)
@@ -13,7 +13,7 @@
 #include <linux/types.h>
 #include <asm/hw_irq.h>
 
-#define MAX_HWEVENTS 4
+#define MAX_HWEVENTS 6
 
 /* event flags */
 #define FSL_EMB_EVENT_VALID      1
index 106c533546758280ae59da38ce45a2c88a7f49b5..0b13f74f5fb309613ee7a0a2a769daa20a74522c 100644 (file)
@@ -462,6 +462,12 @@ static int fsl_emb_pmu_event_init(struct perf_event *event)
        int num_restricted;
        int i;
 
+       if (ppmu->n_counter > MAX_HWEVENTS) {
+               WARN(1, "No. of perf counters (%d) is higher than max array size(%d)\n",
+                       ppmu->n_counter, MAX_HWEVENTS);
+               ppmu->n_counter = MAX_HWEVENTS;
+       }
+
        switch (event->attr.type) {
        case PERF_TYPE_HARDWARE:
                ev = event->attr.config;