oprofile: op_model_athlon.c support for AMD family 10h barcelona performance counters

This patch is for controlling the upper 32bits of the event ctrl msrs.
This includes the upper 4 bits of the event select and the Guest Only and
Host Only bits

This patch is necessary to make Event Based Profiling work reliably on a
Family 10h processor

[akpm@linux-foundation.org: checkpatch.pl fixes]

Signed-off-by: Barry Kasindorf <barry.kasindorf@amd.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

authored by Barry Kasindorf and committed by Ingo Molnar bd87f1f0 c63a1190

+16 -6
+16 -6
arch/x86/oprofile/op_model_athlon.c
··· 1 /** 2 * @file op_model_athlon.h 3 - * athlon / K7 model-specific MSR operations 4 * 5 * @remark Copyright 2002 OProfile authors 6 * @remark Read the file COPYING ··· 31 #define CTRL_WRITE(l,h,msrs,c) do {wrmsr(msrs->controls[(c)].addr, (l), (h));} while (0) 32 #define CTRL_SET_ACTIVE(n) (n |= (1<<22)) 33 #define CTRL_SET_INACTIVE(n) (n &= ~(1<<22)) 34 - #define CTRL_CLEAR(x) (x &= (1<<21)) 35 #define CTRL_SET_ENABLE(val) (val |= 1<<20) 36 #define CTRL_SET_USR(val,u) (val |= ((u & 1) << 16)) 37 #define CTRL_SET_KERN(val,k) (val |= ((k & 1) << 17)) 38 #define CTRL_SET_UM(val, m) (val |= (m << 8)) 39 - #define CTRL_SET_EVENT(val, e) (val |= e) 40 41 static unsigned long reset_value[NUM_COUNTERS]; 42 ··· 74 if (unlikely(!CTRL_IS_RESERVED(msrs,i))) 75 continue; 76 CTRL_READ(low, high, msrs, i); 77 - CTRL_CLEAR(low); 78 CTRL_WRITE(low, high, msrs, i); 79 } 80 ··· 94 CTR_WRITE(counter_config[i].count, msrs, i); 95 96 CTRL_READ(low, high, msrs, i); 97 - CTRL_CLEAR(low); 98 CTRL_SET_ENABLE(low); 99 CTRL_SET_USR(low, counter_config[i].user); 100 CTRL_SET_KERN(low, counter_config[i].kernel); 101 CTRL_SET_UM(low, counter_config[i].unit_mask); 102 - CTRL_SET_EVENT(low, counter_config[i].event); 103 CTRL_WRITE(low, high, msrs, i); 104 } else { 105 reset_value[i] = 0;
··· 1 /** 2 * @file op_model_athlon.h 3 + * athlon / K7 / K8 / Family 10h model-specific MSR operations 4 * 5 * @remark Copyright 2002 OProfile authors 6 * @remark Read the file COPYING ··· 31 #define CTRL_WRITE(l,h,msrs,c) do {wrmsr(msrs->controls[(c)].addr, (l), (h));} while (0) 32 #define CTRL_SET_ACTIVE(n) (n |= (1<<22)) 33 #define CTRL_SET_INACTIVE(n) (n &= ~(1<<22)) 34 + #define CTRL_CLEAR_LO(x) (x &= (1<<21)) 35 + #define CTRL_CLEAR_HI(x) (x &= 0xfffffcf0) 36 #define CTRL_SET_ENABLE(val) (val |= 1<<20) 37 #define CTRL_SET_USR(val,u) (val |= ((u & 1) << 16)) 38 #define CTRL_SET_KERN(val,k) (val |= ((k & 1) << 17)) 39 #define CTRL_SET_UM(val, m) (val |= (m << 8)) 40 + #define CTRL_SET_EVENT_LOW(val, e) (val |= (e & 0xff)) 41 + #define CTRL_SET_EVENT_HIGH(val, e) (val |= ((e >> 8) & 0xf)) 42 + #define CTRL_SET_HOST_ONLY(val, h) (val |= ((h & 1) << 9)) 43 + #define CTRL_SET_GUEST_ONLY(val, h) (val |= ((h & 1) << 8)) 44 45 static unsigned long reset_value[NUM_COUNTERS]; 46 ··· 70 if (unlikely(!CTRL_IS_RESERVED(msrs,i))) 71 continue; 72 CTRL_READ(low, high, msrs, i); 73 + CTRL_CLEAR_LO(low); 74 + CTRL_CLEAR_HI(high); 75 CTRL_WRITE(low, high, msrs, i); 76 } 77 ··· 89 CTR_WRITE(counter_config[i].count, msrs, i); 90 91 CTRL_READ(low, high, msrs, i); 92 + CTRL_CLEAR_LO(low); 93 + CTRL_CLEAR_HI(high); 94 CTRL_SET_ENABLE(low); 95 CTRL_SET_USR(low, counter_config[i].user); 96 CTRL_SET_KERN(low, counter_config[i].kernel); 97 CTRL_SET_UM(low, counter_config[i].unit_mask); 98 + CTRL_SET_EVENT_LOW(low, counter_config[i].event); 99 + CTRL_SET_EVENT_HIGH(high, counter_config[i].event); 100 + CTRL_SET_HOST_ONLY(high, 0); 101 + CTRL_SET_GUEST_ONLY(high, 0); 102 + 103 CTRL_WRITE(low, high, msrs, i); 104 } else { 105 reset_value[i] = 0;