aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/oprofile
diff options
context:
space:
mode:
authorRobert Richter <robert.richter@amd.com>2010-09-21 09:58:32 -0400
committerRobert Richter <robert.richter@amd.com>2010-10-15 06:50:40 -0400
commit4ac945f002c0bebdeb530cbc3729e22895e64a7e (patch)
treecab9bc4f51d5d640f6de256e2168b4bcc77e7b30 /arch/x86/oprofile
parente63414740e15b4e2dc54c63fb9ea501b257fb0b5 (diff)
oprofile, x86: Check IBS capability bits 1 and 2
There are IBS CPUID feature flags in CPUID Fn8000_001B to detect if the cpu supports IBS fetch sampling (FetchSam) and/or IBS execution sampling (OpSam). This patch adds checks if the both features are available. Spec: http://support.amd.com/us/Processor_TechDocs/31116.pdf Signed-off-by: Robert Richter <robert.richter@amd.com>
Diffstat (limited to 'arch/x86/oprofile')
-rw-r--r--arch/x86/oprofile/op_model_amd.c59
1 files changed, 38 insertions, 21 deletions
diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
index b67a6b5aa8d4..96852d5480e0 100644
--- a/arch/x86/oprofile/op_model_amd.c
+++ b/arch/x86/oprofile/op_model_amd.c
@@ -70,9 +70,22 @@ static u64 ibs_op_ctl;
70 * Same bit mask as for IBS cpuid feature flags (Fn8000_001B_EAX), but 70 * Same bit mask as for IBS cpuid feature flags (Fn8000_001B_EAX), but
71 * bit 0 is used to indicate the existence of IBS. 71 * bit 0 is used to indicate the existence of IBS.
72 */ 72 */
73#define IBS_CAPS_AVAIL (1LL<<0) 73#define IBS_CAPS_AVAIL (1U<<0)
74#define IBS_CAPS_RDWROPCNT (1LL<<3) 74#define IBS_CAPS_FETCHSAM (1U<<1)
75#define IBS_CAPS_OPCNT (1LL<<4) 75#define IBS_CAPS_OPSAM (1U<<2)
76#define IBS_CAPS_RDWROPCNT (1U<<3)
77#define IBS_CAPS_OPCNT (1U<<4)
78
79#define IBS_CAPS_DEFAULT (IBS_CAPS_AVAIL \
80 | IBS_CAPS_FETCHSAM \
81 | IBS_CAPS_OPSAM)
82
83/*
84 * IBS APIC setup
85 */
86#define IBSCTL 0x1cc
87#define IBSCTL_LVT_OFFSET_VALID (1ULL<<8)
88#define IBSCTL_LVT_OFFSET_MASK 0x0F
76 89
77/* 90/*
78 * IBS randomization macros 91 * IBS randomization macros
@@ -92,12 +105,12 @@ static u32 get_ibs_caps(void)
92 /* check IBS cpuid feature flags */ 105 /* check IBS cpuid feature flags */
93 max_level = cpuid_eax(0x80000000); 106 max_level = cpuid_eax(0x80000000);
94 if (max_level < IBS_CPUID_FEATURES) 107 if (max_level < IBS_CPUID_FEATURES)
95 return IBS_CAPS_AVAIL; 108 return IBS_CAPS_DEFAULT;
96 109
97 ibs_caps = cpuid_eax(IBS_CPUID_FEATURES); 110 ibs_caps = cpuid_eax(IBS_CPUID_FEATURES);
98 if (!(ibs_caps & IBS_CAPS_AVAIL)) 111 if (!(ibs_caps & IBS_CAPS_AVAIL))
99 /* cpuid flags not valid */ 112 /* cpuid flags not valid */
100 return IBS_CAPS_AVAIL; 113 return IBS_CAPS_DEFAULT;
101 114
102 return ibs_caps; 115 return ibs_caps;
103} 116}
@@ -527,22 +540,26 @@ static int setup_ibs_files(struct super_block *sb, struct dentry *root)
527 ibs_config.op_enabled = 0; 540 ibs_config.op_enabled = 0;
528 ibs_config.dispatched_ops = 0; 541 ibs_config.dispatched_ops = 0;
529 542
530 dir = oprofilefs_mkdir(sb, root, "ibs_fetch"); 543 if (ibs_caps & IBS_CAPS_FETCHSAM) {
531 oprofilefs_create_ulong(sb, dir, "enable", 544 dir = oprofilefs_mkdir(sb, root, "ibs_fetch");
532 &ibs_config.fetch_enabled); 545 oprofilefs_create_ulong(sb, dir, "enable",
533 oprofilefs_create_ulong(sb, dir, "max_count", 546 &ibs_config.fetch_enabled);
534 &ibs_config.max_cnt_fetch); 547 oprofilefs_create_ulong(sb, dir, "max_count",
535 oprofilefs_create_ulong(sb, dir, "rand_enable", 548 &ibs_config.max_cnt_fetch);
536 &ibs_config.rand_en); 549 oprofilefs_create_ulong(sb, dir, "rand_enable",
537 550 &ibs_config.rand_en);
538 dir = oprofilefs_mkdir(sb, root, "ibs_op"); 551 }
539 oprofilefs_create_ulong(sb, dir, "enable", 552
540 &ibs_config.op_enabled); 553 if (ibs_caps & IBS_CAPS_OPSAM) {
541 oprofilefs_create_ulong(sb, dir, "max_count", 554 dir = oprofilefs_mkdir(sb, root, "ibs_op");
542 &ibs_config.max_cnt_op); 555 oprofilefs_create_ulong(sb, dir, "enable",
543 if (ibs_caps & IBS_CAPS_OPCNT) 556 &ibs_config.op_enabled);
544 oprofilefs_create_ulong(sb, dir, "dispatched_ops", 557 oprofilefs_create_ulong(sb, dir, "max_count",
545 &ibs_config.dispatched_ops); 558 &ibs_config.max_cnt_op);
559 if (ibs_caps & IBS_CAPS_OPCNT)
560 oprofilefs_create_ulong(sb, dir, "dispatched_ops",
561 &ibs_config.dispatched_ops);
562 }
546 563
547 return 0; 564 return 0;
548} 565}