op_model_amd.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. /*
  2. * @file op_model_amd.c
  3. * athlon / K7 / K8 / Family 10h model-specific MSR operations
  4. *
  5. * @remark Copyright 2002-2009 OProfile authors
  6. * @remark Read the file COPYING
  7. *
  8. * @author John Levon
  9. * @author Philippe Elie
  10. * @author Graydon Hoare
  11. * @author Robert Richter <robert.richter@amd.com>
  12. * @author Barry Kasindorf <barry.kasindorf@amd.com>
  13. * @author Jason Yeh <jason.yeh@amd.com>
  14. * @author Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
  15. */
  16. #include <linux/oprofile.h>
  17. #include <linux/device.h>
  18. #include <linux/pci.h>
  19. #include <linux/percpu.h>
  20. #include <asm/ptrace.h>
  21. #include <asm/msr.h>
  22. #include <asm/nmi.h>
  23. #include <asm/apic.h>
  24. #include <asm/processor.h>
  25. #include <asm/cpufeature.h>
  26. #include "op_x86_model.h"
  27. #include "op_counter.h"
  28. #define NUM_COUNTERS 4
  29. #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
  30. #define NUM_VIRT_COUNTERS 32
  31. #else
  32. #define NUM_VIRT_COUNTERS NUM_COUNTERS
  33. #endif
  34. #define OP_EVENT_MASK 0x0FFF
  35. #define OP_CTR_OVERFLOW (1ULL<<31)
  36. #define MSR_AMD_EVENTSEL_RESERVED ((0xFFFFFCF0ULL<<32)|(1ULL<<21))
  37. static unsigned long reset_value[NUM_VIRT_COUNTERS];
  38. #define IBS_FETCH_SIZE 6
  39. #define IBS_OP_SIZE 12
  40. static u32 ibs_caps;
  41. struct op_ibs_config {
  42. unsigned long op_enabled;
  43. unsigned long fetch_enabled;
  44. unsigned long max_cnt_fetch;
  45. unsigned long max_cnt_op;
  46. unsigned long rand_en;
  47. unsigned long dispatched_ops;
  48. };
  49. static struct op_ibs_config ibs_config;
  50. static u64 ibs_op_ctl;
  51. /*
  52. * IBS cpuid feature detection
  53. */
  54. #define IBS_CPUID_FEATURES 0x8000001b
  55. /*
  56. * Same bit mask as for IBS cpuid feature flags (Fn8000_001B_EAX), but
  57. * bit 0 is used to indicate the existence of IBS.
  58. */
  59. #define IBS_CAPS_AVAIL (1U<<0)
  60. #define IBS_CAPS_RDWROPCNT (1U<<3)
  61. #define IBS_CAPS_OPCNT (1U<<4)
  62. /*
  63. * IBS APIC setup
  64. */
  65. #define IBSCTL 0x1cc
  66. #define IBSCTL_LVT_OFFSET_VALID (1ULL<<8)
  67. #define IBSCTL_LVT_OFFSET_MASK 0x0F
  68. /*
  69. * IBS randomization macros
  70. */
  71. #define IBS_RANDOM_BITS 12
  72. #define IBS_RANDOM_MASK ((1ULL << IBS_RANDOM_BITS) - 1)
  73. #define IBS_RANDOM_MAXCNT_OFFSET (1ULL << (IBS_RANDOM_BITS - 5))
  74. static u32 get_ibs_caps(void)
  75. {
  76. u32 ibs_caps;
  77. unsigned int max_level;
  78. if (!boot_cpu_has(X86_FEATURE_IBS))
  79. return 0;
  80. /* check IBS cpuid feature flags */
  81. max_level = cpuid_eax(0x80000000);
  82. if (max_level < IBS_CPUID_FEATURES)
  83. return IBS_CAPS_AVAIL;
  84. ibs_caps = cpuid_eax(IBS_CPUID_FEATURES);
  85. if (!(ibs_caps & IBS_CAPS_AVAIL))
  86. /* cpuid flags not valid */
  87. return IBS_CAPS_AVAIL;
  88. return ibs_caps;
  89. }
  90. /*
  91. * 16-bit Linear Feedback Shift Register (LFSR)
  92. *
  93. * 16 14 13 11
  94. * Feedback polynomial = X + X + X + X + 1
  95. */
  96. static unsigned int lfsr_random(void)
  97. {
  98. static unsigned int lfsr_value = 0xF00D;
  99. unsigned int bit;
  100. /* Compute next bit to shift in */
  101. bit = ((lfsr_value >> 0) ^
  102. (lfsr_value >> 2) ^
  103. (lfsr_value >> 3) ^
  104. (lfsr_value >> 5)) & 0x0001;
  105. /* Advance to next register value */
  106. lfsr_value = (lfsr_value >> 1) | (bit << 15);
  107. return lfsr_value;
  108. }
  109. /*
  110. * IBS software randomization
  111. *
  112. * The IBS periodic op counter is randomized in software. The lower 12
  113. * bits of the 20 bit counter are randomized. IbsOpCurCnt is
  114. * initialized with a 12 bit random value.
  115. */
  116. static inline u64 op_amd_randomize_ibs_op(u64 val)
  117. {
  118. unsigned int random = lfsr_random();
  119. if (!(ibs_caps & IBS_CAPS_RDWROPCNT))
  120. /*
  121. * Work around if the hw can not write to IbsOpCurCnt
  122. *
  123. * Randomize the lower 8 bits of the 16 bit
  124. * IbsOpMaxCnt [15:0] value in the range of -128 to
  125. * +127 by adding/subtracting an offset to the
  126. * maximum count (IbsOpMaxCnt).
  127. *
  128. * To avoid over or underflows and protect upper bits
  129. * starting at bit 16, the initial value for
  130. * IbsOpMaxCnt must fit in the range from 0x0081 to
  131. * 0xff80.
  132. */
  133. val += (s8)(random >> 4);
  134. else
  135. val |= (u64)(random & IBS_RANDOM_MASK) << 32;
  136. return val;
  137. }
  138. static inline void
  139. op_amd_handle_ibs(struct pt_regs * const regs,
  140. struct op_msrs const * const msrs)
  141. {
  142. u64 val, ctl;
  143. struct op_entry entry;
  144. if (!ibs_caps)
  145. return;
  146. if (ibs_config.fetch_enabled) {
  147. rdmsrl(MSR_AMD64_IBSFETCHCTL, ctl);
  148. if (ctl & IBS_FETCH_VAL) {
  149. rdmsrl(MSR_AMD64_IBSFETCHLINAD, val);
  150. oprofile_write_reserve(&entry, regs, val,
  151. IBS_FETCH_CODE, IBS_FETCH_SIZE);
  152. oprofile_add_data64(&entry, val);
  153. oprofile_add_data64(&entry, ctl);
  154. rdmsrl(MSR_AMD64_IBSFETCHPHYSAD, val);
  155. oprofile_add_data64(&entry, val);
  156. oprofile_write_commit(&entry);
  157. /* reenable the IRQ */
  158. ctl &= ~(IBS_FETCH_VAL | IBS_FETCH_CNT);
  159. ctl |= IBS_FETCH_ENABLE;
  160. wrmsrl(MSR_AMD64_IBSFETCHCTL, ctl);
  161. }
  162. }
  163. if (ibs_config.op_enabled) {
  164. rdmsrl(MSR_AMD64_IBSOPCTL, ctl);
  165. if (ctl & IBS_OP_VAL) {
  166. rdmsrl(MSR_AMD64_IBSOPRIP, val);
  167. oprofile_write_reserve(&entry, regs, val,
  168. IBS_OP_CODE, IBS_OP_SIZE);
  169. oprofile_add_data64(&entry, val);
  170. rdmsrl(MSR_AMD64_IBSOPDATA, val);
  171. oprofile_add_data64(&entry, val);
  172. rdmsrl(MSR_AMD64_IBSOPDATA2, val);
  173. oprofile_add_data64(&entry, val);
  174. rdmsrl(MSR_AMD64_IBSOPDATA3, val);
  175. oprofile_add_data64(&entry, val);
  176. rdmsrl(MSR_AMD64_IBSDCLINAD, val);
  177. oprofile_add_data64(&entry, val);
  178. rdmsrl(MSR_AMD64_IBSDCPHYSAD, val);
  179. oprofile_add_data64(&entry, val);
  180. oprofile_write_commit(&entry);
  181. /* reenable the IRQ */
  182. ctl = op_amd_randomize_ibs_op(ibs_op_ctl);
  183. wrmsrl(MSR_AMD64_IBSOPCTL, ctl);
  184. }
  185. }
  186. }
  187. static inline void op_amd_start_ibs(void)
  188. {
  189. u64 val;
  190. if (!ibs_caps)
  191. return;
  192. if (ibs_config.fetch_enabled) {
  193. val = (ibs_config.max_cnt_fetch >> 4) & IBS_FETCH_MAX_CNT;
  194. val |= ibs_config.rand_en ? IBS_FETCH_RAND_EN : 0;
  195. val |= IBS_FETCH_ENABLE;
  196. wrmsrl(MSR_AMD64_IBSFETCHCTL, val);
  197. }
  198. if (ibs_config.op_enabled) {
  199. ibs_op_ctl = ibs_config.max_cnt_op >> 4;
  200. if (!(ibs_caps & IBS_CAPS_RDWROPCNT)) {
  201. /*
  202. * IbsOpCurCnt not supported. See
  203. * op_amd_randomize_ibs_op() for details.
  204. */
  205. ibs_op_ctl = clamp(ibs_op_ctl, 0x0081ULL, 0xFF80ULL);
  206. } else {
  207. /*
  208. * The start value is randomized with a
  209. * positive offset, we need to compensate it
  210. * with the half of the randomized range. Also
  211. * avoid underflows.
  212. */
  213. ibs_op_ctl = min(ibs_op_ctl + IBS_RANDOM_MAXCNT_OFFSET,
  214. IBS_OP_MAX_CNT);
  215. }
  216. if (ibs_caps & IBS_CAPS_OPCNT && ibs_config.dispatched_ops)
  217. ibs_op_ctl |= IBS_OP_CNT_CTL;
  218. ibs_op_ctl |= IBS_OP_ENABLE;
  219. val = op_amd_randomize_ibs_op(ibs_op_ctl);
  220. wrmsrl(MSR_AMD64_IBSOPCTL, val);
  221. }
  222. }
  223. static void op_amd_stop_ibs(void)
  224. {
  225. if (!ibs_caps)
  226. return;
  227. if (ibs_config.fetch_enabled)
  228. /* clear max count and enable */
  229. wrmsrl(MSR_AMD64_IBSFETCHCTL, 0);
  230. if (ibs_config.op_enabled)
  231. /* clear max count and enable */
  232. wrmsrl(MSR_AMD64_IBSOPCTL, 0);
  233. }
  234. static inline int eilvt_is_available(int offset)
  235. {
  236. /* check if we may assign a vector */
  237. return !setup_APIC_eilvt(offset, 0, APIC_EILVT_MSG_NMI, 1);
  238. }
  239. static inline int ibs_eilvt_valid(void)
  240. {
  241. u64 val;
  242. int offset;
  243. rdmsrl(MSR_AMD64_IBSCTL, val);
  244. if (!(val & IBSCTL_LVT_OFFSET_VALID)) {
  245. pr_err(FW_BUG "cpu %d, invalid IBS "
  246. "interrupt offset %d (MSR%08X=0x%016llx)",
  247. smp_processor_id(), offset,
  248. MSR_AMD64_IBSCTL, val);
  249. return 0;
  250. }
  251. offset = val & IBSCTL_LVT_OFFSET_MASK;
  252. if (eilvt_is_available(offset))
  253. return !0;
  254. pr_err(FW_BUG "cpu %d, IBS interrupt offset %d "
  255. "not available (MSR%08X=0x%016llx)",
  256. smp_processor_id(), offset,
  257. MSR_AMD64_IBSCTL, val);
  258. return 0;
  259. }
  260. static inline int get_ibs_offset(void)
  261. {
  262. u64 val;
  263. rdmsrl(MSR_AMD64_IBSCTL, val);
  264. if (!(val & IBSCTL_LVT_OFFSET_VALID))
  265. return -EINVAL;
  266. return val & IBSCTL_LVT_OFFSET_MASK;
  267. }
  268. static void setup_APIC_ibs(void)
  269. {
  270. int offset;
  271. offset = get_ibs_offset();
  272. if (offset < 0)
  273. goto failed;
  274. if (!setup_APIC_eilvt(offset, 0, APIC_EILVT_MSG_NMI, 0))
  275. return;
  276. failed:
  277. pr_warn("oprofile: IBS APIC setup failed on cpu #%d\n",
  278. smp_processor_id());
  279. }
  280. static void clear_APIC_ibs(void)
  281. {
  282. int offset;
  283. offset = get_ibs_offset();
  284. if (offset >= 0)
  285. setup_APIC_eilvt(offset, 0, APIC_EILVT_MSG_FIX, 1);
  286. }
  287. #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
  288. static void op_mux_switch_ctrl(struct op_x86_model_spec const *model,
  289. struct op_msrs const * const msrs)
  290. {
  291. u64 val;
  292. int i;
  293. /* enable active counters */
  294. for (i = 0; i < NUM_COUNTERS; ++i) {
  295. int virt = op_x86_phys_to_virt(i);
  296. if (!reset_value[virt])
  297. continue;
  298. rdmsrl(msrs->controls[i].addr, val);
  299. val &= model->reserved;
  300. val |= op_x86_get_ctrl(model, &counter_config[virt]);
  301. wrmsrl(msrs->controls[i].addr, val);
  302. }
  303. }
  304. #endif
  305. /* functions for op_amd_spec */
  306. static void op_amd_shutdown(struct op_msrs const * const msrs)
  307. {
  308. int i;
  309. for (i = 0; i < NUM_COUNTERS; ++i) {
  310. if (!msrs->counters[i].addr)
  311. continue;
  312. release_perfctr_nmi(MSR_K7_PERFCTR0 + i);
  313. release_evntsel_nmi(MSR_K7_EVNTSEL0 + i);
  314. }
  315. }
  316. static int op_amd_fill_in_addresses(struct op_msrs * const msrs)
  317. {
  318. int i;
  319. for (i = 0; i < NUM_COUNTERS; i++) {
  320. if (!reserve_perfctr_nmi(MSR_K7_PERFCTR0 + i))
  321. goto fail;
  322. if (!reserve_evntsel_nmi(MSR_K7_EVNTSEL0 + i)) {
  323. release_perfctr_nmi(MSR_K7_PERFCTR0 + i);
  324. goto fail;
  325. }
  326. /* both registers must be reserved */
  327. msrs->counters[i].addr = MSR_K7_PERFCTR0 + i;
  328. msrs->controls[i].addr = MSR_K7_EVNTSEL0 + i;
  329. continue;
  330. fail:
  331. if (!counter_config[i].enabled)
  332. continue;
  333. op_x86_warn_reserved(i);
  334. op_amd_shutdown(msrs);
  335. return -EBUSY;
  336. }
  337. return 0;
  338. }
  339. static void op_amd_setup_ctrs(struct op_x86_model_spec const *model,
  340. struct op_msrs const * const msrs)
  341. {
  342. u64 val;
  343. int i;
  344. /* setup reset_value */
  345. for (i = 0; i < NUM_VIRT_COUNTERS; ++i) {
  346. if (counter_config[i].enabled
  347. && msrs->counters[op_x86_virt_to_phys(i)].addr)
  348. reset_value[i] = counter_config[i].count;
  349. else
  350. reset_value[i] = 0;
  351. }
  352. /* clear all counters */
  353. for (i = 0; i < NUM_COUNTERS; ++i) {
  354. if (!msrs->controls[i].addr)
  355. continue;
  356. rdmsrl(msrs->controls[i].addr, val);
  357. if (val & ARCH_PERFMON_EVENTSEL_ENABLE)
  358. op_x86_warn_in_use(i);
  359. val &= model->reserved;
  360. wrmsrl(msrs->controls[i].addr, val);
  361. /*
  362. * avoid a false detection of ctr overflows in NMI
  363. * handler
  364. */
  365. wrmsrl(msrs->counters[i].addr, -1LL);
  366. }
  367. /* enable active counters */
  368. for (i = 0; i < NUM_COUNTERS; ++i) {
  369. int virt = op_x86_phys_to_virt(i);
  370. if (!reset_value[virt])
  371. continue;
  372. /* setup counter registers */
  373. wrmsrl(msrs->counters[i].addr, -(u64)reset_value[virt]);
  374. /* setup control registers */
  375. rdmsrl(msrs->controls[i].addr, val);
  376. val &= model->reserved;
  377. val |= op_x86_get_ctrl(model, &counter_config[virt]);
  378. wrmsrl(msrs->controls[i].addr, val);
  379. }
  380. if (ibs_caps)
  381. setup_APIC_ibs();
  382. }
  383. static void op_amd_cpu_shutdown(void)
  384. {
  385. if (ibs_caps)
  386. clear_APIC_ibs();
  387. }
  388. static int op_amd_check_ctrs(struct pt_regs * const regs,
  389. struct op_msrs const * const msrs)
  390. {
  391. u64 val;
  392. int i;
  393. for (i = 0; i < NUM_COUNTERS; ++i) {
  394. int virt = op_x86_phys_to_virt(i);
  395. if (!reset_value[virt])
  396. continue;
  397. rdmsrl(msrs->counters[i].addr, val);
  398. /* bit is clear if overflowed: */
  399. if (val & OP_CTR_OVERFLOW)
  400. continue;
  401. oprofile_add_sample(regs, virt);
  402. wrmsrl(msrs->counters[i].addr, -(u64)reset_value[virt]);
  403. }
  404. op_amd_handle_ibs(regs, msrs);
  405. /* See op_model_ppro.c */
  406. return 1;
  407. }
  408. static void op_amd_start(struct op_msrs const * const msrs)
  409. {
  410. u64 val;
  411. int i;
  412. for (i = 0; i < NUM_COUNTERS; ++i) {
  413. if (!reset_value[op_x86_phys_to_virt(i)])
  414. continue;
  415. rdmsrl(msrs->controls[i].addr, val);
  416. val |= ARCH_PERFMON_EVENTSEL_ENABLE;
  417. wrmsrl(msrs->controls[i].addr, val);
  418. }
  419. op_amd_start_ibs();
  420. }
  421. static void op_amd_stop(struct op_msrs const * const msrs)
  422. {
  423. u64 val;
  424. int i;
  425. /*
  426. * Subtle: stop on all counters to avoid race with setting our
  427. * pm callback
  428. */
  429. for (i = 0; i < NUM_COUNTERS; ++i) {
  430. if (!reset_value[op_x86_phys_to_virt(i)])
  431. continue;
  432. rdmsrl(msrs->controls[i].addr, val);
  433. val &= ~ARCH_PERFMON_EVENTSEL_ENABLE;
  434. wrmsrl(msrs->controls[i].addr, val);
  435. }
  436. op_amd_stop_ibs();
  437. }
  438. static int setup_ibs_ctl(int ibs_eilvt_off)
  439. {
  440. struct pci_dev *cpu_cfg;
  441. int nodes;
  442. u32 value = 0;
  443. nodes = 0;
  444. cpu_cfg = NULL;
  445. do {
  446. cpu_cfg = pci_get_device(PCI_VENDOR_ID_AMD,
  447. PCI_DEVICE_ID_AMD_10H_NB_MISC,
  448. cpu_cfg);
  449. if (!cpu_cfg)
  450. break;
  451. ++nodes;
  452. pci_write_config_dword(cpu_cfg, IBSCTL, ibs_eilvt_off
  453. | IBSCTL_LVT_OFFSET_VALID);
  454. pci_read_config_dword(cpu_cfg, IBSCTL, &value);
  455. if (value != (ibs_eilvt_off | IBSCTL_LVT_OFFSET_VALID)) {
  456. pci_dev_put(cpu_cfg);
  457. printk(KERN_DEBUG "Failed to setup IBS LVT offset, "
  458. "IBSCTL = 0x%08x\n", value);
  459. return -EINVAL;
  460. }
  461. } while (1);
  462. if (!nodes) {
  463. printk(KERN_DEBUG "No CPU node configured for IBS\n");
  464. return -ENODEV;
  465. }
  466. return 0;
  467. }
  468. static int force_ibs_eilvt_setup(void)
  469. {
  470. int i;
  471. int ret;
  472. /* find the next free available EILVT entry */
  473. for (i = 1; i < 4; i++) {
  474. if (!eilvt_is_available(i))
  475. continue;
  476. ret = setup_ibs_ctl(i);
  477. if (ret)
  478. return ret;
  479. return 0;
  480. }
  481. printk(KERN_DEBUG "No EILVT entry available\n");
  482. return -EBUSY;
  483. }
  484. static int __init_ibs_nmi(void)
  485. {
  486. int ret;
  487. if (ibs_eilvt_valid())
  488. return 0;
  489. ret = force_ibs_eilvt_setup();
  490. if (ret)
  491. return ret;
  492. if (!ibs_eilvt_valid())
  493. return -EFAULT;
  494. pr_err(FW_BUG "workaround enabled for IBS LVT offset\n");
  495. return 0;
  496. }
  497. /* initialize the APIC for the IBS interrupts if available */
  498. static void init_ibs(void)
  499. {
  500. ibs_caps = get_ibs_caps();
  501. if (!ibs_caps)
  502. return;
  503. if (__init_ibs_nmi()) {
  504. ibs_caps = 0;
  505. return;
  506. }
  507. printk(KERN_INFO "oprofile: AMD IBS detected (0x%08x)\n",
  508. (unsigned)ibs_caps);
  509. }
  510. static int (*create_arch_files)(struct super_block *sb, struct dentry *root);
  511. static int setup_ibs_files(struct super_block *sb, struct dentry *root)
  512. {
  513. struct dentry *dir;
  514. int ret = 0;
  515. /* architecture specific files */
  516. if (create_arch_files)
  517. ret = create_arch_files(sb, root);
  518. if (ret)
  519. return ret;
  520. if (!ibs_caps)
  521. return ret;
  522. /* model specific files */
  523. /* setup some reasonable defaults */
  524. ibs_config.max_cnt_fetch = 250000;
  525. ibs_config.fetch_enabled = 0;
  526. ibs_config.max_cnt_op = 250000;
  527. ibs_config.op_enabled = 0;
  528. ibs_config.dispatched_ops = 0;
  529. dir = oprofilefs_mkdir(sb, root, "ibs_fetch");
  530. oprofilefs_create_ulong(sb, dir, "enable",
  531. &ibs_config.fetch_enabled);
  532. oprofilefs_create_ulong(sb, dir, "max_count",
  533. &ibs_config.max_cnt_fetch);
  534. oprofilefs_create_ulong(sb, dir, "rand_enable",
  535. &ibs_config.rand_en);
  536. dir = oprofilefs_mkdir(sb, root, "ibs_op");
  537. oprofilefs_create_ulong(sb, dir, "enable",
  538. &ibs_config.op_enabled);
  539. oprofilefs_create_ulong(sb, dir, "max_count",
  540. &ibs_config.max_cnt_op);
  541. if (ibs_caps & IBS_CAPS_OPCNT)
  542. oprofilefs_create_ulong(sb, dir, "dispatched_ops",
  543. &ibs_config.dispatched_ops);
  544. return 0;
  545. }
  546. static int op_amd_init(struct oprofile_operations *ops)
  547. {
  548. init_ibs();
  549. create_arch_files = ops->create_files;
  550. ops->create_files = setup_ibs_files;
  551. return 0;
  552. }
  553. struct op_x86_model_spec op_amd_spec = {
  554. .num_counters = NUM_COUNTERS,
  555. .num_controls = NUM_COUNTERS,
  556. .num_virt_counters = NUM_VIRT_COUNTERS,
  557. .reserved = MSR_AMD_EVENTSEL_RESERVED,
  558. .event_mask = OP_EVENT_MASK,
  559. .init = op_amd_init,
  560. .fill_in_addresses = &op_amd_fill_in_addresses,
  561. .setup_ctrs = &op_amd_setup_ctrs,
  562. .cpu_down = &op_amd_cpu_shutdown,
  563. .check_ctrs = &op_amd_check_ctrs,
  564. .start = &op_amd_start,
  565. .stop = &op_amd_stop,
  566. .shutdown = &op_amd_shutdown,
  567. #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
  568. .switch_ctrl = &op_mux_switch_ctrl,
  569. #endif
  570. };