spu_base.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  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/poll.h>
  27. #include <linux/ptrace.h>
  28. #include <linux/slab.h>
  29. #include <linux/wait.h>
  30. #include <asm/io.h>
  31. #include <asm/prom.h>
  32. #include <asm/semaphore.h>
  33. #include <asm/spu.h>
  34. #include <asm/mmu_context.h>
  35. #include "interrupt.h"
  36. static int __spu_trap_invalid_dma(struct spu *spu)
  37. {
  38. pr_debug("%s\n", __FUNCTION__);
  39. force_sig(SIGBUS, /* info, */ current);
  40. return 0;
  41. }
  42. static int __spu_trap_dma_align(struct spu *spu)
  43. {
  44. pr_debug("%s\n", __FUNCTION__);
  45. force_sig(SIGBUS, /* info, */ current);
  46. return 0;
  47. }
  48. static int __spu_trap_error(struct spu *spu)
  49. {
  50. pr_debug("%s\n", __FUNCTION__);
  51. force_sig(SIGILL, /* info, */ current);
  52. return 0;
  53. }
  54. static void spu_restart_dma(struct spu *spu)
  55. {
  56. struct spu_priv2 __iomem *priv2 = spu->priv2;
  57. if (!test_bit(SPU_CONTEXT_SWITCH_PENDING, &spu->flags))
  58. out_be64(&priv2->mfc_control_RW, MFC_CNTL_RESTART_DMA_COMMAND);
  59. }
  60. static int __spu_trap_data_seg(struct spu *spu, unsigned long ea)
  61. {
  62. struct spu_priv2 __iomem *priv2 = spu->priv2;
  63. struct mm_struct *mm = spu->mm;
  64. u64 esid, vsid;
  65. pr_debug("%s\n", __FUNCTION__);
  66. if (test_bit(SPU_CONTEXT_SWITCH_ACTIVE, &spu->flags)) {
  67. /* SLBs are pre-loaded for context switch, so
  68. * we should never get here!
  69. */
  70. printk("%s: invalid access during switch!\n", __func__);
  71. return 1;
  72. }
  73. if (!mm || (REGION_ID(ea) != USER_REGION_ID)) {
  74. /* Future: support kernel segments so that drivers
  75. * can use SPUs.
  76. */
  77. pr_debug("invalid region access at %016lx\n", ea);
  78. return 1;
  79. }
  80. esid = (ea & ESID_MASK) | SLB_ESID_V;
  81. vsid = (get_vsid(mm->context.id, ea) << SLB_VSID_SHIFT) | SLB_VSID_USER;
  82. if (in_hugepage_area(mm->context, ea))
  83. vsid |= SLB_VSID_L;
  84. out_be64(&priv2->slb_index_W, spu->slb_replace);
  85. out_be64(&priv2->slb_vsid_RW, vsid);
  86. out_be64(&priv2->slb_esid_RW, esid);
  87. spu->slb_replace++;
  88. if (spu->slb_replace >= 8)
  89. spu->slb_replace = 0;
  90. spu_restart_dma(spu);
  91. return 0;
  92. }
  93. extern int hash_page(unsigned long ea, unsigned long access, unsigned long trap); //XXX
  94. static int __spu_trap_data_map(struct spu *spu, unsigned long ea, u64 dsisr)
  95. {
  96. pr_debug("%s\n", __FUNCTION__);
  97. /* Handle kernel space hash faults immediately.
  98. User hash faults need to be deferred to process context. */
  99. if ((dsisr & MFC_DSISR_PTE_NOT_FOUND)
  100. && REGION_ID(ea) != USER_REGION_ID
  101. && hash_page(ea, _PAGE_PRESENT, 0x300) == 0) {
  102. spu_restart_dma(spu);
  103. return 0;
  104. }
  105. if (test_bit(SPU_CONTEXT_SWITCH_ACTIVE, &spu->flags)) {
  106. printk("%s: invalid access during switch!\n", __func__);
  107. return 1;
  108. }
  109. spu->dar = ea;
  110. spu->dsisr = dsisr;
  111. mb();
  112. if (spu->stop_callback)
  113. spu->stop_callback(spu);
  114. return 0;
  115. }
  116. static int __spu_trap_mailbox(struct spu *spu)
  117. {
  118. if (spu->ibox_callback)
  119. spu->ibox_callback(spu);
  120. /* atomically disable SPU mailbox interrupts */
  121. spin_lock(&spu->register_lock);
  122. spu_int_mask_and(spu, 2, ~0x1);
  123. spin_unlock(&spu->register_lock);
  124. return 0;
  125. }
  126. static int __spu_trap_stop(struct spu *spu)
  127. {
  128. pr_debug("%s\n", __FUNCTION__);
  129. spu->stop_code = in_be32(&spu->problem->spu_status_R);
  130. if (spu->stop_callback)
  131. spu->stop_callback(spu);
  132. return 0;
  133. }
  134. static int __spu_trap_halt(struct spu *spu)
  135. {
  136. pr_debug("%s\n", __FUNCTION__);
  137. spu->stop_code = in_be32(&spu->problem->spu_status_R);
  138. if (spu->stop_callback)
  139. spu->stop_callback(spu);
  140. return 0;
  141. }
  142. static int __spu_trap_tag_group(struct spu *spu)
  143. {
  144. pr_debug("%s\n", __FUNCTION__);
  145. /* wake_up(&spu->dma_wq); */
  146. return 0;
  147. }
  148. static int __spu_trap_spubox(struct spu *spu)
  149. {
  150. if (spu->wbox_callback)
  151. spu->wbox_callback(spu);
  152. /* atomically disable SPU mailbox interrupts */
  153. spin_lock(&spu->register_lock);
  154. spu_int_mask_and(spu, 2, ~0x10);
  155. spin_unlock(&spu->register_lock);
  156. return 0;
  157. }
  158. static irqreturn_t
  159. spu_irq_class_0(int irq, void *data, struct pt_regs *regs)
  160. {
  161. struct spu *spu;
  162. spu = data;
  163. spu->class_0_pending = 1;
  164. if (spu->stop_callback)
  165. spu->stop_callback(spu);
  166. return IRQ_HANDLED;
  167. }
  168. int
  169. spu_irq_class_0_bottom(struct spu *spu)
  170. {
  171. unsigned long stat, mask;
  172. spu->class_0_pending = 0;
  173. mask = spu_int_mask_get(spu, 0);
  174. stat = spu_int_stat_get(spu, 0);
  175. stat &= mask;
  176. if (stat & 1) /* invalid MFC DMA */
  177. __spu_trap_invalid_dma(spu);
  178. if (stat & 2) /* invalid DMA alignment */
  179. __spu_trap_dma_align(spu);
  180. if (stat & 4) /* error on SPU */
  181. __spu_trap_error(spu);
  182. spu_int_stat_clear(spu, 0, stat);
  183. return (stat & 0x7) ? -EIO : 0;
  184. }
  185. EXPORT_SYMBOL_GPL(spu_irq_class_0_bottom);
  186. static irqreturn_t
  187. spu_irq_class_1(int irq, void *data, struct pt_regs *regs)
  188. {
  189. struct spu *spu;
  190. unsigned long stat, mask, dar, dsisr;
  191. spu = data;
  192. /* atomically read & clear class1 status. */
  193. spin_lock(&spu->register_lock);
  194. mask = spu_int_mask_get(spu, 1);
  195. stat = spu_int_stat_get(spu, 1) & mask;
  196. dar = spu_mfc_dar_get(spu);
  197. dsisr = spu_mfc_dsisr_get(spu);
  198. if (stat & 2) /* mapping fault */
  199. spu_mfc_dsisr_set(spu, 0ul);
  200. spu_int_stat_clear(spu, 1, stat);
  201. spin_unlock(&spu->register_lock);
  202. if (stat & 1) /* segment fault */
  203. __spu_trap_data_seg(spu, dar);
  204. if (stat & 2) { /* mapping fault */
  205. __spu_trap_data_map(spu, dar, dsisr);
  206. }
  207. if (stat & 4) /* ls compare & suspend on get */
  208. ;
  209. if (stat & 8) /* ls compare & suspend on put */
  210. ;
  211. return stat ? IRQ_HANDLED : IRQ_NONE;
  212. }
  213. EXPORT_SYMBOL_GPL(spu_irq_class_1_bottom);
  214. static irqreturn_t
  215. spu_irq_class_2(int irq, void *data, struct pt_regs *regs)
  216. {
  217. struct spu *spu;
  218. unsigned long stat;
  219. unsigned long mask;
  220. spu = data;
  221. stat = spu_int_stat_get(spu, 2);
  222. mask = spu_int_mask_get(spu, 2);
  223. pr_debug("class 2 interrupt %d, %lx, %lx\n", irq, stat, mask);
  224. stat &= mask;
  225. if (stat & 1) /* PPC core mailbox */
  226. __spu_trap_mailbox(spu);
  227. if (stat & 2) /* SPU stop-and-signal */
  228. __spu_trap_stop(spu);
  229. if (stat & 4) /* SPU halted */
  230. __spu_trap_halt(spu);
  231. if (stat & 8) /* DMA tag group complete */
  232. __spu_trap_tag_group(spu);
  233. if (stat & 0x10) /* SPU mailbox threshold */
  234. __spu_trap_spubox(spu);
  235. spu_int_stat_clear(spu, 2, stat);
  236. return stat ? IRQ_HANDLED : IRQ_NONE;
  237. }
  238. static int
  239. spu_request_irqs(struct spu *spu)
  240. {
  241. int ret;
  242. int irq_base;
  243. irq_base = IIC_NODE_STRIDE * spu->node + IIC_SPE_OFFSET;
  244. snprintf(spu->irq_c0, sizeof (spu->irq_c0), "spe%02d.0", spu->number);
  245. ret = request_irq(irq_base + spu->isrc,
  246. spu_irq_class_0, 0, spu->irq_c0, spu);
  247. if (ret)
  248. goto out;
  249. snprintf(spu->irq_c1, sizeof (spu->irq_c1), "spe%02d.1", spu->number);
  250. ret = request_irq(irq_base + IIC_CLASS_STRIDE + spu->isrc,
  251. spu_irq_class_1, 0, spu->irq_c1, spu);
  252. if (ret)
  253. goto out1;
  254. snprintf(spu->irq_c2, sizeof (spu->irq_c2), "spe%02d.2", spu->number);
  255. ret = request_irq(irq_base + 2*IIC_CLASS_STRIDE + spu->isrc,
  256. spu_irq_class_2, 0, spu->irq_c2, spu);
  257. if (ret)
  258. goto out2;
  259. goto out;
  260. out2:
  261. free_irq(irq_base + IIC_CLASS_STRIDE + spu->isrc, spu);
  262. out1:
  263. free_irq(irq_base + spu->isrc, spu);
  264. out:
  265. return ret;
  266. }
  267. static void
  268. spu_free_irqs(struct spu *spu)
  269. {
  270. int irq_base;
  271. irq_base = IIC_NODE_STRIDE * spu->node + IIC_SPE_OFFSET;
  272. free_irq(irq_base + spu->isrc, spu);
  273. free_irq(irq_base + IIC_CLASS_STRIDE + spu->isrc, spu);
  274. free_irq(irq_base + 2*IIC_CLASS_STRIDE + spu->isrc, spu);
  275. }
  276. static LIST_HEAD(spu_list);
  277. static DECLARE_MUTEX(spu_mutex);
  278. static void spu_init_channels(struct spu *spu)
  279. {
  280. static const struct {
  281. unsigned channel;
  282. unsigned count;
  283. } zero_list[] = {
  284. { 0x00, 1, }, { 0x01, 1, }, { 0x03, 1, }, { 0x04, 1, },
  285. { 0x18, 1, }, { 0x19, 1, }, { 0x1b, 1, }, { 0x1d, 1, },
  286. }, count_list[] = {
  287. { 0x00, 0, }, { 0x03, 0, }, { 0x04, 0, }, { 0x15, 16, },
  288. { 0x17, 1, }, { 0x18, 0, }, { 0x19, 0, }, { 0x1b, 0, },
  289. { 0x1c, 1, }, { 0x1d, 0, }, { 0x1e, 1, },
  290. };
  291. struct spu_priv2 __iomem *priv2;
  292. int i;
  293. priv2 = spu->priv2;
  294. /* initialize all channel data to zero */
  295. for (i = 0; i < ARRAY_SIZE(zero_list); i++) {
  296. int count;
  297. out_be64(&priv2->spu_chnlcntptr_RW, zero_list[i].channel);
  298. for (count = 0; count < zero_list[i].count; count++)
  299. out_be64(&priv2->spu_chnldata_RW, 0);
  300. }
  301. /* initialize channel counts to meaningful values */
  302. for (i = 0; i < ARRAY_SIZE(count_list); i++) {
  303. out_be64(&priv2->spu_chnlcntptr_RW, count_list[i].channel);
  304. out_be64(&priv2->spu_chnlcnt_RW, count_list[i].count);
  305. }
  306. }
  307. struct spu *spu_alloc(void)
  308. {
  309. struct spu *spu;
  310. down(&spu_mutex);
  311. if (!list_empty(&spu_list)) {
  312. spu = list_entry(spu_list.next, struct spu, list);
  313. list_del_init(&spu->list);
  314. pr_debug("Got SPU %x %d\n", spu->isrc, spu->number);
  315. } else {
  316. pr_debug("No SPU left\n");
  317. spu = NULL;
  318. }
  319. up(&spu_mutex);
  320. if (spu)
  321. spu_init_channels(spu);
  322. return spu;
  323. }
  324. EXPORT_SYMBOL_GPL(spu_alloc);
  325. void spu_free(struct spu *spu)
  326. {
  327. down(&spu_mutex);
  328. list_add_tail(&spu->list, &spu_list);
  329. up(&spu_mutex);
  330. }
  331. EXPORT_SYMBOL_GPL(spu_free);
  332. static int spu_handle_mm_fault(struct spu *spu)
  333. {
  334. struct mm_struct *mm = spu->mm;
  335. struct vm_area_struct *vma;
  336. u64 ea, dsisr, is_write;
  337. int ret;
  338. ea = spu->dar;
  339. dsisr = spu->dsisr;
  340. #if 0
  341. if (!IS_VALID_EA(ea)) {
  342. return -EFAULT;
  343. }
  344. #endif /* XXX */
  345. if (mm == NULL) {
  346. return -EFAULT;
  347. }
  348. if (mm->pgd == NULL) {
  349. return -EFAULT;
  350. }
  351. down_read(&mm->mmap_sem);
  352. vma = find_vma(mm, ea);
  353. if (!vma)
  354. goto bad_area;
  355. if (vma->vm_start <= ea)
  356. goto good_area;
  357. if (!(vma->vm_flags & VM_GROWSDOWN))
  358. goto bad_area;
  359. #if 0
  360. if (expand_stack(vma, ea))
  361. goto bad_area;
  362. #endif /* XXX */
  363. good_area:
  364. is_write = dsisr & MFC_DSISR_ACCESS_PUT;
  365. if (is_write) {
  366. if (!(vma->vm_flags & VM_WRITE))
  367. goto bad_area;
  368. } else {
  369. if (dsisr & MFC_DSISR_ACCESS_DENIED)
  370. goto bad_area;
  371. if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
  372. goto bad_area;
  373. }
  374. ret = 0;
  375. switch (handle_mm_fault(mm, vma, ea, is_write)) {
  376. case VM_FAULT_MINOR:
  377. current->min_flt++;
  378. break;
  379. case VM_FAULT_MAJOR:
  380. current->maj_flt++;
  381. break;
  382. case VM_FAULT_SIGBUS:
  383. ret = -EFAULT;
  384. goto bad_area;
  385. case VM_FAULT_OOM:
  386. ret = -ENOMEM;
  387. goto bad_area;
  388. default:
  389. BUG();
  390. }
  391. up_read(&mm->mmap_sem);
  392. return ret;
  393. bad_area:
  394. up_read(&mm->mmap_sem);
  395. return -EFAULT;
  396. }
  397. int spu_irq_class_1_bottom(struct spu *spu)
  398. {
  399. u64 ea, dsisr, access, error = 0UL;
  400. int ret = 0;
  401. ea = spu->dar;
  402. dsisr = spu->dsisr;
  403. if (dsisr & MFC_DSISR_PTE_NOT_FOUND) {
  404. access = (_PAGE_PRESENT | _PAGE_USER);
  405. access |= (dsisr & MFC_DSISR_ACCESS_PUT) ? _PAGE_RW : 0UL;
  406. if (hash_page(ea, access, 0x300) != 0)
  407. error |= CLASS1_ENABLE_STORAGE_FAULT_INTR;
  408. }
  409. if ((error & CLASS1_ENABLE_STORAGE_FAULT_INTR) ||
  410. (dsisr & MFC_DSISR_ACCESS_DENIED)) {
  411. if ((ret = spu_handle_mm_fault(spu)) != 0)
  412. error |= CLASS1_ENABLE_STORAGE_FAULT_INTR;
  413. else
  414. error &= ~CLASS1_ENABLE_STORAGE_FAULT_INTR;
  415. }
  416. spu->dar = 0UL;
  417. spu->dsisr = 0UL;
  418. if (!error) {
  419. spu_restart_dma(spu);
  420. } else {
  421. __spu_trap_invalid_dma(spu);
  422. }
  423. return ret;
  424. }
  425. void spu_irq_setaffinity(struct spu *spu, int cpu)
  426. {
  427. u64 target = iic_get_target_id(cpu);
  428. u64 route = target << 48 | target << 32 | target << 16;
  429. spu_int_route_set(spu, route);
  430. }
  431. EXPORT_SYMBOL_GPL(spu_irq_setaffinity);
  432. static void __iomem * __init map_spe_prop(struct device_node *n,
  433. const char *name)
  434. {
  435. struct address_prop {
  436. unsigned long address;
  437. unsigned int len;
  438. } __attribute__((packed)) *prop;
  439. void *p;
  440. int proplen;
  441. p = get_property(n, name, &proplen);
  442. if (proplen != sizeof (struct address_prop))
  443. return NULL;
  444. prop = p;
  445. return ioremap(prop->address, prop->len);
  446. }
  447. static void spu_unmap(struct spu *spu)
  448. {
  449. iounmap(spu->priv2);
  450. iounmap(spu->priv1);
  451. iounmap(spu->problem);
  452. iounmap((u8 __iomem *)spu->local_store);
  453. }
  454. static int __init spu_map_device(struct spu *spu, struct device_node *spe)
  455. {
  456. char *prop;
  457. int ret;
  458. ret = -ENODEV;
  459. prop = get_property(spe, "isrc", NULL);
  460. if (!prop)
  461. goto out;
  462. spu->isrc = *(unsigned int *)prop;
  463. spu->name = get_property(spe, "name", NULL);
  464. if (!spu->name)
  465. goto out;
  466. prop = get_property(spe, "local-store", NULL);
  467. if (!prop)
  468. goto out;
  469. spu->local_store_phys = *(unsigned long *)prop;
  470. /* we use local store as ram, not io memory */
  471. spu->local_store = (void __force *)map_spe_prop(spe, "local-store");
  472. if (!spu->local_store)
  473. goto out;
  474. spu->problem= map_spe_prop(spe, "problem");
  475. if (!spu->problem)
  476. goto out_unmap;
  477. spu->priv1= map_spe_prop(spe, "priv1");
  478. /* priv1 is not available on a hypervisor */
  479. spu->priv2= map_spe_prop(spe, "priv2");
  480. if (!spu->priv2)
  481. goto out_unmap;
  482. ret = 0;
  483. goto out;
  484. out_unmap:
  485. spu_unmap(spu);
  486. out:
  487. return ret;
  488. }
  489. static int __init find_spu_node_id(struct device_node *spe)
  490. {
  491. unsigned int *id;
  492. struct device_node *cpu;
  493. cpu = spe->parent->parent;
  494. id = (unsigned int *)get_property(cpu, "node-id", NULL);
  495. return id ? *id : 0;
  496. }
  497. static int __init create_spu(struct device_node *spe)
  498. {
  499. struct spu *spu;
  500. int ret;
  501. static int number;
  502. ret = -ENOMEM;
  503. spu = kmalloc(sizeof (*spu), GFP_KERNEL);
  504. if (!spu)
  505. goto out;
  506. ret = spu_map_device(spu, spe);
  507. if (ret)
  508. goto out_free;
  509. spu->node = find_spu_node_id(spe);
  510. spu->stop_code = 0;
  511. spu->slb_replace = 0;
  512. spu->mm = NULL;
  513. spu->ctx = NULL;
  514. spu->rq = NULL;
  515. spu->pid = 0;
  516. spu->class_0_pending = 0;
  517. spu->flags = 0UL;
  518. spu->dar = 0UL;
  519. spu->dsisr = 0UL;
  520. spin_lock_init(&spu->register_lock);
  521. spu_mfc_sdr_set(spu, mfspr(SPRN_SDR1));
  522. spu_mfc_sr1_set(spu, 0x33);
  523. spu->ibox_callback = NULL;
  524. spu->wbox_callback = NULL;
  525. spu->stop_callback = NULL;
  526. down(&spu_mutex);
  527. spu->number = number++;
  528. ret = spu_request_irqs(spu);
  529. if (ret)
  530. goto out_unmap;
  531. list_add(&spu->list, &spu_list);
  532. up(&spu_mutex);
  533. pr_debug(KERN_DEBUG "Using SPE %s %02x %p %p %p %p %d\n",
  534. spu->name, spu->isrc, spu->local_store,
  535. spu->problem, spu->priv1, spu->priv2, spu->number);
  536. goto out;
  537. out_unmap:
  538. up(&spu_mutex);
  539. spu_unmap(spu);
  540. out_free:
  541. kfree(spu);
  542. out:
  543. return ret;
  544. }
  545. static void destroy_spu(struct spu *spu)
  546. {
  547. list_del_init(&spu->list);
  548. spu_free_irqs(spu);
  549. spu_unmap(spu);
  550. kfree(spu);
  551. }
  552. static void cleanup_spu_base(void)
  553. {
  554. struct spu *spu, *tmp;
  555. down(&spu_mutex);
  556. list_for_each_entry_safe(spu, tmp, &spu_list, list)
  557. destroy_spu(spu);
  558. up(&spu_mutex);
  559. }
  560. module_exit(cleanup_spu_base);
  561. static int __init init_spu_base(void)
  562. {
  563. struct device_node *node;
  564. int ret;
  565. ret = -ENODEV;
  566. for (node = of_find_node_by_type(NULL, "spe");
  567. node; node = of_find_node_by_type(node, "spe")) {
  568. ret = create_spu(node);
  569. if (ret) {
  570. printk(KERN_WARNING "%s: Error initializing %s\n",
  571. __FUNCTION__, node->name);
  572. cleanup_spu_base();
  573. break;
  574. }
  575. }
  576. /* in some old firmware versions, the spe is called 'spc', so we
  577. look for that as well */
  578. for (node = of_find_node_by_type(NULL, "spc");
  579. node; node = of_find_node_by_type(node, "spc")) {
  580. ret = create_spu(node);
  581. if (ret) {
  582. printk(KERN_WARNING "%s: Error initializing %s\n",
  583. __FUNCTION__, node->name);
  584. cleanup_spu_base();
  585. break;
  586. }
  587. }
  588. return ret;
  589. }
  590. module_init(init_spu_base);
  591. MODULE_LICENSE("GPL");
  592. MODULE_AUTHOR("Arnd Bergmann <arndb@de.ibm.com>");