spu_base.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. /*
  2. * Low-level SPU handling
  3. *
  4. * (C) Copyright IBM Deutschland Entwicklung GmbH 2005
  5. *
  6. * Author: Arnd Bergmann <arndb@de.ibm.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2, or (at your option)
  11. * any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. */
  22. #undef DEBUG
  23. #include <linux/interrupt.h>
  24. #include <linux/list.h>
  25. #include <linux/module.h>
  26. #include <linux/ptrace.h>
  27. #include <linux/slab.h>
  28. #include <linux/wait.h>
  29. #include <linux/mm.h>
  30. #include <linux/io.h>
  31. #include <linux/mutex.h>
  32. #include <linux/linux_logo.h>
  33. #include <asm/spu.h>
  34. #include <asm/spu_priv1.h>
  35. #include <asm/xmon.h>
  36. const struct spu_management_ops *spu_management_ops;
  37. EXPORT_SYMBOL_GPL(spu_management_ops);
  38. const struct spu_priv1_ops *spu_priv1_ops;
  39. static struct list_head spu_list[MAX_NUMNODES];
  40. static LIST_HEAD(spu_full_list);
  41. static DEFINE_MUTEX(spu_mutex);
  42. static DEFINE_SPINLOCK(spu_list_lock);
  43. EXPORT_SYMBOL_GPL(spu_priv1_ops);
  44. void spu_invalidate_slbs(struct spu *spu)
  45. {
  46. struct spu_priv2 __iomem *priv2 = spu->priv2;
  47. if (spu_mfc_sr1_get(spu) & MFC_STATE1_RELOCATE_MASK)
  48. out_be64(&priv2->slb_invalidate_all_W, 0UL);
  49. }
  50. EXPORT_SYMBOL_GPL(spu_invalidate_slbs);
  51. /* This is called by the MM core when a segment size is changed, to
  52. * request a flush of all the SPEs using a given mm
  53. */
  54. void spu_flush_all_slbs(struct mm_struct *mm)
  55. {
  56. struct spu *spu;
  57. unsigned long flags;
  58. spin_lock_irqsave(&spu_list_lock, flags);
  59. list_for_each_entry(spu, &spu_full_list, full_list) {
  60. if (spu->mm == mm)
  61. spu_invalidate_slbs(spu);
  62. }
  63. spin_unlock_irqrestore(&spu_list_lock, flags);
  64. }
  65. /* The hack below stinks... try to do something better one of
  66. * these days... Does it even work properly with NR_CPUS == 1 ?
  67. */
  68. static inline void mm_needs_global_tlbie(struct mm_struct *mm)
  69. {
  70. int nr = (NR_CPUS > 1) ? NR_CPUS : NR_CPUS + 1;
  71. /* Global TLBIE broadcast required with SPEs. */
  72. __cpus_setall(&mm->cpu_vm_mask, nr);
  73. }
  74. void spu_associate_mm(struct spu *spu, struct mm_struct *mm)
  75. {
  76. unsigned long flags;
  77. spin_lock_irqsave(&spu_list_lock, flags);
  78. spu->mm = mm;
  79. spin_unlock_irqrestore(&spu_list_lock, flags);
  80. if (mm)
  81. mm_needs_global_tlbie(mm);
  82. }
  83. EXPORT_SYMBOL_GPL(spu_associate_mm);
  84. static int __spu_trap_invalid_dma(struct spu *spu)
  85. {
  86. pr_debug("%s\n", __FUNCTION__);
  87. spu->dma_callback(spu, SPE_EVENT_INVALID_DMA);
  88. return 0;
  89. }
  90. static int __spu_trap_dma_align(struct spu *spu)
  91. {
  92. pr_debug("%s\n", __FUNCTION__);
  93. spu->dma_callback(spu, SPE_EVENT_DMA_ALIGNMENT);
  94. return 0;
  95. }
  96. static int __spu_trap_error(struct spu *spu)
  97. {
  98. pr_debug("%s\n", __FUNCTION__);
  99. spu->dma_callback(spu, SPE_EVENT_SPE_ERROR);
  100. return 0;
  101. }
  102. static void spu_restart_dma(struct spu *spu)
  103. {
  104. struct spu_priv2 __iomem *priv2 = spu->priv2;
  105. if (!test_bit(SPU_CONTEXT_SWITCH_PENDING, &spu->flags))
  106. out_be64(&priv2->mfc_control_RW, MFC_CNTL_RESTART_DMA_COMMAND);
  107. }
  108. static int __spu_trap_data_seg(struct spu *spu, unsigned long ea)
  109. {
  110. struct spu_priv2 __iomem *priv2 = spu->priv2;
  111. struct mm_struct *mm = spu->mm;
  112. u64 esid, vsid, llp;
  113. int psize;
  114. pr_debug("%s\n", __FUNCTION__);
  115. if (test_bit(SPU_CONTEXT_SWITCH_ACTIVE, &spu->flags)) {
  116. /* SLBs are pre-loaded for context switch, so
  117. * we should never get here!
  118. */
  119. printk("%s: invalid access during switch!\n", __func__);
  120. return 1;
  121. }
  122. esid = (ea & ESID_MASK) | SLB_ESID_V;
  123. switch(REGION_ID(ea)) {
  124. case USER_REGION_ID:
  125. #ifdef CONFIG_PPC_MM_SLICES
  126. psize = get_slice_psize(mm, ea);
  127. #else
  128. psize = mm->context.user_psize;
  129. #endif
  130. vsid = (get_vsid(mm->context.id, ea) << SLB_VSID_SHIFT) |
  131. SLB_VSID_USER;
  132. break;
  133. case VMALLOC_REGION_ID:
  134. if (ea < VMALLOC_END)
  135. psize = mmu_vmalloc_psize;
  136. else
  137. psize = mmu_io_psize;
  138. vsid = (get_kernel_vsid(ea) << SLB_VSID_SHIFT) |
  139. SLB_VSID_KERNEL;
  140. break;
  141. case KERNEL_REGION_ID:
  142. psize = mmu_linear_psize;
  143. vsid = (get_kernel_vsid(ea) << SLB_VSID_SHIFT) |
  144. SLB_VSID_KERNEL;
  145. break;
  146. default:
  147. /* Future: support kernel segments so that drivers
  148. * can use SPUs.
  149. */
  150. pr_debug("invalid region access at %016lx\n", ea);
  151. return 1;
  152. }
  153. llp = mmu_psize_defs[psize].sllp;
  154. out_be64(&priv2->slb_index_W, spu->slb_replace);
  155. out_be64(&priv2->slb_vsid_RW, vsid | llp);
  156. out_be64(&priv2->slb_esid_RW, esid);
  157. spu->slb_replace++;
  158. if (spu->slb_replace >= 8)
  159. spu->slb_replace = 0;
  160. spu_restart_dma(spu);
  161. spu->stats.slb_flt++;
  162. return 0;
  163. }
  164. extern int hash_page(unsigned long ea, unsigned long access, unsigned long trap); //XXX
  165. static int __spu_trap_data_map(struct spu *spu, unsigned long ea, u64 dsisr)
  166. {
  167. pr_debug("%s, %lx, %lx\n", __FUNCTION__, dsisr, ea);
  168. /* Handle kernel space hash faults immediately.
  169. User hash faults need to be deferred to process context. */
  170. if ((dsisr & MFC_DSISR_PTE_NOT_FOUND)
  171. && REGION_ID(ea) != USER_REGION_ID
  172. && hash_page(ea, _PAGE_PRESENT, 0x300) == 0) {
  173. spu_restart_dma(spu);
  174. return 0;
  175. }
  176. if (test_bit(SPU_CONTEXT_SWITCH_ACTIVE, &spu->flags)) {
  177. printk("%s: invalid access during switch!\n", __func__);
  178. return 1;
  179. }
  180. spu->dar = ea;
  181. spu->dsisr = dsisr;
  182. mb();
  183. spu->stop_callback(spu);
  184. return 0;
  185. }
  186. static irqreturn_t
  187. spu_irq_class_0(int irq, void *data)
  188. {
  189. struct spu *spu;
  190. spu = data;
  191. spu->class_0_pending = 1;
  192. spu->stop_callback(spu);
  193. return IRQ_HANDLED;
  194. }
  195. int
  196. spu_irq_class_0_bottom(struct spu *spu)
  197. {
  198. unsigned long stat, mask;
  199. unsigned long flags;
  200. spu->class_0_pending = 0;
  201. spin_lock_irqsave(&spu->register_lock, flags);
  202. mask = spu_int_mask_get(spu, 0);
  203. stat = spu_int_stat_get(spu, 0);
  204. stat &= mask;
  205. if (stat & 1) /* invalid DMA alignment */
  206. __spu_trap_dma_align(spu);
  207. if (stat & 2) /* invalid MFC DMA */
  208. __spu_trap_invalid_dma(spu);
  209. if (stat & 4) /* error on SPU */
  210. __spu_trap_error(spu);
  211. spu_int_stat_clear(spu, 0, stat);
  212. spin_unlock_irqrestore(&spu->register_lock, flags);
  213. return (stat & 0x7) ? -EIO : 0;
  214. }
  215. EXPORT_SYMBOL_GPL(spu_irq_class_0_bottom);
  216. static irqreturn_t
  217. spu_irq_class_1(int irq, void *data)
  218. {
  219. struct spu *spu;
  220. unsigned long stat, mask, dar, dsisr;
  221. spu = data;
  222. /* atomically read & clear class1 status. */
  223. spin_lock(&spu->register_lock);
  224. mask = spu_int_mask_get(spu, 1);
  225. stat = spu_int_stat_get(spu, 1) & mask;
  226. dar = spu_mfc_dar_get(spu);
  227. dsisr = spu_mfc_dsisr_get(spu);
  228. if (stat & 2) /* mapping fault */
  229. spu_mfc_dsisr_set(spu, 0ul);
  230. spu_int_stat_clear(spu, 1, stat);
  231. spin_unlock(&spu->register_lock);
  232. pr_debug("%s: %lx %lx %lx %lx\n", __FUNCTION__, mask, stat,
  233. dar, dsisr);
  234. if (stat & 1) /* segment fault */
  235. __spu_trap_data_seg(spu, dar);
  236. if (stat & 2) { /* mapping fault */
  237. __spu_trap_data_map(spu, dar, dsisr);
  238. }
  239. if (stat & 4) /* ls compare & suspend on get */
  240. ;
  241. if (stat & 8) /* ls compare & suspend on put */
  242. ;
  243. return stat ? IRQ_HANDLED : IRQ_NONE;
  244. }
  245. static irqreturn_t
  246. spu_irq_class_2(int irq, void *data)
  247. {
  248. struct spu *spu;
  249. unsigned long stat;
  250. unsigned long mask;
  251. spu = data;
  252. spin_lock(&spu->register_lock);
  253. stat = spu_int_stat_get(spu, 2);
  254. mask = spu_int_mask_get(spu, 2);
  255. /* ignore interrupts we're not waiting for */
  256. stat &= mask;
  257. /*
  258. * mailbox interrupts (0x1 and 0x10) are level triggered.
  259. * mask them now before acknowledging.
  260. */
  261. if (stat & 0x11)
  262. spu_int_mask_and(spu, 2, ~(stat & 0x11));
  263. /* acknowledge all interrupts before the callbacks */
  264. spu_int_stat_clear(spu, 2, stat);
  265. spin_unlock(&spu->register_lock);
  266. pr_debug("class 2 interrupt %d, %lx, %lx\n", irq, stat, mask);
  267. if (stat & 1) /* PPC core mailbox */
  268. spu->ibox_callback(spu);
  269. if (stat & 2) /* SPU stop-and-signal */
  270. spu->stop_callback(spu);
  271. if (stat & 4) /* SPU halted */
  272. spu->stop_callback(spu);
  273. if (stat & 8) /* DMA tag group complete */
  274. spu->mfc_callback(spu);
  275. if (stat & 0x10) /* SPU mailbox threshold */
  276. spu->wbox_callback(spu);
  277. spu->stats.class2_intr++;
  278. return stat ? IRQ_HANDLED : IRQ_NONE;
  279. }
  280. static int spu_request_irqs(struct spu *spu)
  281. {
  282. int ret = 0;
  283. if (spu->irqs[0] != NO_IRQ) {
  284. snprintf(spu->irq_c0, sizeof (spu->irq_c0), "spe%02d.0",
  285. spu->number);
  286. ret = request_irq(spu->irqs[0], spu_irq_class_0,
  287. IRQF_DISABLED,
  288. spu->irq_c0, spu);
  289. if (ret)
  290. goto bail0;
  291. }
  292. if (spu->irqs[1] != NO_IRQ) {
  293. snprintf(spu->irq_c1, sizeof (spu->irq_c1), "spe%02d.1",
  294. spu->number);
  295. ret = request_irq(spu->irqs[1], spu_irq_class_1,
  296. IRQF_DISABLED,
  297. spu->irq_c1, spu);
  298. if (ret)
  299. goto bail1;
  300. }
  301. if (spu->irqs[2] != NO_IRQ) {
  302. snprintf(spu->irq_c2, sizeof (spu->irq_c2), "spe%02d.2",
  303. spu->number);
  304. ret = request_irq(spu->irqs[2], spu_irq_class_2,
  305. IRQF_DISABLED,
  306. spu->irq_c2, spu);
  307. if (ret)
  308. goto bail2;
  309. }
  310. return 0;
  311. bail2:
  312. if (spu->irqs[1] != NO_IRQ)
  313. free_irq(spu->irqs[1], spu);
  314. bail1:
  315. if (spu->irqs[0] != NO_IRQ)
  316. free_irq(spu->irqs[0], spu);
  317. bail0:
  318. return ret;
  319. }
  320. static void spu_free_irqs(struct spu *spu)
  321. {
  322. if (spu->irqs[0] != NO_IRQ)
  323. free_irq(spu->irqs[0], spu);
  324. if (spu->irqs[1] != NO_IRQ)
  325. free_irq(spu->irqs[1], spu);
  326. if (spu->irqs[2] != NO_IRQ)
  327. free_irq(spu->irqs[2], spu);
  328. }
  329. static void spu_init_channels(struct spu *spu)
  330. {
  331. static const struct {
  332. unsigned channel;
  333. unsigned count;
  334. } zero_list[] = {
  335. { 0x00, 1, }, { 0x01, 1, }, { 0x03, 1, }, { 0x04, 1, },
  336. { 0x18, 1, }, { 0x19, 1, }, { 0x1b, 1, }, { 0x1d, 1, },
  337. }, count_list[] = {
  338. { 0x00, 0, }, { 0x03, 0, }, { 0x04, 0, }, { 0x15, 16, },
  339. { 0x17, 1, }, { 0x18, 0, }, { 0x19, 0, }, { 0x1b, 0, },
  340. { 0x1c, 1, }, { 0x1d, 0, }, { 0x1e, 1, },
  341. };
  342. struct spu_priv2 __iomem *priv2;
  343. int i;
  344. priv2 = spu->priv2;
  345. /* initialize all channel data to zero */
  346. for (i = 0; i < ARRAY_SIZE(zero_list); i++) {
  347. int count;
  348. out_be64(&priv2->spu_chnlcntptr_RW, zero_list[i].channel);
  349. for (count = 0; count < zero_list[i].count; count++)
  350. out_be64(&priv2->spu_chnldata_RW, 0);
  351. }
  352. /* initialize channel counts to meaningful values */
  353. for (i = 0; i < ARRAY_SIZE(count_list); i++) {
  354. out_be64(&priv2->spu_chnlcntptr_RW, count_list[i].channel);
  355. out_be64(&priv2->spu_chnlcnt_RW, count_list[i].count);
  356. }
  357. }
  358. struct spu *spu_alloc_node(int node)
  359. {
  360. struct spu *spu = NULL;
  361. mutex_lock(&spu_mutex);
  362. if (!list_empty(&spu_list[node])) {
  363. spu = list_entry(spu_list[node].next, struct spu, list);
  364. list_del_init(&spu->list);
  365. pr_debug("Got SPU %d %d\n", spu->number, spu->node);
  366. }
  367. mutex_unlock(&spu_mutex);
  368. if (spu)
  369. spu_init_channels(spu);
  370. return spu;
  371. }
  372. EXPORT_SYMBOL_GPL(spu_alloc_node);
  373. struct spu *spu_alloc(void)
  374. {
  375. struct spu *spu = NULL;
  376. int node;
  377. for (node = 0; node < MAX_NUMNODES; node++) {
  378. spu = spu_alloc_node(node);
  379. if (spu)
  380. break;
  381. }
  382. return spu;
  383. }
  384. void spu_free(struct spu *spu)
  385. {
  386. mutex_lock(&spu_mutex);
  387. list_add_tail(&spu->list, &spu_list[spu->node]);
  388. mutex_unlock(&spu_mutex);
  389. }
  390. EXPORT_SYMBOL_GPL(spu_free);
  391. static int spu_shutdown(struct sys_device *sysdev)
  392. {
  393. struct spu *spu = container_of(sysdev, struct spu, sysdev);
  394. spu_free_irqs(spu);
  395. spu_destroy_spu(spu);
  396. return 0;
  397. }
  398. struct sysdev_class spu_sysdev_class = {
  399. set_kset_name("spu"),
  400. .shutdown = spu_shutdown,
  401. };
  402. int spu_add_sysdev_attr(struct sysdev_attribute *attr)
  403. {
  404. struct spu *spu;
  405. mutex_lock(&spu_mutex);
  406. list_for_each_entry(spu, &spu_full_list, full_list)
  407. sysdev_create_file(&spu->sysdev, attr);
  408. mutex_unlock(&spu_mutex);
  409. return 0;
  410. }
  411. EXPORT_SYMBOL_GPL(spu_add_sysdev_attr);
  412. int spu_add_sysdev_attr_group(struct attribute_group *attrs)
  413. {
  414. struct spu *spu;
  415. mutex_lock(&spu_mutex);
  416. list_for_each_entry(spu, &spu_full_list, full_list)
  417. sysfs_create_group(&spu->sysdev.kobj, attrs);
  418. mutex_unlock(&spu_mutex);
  419. return 0;
  420. }
  421. EXPORT_SYMBOL_GPL(spu_add_sysdev_attr_group);
  422. void spu_remove_sysdev_attr(struct sysdev_attribute *attr)
  423. {
  424. struct spu *spu;
  425. mutex_lock(&spu_mutex);
  426. list_for_each_entry(spu, &spu_full_list, full_list)
  427. sysdev_remove_file(&spu->sysdev, attr);
  428. mutex_unlock(&spu_mutex);
  429. }
  430. EXPORT_SYMBOL_GPL(spu_remove_sysdev_attr);
  431. void spu_remove_sysdev_attr_group(struct attribute_group *attrs)
  432. {
  433. struct spu *spu;
  434. mutex_lock(&spu_mutex);
  435. list_for_each_entry(spu, &spu_full_list, full_list)
  436. sysfs_remove_group(&spu->sysdev.kobj, attrs);
  437. mutex_unlock(&spu_mutex);
  438. }
  439. EXPORT_SYMBOL_GPL(spu_remove_sysdev_attr_group);
  440. static int spu_create_sysdev(struct spu *spu)
  441. {
  442. int ret;
  443. spu->sysdev.id = spu->number;
  444. spu->sysdev.cls = &spu_sysdev_class;
  445. ret = sysdev_register(&spu->sysdev);
  446. if (ret) {
  447. printk(KERN_ERR "Can't register SPU %d with sysfs\n",
  448. spu->number);
  449. return ret;
  450. }
  451. sysfs_add_device_to_node(&spu->sysdev, spu->node);
  452. return 0;
  453. }
  454. static int __init create_spu(void *data)
  455. {
  456. struct spu *spu;
  457. int ret;
  458. static int number;
  459. unsigned long flags;
  460. ret = -ENOMEM;
  461. spu = kzalloc(sizeof (*spu), GFP_KERNEL);
  462. if (!spu)
  463. goto out;
  464. spin_lock_init(&spu->register_lock);
  465. mutex_lock(&spu_mutex);
  466. spu->number = number++;
  467. mutex_unlock(&spu_mutex);
  468. ret = spu_create_spu(spu, data);
  469. if (ret)
  470. goto out_free;
  471. spu_mfc_sdr_setup(spu);
  472. spu_mfc_sr1_set(spu, 0x33);
  473. ret = spu_request_irqs(spu);
  474. if (ret)
  475. goto out_destroy;
  476. ret = spu_create_sysdev(spu);
  477. if (ret)
  478. goto out_free_irqs;
  479. mutex_lock(&spu_mutex);
  480. spin_lock_irqsave(&spu_list_lock, flags);
  481. list_add(&spu->list, &spu_list[spu->node]);
  482. list_add(&spu->full_list, &spu_full_list);
  483. spin_unlock_irqrestore(&spu_list_lock, flags);
  484. mutex_unlock(&spu_mutex);
  485. spu->stats.utilization_state = SPU_UTIL_IDLE;
  486. spu->stats.tstamp = jiffies;
  487. goto out;
  488. out_free_irqs:
  489. spu_free_irqs(spu);
  490. out_destroy:
  491. spu_destroy_spu(spu);
  492. out_free:
  493. kfree(spu);
  494. out:
  495. return ret;
  496. }
  497. static const char *spu_state_names[] = {
  498. "user", "system", "iowait", "idle"
  499. };
  500. static unsigned long long spu_acct_time(struct spu *spu,
  501. enum spu_utilization_state state)
  502. {
  503. unsigned long long time = spu->stats.times[state];
  504. if (spu->stats.utilization_state == state)
  505. time += jiffies - spu->stats.tstamp;
  506. return jiffies_to_msecs(time);
  507. }
  508. static ssize_t spu_stat_show(struct sys_device *sysdev, char *buf)
  509. {
  510. struct spu *spu = container_of(sysdev, struct spu, sysdev);
  511. return sprintf(buf, "%s %llu %llu %llu %llu "
  512. "%llu %llu %llu %llu %llu %llu %llu %llu\n",
  513. spu_state_names[spu->stats.utilization_state],
  514. spu_acct_time(spu, SPU_UTIL_USER),
  515. spu_acct_time(spu, SPU_UTIL_SYSTEM),
  516. spu_acct_time(spu, SPU_UTIL_IOWAIT),
  517. spu_acct_time(spu, SPU_UTIL_IDLE),
  518. spu->stats.vol_ctx_switch,
  519. spu->stats.invol_ctx_switch,
  520. spu->stats.slb_flt,
  521. spu->stats.hash_flt,
  522. spu->stats.min_flt,
  523. spu->stats.maj_flt,
  524. spu->stats.class2_intr,
  525. spu->stats.libassist);
  526. }
  527. static SYSDEV_ATTR(stat, 0644, spu_stat_show, NULL);
  528. static int __init init_spu_base(void)
  529. {
  530. int i, ret = 0;
  531. for (i = 0; i < MAX_NUMNODES; i++)
  532. INIT_LIST_HEAD(&spu_list[i]);
  533. if (!spu_management_ops)
  534. goto out;
  535. /* create sysdev class for spus */
  536. ret = sysdev_class_register(&spu_sysdev_class);
  537. if (ret)
  538. goto out;
  539. ret = spu_enumerate_spus(create_spu);
  540. if (ret < 0) {
  541. printk(KERN_WARNING "%s: Error initializing spus\n",
  542. __FUNCTION__);
  543. goto out_unregister_sysdev_class;
  544. }
  545. if (ret > 0) {
  546. /*
  547. * We cannot put the forward declaration in
  548. * <linux/linux_logo.h> because of conflicting session type
  549. * conflicts for const and __initdata with different compiler
  550. * versions
  551. */
  552. extern const struct linux_logo logo_spe_clut224;
  553. fb_append_extra_logo(&logo_spe_clut224, ret);
  554. }
  555. xmon_register_spus(&spu_full_list);
  556. spu_add_sysdev_attr(&attr_stat);
  557. return 0;
  558. out_unregister_sysdev_class:
  559. sysdev_class_unregister(&spu_sysdev_class);
  560. out:
  561. return ret;
  562. }
  563. module_init(init_spu_base);
  564. MODULE_LICENSE("GPL");
  565. MODULE_AUTHOR("Arnd Bergmann <arndb@de.ibm.com>");