op_model_cell.c 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720
  1. /*
  2. * Cell Broadband Engine OProfile Support
  3. *
  4. * (C) Copyright IBM Corporation 2006
  5. *
  6. * Author: David Erb (djerb@us.ibm.com)
  7. * Modifications:
  8. * Carl Love <carll@us.ibm.com>
  9. * Maynard Johnson <maynardj@us.ibm.com>
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License
  13. * as published by the Free Software Foundation; either version
  14. * 2 of the License, or (at your option) any later version.
  15. */
  16. #include <linux/cpufreq.h>
  17. #include <linux/delay.h>
  18. #include <linux/init.h>
  19. #include <linux/jiffies.h>
  20. #include <linux/kthread.h>
  21. #include <linux/oprofile.h>
  22. #include <linux/percpu.h>
  23. #include <linux/smp.h>
  24. #include <linux/spinlock.h>
  25. #include <linux/timer.h>
  26. #include <asm/cell-pmu.h>
  27. #include <asm/cputable.h>
  28. #include <asm/firmware.h>
  29. #include <asm/io.h>
  30. #include <asm/oprofile_impl.h>
  31. #include <asm/processor.h>
  32. #include <asm/prom.h>
  33. #include <asm/ptrace.h>
  34. #include <asm/reg.h>
  35. #include <asm/rtas.h>
  36. #include <asm/system.h>
  37. #include <asm/cell-regs.h>
  38. #include "../platforms/cell/interrupt.h"
  39. #include "cell/pr_util.h"
  40. #define PPU_PROFILING 0
  41. #define SPU_PROFILING_CYCLES 1
  42. #define SPU_PROFILING_EVENTS 2
  43. #define SPU_EVENT_NUM_START 4100
  44. #define SPU_EVENT_NUM_STOP 4399
  45. #define SPU_PROFILE_EVENT_ADDR 4363 /* spu, address trace, decimal */
  46. #define SPU_PROFILE_EVENT_ADDR_MASK_A 0x146 /* sub unit set to zero */
  47. #define SPU_PROFILE_EVENT_ADDR_MASK_B 0x186 /* sub unit set to zero */
  48. #define NUM_SPUS_PER_NODE 8
  49. #define SPU_CYCLES_EVENT_NUM 2 /* event number for SPU_CYCLES */
  50. #define PPU_CYCLES_EVENT_NUM 1 /* event number for CYCLES */
  51. #define PPU_CYCLES_GRP_NUM 1 /* special group number for identifying
  52. * PPU_CYCLES event
  53. */
  54. #define CBE_COUNT_ALL_CYCLES 0x42800000 /* PPU cycle event specifier */
  55. #define NUM_THREADS 2 /* number of physical threads in
  56. * physical processor
  57. */
  58. #define NUM_DEBUG_BUS_WORDS 4
  59. #define NUM_INPUT_BUS_WORDS 2
  60. #define MAX_SPU_COUNT 0xFFFFFF /* maximum 24 bit LFSR value */
  61. /* Minumum HW interval timer setting to send value to trace buffer is 10 cycle.
  62. * To configure counter to send value every N cycles set counter to
  63. * 2^32 - 1 - N.
  64. */
  65. #define NUM_INTERVAL_CYC 0xFFFFFFFF - 10
  66. /*
  67. * spu_cycle_reset is the number of cycles between samples.
  68. * This variable is used for SPU profiling and should ONLY be set
  69. * at the beginning of cell_reg_setup; otherwise, it's read-only.
  70. */
  71. static unsigned int spu_cycle_reset;
  72. static unsigned int profiling_mode;
  73. static int spu_evnt_phys_spu_indx;
  74. struct pmc_cntrl_data {
  75. unsigned long vcntr;
  76. unsigned long evnts;
  77. unsigned long masks;
  78. unsigned long enabled;
  79. };
  80. /*
  81. * ibm,cbe-perftools rtas parameters
  82. */
  83. struct pm_signal {
  84. u16 cpu; /* Processor to modify */
  85. u16 sub_unit; /* hw subunit this applies to (if applicable)*/
  86. short int signal_group; /* Signal Group to Enable/Disable */
  87. u8 bus_word; /* Enable/Disable on this Trace/Trigger/Event
  88. * Bus Word(s) (bitmask)
  89. */
  90. u8 bit; /* Trigger/Event bit (if applicable) */
  91. };
  92. /*
  93. * rtas call arguments
  94. */
  95. enum {
  96. SUBFUNC_RESET = 1,
  97. SUBFUNC_ACTIVATE = 2,
  98. SUBFUNC_DEACTIVATE = 3,
  99. PASSTHRU_IGNORE = 0,
  100. PASSTHRU_ENABLE = 1,
  101. PASSTHRU_DISABLE = 2,
  102. };
  103. struct pm_cntrl {
  104. u16 enable;
  105. u16 stop_at_max;
  106. u16 trace_mode;
  107. u16 freeze;
  108. u16 count_mode;
  109. u16 spu_addr_trace;
  110. u8 trace_buf_ovflw;
  111. };
  112. static struct {
  113. u32 group_control;
  114. u32 debug_bus_control;
  115. struct pm_cntrl pm_cntrl;
  116. u32 pm07_cntrl[NR_PHYS_CTRS];
  117. } pm_regs;
  118. #define GET_SUB_UNIT(x) ((x & 0x0000f000) >> 12)
  119. #define GET_BUS_WORD(x) ((x & 0x000000f0) >> 4)
  120. #define GET_BUS_TYPE(x) ((x & 0x00000300) >> 8)
  121. #define GET_POLARITY(x) ((x & 0x00000002) >> 1)
  122. #define GET_COUNT_CYCLES(x) (x & 0x00000001)
  123. #define GET_INPUT_CONTROL(x) ((x & 0x00000004) >> 2)
  124. static DEFINE_PER_CPU(unsigned long[NR_PHYS_CTRS], pmc_values);
  125. static unsigned long spu_pm_cnt[MAX_NUMNODES * NUM_SPUS_PER_NODE];
  126. static struct pmc_cntrl_data pmc_cntrl[NUM_THREADS][NR_PHYS_CTRS];
  127. /*
  128. * The CELL profiling code makes rtas calls to setup the debug bus to
  129. * route the performance signals. Additionally, SPU profiling requires
  130. * a second rtas call to setup the hardware to capture the SPU PCs.
  131. * The EIO error value is returned if the token lookups or the rtas
  132. * call fail. The EIO error number is the best choice of the existing
  133. * error numbers. The probability of rtas related error is very low. But
  134. * by returning EIO and printing additional information to dmsg the user
  135. * will know that OProfile did not start and dmesg will tell them why.
  136. * OProfile does not support returning errors on Stop. Not a huge issue
  137. * since failure to reset the debug bus or stop the SPU PC collection is
  138. * not a fatel issue. Chances are if the Stop failed, Start doesn't work
  139. * either.
  140. */
  141. /*
  142. * Interpetation of hdw_thread:
  143. * 0 - even virtual cpus 0, 2, 4,...
  144. * 1 - odd virtual cpus 1, 3, 5, ...
  145. *
  146. * FIXME: this is strictly wrong, we need to clean this up in a number
  147. * of places. It works for now. -arnd
  148. */
  149. static u32 hdw_thread;
  150. static u32 virt_cntr_inter_mask;
  151. static struct timer_list timer_virt_cntr;
  152. static struct timer_list timer_spu_event_swap;
  153. /*
  154. * pm_signal needs to be global since it is initialized in
  155. * cell_reg_setup at the time when the necessary information
  156. * is available.
  157. */
  158. static struct pm_signal pm_signal[NR_PHYS_CTRS];
  159. static int pm_rtas_token; /* token for debug bus setup call */
  160. static int spu_rtas_token; /* token for SPU cycle profiling */
  161. static u32 reset_value[NR_PHYS_CTRS];
  162. static int num_counters;
  163. static int oprofile_running;
  164. static DEFINE_SPINLOCK(cntr_lock);
  165. static u32 ctr_enabled;
  166. static unsigned char input_bus[NUM_INPUT_BUS_WORDS];
  167. /*
  168. * Firmware interface functions
  169. */
  170. static int
  171. rtas_ibm_cbe_perftools(int subfunc, int passthru,
  172. void *address, unsigned long length)
  173. {
  174. u64 paddr = __pa(address);
  175. return rtas_call(pm_rtas_token, 5, 1, NULL, subfunc,
  176. passthru, paddr >> 32, paddr & 0xffffffff, length);
  177. }
  178. static void pm_rtas_reset_signals(u32 node)
  179. {
  180. int ret;
  181. struct pm_signal pm_signal_local;
  182. /*
  183. * The debug bus is being set to the passthru disable state.
  184. * However, the FW still expects atleast one legal signal routing
  185. * entry or it will return an error on the arguments. If we don't
  186. * supply a valid entry, we must ignore all return values. Ignoring
  187. * all return values means we might miss an error we should be
  188. * concerned about.
  189. */
  190. /* fw expects physical cpu #. */
  191. pm_signal_local.cpu = node;
  192. pm_signal_local.signal_group = 21;
  193. pm_signal_local.bus_word = 1;
  194. pm_signal_local.sub_unit = 0;
  195. pm_signal_local.bit = 0;
  196. ret = rtas_ibm_cbe_perftools(SUBFUNC_RESET, PASSTHRU_DISABLE,
  197. &pm_signal_local,
  198. sizeof(struct pm_signal));
  199. if (unlikely(ret))
  200. /*
  201. * Not a fatal error. For Oprofile stop, the oprofile
  202. * functions do not support returning an error for
  203. * failure to stop OProfile.
  204. */
  205. printk(KERN_WARNING "%s: rtas returned: %d\n",
  206. __func__, ret);
  207. }
  208. static int pm_rtas_activate_signals(u32 node, u32 count)
  209. {
  210. int ret;
  211. int i, j;
  212. struct pm_signal pm_signal_local[NR_PHYS_CTRS];
  213. /*
  214. * There is no debug setup required for the cycles event.
  215. * Note that only events in the same group can be used.
  216. * Otherwise, there will be conflicts in correctly routing
  217. * the signals on the debug bus. It is the responsiblity
  218. * of the OProfile user tool to check the events are in
  219. * the same group.
  220. */
  221. i = 0;
  222. for (j = 0; j < count; j++) {
  223. if (pm_signal[j].signal_group != PPU_CYCLES_GRP_NUM) {
  224. /* fw expects physical cpu # */
  225. pm_signal_local[i].cpu = node;
  226. pm_signal_local[i].signal_group
  227. = pm_signal[j].signal_group;
  228. pm_signal_local[i].bus_word = pm_signal[j].bus_word;
  229. pm_signal_local[i].sub_unit = pm_signal[j].sub_unit;
  230. pm_signal_local[i].bit = pm_signal[j].bit;
  231. i++;
  232. }
  233. }
  234. if (i != 0) {
  235. ret = rtas_ibm_cbe_perftools(SUBFUNC_ACTIVATE, PASSTHRU_ENABLE,
  236. pm_signal_local,
  237. i * sizeof(struct pm_signal));
  238. if (unlikely(ret)) {
  239. printk(KERN_WARNING "%s: rtas returned: %d\n",
  240. __func__, ret);
  241. return -EIO;
  242. }
  243. }
  244. return 0;
  245. }
  246. /*
  247. * PM Signal functions
  248. */
  249. static void set_pm_event(u32 ctr, int event, u32 unit_mask)
  250. {
  251. struct pm_signal *p;
  252. u32 signal_bit;
  253. u32 bus_word, bus_type, count_cycles, polarity, input_control;
  254. int j, i;
  255. if (event == PPU_CYCLES_EVENT_NUM) {
  256. /* Special Event: Count all cpu cycles */
  257. pm_regs.pm07_cntrl[ctr] = CBE_COUNT_ALL_CYCLES;
  258. p = &(pm_signal[ctr]);
  259. p->signal_group = PPU_CYCLES_GRP_NUM;
  260. p->bus_word = 1;
  261. p->sub_unit = 0;
  262. p->bit = 0;
  263. goto out;
  264. } else {
  265. pm_regs.pm07_cntrl[ctr] = 0;
  266. }
  267. bus_word = GET_BUS_WORD(unit_mask);
  268. bus_type = GET_BUS_TYPE(unit_mask);
  269. count_cycles = GET_COUNT_CYCLES(unit_mask);
  270. polarity = GET_POLARITY(unit_mask);
  271. input_control = GET_INPUT_CONTROL(unit_mask);
  272. signal_bit = (event % 100);
  273. p = &(pm_signal[ctr]);
  274. p->signal_group = event / 100;
  275. p->bus_word = bus_word;
  276. p->sub_unit = GET_SUB_UNIT(unit_mask);
  277. pm_regs.pm07_cntrl[ctr] = 0;
  278. pm_regs.pm07_cntrl[ctr] |= PM07_CTR_COUNT_CYCLES(count_cycles);
  279. pm_regs.pm07_cntrl[ctr] |= PM07_CTR_POLARITY(polarity);
  280. pm_regs.pm07_cntrl[ctr] |= PM07_CTR_INPUT_CONTROL(input_control);
  281. /*
  282. * Some of the islands signal selection is based on 64 bit words.
  283. * The debug bus words are 32 bits, the input words to the performance
  284. * counters are defined as 32 bits. Need to convert the 64 bit island
  285. * specification to the appropriate 32 input bit and bus word for the
  286. * performance counter event selection. See the CELL Performance
  287. * monitoring signals manual and the Perf cntr hardware descriptions
  288. * for the details.
  289. */
  290. if (input_control == 0) {
  291. if (signal_bit > 31) {
  292. signal_bit -= 32;
  293. if (bus_word == 0x3)
  294. bus_word = 0x2;
  295. else if (bus_word == 0xc)
  296. bus_word = 0x8;
  297. }
  298. if ((bus_type == 0) && p->signal_group >= 60)
  299. bus_type = 2;
  300. if ((bus_type == 1) && p->signal_group >= 50)
  301. bus_type = 0;
  302. pm_regs.pm07_cntrl[ctr] |= PM07_CTR_INPUT_MUX(signal_bit);
  303. } else {
  304. pm_regs.pm07_cntrl[ctr] = 0;
  305. p->bit = signal_bit;
  306. }
  307. for (i = 0; i < NUM_DEBUG_BUS_WORDS; i++) {
  308. if (bus_word & (1 << i)) {
  309. pm_regs.debug_bus_control |=
  310. (bus_type << (30 - (2 * i)));
  311. for (j = 0; j < NUM_INPUT_BUS_WORDS; j++) {
  312. if (input_bus[j] == 0xff) {
  313. input_bus[j] = i;
  314. pm_regs.group_control |=
  315. (i << (30 - (2 * j)));
  316. break;
  317. }
  318. }
  319. }
  320. }
  321. out:
  322. ;
  323. }
  324. static void write_pm_cntrl(int cpu)
  325. {
  326. /*
  327. * Oprofile will use 32 bit counters, set bits 7:10 to 0
  328. * pmregs.pm_cntrl is a global
  329. */
  330. u32 val = 0;
  331. if (pm_regs.pm_cntrl.enable == 1)
  332. val |= CBE_PM_ENABLE_PERF_MON;
  333. if (pm_regs.pm_cntrl.stop_at_max == 1)
  334. val |= CBE_PM_STOP_AT_MAX;
  335. if (pm_regs.pm_cntrl.trace_mode != 0)
  336. val |= CBE_PM_TRACE_MODE_SET(pm_regs.pm_cntrl.trace_mode);
  337. if (pm_regs.pm_cntrl.trace_buf_ovflw == 1)
  338. val |= CBE_PM_TRACE_BUF_OVFLW(pm_regs.pm_cntrl.trace_buf_ovflw);
  339. if (pm_regs.pm_cntrl.freeze == 1)
  340. val |= CBE_PM_FREEZE_ALL_CTRS;
  341. val |= CBE_PM_SPU_ADDR_TRACE_SET(pm_regs.pm_cntrl.spu_addr_trace);
  342. /*
  343. * Routine set_count_mode must be called previously to set
  344. * the count mode based on the user selection of user and kernel.
  345. */
  346. val |= CBE_PM_COUNT_MODE_SET(pm_regs.pm_cntrl.count_mode);
  347. cbe_write_pm(cpu, pm_control, val);
  348. }
  349. static inline void
  350. set_count_mode(u32 kernel, u32 user)
  351. {
  352. /*
  353. * The user must specify user and kernel if they want them. If
  354. * neither is specified, OProfile will count in hypervisor mode.
  355. * pm_regs.pm_cntrl is a global
  356. */
  357. if (kernel) {
  358. if (user)
  359. pm_regs.pm_cntrl.count_mode = CBE_COUNT_ALL_MODES;
  360. else
  361. pm_regs.pm_cntrl.count_mode =
  362. CBE_COUNT_SUPERVISOR_MODE;
  363. } else {
  364. if (user)
  365. pm_regs.pm_cntrl.count_mode = CBE_COUNT_PROBLEM_MODE;
  366. else
  367. pm_regs.pm_cntrl.count_mode =
  368. CBE_COUNT_HYPERVISOR_MODE;
  369. }
  370. }
  371. static inline void enable_ctr(u32 cpu, u32 ctr, u32 *pm07_cntrl)
  372. {
  373. pm07_cntrl[ctr] |= CBE_PM_CTR_ENABLE;
  374. cbe_write_pm07_control(cpu, ctr, pm07_cntrl[ctr]);
  375. }
  376. /*
  377. * Oprofile is expected to collect data on all CPUs simultaneously.
  378. * However, there is one set of performance counters per node. There are
  379. * two hardware threads or virtual CPUs on each node. Hence, OProfile must
  380. * multiplex in time the performance counter collection on the two virtual
  381. * CPUs. The multiplexing of the performance counters is done by this
  382. * virtual counter routine.
  383. *
  384. * The pmc_values used below is defined as 'per-cpu' but its use is
  385. * more akin to 'per-node'. We need to store two sets of counter
  386. * values per node -- one for the previous run and one for the next.
  387. * The per-cpu[NR_PHYS_CTRS] gives us the storage we need. Each odd/even
  388. * pair of per-cpu arrays is used for storing the previous and next
  389. * pmc values for a given node.
  390. * NOTE: We use the per-cpu variable to improve cache performance.
  391. *
  392. * This routine will alternate loading the virtual counters for
  393. * virtual CPUs
  394. */
  395. static void cell_virtual_cntr(unsigned long data)
  396. {
  397. int i, prev_hdw_thread, next_hdw_thread;
  398. u32 cpu;
  399. unsigned long flags;
  400. /*
  401. * Make sure that the interrupt_hander and the virt counter are
  402. * not both playing with the counters on the same node.
  403. */
  404. spin_lock_irqsave(&cntr_lock, flags);
  405. prev_hdw_thread = hdw_thread;
  406. /* switch the cpu handling the interrupts */
  407. hdw_thread = 1 ^ hdw_thread;
  408. next_hdw_thread = hdw_thread;
  409. pm_regs.group_control = 0;
  410. pm_regs.debug_bus_control = 0;
  411. for (i = 0; i < NUM_INPUT_BUS_WORDS; i++)
  412. input_bus[i] = 0xff;
  413. /*
  414. * There are some per thread events. Must do the
  415. * set event, for the thread that is being started
  416. */
  417. for (i = 0; i < num_counters; i++)
  418. set_pm_event(i,
  419. pmc_cntrl[next_hdw_thread][i].evnts,
  420. pmc_cntrl[next_hdw_thread][i].masks);
  421. /*
  422. * The following is done only once per each node, but
  423. * we need cpu #, not node #, to pass to the cbe_xxx functions.
  424. */
  425. for_each_online_cpu(cpu) {
  426. if (cbe_get_hw_thread_id(cpu))
  427. continue;
  428. /*
  429. * stop counters, save counter values, restore counts
  430. * for previous thread
  431. */
  432. cbe_disable_pm(cpu);
  433. cbe_disable_pm_interrupts(cpu);
  434. for (i = 0; i < num_counters; i++) {
  435. per_cpu(pmc_values, cpu + prev_hdw_thread)[i]
  436. = cbe_read_ctr(cpu, i);
  437. if (per_cpu(pmc_values, cpu + next_hdw_thread)[i]
  438. == 0xFFFFFFFF)
  439. /* If the cntr value is 0xffffffff, we must
  440. * reset that to 0xfffffff0 when the current
  441. * thread is restarted. This will generate a
  442. * new interrupt and make sure that we never
  443. * restore the counters to the max value. If
  444. * the counters were restored to the max value,
  445. * they do not increment and no interrupts are
  446. * generated. Hence no more samples will be
  447. * collected on that cpu.
  448. */
  449. cbe_write_ctr(cpu, i, 0xFFFFFFF0);
  450. else
  451. cbe_write_ctr(cpu, i,
  452. per_cpu(pmc_values,
  453. cpu +
  454. next_hdw_thread)[i]);
  455. }
  456. /*
  457. * Switch to the other thread. Change the interrupt
  458. * and control regs to be scheduled on the CPU
  459. * corresponding to the thread to execute.
  460. */
  461. for (i = 0; i < num_counters; i++) {
  462. if (pmc_cntrl[next_hdw_thread][i].enabled) {
  463. /*
  464. * There are some per thread events.
  465. * Must do the set event, enable_cntr
  466. * for each cpu.
  467. */
  468. enable_ctr(cpu, i,
  469. pm_regs.pm07_cntrl);
  470. } else {
  471. cbe_write_pm07_control(cpu, i, 0);
  472. }
  473. }
  474. /* Enable interrupts on the CPU thread that is starting */
  475. cbe_enable_pm_interrupts(cpu, next_hdw_thread,
  476. virt_cntr_inter_mask);
  477. cbe_enable_pm(cpu);
  478. }
  479. spin_unlock_irqrestore(&cntr_lock, flags);
  480. mod_timer(&timer_virt_cntr, jiffies + HZ / 10);
  481. }
  482. static void start_virt_cntrs(void)
  483. {
  484. init_timer(&timer_virt_cntr);
  485. timer_virt_cntr.function = cell_virtual_cntr;
  486. timer_virt_cntr.data = 0UL;
  487. timer_virt_cntr.expires = jiffies + HZ / 10;
  488. add_timer(&timer_virt_cntr);
  489. }
  490. static int cell_reg_setup_spu_cycles(struct op_counter_config *ctr,
  491. struct op_system_config *sys, int num_ctrs)
  492. {
  493. spu_cycle_reset = ctr[0].count;
  494. /*
  495. * Each node will need to make the rtas call to start
  496. * and stop SPU profiling. Get the token once and store it.
  497. */
  498. spu_rtas_token = rtas_token("ibm,cbe-spu-perftools");
  499. if (unlikely(spu_rtas_token == RTAS_UNKNOWN_SERVICE)) {
  500. printk(KERN_ERR
  501. "%s: rtas token ibm,cbe-spu-perftools unknown\n",
  502. __func__);
  503. return -EIO;
  504. }
  505. return 0;
  506. }
  507. /* Unfortunately, the hardware will only support event profiling
  508. * on one SPU per node at a time. Therefore, we must time slice
  509. * the profiling across all SPUs in the node. Note, we do this
  510. * in parallel for each node. The following routine is called
  511. * periodically based on kernel timer to switch which SPU is
  512. * being monitored in a round robbin fashion.
  513. */
  514. static void spu_evnt_swap(unsigned long data)
  515. {
  516. int node;
  517. int cur_phys_spu, nxt_phys_spu, cur_spu_evnt_phys_spu_indx;
  518. unsigned long flags;
  519. int cpu;
  520. int ret;
  521. u32 interrupt_mask;
  522. /* enable interrupts on cntr 0 */
  523. interrupt_mask = CBE_PM_CTR_OVERFLOW_INTR(0);
  524. hdw_thread = 0;
  525. /* Make sure spu event interrupt handler and spu event swap
  526. * don't access the counters simultaneously.
  527. */
  528. spin_lock_irqsave(&cntr_lock, flags);
  529. cur_spu_evnt_phys_spu_indx = spu_evnt_phys_spu_indx;
  530. if (++(spu_evnt_phys_spu_indx) == NUM_SPUS_PER_NODE)
  531. spu_evnt_phys_spu_indx = 0;
  532. pm_signal[0].sub_unit = spu_evnt_phys_spu_indx;
  533. pm_signal[1].sub_unit = spu_evnt_phys_spu_indx;
  534. pm_signal[2].sub_unit = spu_evnt_phys_spu_indx;
  535. /* switch the SPU being profiled on each node */
  536. for_each_online_cpu(cpu) {
  537. if (cbe_get_hw_thread_id(cpu))
  538. continue;
  539. node = cbe_cpu_to_node(cpu);
  540. cur_phys_spu = (node * NUM_SPUS_PER_NODE)
  541. + cur_spu_evnt_phys_spu_indx;
  542. nxt_phys_spu = (node * NUM_SPUS_PER_NODE)
  543. + spu_evnt_phys_spu_indx;
  544. /*
  545. * stop counters, save counter values, restore counts
  546. * for previous physical SPU
  547. */
  548. cbe_disable_pm(cpu);
  549. cbe_disable_pm_interrupts(cpu);
  550. spu_pm_cnt[cur_phys_spu]
  551. = cbe_read_ctr(cpu, 0);
  552. /* restore previous count for the next spu to sample */
  553. /* NOTE, hardware issue, counter will not start if the
  554. * counter value is at max (0xFFFFFFFF).
  555. */
  556. if (spu_pm_cnt[nxt_phys_spu] >= 0xFFFFFFFF)
  557. cbe_write_ctr(cpu, 0, 0xFFFFFFF0);
  558. else
  559. cbe_write_ctr(cpu, 0, spu_pm_cnt[nxt_phys_spu]);
  560. pm_rtas_reset_signals(cbe_cpu_to_node(cpu));
  561. /* setup the debug bus measure the one event and
  562. * the two events to route the next SPU's PC on
  563. * the debug bus
  564. */
  565. ret = pm_rtas_activate_signals(cbe_cpu_to_node(cpu), 3);
  566. if (ret)
  567. printk(KERN_ERR "%s: pm_rtas_activate_signals failed, "
  568. "SPU event swap\n", __func__);
  569. /* clear the trace buffer, don't want to take PC for
  570. * previous SPU*/
  571. cbe_write_pm(cpu, trace_address, 0);
  572. enable_ctr(cpu, 0, pm_regs.pm07_cntrl);
  573. /* Enable interrupts on the CPU thread that is starting */
  574. cbe_enable_pm_interrupts(cpu, hdw_thread,
  575. interrupt_mask);
  576. cbe_enable_pm(cpu);
  577. }
  578. spin_unlock_irqrestore(&cntr_lock, flags);
  579. /* swap approximately every 0.1 seconds */
  580. mod_timer(&timer_spu_event_swap, jiffies + HZ / 25);
  581. }
  582. static void start_spu_event_swap(void)
  583. {
  584. init_timer(&timer_spu_event_swap);
  585. timer_spu_event_swap.function = spu_evnt_swap;
  586. timer_spu_event_swap.data = 0UL;
  587. timer_spu_event_swap.expires = jiffies + HZ / 25;
  588. add_timer(&timer_spu_event_swap);
  589. }
  590. static int cell_reg_setup_spu_events(struct op_counter_config *ctr,
  591. struct op_system_config *sys, int num_ctrs)
  592. {
  593. int i;
  594. /* routine is called once for all nodes */
  595. spu_evnt_phys_spu_indx = 0;
  596. /*
  597. * For all events except PPU CYCLEs, each node will need to make
  598. * the rtas cbe-perftools call to setup and reset the debug bus.
  599. * Make the token lookup call once and store it in the global
  600. * variable pm_rtas_token.
  601. */
  602. pm_rtas_token = rtas_token("ibm,cbe-perftools");
  603. if (unlikely(pm_rtas_token == RTAS_UNKNOWN_SERVICE)) {
  604. printk(KERN_ERR
  605. "%s: rtas token ibm,cbe-perftools unknown\n",
  606. __func__);
  607. return -EIO;
  608. }
  609. /* setup the pm_control register settings,
  610. * settings will be written per node by the
  611. * cell_cpu_setup() function.
  612. */
  613. pm_regs.pm_cntrl.trace_buf_ovflw = 1;
  614. /* Use the occurrence trace mode to have SPU PC saved
  615. * to the trace buffer. Occurrence data in trace buffer
  616. * is not used. Bit 2 must be set to store SPU addresses.
  617. */
  618. pm_regs.pm_cntrl.trace_mode = 2;
  619. pm_regs.pm_cntrl.spu_addr_trace = 0x1; /* using debug bus
  620. event 2 & 3 */
  621. /* setup the debug bus event array with the SPU PC routing events.
  622. * Note, pm_signal[0] will be filled in by set_pm_event() call below.
  623. */
  624. pm_signal[1].signal_group = SPU_PROFILE_EVENT_ADDR / 100;
  625. pm_signal[1].bus_word = GET_BUS_WORD(SPU_PROFILE_EVENT_ADDR_MASK_A);
  626. pm_signal[1].bit = SPU_PROFILE_EVENT_ADDR % 100;
  627. pm_signal[1].sub_unit = spu_evnt_phys_spu_indx;
  628. pm_signal[2].signal_group = SPU_PROFILE_EVENT_ADDR / 100;
  629. pm_signal[2].bus_word = GET_BUS_WORD(SPU_PROFILE_EVENT_ADDR_MASK_B);
  630. pm_signal[2].bit = SPU_PROFILE_EVENT_ADDR % 100;
  631. pm_signal[2].sub_unit = spu_evnt_phys_spu_indx;
  632. /* Set the user selected spu event to profile on,
  633. * note, only one SPU profiling event is supported
  634. */
  635. num_counters = 1; /* Only support one SPU event at a time */
  636. set_pm_event(0, ctr[0].event, ctr[0].unit_mask);
  637. reset_value[0] = 0xFFFFFFFF - ctr[0].count;
  638. /* global, used by cell_cpu_setup */
  639. ctr_enabled |= 1;
  640. /* Initialize the count for each SPU to the reset value */
  641. for (i=0; i < MAX_NUMNODES * NUM_SPUS_PER_NODE; i++)
  642. spu_pm_cnt[i] = reset_value[0];
  643. return 0;
  644. }
  645. static int cell_reg_setup_ppu(struct op_counter_config *ctr,
  646. struct op_system_config *sys, int num_ctrs)
  647. {
  648. /* routine is called once for all nodes */
  649. int i, j, cpu;
  650. num_counters = num_ctrs;
  651. if (unlikely(num_ctrs > NR_PHYS_CTRS)) {
  652. printk(KERN_ERR
  653. "%s: Oprofile, number of specified events " \
  654. "exceeds number of physical counters\n",
  655. __func__);
  656. return -EIO;
  657. }
  658. set_count_mode(sys->enable_kernel, sys->enable_user);
  659. /* Setup the thread 0 events */
  660. for (i = 0; i < num_ctrs; ++i) {
  661. pmc_cntrl[0][i].evnts = ctr[i].event;
  662. pmc_cntrl[0][i].masks = ctr[i].unit_mask;
  663. pmc_cntrl[0][i].enabled = ctr[i].enabled;
  664. pmc_cntrl[0][i].vcntr = i;
  665. for_each_possible_cpu(j)
  666. per_cpu(pmc_values, j)[i] = 0;
  667. }
  668. /*
  669. * Setup the thread 1 events, map the thread 0 event to the
  670. * equivalent thread 1 event.
  671. */
  672. for (i = 0; i < num_ctrs; ++i) {
  673. if ((ctr[i].event >= 2100) && (ctr[i].event <= 2111))
  674. pmc_cntrl[1][i].evnts = ctr[i].event + 19;
  675. else if (ctr[i].event == 2203)
  676. pmc_cntrl[1][i].evnts = ctr[i].event;
  677. else if ((ctr[i].event >= 2200) && (ctr[i].event <= 2215))
  678. pmc_cntrl[1][i].evnts = ctr[i].event + 16;
  679. else
  680. pmc_cntrl[1][i].evnts = ctr[i].event;
  681. pmc_cntrl[1][i].masks = ctr[i].unit_mask;
  682. pmc_cntrl[1][i].enabled = ctr[i].enabled;
  683. pmc_cntrl[1][i].vcntr = i;
  684. }
  685. for (i = 0; i < NUM_INPUT_BUS_WORDS; i++)
  686. input_bus[i] = 0xff;
  687. /*
  688. * Our counters count up, and "count" refers to
  689. * how much before the next interrupt, and we interrupt
  690. * on overflow. So we calculate the starting value
  691. * which will give us "count" until overflow.
  692. * Then we set the events on the enabled counters.
  693. */
  694. for (i = 0; i < num_counters; ++i) {
  695. /* start with virtual counter set 0 */
  696. if (pmc_cntrl[0][i].enabled) {
  697. /* Using 32bit counters, reset max - count */
  698. reset_value[i] = 0xFFFFFFFF - ctr[i].count;
  699. set_pm_event(i,
  700. pmc_cntrl[0][i].evnts,
  701. pmc_cntrl[0][i].masks);
  702. /* global, used by cell_cpu_setup */
  703. ctr_enabled |= (1 << i);
  704. }
  705. }
  706. /* initialize the previous counts for the virtual cntrs */
  707. for_each_online_cpu(cpu)
  708. for (i = 0; i < num_counters; ++i) {
  709. per_cpu(pmc_values, cpu)[i] = reset_value[i];
  710. }
  711. return 0;
  712. }
  713. /* This function is called once for all cpus combined */
  714. static int cell_reg_setup(struct op_counter_config *ctr,
  715. struct op_system_config *sys, int num_ctrs)
  716. {
  717. int ret=0;
  718. spu_cycle_reset = 0;
  719. /* initialize the spu_arr_trace value, will be reset if
  720. * doing spu event profiling.
  721. */
  722. pm_regs.group_control = 0;
  723. pm_regs.debug_bus_control = 0;
  724. pm_regs.pm_cntrl.stop_at_max = 1;
  725. pm_regs.pm_cntrl.trace_mode = 0;
  726. pm_regs.pm_cntrl.freeze = 1;
  727. pm_regs.pm_cntrl.trace_buf_ovflw = 0;
  728. pm_regs.pm_cntrl.spu_addr_trace = 0;
  729. /*
  730. * For all events except PPU CYCLEs, each node will need to make
  731. * the rtas cbe-perftools call to setup and reset the debug bus.
  732. * Make the token lookup call once and store it in the global
  733. * variable pm_rtas_token.
  734. */
  735. pm_rtas_token = rtas_token("ibm,cbe-perftools");
  736. if (unlikely(pm_rtas_token == RTAS_UNKNOWN_SERVICE)) {
  737. printk(KERN_ERR
  738. "%s: rtas token ibm,cbe-perftools unknown\n",
  739. __func__);
  740. return -EIO;
  741. }
  742. if (ctr[0].event == SPU_CYCLES_EVENT_NUM) {
  743. profiling_mode = SPU_PROFILING_CYCLES;
  744. ret = cell_reg_setup_spu_cycles(ctr, sys, num_ctrs);
  745. } else if ((ctr[0].event >= SPU_EVENT_NUM_START) &&
  746. (ctr[0].event <= SPU_EVENT_NUM_STOP)) {
  747. profiling_mode = SPU_PROFILING_EVENTS;
  748. spu_cycle_reset = ctr[0].count;
  749. /* for SPU event profiling, need to setup the
  750. * pm_signal array with the events to route the
  751. * SPU PC before making the FW call. Note, only
  752. * one SPU event for profiling can be specified
  753. * at a time.
  754. */
  755. cell_reg_setup_spu_events(ctr, sys, num_ctrs);
  756. } else {
  757. profiling_mode = PPU_PROFILING;
  758. ret = cell_reg_setup_ppu(ctr, sys, num_ctrs);
  759. }
  760. return ret;
  761. }
  762. /* This function is called once for each cpu */
  763. static int cell_cpu_setup(struct op_counter_config *cntr)
  764. {
  765. u32 cpu = smp_processor_id();
  766. u32 num_enabled = 0;
  767. int i;
  768. int ret;
  769. /* Cycle based SPU profiling does not use the performance
  770. * counters. The trace array is configured to collect
  771. * the data.
  772. */
  773. if (profiling_mode == SPU_PROFILING_CYCLES)
  774. return 0;
  775. /* There is one performance monitor per processor chip (i.e. node),
  776. * so we only need to perform this function once per node.
  777. */
  778. if (cbe_get_hw_thread_id(cpu))
  779. return 0;
  780. /* Stop all counters */
  781. cbe_disable_pm(cpu);
  782. cbe_disable_pm_interrupts(cpu);
  783. cbe_write_pm(cpu, pm_start_stop, 0);
  784. cbe_write_pm(cpu, group_control, pm_regs.group_control);
  785. cbe_write_pm(cpu, debug_bus_control, pm_regs.debug_bus_control);
  786. write_pm_cntrl(cpu);
  787. for (i = 0; i < num_counters; ++i) {
  788. if (ctr_enabled & (1 << i)) {
  789. pm_signal[num_enabled].cpu = cbe_cpu_to_node(cpu);
  790. num_enabled++;
  791. }
  792. }
  793. /*
  794. * The pm_rtas_activate_signals will return -EIO if the FW
  795. * call failed.
  796. */
  797. if (profiling_mode == SPU_PROFILING_EVENTS) {
  798. /* For SPU event profiling also need to setup the
  799. * pm interval timer
  800. */
  801. ret = pm_rtas_activate_signals(cbe_cpu_to_node(cpu),
  802. num_enabled+2);
  803. /* store PC from debug bus to Trace buffer as often
  804. * as possible (every 10 cycles)
  805. */
  806. cbe_write_pm(cpu, pm_interval, NUM_INTERVAL_CYC);
  807. return ret;
  808. } else
  809. return pm_rtas_activate_signals(cbe_cpu_to_node(cpu),
  810. num_enabled);
  811. }
  812. #define ENTRIES 303
  813. #define MAXLFSR 0xFFFFFF
  814. /* precomputed table of 24 bit LFSR values */
  815. static int initial_lfsr[] = {
  816. 8221349, 12579195, 5379618, 10097839, 7512963, 7519310, 3955098, 10753424,
  817. 15507573, 7458917, 285419, 2641121, 9780088, 3915503, 6668768, 1548716,
  818. 4885000, 8774424, 9650099, 2044357, 2304411, 9326253, 10332526, 4421547,
  819. 3440748, 10179459, 13332843, 10375561, 1313462, 8375100, 5198480, 6071392,
  820. 9341783, 1526887, 3985002, 1439429, 13923762, 7010104, 11969769, 4547026,
  821. 2040072, 4025602, 3437678, 7939992, 11444177, 4496094, 9803157, 10745556,
  822. 3671780, 4257846, 5662259, 13196905, 3237343, 12077182, 16222879, 7587769,
  823. 14706824, 2184640, 12591135, 10420257, 7406075, 3648978, 11042541, 15906893,
  824. 11914928, 4732944, 10695697, 12928164, 11980531, 4430912, 11939291, 2917017,
  825. 6119256, 4172004, 9373765, 8410071, 14788383, 5047459, 5474428, 1737756,
  826. 15967514, 13351758, 6691285, 8034329, 2856544, 14394753, 11310160, 12149558,
  827. 7487528, 7542781, 15668898, 12525138, 12790975, 3707933, 9106617, 1965401,
  828. 16219109, 12801644, 2443203, 4909502, 8762329, 3120803, 6360315, 9309720,
  829. 15164599, 10844842, 4456529, 6667610, 14924259, 884312, 6234963, 3326042,
  830. 15973422, 13919464, 5272099, 6414643, 3909029, 2764324, 5237926, 4774955,
  831. 10445906, 4955302, 5203726, 10798229, 11443419, 2303395, 333836, 9646934,
  832. 3464726, 4159182, 568492, 995747, 10318756, 13299332, 4836017, 8237783,
  833. 3878992, 2581665, 11394667, 5672745, 14412947, 3159169, 9094251, 16467278,
  834. 8671392, 15230076, 4843545, 7009238, 15504095, 1494895, 9627886, 14485051,
  835. 8304291, 252817, 12421642, 16085736, 4774072, 2456177, 4160695, 15409741,
  836. 4902868, 5793091, 13162925, 16039714, 782255, 11347835, 14884586, 366972,
  837. 16308990, 11913488, 13390465, 2958444, 10340278, 1177858, 1319431, 10426302,
  838. 2868597, 126119, 5784857, 5245324, 10903900, 16436004, 3389013, 1742384,
  839. 14674502, 10279218, 8536112, 10364279, 6877778, 14051163, 1025130, 6072469,
  840. 1988305, 8354440, 8216060, 16342977, 13112639, 3976679, 5913576, 8816697,
  841. 6879995, 14043764, 3339515, 9364420, 15808858, 12261651, 2141560, 5636398,
  842. 10345425, 10414756, 781725, 6155650, 4746914, 5078683, 7469001, 6799140,
  843. 10156444, 9667150, 10116470, 4133858, 2121972, 1124204, 1003577, 1611214,
  844. 14304602, 16221850, 13878465, 13577744, 3629235, 8772583, 10881308, 2410386,
  845. 7300044, 5378855, 9301235, 12755149, 4977682, 8083074, 10327581, 6395087,
  846. 9155434, 15501696, 7514362, 14520507, 15808945, 3244584, 4741962, 9658130,
  847. 14336147, 8654727, 7969093, 15759799, 14029445, 5038459, 9894848, 8659300,
  848. 13699287, 8834306, 10712885, 14753895, 10410465, 3373251, 309501, 9561475,
  849. 5526688, 14647426, 14209836, 5339224, 207299, 14069911, 8722990, 2290950,
  850. 3258216, 12505185, 6007317, 9218111, 14661019, 10537428, 11731949, 9027003,
  851. 6641507, 9490160, 200241, 9720425, 16277895, 10816638, 1554761, 10431375,
  852. 7467528, 6790302, 3429078, 14633753, 14428997, 11463204, 3576212, 2003426,
  853. 6123687, 820520, 9992513, 15784513, 5778891, 6428165, 8388607
  854. };
  855. /*
  856. * The hardware uses an LFSR counting sequence to determine when to capture
  857. * the SPU PCs. An LFSR sequence is like a puesdo random number sequence
  858. * where each number occurs once in the sequence but the sequence is not in
  859. * numerical order. The SPU PC capture is done when the LFSR sequence reaches
  860. * the last value in the sequence. Hence the user specified value N
  861. * corresponds to the LFSR number that is N from the end of the sequence.
  862. *
  863. * To avoid the time to compute the LFSR, a lookup table is used. The 24 bit
  864. * LFSR sequence is broken into four ranges. The spacing of the precomputed
  865. * values is adjusted in each range so the error between the user specifed
  866. * number (N) of events between samples and the actual number of events based
  867. * on the precomputed value will be les then about 6.2%. Note, if the user
  868. * specifies N < 2^16, the LFSR value that is 2^16 from the end will be used.
  869. * This is to prevent the loss of samples because the trace buffer is full.
  870. *
  871. * User specified N Step between Index in
  872. * precomputed values precomputed
  873. * table
  874. * 0 to 2^16-1 ---- 0
  875. * 2^16 to 2^16+2^19-1 2^12 1 to 128
  876. * 2^16+2^19 to 2^16+2^19+2^22-1 2^15 129 to 256
  877. * 2^16+2^19+2^22 to 2^24-1 2^18 257 to 302
  878. *
  879. *
  880. * For example, the LFSR values in the second range are computed for 2^16,
  881. * 2^16+2^12, ... , 2^19-2^16, 2^19 and stored in the table at indicies
  882. * 1, 2,..., 127, 128.
  883. *
  884. * The 24 bit LFSR value for the nth number in the sequence can be
  885. * calculated using the following code:
  886. *
  887. * #define size 24
  888. * int calculate_lfsr(int n)
  889. * {
  890. * int i;
  891. * unsigned int newlfsr0;
  892. * unsigned int lfsr = 0xFFFFFF;
  893. * unsigned int howmany = n;
  894. *
  895. * for (i = 2; i < howmany + 2; i++) {
  896. * newlfsr0 = (((lfsr >> (size - 1 - 0)) & 1) ^
  897. * ((lfsr >> (size - 1 - 1)) & 1) ^
  898. * (((lfsr >> (size - 1 - 6)) & 1) ^
  899. * ((lfsr >> (size - 1 - 23)) & 1)));
  900. *
  901. * lfsr >>= 1;
  902. * lfsr = lfsr | (newlfsr0 << (size - 1));
  903. * }
  904. * return lfsr;
  905. * }
  906. */
  907. #define V2_16 (0x1 << 16)
  908. #define V2_19 (0x1 << 19)
  909. #define V2_22 (0x1 << 22)
  910. static int calculate_lfsr(int n)
  911. {
  912. /*
  913. * The ranges and steps are in powers of 2 so the calculations
  914. * can be done using shifts rather then divide.
  915. */
  916. int index;
  917. if ((n >> 16) == 0)
  918. index = 0;
  919. else if (((n - V2_16) >> 19) == 0)
  920. index = ((n - V2_16) >> 12) + 1;
  921. else if (((n - V2_16 - V2_19) >> 22) == 0)
  922. index = ((n - V2_16 - V2_19) >> 15 ) + 1 + 128;
  923. else if (((n - V2_16 - V2_19 - V2_22) >> 24) == 0)
  924. index = ((n - V2_16 - V2_19 - V2_22) >> 18 ) + 1 + 256;
  925. else
  926. index = ENTRIES-1;
  927. /* make sure index is valid */
  928. if ((index > ENTRIES) || (index < 0))
  929. index = ENTRIES-1;
  930. return initial_lfsr[index];
  931. }
  932. static int pm_rtas_activate_spu_profiling(u32 node)
  933. {
  934. int ret, i;
  935. struct pm_signal pm_signal_local[NUM_SPUS_PER_NODE];
  936. /*
  937. * Set up the rtas call to configure the debug bus to
  938. * route the SPU PCs. Setup the pm_signal for each SPU
  939. */
  940. for (i = 0; i < ARRAY_SIZE(pm_signal_local); i++) {
  941. pm_signal_local[i].cpu = node;
  942. pm_signal_local[i].signal_group = 41;
  943. /* spu i on word (i/2) */
  944. pm_signal_local[i].bus_word = 1 << i / 2;
  945. /* spu i */
  946. pm_signal_local[i].sub_unit = i;
  947. pm_signal_local[i].bit = 63;
  948. }
  949. ret = rtas_ibm_cbe_perftools(SUBFUNC_ACTIVATE,
  950. PASSTHRU_ENABLE, pm_signal_local,
  951. (ARRAY_SIZE(pm_signal_local)
  952. * sizeof(struct pm_signal)));
  953. if (unlikely(ret)) {
  954. printk(KERN_WARNING "%s: rtas returned: %d\n",
  955. __func__, ret);
  956. return -EIO;
  957. }
  958. return 0;
  959. }
  960. #ifdef CONFIG_CPU_FREQ
  961. static int
  962. oprof_cpufreq_notify(struct notifier_block *nb, unsigned long val, void *data)
  963. {
  964. int ret = 0;
  965. struct cpufreq_freqs *frq = data;
  966. if ((val == CPUFREQ_PRECHANGE && frq->old < frq->new) ||
  967. (val == CPUFREQ_POSTCHANGE && frq->old > frq->new) ||
  968. (val == CPUFREQ_RESUMECHANGE || val == CPUFREQ_SUSPENDCHANGE))
  969. set_spu_profiling_frequency(frq->new, spu_cycle_reset);
  970. return ret;
  971. }
  972. static struct notifier_block cpu_freq_notifier_block = {
  973. .notifier_call = oprof_cpufreq_notify
  974. };
  975. #endif
  976. /*
  977. * Note the generic OProfile stop calls do not support returning
  978. * an error on stop. Hence, will not return an error if the FW
  979. * calls fail on stop. Failure to reset the debug bus is not an issue.
  980. * Failure to disable the SPU profiling is not an issue. The FW calls
  981. * to enable the performance counters and debug bus will work even if
  982. * the hardware was not cleanly reset.
  983. */
  984. static void cell_global_stop_spu_cycles(void)
  985. {
  986. int subfunc, rtn_value;
  987. unsigned int lfsr_value;
  988. int cpu;
  989. oprofile_running = 0;
  990. smp_wmb();
  991. #ifdef CONFIG_CPU_FREQ
  992. cpufreq_unregister_notifier(&cpu_freq_notifier_block,
  993. CPUFREQ_TRANSITION_NOTIFIER);
  994. #endif
  995. for_each_online_cpu(cpu) {
  996. if (cbe_get_hw_thread_id(cpu))
  997. continue;
  998. subfunc = 3; /*
  999. * 2 - activate SPU tracing,
  1000. * 3 - deactivate
  1001. */
  1002. lfsr_value = 0x8f100000;
  1003. rtn_value = rtas_call(spu_rtas_token, 3, 1, NULL,
  1004. subfunc, cbe_cpu_to_node(cpu),
  1005. lfsr_value);
  1006. if (unlikely(rtn_value != 0)) {
  1007. printk(KERN_ERR
  1008. "%s: rtas call ibm,cbe-spu-perftools " \
  1009. "failed, return = %d\n",
  1010. __func__, rtn_value);
  1011. }
  1012. /* Deactivate the signals */
  1013. pm_rtas_reset_signals(cbe_cpu_to_node(cpu));
  1014. }
  1015. stop_spu_profiling_cycles();
  1016. }
  1017. static void cell_global_stop_spu_events(void)
  1018. {
  1019. int cpu;
  1020. oprofile_running = 0;
  1021. stop_spu_profiling_events();
  1022. smp_wmb();
  1023. for_each_online_cpu(cpu) {
  1024. if (cbe_get_hw_thread_id(cpu))
  1025. continue;
  1026. cbe_sync_irq(cbe_cpu_to_node(cpu));
  1027. /* Stop the counters */
  1028. cbe_disable_pm(cpu);
  1029. cbe_write_pm07_control(cpu, 0, 0);
  1030. /* Deactivate the signals */
  1031. pm_rtas_reset_signals(cbe_cpu_to_node(cpu));
  1032. /* Deactivate interrupts */
  1033. cbe_disable_pm_interrupts(cpu);
  1034. }
  1035. del_timer_sync(&timer_spu_event_swap);
  1036. }
  1037. static void cell_global_stop_ppu(void)
  1038. {
  1039. int cpu;
  1040. /*
  1041. * This routine will be called once for the system.
  1042. * There is one performance monitor per node, so we
  1043. * only need to perform this function once per node.
  1044. */
  1045. del_timer_sync(&timer_virt_cntr);
  1046. oprofile_running = 0;
  1047. smp_wmb();
  1048. for_each_online_cpu(cpu) {
  1049. if (cbe_get_hw_thread_id(cpu))
  1050. continue;
  1051. cbe_sync_irq(cbe_cpu_to_node(cpu));
  1052. /* Stop the counters */
  1053. cbe_disable_pm(cpu);
  1054. /* Deactivate the signals */
  1055. pm_rtas_reset_signals(cbe_cpu_to_node(cpu));
  1056. /* Deactivate interrupts */
  1057. cbe_disable_pm_interrupts(cpu);
  1058. }
  1059. }
  1060. static void cell_global_stop(void)
  1061. {
  1062. if (profiling_mode == PPU_PROFILING)
  1063. cell_global_stop_ppu();
  1064. else if (profiling_mode == SPU_PROFILING_EVENTS)
  1065. cell_global_stop_spu_events();
  1066. else
  1067. cell_global_stop_spu_cycles();
  1068. }
  1069. static int cell_global_start_spu_cycles(struct op_counter_config *ctr)
  1070. {
  1071. int subfunc;
  1072. unsigned int lfsr_value;
  1073. int cpu;
  1074. int ret;
  1075. int rtas_error;
  1076. unsigned int cpu_khzfreq = 0;
  1077. /* The SPU profiling uses time-based profiling based on
  1078. * cpu frequency, so if configured with the CPU_FREQ
  1079. * option, we should detect frequency changes and react
  1080. * accordingly.
  1081. */
  1082. #ifdef CONFIG_CPU_FREQ
  1083. ret = cpufreq_register_notifier(&cpu_freq_notifier_block,
  1084. CPUFREQ_TRANSITION_NOTIFIER);
  1085. if (ret < 0)
  1086. /* this is not a fatal error */
  1087. printk(KERN_ERR "CPU freq change registration failed: %d\n",
  1088. ret);
  1089. else
  1090. cpu_khzfreq = cpufreq_quick_get(smp_processor_id());
  1091. #endif
  1092. set_spu_profiling_frequency(cpu_khzfreq, spu_cycle_reset);
  1093. for_each_online_cpu(cpu) {
  1094. if (cbe_get_hw_thread_id(cpu))
  1095. continue;
  1096. /*
  1097. * Setup SPU cycle-based profiling.
  1098. * Set perf_mon_control bit 0 to a zero before
  1099. * enabling spu collection hardware.
  1100. */
  1101. cbe_write_pm(cpu, pm_control, 0);
  1102. if (spu_cycle_reset > MAX_SPU_COUNT)
  1103. /* use largest possible value */
  1104. lfsr_value = calculate_lfsr(MAX_SPU_COUNT-1);
  1105. else
  1106. lfsr_value = calculate_lfsr(spu_cycle_reset);
  1107. /* must use a non zero value. Zero disables data collection. */
  1108. if (lfsr_value == 0)
  1109. lfsr_value = calculate_lfsr(1);
  1110. lfsr_value = lfsr_value << 8; /* shift lfsr to correct
  1111. * register location
  1112. */
  1113. /* debug bus setup */
  1114. ret = pm_rtas_activate_spu_profiling(cbe_cpu_to_node(cpu));
  1115. if (unlikely(ret)) {
  1116. rtas_error = ret;
  1117. goto out;
  1118. }
  1119. subfunc = 2; /* 2 - activate SPU tracing, 3 - deactivate */
  1120. /* start profiling */
  1121. ret = rtas_call(spu_rtas_token, 3, 1, NULL, subfunc,
  1122. cbe_cpu_to_node(cpu), lfsr_value);
  1123. if (unlikely(ret != 0)) {
  1124. printk(KERN_ERR
  1125. "%s: rtas call ibm,cbe-spu-perftools failed, " \
  1126. "return = %d\n", __func__, ret);
  1127. rtas_error = -EIO;
  1128. goto out;
  1129. }
  1130. }
  1131. rtas_error = start_spu_profiling_cycles(spu_cycle_reset);
  1132. if (rtas_error)
  1133. goto out_stop;
  1134. oprofile_running = 1;
  1135. return 0;
  1136. out_stop:
  1137. cell_global_stop_spu_cycles(); /* clean up the PMU/debug bus */
  1138. out:
  1139. return rtas_error;
  1140. }
  1141. static int cell_global_start_spu_events(struct op_counter_config *ctr)
  1142. {
  1143. int cpu;
  1144. u32 interrupt_mask = 0;
  1145. int rtn = 0;
  1146. hdw_thread = 0;
  1147. /* spu event profiling, uses the performance counters to generate
  1148. * an interrupt. The hardware is setup to store the SPU program
  1149. * counter into the trace array. The occurrence mode is used to
  1150. * enable storing data to the trace buffer. The bits are set
  1151. * to send/store the SPU address in the trace buffer. The debug
  1152. * bus must be setup to route the SPU program counter onto the
  1153. * debug bus. The occurrence data in the trace buffer is not used.
  1154. */
  1155. /* This routine gets called once for the system.
  1156. * There is one performance monitor per node, so we
  1157. * only need to perform this function once per node.
  1158. */
  1159. for_each_online_cpu(cpu) {
  1160. if (cbe_get_hw_thread_id(cpu))
  1161. continue;
  1162. /*
  1163. * Setup SPU event-based profiling.
  1164. * Set perf_mon_control bit 0 to a zero before
  1165. * enabling spu collection hardware.
  1166. *
  1167. * Only support one SPU event on one SPU per node.
  1168. */
  1169. if (ctr_enabled & 1) {
  1170. cbe_write_ctr(cpu, 0, reset_value[0]);
  1171. enable_ctr(cpu, 0, pm_regs.pm07_cntrl);
  1172. interrupt_mask |=
  1173. CBE_PM_CTR_OVERFLOW_INTR(0);
  1174. } else {
  1175. /* Disable counter */
  1176. cbe_write_pm07_control(cpu, 0, 0);
  1177. }
  1178. cbe_get_and_clear_pm_interrupts(cpu);
  1179. cbe_enable_pm_interrupts(cpu, hdw_thread, interrupt_mask);
  1180. cbe_enable_pm(cpu);
  1181. /* clear the trace buffer */
  1182. cbe_write_pm(cpu, trace_address, 0);
  1183. }
  1184. /* Start the timer to time slice collecting the event profile
  1185. * on each of the SPUs. Note, can collect profile on one SPU
  1186. * per node at a time.
  1187. */
  1188. start_spu_event_swap();
  1189. start_spu_profiling_events();
  1190. oprofile_running = 1;
  1191. smp_wmb();
  1192. return rtn;
  1193. }
  1194. static int cell_global_start_ppu(struct op_counter_config *ctr)
  1195. {
  1196. u32 cpu, i;
  1197. u32 interrupt_mask = 0;
  1198. /* This routine gets called once for the system.
  1199. * There is one performance monitor per node, so we
  1200. * only need to perform this function once per node.
  1201. */
  1202. for_each_online_cpu(cpu) {
  1203. if (cbe_get_hw_thread_id(cpu))
  1204. continue;
  1205. interrupt_mask = 0;
  1206. for (i = 0; i < num_counters; ++i) {
  1207. if (ctr_enabled & (1 << i)) {
  1208. cbe_write_ctr(cpu, i, reset_value[i]);
  1209. enable_ctr(cpu, i, pm_regs.pm07_cntrl);
  1210. interrupt_mask |= CBE_PM_CTR_OVERFLOW_INTR(i);
  1211. } else {
  1212. /* Disable counter */
  1213. cbe_write_pm07_control(cpu, i, 0);
  1214. }
  1215. }
  1216. cbe_get_and_clear_pm_interrupts(cpu);
  1217. cbe_enable_pm_interrupts(cpu, hdw_thread, interrupt_mask);
  1218. cbe_enable_pm(cpu);
  1219. }
  1220. virt_cntr_inter_mask = interrupt_mask;
  1221. oprofile_running = 1;
  1222. smp_wmb();
  1223. /*
  1224. * NOTE: start_virt_cntrs will result in cell_virtual_cntr() being
  1225. * executed which manipulates the PMU. We start the "virtual counter"
  1226. * here so that we do not need to synchronize access to the PMU in
  1227. * the above for-loop.
  1228. */
  1229. start_virt_cntrs();
  1230. return 0;
  1231. }
  1232. static int cell_global_start(struct op_counter_config *ctr)
  1233. {
  1234. if (profiling_mode == SPU_PROFILING_CYCLES)
  1235. return cell_global_start_spu_cycles(ctr);
  1236. else if (profiling_mode == SPU_PROFILING_EVENTS)
  1237. return cell_global_start_spu_events(ctr);
  1238. else
  1239. return cell_global_start_ppu(ctr);
  1240. }
  1241. /* The SPU interrupt handler
  1242. *
  1243. * SPU event profiling works as follows:
  1244. * The pm_signal[0] holds the one SPU event to be measured. It is routed on
  1245. * the debug bus using word 0 or 1. The value of pm_signal[1] and
  1246. * pm_signal[2] contain the necessary events to route the SPU program
  1247. * counter for the selected SPU onto the debug bus using words 2 and 3.
  1248. * The pm_interval register is setup to write the SPU PC value into the
  1249. * trace buffer at the maximum rate possible. The trace buffer is configured
  1250. * to store the PCs, wrapping when it is full. The performance counter is
  1251. * intialized to the max hardware count minus the number of events, N, between
  1252. * samples. Once the N events have occured, a HW counter overflow occurs
  1253. * causing the generation of a HW counter interrupt which also stops the
  1254. * writing of the SPU PC values to the trace buffer. Hence the last PC
  1255. * written to the trace buffer is the SPU PC that we want. Unfortunately,
  1256. * we have to read from the beginning of the trace buffer to get to the
  1257. * last value written. We just hope the PPU has nothing better to do then
  1258. * service this interrupt. The PC for the specific SPU being profiled is
  1259. * extracted from the trace buffer processed and stored. The trace buffer
  1260. * is cleared, interrupts are cleared, the counter is reset to max - N.
  1261. * A kernel timer is used to periodically call the routine spu_evnt_swap()
  1262. * to switch to the next physical SPU in the node to profile in round robbin
  1263. * order. This way data is collected for all SPUs on the node. It does mean
  1264. * that we need to use a relatively small value of N to ensure enough samples
  1265. * on each SPU are collected each SPU is being profiled 1/8 of the time.
  1266. * It may also be necessary to use a longer sample collection period.
  1267. */
  1268. static void cell_handle_interrupt_spu(struct pt_regs *regs,
  1269. struct op_counter_config *ctr)
  1270. {
  1271. u32 cpu, cpu_tmp;
  1272. u64 trace_entry;
  1273. u32 interrupt_mask;
  1274. u64 trace_buffer[2];
  1275. u64 last_trace_buffer;
  1276. u32 sample;
  1277. u32 trace_addr;
  1278. unsigned long sample_array_lock_flags;
  1279. int spu_num;
  1280. unsigned long flags;
  1281. /* Make sure spu event interrupt handler and spu event swap
  1282. * don't access the counters simultaneously.
  1283. */
  1284. cpu = smp_processor_id();
  1285. spin_lock_irqsave(&cntr_lock, flags);
  1286. cpu_tmp = cpu;
  1287. cbe_disable_pm(cpu);
  1288. interrupt_mask = cbe_get_and_clear_pm_interrupts(cpu);
  1289. sample = 0xABCDEF;
  1290. trace_entry = 0xfedcba;
  1291. last_trace_buffer = 0xdeadbeaf;
  1292. if ((oprofile_running == 1) && (interrupt_mask != 0)) {
  1293. /* disable writes to trace buff */
  1294. cbe_write_pm(cpu, pm_interval, 0);
  1295. /* only have one perf cntr being used, cntr 0 */
  1296. if ((interrupt_mask & CBE_PM_CTR_OVERFLOW_INTR(0))
  1297. && ctr[0].enabled)
  1298. /* The SPU PC values will be read
  1299. * from the trace buffer, reset counter
  1300. */
  1301. cbe_write_ctr(cpu, 0, reset_value[0]);
  1302. trace_addr = cbe_read_pm(cpu, trace_address);
  1303. while (!(trace_addr & CBE_PM_TRACE_BUF_EMPTY)) {
  1304. /* There is data in the trace buffer to process
  1305. * Read the buffer until you get to the last
  1306. * entry. This is the value we want.
  1307. */
  1308. cbe_read_trace_buffer(cpu, trace_buffer);
  1309. trace_addr = cbe_read_pm(cpu, trace_address);
  1310. }
  1311. /* SPU Address 16 bit count format for 128 bit
  1312. * HW trace buffer is used for the SPU PC storage
  1313. * HDR bits 0:15
  1314. * SPU Addr 0 bits 16:31
  1315. * SPU Addr 1 bits 32:47
  1316. * unused bits 48:127
  1317. *
  1318. * HDR: bit4 = 1 SPU Address 0 valid
  1319. * HDR: bit5 = 1 SPU Address 1 valid
  1320. * - unfortunately, the valid bits don't seem to work
  1321. *
  1322. * Note trace_buffer[0] holds bits 0:63 of the HW
  1323. * trace buffer, trace_buffer[1] holds bits 64:127
  1324. */
  1325. trace_entry = trace_buffer[0]
  1326. & 0x00000000FFFF0000;
  1327. /* only top 16 of the 18 bit SPU PC address
  1328. * is stored in trace buffer, hence shift right
  1329. * by 16 -2 bits */
  1330. sample = trace_entry >> 14;
  1331. last_trace_buffer = trace_buffer[0];
  1332. spu_num = spu_evnt_phys_spu_indx
  1333. + (cbe_cpu_to_node(cpu) * NUM_SPUS_PER_NODE);
  1334. /* make sure only one process at a time is calling
  1335. * spu_sync_buffer()
  1336. */
  1337. spin_lock_irqsave(&oprof_spu_smpl_arry_lck,
  1338. sample_array_lock_flags);
  1339. spu_sync_buffer(spu_num, &sample, 1);
  1340. spin_unlock_irqrestore(&oprof_spu_smpl_arry_lck,
  1341. sample_array_lock_flags);
  1342. smp_wmb(); /* insure spu event buffer updates are written
  1343. * don't want events intermingled... */
  1344. /* The counters were frozen by the interrupt.
  1345. * Reenable the interrupt and restart the counters.
  1346. */
  1347. cbe_write_pm(cpu, pm_interval, NUM_INTERVAL_CYC);
  1348. cbe_enable_pm_interrupts(cpu, hdw_thread,
  1349. virt_cntr_inter_mask);
  1350. /* clear the trace buffer, re-enable writes to trace buff */
  1351. cbe_write_pm(cpu, trace_address, 0);
  1352. cbe_write_pm(cpu, pm_interval, NUM_INTERVAL_CYC);
  1353. /* The writes to the various performance counters only writes
  1354. * to a latch. The new values (interrupt setting bits, reset
  1355. * counter value etc.) are not copied to the actual registers
  1356. * until the performance monitor is enabled. In order to get
  1357. * this to work as desired, the permormance monitor needs to
  1358. * be disabled while writing to the latches. This is a
  1359. * HW design issue.
  1360. */
  1361. write_pm_cntrl(cpu);
  1362. cbe_enable_pm(cpu);
  1363. }
  1364. spin_unlock_irqrestore(&cntr_lock, flags);
  1365. }
  1366. static void cell_handle_interrupt_ppu(struct pt_regs *regs,
  1367. struct op_counter_config *ctr)
  1368. {
  1369. u32 cpu;
  1370. u64 pc;
  1371. int is_kernel;
  1372. unsigned long flags = 0;
  1373. u32 interrupt_mask;
  1374. int i;
  1375. cpu = smp_processor_id();
  1376. /*
  1377. * Need to make sure the interrupt handler and the virt counter
  1378. * routine are not running at the same time. See the
  1379. * cell_virtual_cntr() routine for additional comments.
  1380. */
  1381. spin_lock_irqsave(&cntr_lock, flags);
  1382. /*
  1383. * Need to disable and reenable the performance counters
  1384. * to get the desired behavior from the hardware. This
  1385. * is hardware specific.
  1386. */
  1387. cbe_disable_pm(cpu);
  1388. interrupt_mask = cbe_get_and_clear_pm_interrupts(cpu);
  1389. /*
  1390. * If the interrupt mask has been cleared, then the virt cntr
  1391. * has cleared the interrupt. When the thread that generated
  1392. * the interrupt is restored, the data count will be restored to
  1393. * 0xffffff0 to cause the interrupt to be regenerated.
  1394. */
  1395. if ((oprofile_running == 1) && (interrupt_mask != 0)) {
  1396. pc = regs->nip;
  1397. is_kernel = is_kernel_addr(pc);
  1398. for (i = 0; i < num_counters; ++i) {
  1399. if ((interrupt_mask & CBE_PM_CTR_OVERFLOW_INTR(i))
  1400. && ctr[i].enabled) {
  1401. oprofile_add_ext_sample(pc, regs, i, is_kernel);
  1402. cbe_write_ctr(cpu, i, reset_value[i]);
  1403. }
  1404. }
  1405. /*
  1406. * The counters were frozen by the interrupt.
  1407. * Reenable the interrupt and restart the counters.
  1408. * If there was a race between the interrupt handler and
  1409. * the virtual counter routine. The virutal counter
  1410. * routine may have cleared the interrupts. Hence must
  1411. * use the virt_cntr_inter_mask to re-enable the interrupts.
  1412. */
  1413. cbe_enable_pm_interrupts(cpu, hdw_thread,
  1414. virt_cntr_inter_mask);
  1415. /*
  1416. * The writes to the various performance counters only writes
  1417. * to a latch. The new values (interrupt setting bits, reset
  1418. * counter value etc.) are not copied to the actual registers
  1419. * until the performance monitor is enabled. In order to get
  1420. * this to work as desired, the permormance monitor needs to
  1421. * be disabled while writing to the latches. This is a
  1422. * HW design issue.
  1423. */
  1424. cbe_enable_pm(cpu);
  1425. }
  1426. spin_unlock_irqrestore(&cntr_lock, flags);
  1427. }
  1428. static void cell_handle_interrupt(struct pt_regs *regs,
  1429. struct op_counter_config *ctr)
  1430. {
  1431. if (profiling_mode == PPU_PROFILING)
  1432. cell_handle_interrupt_ppu(regs, ctr);
  1433. else
  1434. cell_handle_interrupt_spu(regs, ctr);
  1435. }
  1436. /*
  1437. * This function is called from the generic OProfile
  1438. * driver. When profiling PPUs, we need to do the
  1439. * generic sync start; otherwise, do spu_sync_start.
  1440. */
  1441. static int cell_sync_start(void)
  1442. {
  1443. if ((profiling_mode == SPU_PROFILING_CYCLES) ||
  1444. (profiling_mode == SPU_PROFILING_EVENTS))
  1445. return spu_sync_start();
  1446. else
  1447. return DO_GENERIC_SYNC;
  1448. }
  1449. static int cell_sync_stop(void)
  1450. {
  1451. if ((profiling_mode == SPU_PROFILING_CYCLES) ||
  1452. (profiling_mode == SPU_PROFILING_EVENTS))
  1453. return spu_sync_stop();
  1454. else
  1455. return 1;
  1456. }
  1457. struct op_powerpc_model op_model_cell = {
  1458. .reg_setup = cell_reg_setup,
  1459. .cpu_setup = cell_cpu_setup,
  1460. .global_start = cell_global_start,
  1461. .global_stop = cell_global_stop,
  1462. .sync_start = cell_sync_start,
  1463. .sync_stop = cell_sync_stop,
  1464. .handle_interrupt = cell_handle_interrupt,
  1465. };