[PATCH][2.6] OProfile/XScale fixes for PXA270/XScale2

From: Zwane Mwaikambo
Date: Sat Aug 07 2004 - 21:31:13 EST


The incorrect mask was being used when writing back to PMNC
write-only-zero bits as well as only ticking the CCNT every 64 processor
cycles. Tested on IOP331 and PXA270, i'm still looking for XScale1 users...

Andrew please apply.

Signed-off-by: Luca Rossato <l.rossato@xxxxxxxxxx>
Signed-off-by: Zwane Mwaikambo <zwane@xxxxxxxxxxxxxxxx>

Index: linux-2.6.8-rc3/arch/arm/oprofile/op_model_xscale.c
===================================================================
RCS file: /home/cvsroot/linux-2.6.8-rc3/arch/arm/oprofile/op_model_xscale.c,v
retrieving revision 1.1.1.1
diff -u -p -B -r1.1.1.1 op_model_xscale.c
--- linux-2.6.8-rc3/arch/arm/oprofile/op_model_xscale.c 4 Aug 2004 02:22:30 -0000 1.1.1.1
+++ linux-2.6.8-rc3/arch/arm/oprofile/op_model_xscale.c 8 Aug 2004 00:30:03 -0000
@@ -30,6 +30,7 @@
#define PMN_RESET 0x002 /* Reset event counters */
#define CCNT_RESET 0x004 /* Reset clock counter */
#define PMU_RESET (CCNT_RESET | PMN_RESET)
+#define PMU_CNT64 0x008 /* Make CCNT count every 64th cycle */

/* TODO do runtime detection */
#ifdef CONFIG_ARCH_IOP310
@@ -125,12 +126,15 @@ static struct pmu_type *pmu;

static void write_pmnc(u32 val)
{
- /* upper 4bits and 7, 11 are write-as-0 */
- val &= 0xffff77f;
- if (pmu->id == PMU_XSC1)
+ if (pmu->id == PMU_XSC1) {
+ /* upper 4bits and 7, 11 are write-as-0 */
+ val &= 0xffff77f;
__asm__ __volatile__ ("mcr p14, 0, %0, c0, c0, 0" : : "r" (val));
- else
+ } else {
+ /* bits 4-23 are write-as-0, 24-31 are write ignored */
+ val &= 0xf;
__asm__ __volatile__ ("mcr p14, 0, %0, c0, c1, 0" : : "r" (val));
+ }
}

static u32 read_pmnc(void)
@@ -139,8 +143,11 @@ static u32 read_pmnc(void)

if (pmu->id == PMU_XSC1)
__asm__ __volatile__ ("mrc p14, 0, %0, c0, c0, 0" : "=r" (val));
- else
+ else {
__asm__ __volatile__ ("mrc p14, 0, %0, c0, c1, 0" : "=r" (val));
+ /* bits 1-2 and 4-23 are read-unpredictable */
+ val &= 0xff000009;
+ }

return val;
}
@@ -386,8 +393,10 @@ static int xscale_pmu_start(void)

if (pmu->id == PMU_XSC1)
pmnc |= pmu->int_enable;
- else
+ else {
__asm__ __volatile__ ("mcr p14, 0, %0, c4, c1, 0" : : "r" (pmu->int_enable));
+ pmnc &= ~PMU_CNT64;
+ }

pmnc |= PMU_ENABLE;
write_pmnc(pmnc);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/