power6-pmu.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. /*
  2. * Performance counter support for POWER6 processors.
  3. *
  4. * Copyright 2008-2009 Paul Mackerras, IBM Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/perf_event.h>
  13. #include <linux/string.h>
  14. #include <asm/reg.h>
  15. #include <asm/cputable.h>
  16. /*
  17. * Bits in event code for POWER6
  18. */
  19. #define PM_PMC_SH 20 /* PMC number (1-based) for direct events */
  20. #define PM_PMC_MSK 0x7
  21. #define PM_PMC_MSKS (PM_PMC_MSK << PM_PMC_SH)
  22. #define PM_UNIT_SH 16 /* Unit event comes (TTMxSEL encoding) */
  23. #define PM_UNIT_MSK 0xf
  24. #define PM_UNIT_MSKS (PM_UNIT_MSK << PM_UNIT_SH)
  25. #define PM_LLAV 0x8000 /* Load lookahead match value */
  26. #define PM_LLA 0x4000 /* Load lookahead match enable */
  27. #define PM_BYTE_SH 12 /* Byte of event bus to use */
  28. #define PM_BYTE_MSK 3
  29. #define PM_SUBUNIT_SH 8 /* Subunit event comes from (NEST_SEL enc.) */
  30. #define PM_SUBUNIT_MSK 7
  31. #define PM_SUBUNIT_MSKS (PM_SUBUNIT_MSK << PM_SUBUNIT_SH)
  32. #define PM_PMCSEL_MSK 0xff /* PMCxSEL value */
  33. #define PM_BUSEVENT_MSK 0xf3700
  34. /*
  35. * Bits in MMCR1 for POWER6
  36. */
  37. #define MMCR1_TTM0SEL_SH 60
  38. #define MMCR1_TTMSEL_SH(n) (MMCR1_TTM0SEL_SH - (n) * 4)
  39. #define MMCR1_TTMSEL_MSK 0xf
  40. #define MMCR1_TTMSEL(m, n) (((m) >> MMCR1_TTMSEL_SH(n)) & MMCR1_TTMSEL_MSK)
  41. #define MMCR1_NESTSEL_SH 45
  42. #define MMCR1_NESTSEL_MSK 0x7
  43. #define MMCR1_NESTSEL(m) (((m) >> MMCR1_NESTSEL_SH) & MMCR1_NESTSEL_MSK)
  44. #define MMCR1_PMC1_LLA (1ul << 44)
  45. #define MMCR1_PMC1_LLA_VALUE (1ul << 39)
  46. #define MMCR1_PMC1_ADDR_SEL (1ul << 35)
  47. #define MMCR1_PMC1SEL_SH 24
  48. #define MMCR1_PMCSEL_SH(n) (MMCR1_PMC1SEL_SH - (n) * 8)
  49. #define MMCR1_PMCSEL_MSK 0xff
  50. /*
  51. * Map of which direct events on which PMCs are marked instruction events.
  52. * Indexed by PMCSEL value >> 1.
  53. * Bottom 4 bits are a map of which PMCs are interesting,
  54. * top 4 bits say what sort of event:
  55. * 0 = direct marked event,
  56. * 1 = byte decode event,
  57. * 4 = add/and event (PMC1 -> bits 0 & 4),
  58. * 5 = add/and event (PMC1 -> bits 1 & 5),
  59. * 6 = add/and event (PMC1 -> bits 2 & 6),
  60. * 7 = add/and event (PMC1 -> bits 3 & 7).
  61. */
  62. static unsigned char direct_event_is_marked[0x60 >> 1] = {
  63. 0, /* 00 */
  64. 0, /* 02 */
  65. 0, /* 04 */
  66. 0x07, /* 06 PM_MRK_ST_CMPL, PM_MRK_ST_GPS, PM_MRK_ST_CMPL_INT */
  67. 0x04, /* 08 PM_MRK_DFU_FIN */
  68. 0x06, /* 0a PM_MRK_IFU_FIN, PM_MRK_INST_FIN */
  69. 0, /* 0c */
  70. 0, /* 0e */
  71. 0x02, /* 10 PM_MRK_INST_DISP */
  72. 0x08, /* 12 PM_MRK_LSU_DERAT_MISS */
  73. 0, /* 14 */
  74. 0, /* 16 */
  75. 0x0c, /* 18 PM_THRESH_TIMEO, PM_MRK_INST_FIN */
  76. 0x0f, /* 1a PM_MRK_INST_DISP, PM_MRK_{FXU,FPU,LSU}_FIN */
  77. 0x01, /* 1c PM_MRK_INST_ISSUED */
  78. 0, /* 1e */
  79. 0, /* 20 */
  80. 0, /* 22 */
  81. 0, /* 24 */
  82. 0, /* 26 */
  83. 0x15, /* 28 PM_MRK_DATA_FROM_L2MISS, PM_MRK_DATA_FROM_L3MISS */
  84. 0, /* 2a */
  85. 0, /* 2c */
  86. 0, /* 2e */
  87. 0x4f, /* 30 */
  88. 0x7f, /* 32 */
  89. 0x4f, /* 34 */
  90. 0x5f, /* 36 */
  91. 0x6f, /* 38 */
  92. 0x4f, /* 3a */
  93. 0, /* 3c */
  94. 0x08, /* 3e PM_MRK_INST_TIMEO */
  95. 0x1f, /* 40 */
  96. 0x1f, /* 42 */
  97. 0x1f, /* 44 */
  98. 0x1f, /* 46 */
  99. 0x1f, /* 48 */
  100. 0x1f, /* 4a */
  101. 0x1f, /* 4c */
  102. 0x1f, /* 4e */
  103. 0, /* 50 */
  104. 0x05, /* 52 PM_MRK_BR_TAKEN, PM_MRK_BR_MPRED */
  105. 0x1c, /* 54 PM_MRK_PTEG_FROM_L3MISS, PM_MRK_PTEG_FROM_L2MISS */
  106. 0x02, /* 56 PM_MRK_LD_MISS_L1 */
  107. 0, /* 58 */
  108. 0, /* 5a */
  109. 0, /* 5c */
  110. 0, /* 5e */
  111. };
  112. /*
  113. * Masks showing for each unit which bits are marked events.
  114. * These masks are in LE order, i.e. 0x00000001 is byte 0, bit 0.
  115. */
  116. static u32 marked_bus_events[16] = {
  117. 0x01000000, /* direct events set 1: byte 3 bit 0 */
  118. 0x00010000, /* direct events set 2: byte 2 bit 0 */
  119. 0, 0, 0, 0, /* IDU, IFU, nest: nothing */
  120. 0x00000088, /* VMX set 1: byte 0 bits 3, 7 */
  121. 0x000000c0, /* VMX set 2: byte 0 bits 4-7 */
  122. 0x04010000, /* LSU set 1: byte 2 bit 0, byte 3 bit 2 */
  123. 0xff010000u, /* LSU set 2: byte 2 bit 0, all of byte 3 */
  124. 0, /* LSU set 3 */
  125. 0x00000010, /* VMX set 3: byte 0 bit 4 */
  126. 0, /* BFP set 1 */
  127. 0x00000022, /* BFP set 2: byte 0 bits 1, 5 */
  128. 0, 0
  129. };
  130. /*
  131. * Returns 1 if event counts things relating to marked instructions
  132. * and thus needs the MMCRA_SAMPLE_ENABLE bit set, or 0 if not.
  133. */
  134. static int power6_marked_instr_event(u64 event)
  135. {
  136. int pmc, psel, ptype;
  137. int bit, byte, unit;
  138. u32 mask;
  139. pmc = (event >> PM_PMC_SH) & PM_PMC_MSK;
  140. psel = (event & PM_PMCSEL_MSK) >> 1; /* drop edge/level bit */
  141. if (pmc >= 5)
  142. return 0;
  143. bit = -1;
  144. if (psel < sizeof(direct_event_is_marked)) {
  145. ptype = direct_event_is_marked[psel];
  146. if (pmc == 0 || !(ptype & (1 << (pmc - 1))))
  147. return 0;
  148. ptype >>= 4;
  149. if (ptype == 0)
  150. return 1;
  151. if (ptype == 1)
  152. bit = 0;
  153. else
  154. bit = ptype ^ (pmc - 1);
  155. } else if ((psel & 0x48) == 0x40)
  156. bit = psel & 7;
  157. if (!(event & PM_BUSEVENT_MSK) || bit == -1)
  158. return 0;
  159. byte = (event >> PM_BYTE_SH) & PM_BYTE_MSK;
  160. unit = (event >> PM_UNIT_SH) & PM_UNIT_MSK;
  161. mask = marked_bus_events[unit];
  162. return (mask >> (byte * 8 + bit)) & 1;
  163. }
  164. /*
  165. * Assign PMC numbers and compute MMCR1 value for a set of events
  166. */
  167. static int p6_compute_mmcr(u64 event[], int n_ev,
  168. unsigned int hwc[], unsigned long mmcr[], struct perf_event *pevents[])
  169. {
  170. unsigned long mmcr1 = 0;
  171. unsigned long mmcra = MMCRA_SDAR_DCACHE_MISS | MMCRA_SDAR_ERAT_MISS;
  172. int i;
  173. unsigned int pmc, ev, b, u, s, psel;
  174. unsigned int ttmset = 0;
  175. unsigned int pmc_inuse = 0;
  176. if (n_ev > 6)
  177. return -1;
  178. for (i = 0; i < n_ev; ++i) {
  179. pmc = (event[i] >> PM_PMC_SH) & PM_PMC_MSK;
  180. if (pmc) {
  181. if (pmc_inuse & (1 << (pmc - 1)))
  182. return -1; /* collision! */
  183. pmc_inuse |= 1 << (pmc - 1);
  184. }
  185. }
  186. for (i = 0; i < n_ev; ++i) {
  187. ev = event[i];
  188. pmc = (ev >> PM_PMC_SH) & PM_PMC_MSK;
  189. if (pmc) {
  190. --pmc;
  191. } else {
  192. /* can go on any PMC; find a free one */
  193. for (pmc = 0; pmc < 4; ++pmc)
  194. if (!(pmc_inuse & (1 << pmc)))
  195. break;
  196. if (pmc >= 4)
  197. return -1;
  198. pmc_inuse |= 1 << pmc;
  199. }
  200. hwc[i] = pmc;
  201. psel = ev & PM_PMCSEL_MSK;
  202. if (ev & PM_BUSEVENT_MSK) {
  203. /* this event uses the event bus */
  204. b = (ev >> PM_BYTE_SH) & PM_BYTE_MSK;
  205. u = (ev >> PM_UNIT_SH) & PM_UNIT_MSK;
  206. /* check for conflict on this byte of event bus */
  207. if ((ttmset & (1 << b)) && MMCR1_TTMSEL(mmcr1, b) != u)
  208. return -1;
  209. mmcr1 |= (unsigned long)u << MMCR1_TTMSEL_SH(b);
  210. ttmset |= 1 << b;
  211. if (u == 5) {
  212. /* Nest events have a further mux */
  213. s = (ev >> PM_SUBUNIT_SH) & PM_SUBUNIT_MSK;
  214. if ((ttmset & 0x10) &&
  215. MMCR1_NESTSEL(mmcr1) != s)
  216. return -1;
  217. ttmset |= 0x10;
  218. mmcr1 |= (unsigned long)s << MMCR1_NESTSEL_SH;
  219. }
  220. if (0x30 <= psel && psel <= 0x3d) {
  221. /* these need the PMCx_ADDR_SEL bits */
  222. if (b >= 2)
  223. mmcr1 |= MMCR1_PMC1_ADDR_SEL >> pmc;
  224. }
  225. /* bus select values are different for PMC3/4 */
  226. if (pmc >= 2 && (psel & 0x90) == 0x80)
  227. psel ^= 0x20;
  228. }
  229. if (ev & PM_LLA) {
  230. mmcr1 |= MMCR1_PMC1_LLA >> pmc;
  231. if (ev & PM_LLAV)
  232. mmcr1 |= MMCR1_PMC1_LLA_VALUE >> pmc;
  233. }
  234. if (power6_marked_instr_event(event[i]))
  235. mmcra |= MMCRA_SAMPLE_ENABLE;
  236. if (pmc < 4)
  237. mmcr1 |= (unsigned long)psel << MMCR1_PMCSEL_SH(pmc);
  238. }
  239. mmcr[0] = 0;
  240. if (pmc_inuse & 1)
  241. mmcr[0] = MMCR0_PMC1CE;
  242. if (pmc_inuse & 0xe)
  243. mmcr[0] |= MMCR0_PMCjCE;
  244. mmcr[1] = mmcr1;
  245. mmcr[2] = mmcra;
  246. return 0;
  247. }
  248. /*
  249. * Layout of constraint bits:
  250. *
  251. * 0-1 add field: number of uses of PMC1 (max 1)
  252. * 2-3, 4-5, 6-7, 8-9, 10-11: ditto for PMC2, 3, 4, 5, 6
  253. * 12-15 add field: number of uses of PMC1-4 (max 4)
  254. * 16-19 select field: unit on byte 0 of event bus
  255. * 20-23, 24-27, 28-31 ditto for bytes 1, 2, 3
  256. * 32-34 select field: nest (subunit) event selector
  257. */
  258. static int p6_get_constraint(u64 event, unsigned long *maskp,
  259. unsigned long *valp)
  260. {
  261. int pmc, byte, sh, subunit;
  262. unsigned long mask = 0, value = 0;
  263. pmc = (event >> PM_PMC_SH) & PM_PMC_MSK;
  264. if (pmc) {
  265. if (pmc > 4 && !(event == 0x500009 || event == 0x600005))
  266. return -1;
  267. sh = (pmc - 1) * 2;
  268. mask |= 2 << sh;
  269. value |= 1 << sh;
  270. }
  271. if (event & PM_BUSEVENT_MSK) {
  272. byte = (event >> PM_BYTE_SH) & PM_BYTE_MSK;
  273. sh = byte * 4 + (16 - PM_UNIT_SH);
  274. mask |= PM_UNIT_MSKS << sh;
  275. value |= (unsigned long)(event & PM_UNIT_MSKS) << sh;
  276. if ((event & PM_UNIT_MSKS) == (5 << PM_UNIT_SH)) {
  277. subunit = (event >> PM_SUBUNIT_SH) & PM_SUBUNIT_MSK;
  278. mask |= (unsigned long)PM_SUBUNIT_MSK << 32;
  279. value |= (unsigned long)subunit << 32;
  280. }
  281. }
  282. if (pmc <= 4) {
  283. mask |= 0x8000; /* add field for count of PMC1-4 uses */
  284. value |= 0x1000;
  285. }
  286. *maskp = mask;
  287. *valp = value;
  288. return 0;
  289. }
  290. static int p6_limited_pmc_event(u64 event)
  291. {
  292. int pmc = (event >> PM_PMC_SH) & PM_PMC_MSK;
  293. return pmc == 5 || pmc == 6;
  294. }
  295. #define MAX_ALT 4 /* at most 4 alternatives for any event */
  296. static const unsigned int event_alternatives[][MAX_ALT] = {
  297. { 0x0130e8, 0x2000f6, 0x3000fc }, /* PM_PTEG_RELOAD_VALID */
  298. { 0x080080, 0x10000d, 0x30000c, 0x4000f0 }, /* PM_LD_MISS_L1 */
  299. { 0x080088, 0x200054, 0x3000f0 }, /* PM_ST_MISS_L1 */
  300. { 0x10000a, 0x2000f4, 0x600005 }, /* PM_RUN_CYC */
  301. { 0x10000b, 0x2000f5 }, /* PM_RUN_COUNT */
  302. { 0x10000e, 0x400010 }, /* PM_PURR */
  303. { 0x100010, 0x4000f8 }, /* PM_FLUSH */
  304. { 0x10001a, 0x200010 }, /* PM_MRK_INST_DISP */
  305. { 0x100026, 0x3000f8 }, /* PM_TB_BIT_TRANS */
  306. { 0x100054, 0x2000f0 }, /* PM_ST_FIN */
  307. { 0x100056, 0x2000fc }, /* PM_L1_ICACHE_MISS */
  308. { 0x1000f0, 0x40000a }, /* PM_INST_IMC_MATCH_CMPL */
  309. { 0x1000f8, 0x200008 }, /* PM_GCT_EMPTY_CYC */
  310. { 0x1000fc, 0x400006 }, /* PM_LSU_DERAT_MISS_CYC */
  311. { 0x20000e, 0x400007 }, /* PM_LSU_DERAT_MISS */
  312. { 0x200012, 0x300012 }, /* PM_INST_DISP */
  313. { 0x2000f2, 0x3000f2 }, /* PM_INST_DISP */
  314. { 0x2000f8, 0x300010 }, /* PM_EXT_INT */
  315. { 0x2000fe, 0x300056 }, /* PM_DATA_FROM_L2MISS */
  316. { 0x2d0030, 0x30001a }, /* PM_MRK_FPU_FIN */
  317. { 0x30000a, 0x400018 }, /* PM_MRK_INST_FIN */
  318. { 0x3000f6, 0x40000e }, /* PM_L1_DCACHE_RELOAD_VALID */
  319. { 0x3000fe, 0x400056 }, /* PM_DATA_FROM_L3MISS */
  320. };
  321. /*
  322. * This could be made more efficient with a binary search on
  323. * a presorted list, if necessary
  324. */
  325. static int find_alternatives_list(u64 event)
  326. {
  327. int i, j;
  328. unsigned int alt;
  329. for (i = 0; i < ARRAY_SIZE(event_alternatives); ++i) {
  330. if (event < event_alternatives[i][0])
  331. return -1;
  332. for (j = 0; j < MAX_ALT; ++j) {
  333. alt = event_alternatives[i][j];
  334. if (!alt || event < alt)
  335. break;
  336. if (event == alt)
  337. return i;
  338. }
  339. }
  340. return -1;
  341. }
  342. static int p6_get_alternatives(u64 event, unsigned int flags, u64 alt[])
  343. {
  344. int i, j, nlim;
  345. unsigned int psel, pmc;
  346. unsigned int nalt = 1;
  347. u64 aevent;
  348. alt[0] = event;
  349. nlim = p6_limited_pmc_event(event);
  350. /* check the alternatives table */
  351. i = find_alternatives_list(event);
  352. if (i >= 0) {
  353. /* copy out alternatives from list */
  354. for (j = 0; j < MAX_ALT; ++j) {
  355. aevent = event_alternatives[i][j];
  356. if (!aevent)
  357. break;
  358. if (aevent != event)
  359. alt[nalt++] = aevent;
  360. nlim += p6_limited_pmc_event(aevent);
  361. }
  362. } else {
  363. /* Check for alternative ways of computing sum events */
  364. /* PMCSEL 0x32 counter N == PMCSEL 0x34 counter 5-N */
  365. psel = event & (PM_PMCSEL_MSK & ~1); /* ignore edge bit */
  366. pmc = (event >> PM_PMC_SH) & PM_PMC_MSK;
  367. if (pmc && (psel == 0x32 || psel == 0x34))
  368. alt[nalt++] = ((event ^ 0x6) & ~PM_PMC_MSKS) |
  369. ((5 - pmc) << PM_PMC_SH);
  370. /* PMCSEL 0x38 counter N == PMCSEL 0x3a counter N+/-2 */
  371. if (pmc && (psel == 0x38 || psel == 0x3a))
  372. alt[nalt++] = ((event ^ 0x2) & ~PM_PMC_MSKS) |
  373. ((pmc > 2? pmc - 2: pmc + 2) << PM_PMC_SH);
  374. }
  375. if (flags & PPMU_ONLY_COUNT_RUN) {
  376. /*
  377. * We're only counting in RUN state,
  378. * so PM_CYC is equivalent to PM_RUN_CYC,
  379. * PM_INST_CMPL === PM_RUN_INST_CMPL, PM_PURR === PM_RUN_PURR.
  380. * This doesn't include alternatives that don't provide
  381. * any extra flexibility in assigning PMCs (e.g.
  382. * 0x10000a for PM_RUN_CYC vs. 0x1e for PM_CYC).
  383. * Note that even with these additional alternatives
  384. * we never end up with more than 4 alternatives for any event.
  385. */
  386. j = nalt;
  387. for (i = 0; i < nalt; ++i) {
  388. switch (alt[i]) {
  389. case 0x1e: /* PM_CYC */
  390. alt[j++] = 0x600005; /* PM_RUN_CYC */
  391. ++nlim;
  392. break;
  393. case 0x10000a: /* PM_RUN_CYC */
  394. alt[j++] = 0x1e; /* PM_CYC */
  395. break;
  396. case 2: /* PM_INST_CMPL */
  397. alt[j++] = 0x500009; /* PM_RUN_INST_CMPL */
  398. ++nlim;
  399. break;
  400. case 0x500009: /* PM_RUN_INST_CMPL */
  401. alt[j++] = 2; /* PM_INST_CMPL */
  402. break;
  403. case 0x10000e: /* PM_PURR */
  404. alt[j++] = 0x4000f4; /* PM_RUN_PURR */
  405. break;
  406. case 0x4000f4: /* PM_RUN_PURR */
  407. alt[j++] = 0x10000e; /* PM_PURR */
  408. break;
  409. }
  410. }
  411. nalt = j;
  412. }
  413. if (!(flags & PPMU_LIMITED_PMC_OK) && nlim) {
  414. /* remove the limited PMC events */
  415. j = 0;
  416. for (i = 0; i < nalt; ++i) {
  417. if (!p6_limited_pmc_event(alt[i])) {
  418. alt[j] = alt[i];
  419. ++j;
  420. }
  421. }
  422. nalt = j;
  423. } else if ((flags & PPMU_LIMITED_PMC_REQD) && nlim < nalt) {
  424. /* remove all but the limited PMC events */
  425. j = 0;
  426. for (i = 0; i < nalt; ++i) {
  427. if (p6_limited_pmc_event(alt[i])) {
  428. alt[j] = alt[i];
  429. ++j;
  430. }
  431. }
  432. nalt = j;
  433. }
  434. return nalt;
  435. }
  436. static void p6_disable_pmc(unsigned int pmc, unsigned long mmcr[])
  437. {
  438. /* Set PMCxSEL to 0 to disable PMCx */
  439. if (pmc <= 3)
  440. mmcr[1] &= ~(0xffUL << MMCR1_PMCSEL_SH(pmc));
  441. }
  442. static int power6_generic_events[] = {
  443. [PERF_COUNT_HW_CPU_CYCLES] = 0x1e,
  444. [PERF_COUNT_HW_INSTRUCTIONS] = 2,
  445. [PERF_COUNT_HW_CACHE_REFERENCES] = 0x280030, /* LD_REF_L1 */
  446. [PERF_COUNT_HW_CACHE_MISSES] = 0x30000c, /* LD_MISS_L1 */
  447. [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 0x410a0, /* BR_PRED */
  448. [PERF_COUNT_HW_BRANCH_MISSES] = 0x400052, /* BR_MPRED */
  449. };
  450. #define C(x) PERF_COUNT_HW_CACHE_##x
  451. /*
  452. * Table of generalized cache-related events.
  453. * 0 means not supported, -1 means nonsensical, other values
  454. * are event codes.
  455. * The "DTLB" and "ITLB" events relate to the DERAT and IERAT.
  456. */
  457. static int power6_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = {
  458. [C(L1D)] = { /* RESULT_ACCESS RESULT_MISS */
  459. [C(OP_READ)] = { 0x280030, 0x80080 },
  460. [C(OP_WRITE)] = { 0x180032, 0x80088 },
  461. [C(OP_PREFETCH)] = { 0x810a4, 0 },
  462. },
  463. [C(L1I)] = { /* RESULT_ACCESS RESULT_MISS */
  464. [C(OP_READ)] = { 0, 0x100056 },
  465. [C(OP_WRITE)] = { -1, -1 },
  466. [C(OP_PREFETCH)] = { 0x4008c, 0 },
  467. },
  468. [C(LL)] = { /* RESULT_ACCESS RESULT_MISS */
  469. [C(OP_READ)] = { 0x150730, 0x250532 },
  470. [C(OP_WRITE)] = { 0x250432, 0x150432 },
  471. [C(OP_PREFETCH)] = { 0x810a6, 0 },
  472. },
  473. [C(DTLB)] = { /* RESULT_ACCESS RESULT_MISS */
  474. [C(OP_READ)] = { 0, 0x20000e },
  475. [C(OP_WRITE)] = { -1, -1 },
  476. [C(OP_PREFETCH)] = { -1, -1 },
  477. },
  478. [C(ITLB)] = { /* RESULT_ACCESS RESULT_MISS */
  479. [C(OP_READ)] = { 0, 0x420ce },
  480. [C(OP_WRITE)] = { -1, -1 },
  481. [C(OP_PREFETCH)] = { -1, -1 },
  482. },
  483. [C(BPU)] = { /* RESULT_ACCESS RESULT_MISS */
  484. [C(OP_READ)] = { 0x430e6, 0x400052 },
  485. [C(OP_WRITE)] = { -1, -1 },
  486. [C(OP_PREFETCH)] = { -1, -1 },
  487. },
  488. [C(NODE)] = { /* RESULT_ACCESS RESULT_MISS */
  489. [C(OP_READ)] = { -1, -1 },
  490. [C(OP_WRITE)] = { -1, -1 },
  491. [C(OP_PREFETCH)] = { -1, -1 },
  492. },
  493. };
  494. static struct power_pmu power6_pmu = {
  495. .name = "POWER6",
  496. .n_counter = 6,
  497. .max_alternatives = MAX_ALT,
  498. .add_fields = 0x1555,
  499. .test_adder = 0x3000,
  500. .compute_mmcr = p6_compute_mmcr,
  501. .get_constraint = p6_get_constraint,
  502. .get_alternatives = p6_get_alternatives,
  503. .disable_pmc = p6_disable_pmc,
  504. .limited_pmc_event = p6_limited_pmc_event,
  505. .flags = PPMU_LIMITED_PMC5_6 | PPMU_ALT_SIPR,
  506. .n_generic = ARRAY_SIZE(power6_generic_events),
  507. .generic_events = power6_generic_events,
  508. .cache_events = &power6_cache_events,
  509. };
  510. static int __init init_power6_pmu(void)
  511. {
  512. if (!cur_cpu_spec->oprofile_cpu_type ||
  513. strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power6"))
  514. return -ENODEV;
  515. return register_power_pmu(&power6_pmu);
  516. }
  517. early_initcall(init_power6_pmu);