]> err.no Git - linux-2.6/blobdiff - arch/mips/oprofile/op_model_mipsxx.c
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[linux-2.6] / arch / mips / oprofile / op_model_mipsxx.c
index 455d76ad06d83cf1eb3045c3ca6691cb088584c3..1ea5c9c1010b19610943012838f5b9a00fdb5964 100644 (file)
@@ -35,7 +35,7 @@
 #define vpe_id()       smp_processor_id()
 #else
 #define WHAT           0
-#define vpe_id()       smp_processor_id()
+#define vpe_id()       0
 #endif
 
 #define __define_perf_accessors(r, n, np)                              \
@@ -74,13 +74,13 @@ static inline void w_c0_ ## r ## n(unsigned int value)                      \
 
 __define_perf_accessors(perfcntr, 0, 2)
 __define_perf_accessors(perfcntr, 1, 3)
-__define_perf_accessors(perfcntr, 2, 2)
-__define_perf_accessors(perfcntr, 3, 2)
+__define_perf_accessors(perfcntr, 2, 0)
+__define_perf_accessors(perfcntr, 3, 1)
 
 __define_perf_accessors(perfctrl, 0, 2)
 __define_perf_accessors(perfctrl, 1, 3)
-__define_perf_accessors(perfctrl, 2, 2)
-__define_perf_accessors(perfctrl, 3, 2)
+__define_perf_accessors(perfctrl, 2, 0)
+__define_perf_accessors(perfctrl, 3, 1)
 
 struct op_mips_model op_model_mipsxx_ops;
 
@@ -97,7 +97,6 @@ static void mipsxx_reg_setup(struct op_counter_config *ctr)
        int i;
 
        /* Compute the performance counter control word.  */
-       /* For now count kernel and user mode */
        for (i = 0; i < counters; i++) {
                reg.control[i] = 0;
                reg.counter[i] = 0;
@@ -178,7 +177,10 @@ static int mipsxx_perfcount_handler(void)
        unsigned int counters = op_model_mipsxx_ops.num_counters;
        unsigned int control;
        unsigned int counter;
-       int handled = 0;
+       int handled = IRQ_NONE;
+
+       if (cpu_has_mips_r2 && !(read_c0_cause() & (1 << 26)))
+               return handled;
 
        switch (counters) {
 #define HANDLE_COUNTER(n)                                              \
@@ -189,7 +191,7 @@ static int mipsxx_perfcount_handler(void)
                    (counter & M_COUNTER_OVERFLOW)) {                   \
                        oprofile_add_sample(get_irq_regs(), n);         \
                        w_c0_perfcntr ## n(reg.counter[n]);             \
-                       handled = 1;                                    \
+                       handled = IRQ_HANDLED;                          \
                }
        HANDLE_COUNTER(3)
        HANDLE_COUNTER(2)
@@ -223,18 +225,17 @@ static inline int n_counters(void)
        switch (current_cpu_data.cputype) {
        case CPU_R10000:
                counters = 2;
+               break;
 
        case CPU_R12000:
        case CPU_R14000:
                counters = 4;
+               break;
 
        default:
                counters = __n_counters();
        }
 
-#ifdef CONFIG_MIPS_MT_SMP
-       counters >> 1;
-#endif
        return counters;
 }
 
@@ -268,6 +269,10 @@ static int __init mipsxx_init(void)
 
        reset_counters(counters);
 
+#ifdef CONFIG_MIPS_MT_SMP
+       counters >>= 1;
+#endif
+
        op_model_mipsxx_ops.num_counters = counters;
        switch (current_cpu_data.cputype) {
        case CPU_20KC:
@@ -324,7 +329,11 @@ static int __init mipsxx_init(void)
 
 static void mipsxx_exit(void)
 {
-       reset_counters(op_model_mipsxx_ops.num_counters);
+       int counters = op_model_mipsxx_ops.num_counters;
+#ifdef CONFIG_MIPS_MT_SMP
+       counters <<= 1;
+#endif
+       reset_counters(counters);
 
        perf_irq = null_perf_irq;
 }