file.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372
  1. /*
  2. * SPU file system -- file contents
  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/fs.h>
  24. #include <linux/ioctl.h>
  25. #include <linux/module.h>
  26. #include <linux/pagemap.h>
  27. #include <linux/poll.h>
  28. #include <linux/ptrace.h>
  29. #include <asm/io.h>
  30. #include <asm/semaphore.h>
  31. #include <asm/spu.h>
  32. #include <asm/uaccess.h>
  33. #include "spufs.h"
  34. static int
  35. spufs_mem_open(struct inode *inode, struct file *file)
  36. {
  37. struct spufs_inode_info *i = SPUFS_I(inode);
  38. struct spu_context *ctx = i->i_ctx;
  39. file->private_data = ctx;
  40. file->f_mapping = inode->i_mapping;
  41. ctx->local_store = inode->i_mapping;
  42. return 0;
  43. }
  44. static ssize_t
  45. spufs_mem_read(struct file *file, char __user *buffer,
  46. size_t size, loff_t *pos)
  47. {
  48. struct spu_context *ctx = file->private_data;
  49. char *local_store;
  50. int ret;
  51. spu_acquire(ctx);
  52. local_store = ctx->ops->get_ls(ctx);
  53. ret = simple_read_from_buffer(buffer, size, pos, local_store, LS_SIZE);
  54. spu_release(ctx);
  55. return ret;
  56. }
  57. static ssize_t
  58. spufs_mem_write(struct file *file, const char __user *buffer,
  59. size_t size, loff_t *pos)
  60. {
  61. struct spu_context *ctx = file->private_data;
  62. char *local_store;
  63. int ret;
  64. size = min_t(ssize_t, LS_SIZE - *pos, size);
  65. if (size <= 0)
  66. return -EFBIG;
  67. *pos += size;
  68. spu_acquire(ctx);
  69. local_store = ctx->ops->get_ls(ctx);
  70. ret = copy_from_user(local_store + *pos - size,
  71. buffer, size) ? -EFAULT : size;
  72. spu_release(ctx);
  73. return ret;
  74. }
  75. #ifdef CONFIG_SPUFS_MMAP
  76. static struct page *
  77. spufs_mem_mmap_nopage(struct vm_area_struct *vma,
  78. unsigned long address, int *type)
  79. {
  80. struct page *page = NOPAGE_SIGBUS;
  81. struct spu_context *ctx = vma->vm_file->private_data;
  82. unsigned long offset = address - vma->vm_start;
  83. offset += vma->vm_pgoff << PAGE_SHIFT;
  84. spu_acquire(ctx);
  85. if (ctx->state == SPU_STATE_SAVED)
  86. page = vmalloc_to_page(ctx->csa.lscsa->ls + offset);
  87. else
  88. page = pfn_to_page((ctx->spu->local_store_phys + offset)
  89. >> PAGE_SHIFT);
  90. spu_release(ctx);
  91. if (type)
  92. *type = VM_FAULT_MINOR;
  93. page_cache_get(page);
  94. return page;
  95. }
  96. static struct vm_operations_struct spufs_mem_mmap_vmops = {
  97. .nopage = spufs_mem_mmap_nopage,
  98. };
  99. static int
  100. spufs_mem_mmap(struct file *file, struct vm_area_struct *vma)
  101. {
  102. if (!(vma->vm_flags & VM_SHARED))
  103. return -EINVAL;
  104. /* FIXME: */
  105. vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
  106. | _PAGE_NO_CACHE);
  107. vma->vm_ops = &spufs_mem_mmap_vmops;
  108. return 0;
  109. }
  110. #endif
  111. static struct file_operations spufs_mem_fops = {
  112. .open = spufs_mem_open,
  113. .read = spufs_mem_read,
  114. .write = spufs_mem_write,
  115. .llseek = generic_file_llseek,
  116. #ifdef CONFIG_SPUFS_MMAP
  117. .mmap = spufs_mem_mmap,
  118. #endif
  119. };
  120. #ifdef CONFIG_SPUFS_MMAP
  121. static struct page *spufs_ps_nopage(struct vm_area_struct *vma,
  122. unsigned long address,
  123. int *type, unsigned long ps_offs)
  124. {
  125. struct page *page = NOPAGE_SIGBUS;
  126. int fault_type = VM_FAULT_SIGBUS;
  127. struct spu_context *ctx = vma->vm_file->private_data;
  128. unsigned long offset = address - vma->vm_start;
  129. unsigned long area;
  130. int ret;
  131. offset += vma->vm_pgoff << PAGE_SHIFT;
  132. if (offset >= 0x4000)
  133. goto out;
  134. ret = spu_acquire_runnable(ctx);
  135. if (ret)
  136. goto out;
  137. area = ctx->spu->problem_phys + ps_offs;
  138. page = pfn_to_page((area + offset) >> PAGE_SHIFT);
  139. fault_type = VM_FAULT_MINOR;
  140. page_cache_get(page);
  141. spu_release(ctx);
  142. out:
  143. if (type)
  144. *type = fault_type;
  145. return page;
  146. }
  147. static struct page *spufs_cntl_mmap_nopage(struct vm_area_struct *vma,
  148. unsigned long address, int *type)
  149. {
  150. return spufs_ps_nopage(vma, address, type, 0x4000);
  151. }
  152. static struct vm_operations_struct spufs_cntl_mmap_vmops = {
  153. .nopage = spufs_cntl_mmap_nopage,
  154. };
  155. /*
  156. * mmap support for problem state control area [0x4000 - 0x4fff].
  157. * Mapping this area requires that the application have CAP_SYS_RAWIO,
  158. * as these registers require special care when read/writing.
  159. */
  160. static int spufs_cntl_mmap(struct file *file, struct vm_area_struct *vma)
  161. {
  162. if (!(vma->vm_flags & VM_SHARED))
  163. return -EINVAL;
  164. if (!capable(CAP_SYS_RAWIO))
  165. return -EPERM;
  166. vma->vm_flags |= VM_RESERVED;
  167. vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
  168. | _PAGE_NO_CACHE | _PAGE_GUARDED);
  169. vma->vm_ops = &spufs_cntl_mmap_vmops;
  170. return 0;
  171. }
  172. #endif
  173. static int spufs_cntl_open(struct inode *inode, struct file *file)
  174. {
  175. struct spufs_inode_info *i = SPUFS_I(inode);
  176. struct spu_context *ctx = i->i_ctx;
  177. file->private_data = ctx;
  178. file->f_mapping = inode->i_mapping;
  179. ctx->cntl = inode->i_mapping;
  180. return 0;
  181. }
  182. static ssize_t
  183. spufs_cntl_read(struct file *file, char __user *buffer,
  184. size_t size, loff_t *pos)
  185. {
  186. /* FIXME: read from spu status */
  187. return -EINVAL;
  188. }
  189. static ssize_t
  190. spufs_cntl_write(struct file *file, const char __user *buffer,
  191. size_t size, loff_t *pos)
  192. {
  193. /* FIXME: write to runctl bit */
  194. return -EINVAL;
  195. }
  196. static struct file_operations spufs_cntl_fops = {
  197. .open = spufs_cntl_open,
  198. .read = spufs_cntl_read,
  199. .write = spufs_cntl_write,
  200. #ifdef CONFIG_SPUFS_MMAP
  201. .mmap = spufs_cntl_mmap,
  202. #endif
  203. };
  204. static int
  205. spufs_regs_open(struct inode *inode, struct file *file)
  206. {
  207. struct spufs_inode_info *i = SPUFS_I(inode);
  208. file->private_data = i->i_ctx;
  209. return 0;
  210. }
  211. static ssize_t
  212. spufs_regs_read(struct file *file, char __user *buffer,
  213. size_t size, loff_t *pos)
  214. {
  215. struct spu_context *ctx = file->private_data;
  216. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  217. int ret;
  218. spu_acquire_saved(ctx);
  219. ret = simple_read_from_buffer(buffer, size, pos,
  220. lscsa->gprs, sizeof lscsa->gprs);
  221. spu_release(ctx);
  222. return ret;
  223. }
  224. static ssize_t
  225. spufs_regs_write(struct file *file, const char __user *buffer,
  226. size_t size, loff_t *pos)
  227. {
  228. struct spu_context *ctx = file->private_data;
  229. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  230. int ret;
  231. size = min_t(ssize_t, sizeof lscsa->gprs - *pos, size);
  232. if (size <= 0)
  233. return -EFBIG;
  234. *pos += size;
  235. spu_acquire_saved(ctx);
  236. ret = copy_from_user(lscsa->gprs + *pos - size,
  237. buffer, size) ? -EFAULT : size;
  238. spu_release(ctx);
  239. return ret;
  240. }
  241. static struct file_operations spufs_regs_fops = {
  242. .open = spufs_regs_open,
  243. .read = spufs_regs_read,
  244. .write = spufs_regs_write,
  245. .llseek = generic_file_llseek,
  246. };
  247. static ssize_t
  248. spufs_fpcr_read(struct file *file, char __user * buffer,
  249. size_t size, loff_t * pos)
  250. {
  251. struct spu_context *ctx = file->private_data;
  252. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  253. int ret;
  254. spu_acquire_saved(ctx);
  255. ret = simple_read_from_buffer(buffer, size, pos,
  256. &lscsa->fpcr, sizeof(lscsa->fpcr));
  257. spu_release(ctx);
  258. return ret;
  259. }
  260. static ssize_t
  261. spufs_fpcr_write(struct file *file, const char __user * buffer,
  262. size_t size, loff_t * pos)
  263. {
  264. struct spu_context *ctx = file->private_data;
  265. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  266. int ret;
  267. size = min_t(ssize_t, sizeof(lscsa->fpcr) - *pos, size);
  268. if (size <= 0)
  269. return -EFBIG;
  270. *pos += size;
  271. spu_acquire_saved(ctx);
  272. ret = copy_from_user((char *)&lscsa->fpcr + *pos - size,
  273. buffer, size) ? -EFAULT : size;
  274. spu_release(ctx);
  275. return ret;
  276. }
  277. static struct file_operations spufs_fpcr_fops = {
  278. .open = spufs_regs_open,
  279. .read = spufs_fpcr_read,
  280. .write = spufs_fpcr_write,
  281. .llseek = generic_file_llseek,
  282. };
  283. /* generic open function for all pipe-like files */
  284. static int spufs_pipe_open(struct inode *inode, struct file *file)
  285. {
  286. struct spufs_inode_info *i = SPUFS_I(inode);
  287. file->private_data = i->i_ctx;
  288. return nonseekable_open(inode, file);
  289. }
  290. static ssize_t spufs_mbox_read(struct file *file, char __user *buf,
  291. size_t len, loff_t *pos)
  292. {
  293. struct spu_context *ctx = file->private_data;
  294. u32 mbox_data;
  295. int ret;
  296. if (len < 4)
  297. return -EINVAL;
  298. spu_acquire(ctx);
  299. ret = ctx->ops->mbox_read(ctx, &mbox_data);
  300. spu_release(ctx);
  301. if (!ret)
  302. return -EAGAIN;
  303. if (copy_to_user(buf, &mbox_data, sizeof mbox_data))
  304. return -EFAULT;
  305. return 4;
  306. }
  307. static struct file_operations spufs_mbox_fops = {
  308. .open = spufs_pipe_open,
  309. .read = spufs_mbox_read,
  310. };
  311. static ssize_t spufs_mbox_stat_read(struct file *file, char __user *buf,
  312. size_t len, loff_t *pos)
  313. {
  314. struct spu_context *ctx = file->private_data;
  315. u32 mbox_stat;
  316. if (len < 4)
  317. return -EINVAL;
  318. spu_acquire(ctx);
  319. mbox_stat = ctx->ops->mbox_stat_read(ctx) & 0xff;
  320. spu_release(ctx);
  321. if (copy_to_user(buf, &mbox_stat, sizeof mbox_stat))
  322. return -EFAULT;
  323. return 4;
  324. }
  325. static struct file_operations spufs_mbox_stat_fops = {
  326. .open = spufs_pipe_open,
  327. .read = spufs_mbox_stat_read,
  328. };
  329. /* low-level ibox access function */
  330. size_t spu_ibox_read(struct spu_context *ctx, u32 *data)
  331. {
  332. return ctx->ops->ibox_read(ctx, data);
  333. }
  334. static int spufs_ibox_fasync(int fd, struct file *file, int on)
  335. {
  336. struct spu_context *ctx = file->private_data;
  337. return fasync_helper(fd, file, on, &ctx->ibox_fasync);
  338. }
  339. /* interrupt-level ibox callback function. */
  340. void spufs_ibox_callback(struct spu *spu)
  341. {
  342. struct spu_context *ctx = spu->ctx;
  343. wake_up_all(&ctx->ibox_wq);
  344. kill_fasync(&ctx->ibox_fasync, SIGIO, POLLIN);
  345. }
  346. static ssize_t spufs_ibox_read(struct file *file, char __user *buf,
  347. size_t len, loff_t *pos)
  348. {
  349. struct spu_context *ctx = file->private_data;
  350. u32 ibox_data;
  351. ssize_t ret;
  352. if (len < 4)
  353. return -EINVAL;
  354. spu_acquire(ctx);
  355. ret = 0;
  356. if (file->f_flags & O_NONBLOCK) {
  357. if (!spu_ibox_read(ctx, &ibox_data))
  358. ret = -EAGAIN;
  359. } else {
  360. ret = spufs_wait(ctx->ibox_wq, spu_ibox_read(ctx, &ibox_data));
  361. }
  362. spu_release(ctx);
  363. if (ret)
  364. return ret;
  365. ret = 4;
  366. if (copy_to_user(buf, &ibox_data, sizeof ibox_data))
  367. ret = -EFAULT;
  368. return ret;
  369. }
  370. static unsigned int spufs_ibox_poll(struct file *file, poll_table *wait)
  371. {
  372. struct spu_context *ctx = file->private_data;
  373. unsigned int mask;
  374. poll_wait(file, &ctx->ibox_wq, wait);
  375. spu_acquire(ctx);
  376. mask = ctx->ops->mbox_stat_poll(ctx, POLLIN | POLLRDNORM);
  377. spu_release(ctx);
  378. return mask;
  379. }
  380. static struct file_operations spufs_ibox_fops = {
  381. .open = spufs_pipe_open,
  382. .read = spufs_ibox_read,
  383. .poll = spufs_ibox_poll,
  384. .fasync = spufs_ibox_fasync,
  385. };
  386. static ssize_t spufs_ibox_stat_read(struct file *file, char __user *buf,
  387. size_t len, loff_t *pos)
  388. {
  389. struct spu_context *ctx = file->private_data;
  390. u32 ibox_stat;
  391. if (len < 4)
  392. return -EINVAL;
  393. spu_acquire(ctx);
  394. ibox_stat = (ctx->ops->mbox_stat_read(ctx) >> 16) & 0xff;
  395. spu_release(ctx);
  396. if (copy_to_user(buf, &ibox_stat, sizeof ibox_stat))
  397. return -EFAULT;
  398. return 4;
  399. }
  400. static struct file_operations spufs_ibox_stat_fops = {
  401. .open = spufs_pipe_open,
  402. .read = spufs_ibox_stat_read,
  403. };
  404. /* low-level mailbox write */
  405. size_t spu_wbox_write(struct spu_context *ctx, u32 data)
  406. {
  407. return ctx->ops->wbox_write(ctx, data);
  408. }
  409. static int spufs_wbox_fasync(int fd, struct file *file, int on)
  410. {
  411. struct spu_context *ctx = file->private_data;
  412. int ret;
  413. ret = fasync_helper(fd, file, on, &ctx->wbox_fasync);
  414. return ret;
  415. }
  416. /* interrupt-level wbox callback function. */
  417. void spufs_wbox_callback(struct spu *spu)
  418. {
  419. struct spu_context *ctx = spu->ctx;
  420. wake_up_all(&ctx->wbox_wq);
  421. kill_fasync(&ctx->wbox_fasync, SIGIO, POLLOUT);
  422. }
  423. static ssize_t spufs_wbox_write(struct file *file, const char __user *buf,
  424. size_t len, loff_t *pos)
  425. {
  426. struct spu_context *ctx = file->private_data;
  427. u32 wbox_data;
  428. int ret;
  429. if (len < 4)
  430. return -EINVAL;
  431. if (copy_from_user(&wbox_data, buf, sizeof wbox_data))
  432. return -EFAULT;
  433. spu_acquire(ctx);
  434. ret = 0;
  435. if (file->f_flags & O_NONBLOCK) {
  436. if (!spu_wbox_write(ctx, wbox_data))
  437. ret = -EAGAIN;
  438. } else {
  439. ret = spufs_wait(ctx->wbox_wq, spu_wbox_write(ctx, wbox_data));
  440. }
  441. spu_release(ctx);
  442. return ret ? ret : sizeof wbox_data;
  443. }
  444. static unsigned int spufs_wbox_poll(struct file *file, poll_table *wait)
  445. {
  446. struct spu_context *ctx = file->private_data;
  447. unsigned int mask;
  448. poll_wait(file, &ctx->wbox_wq, wait);
  449. spu_acquire(ctx);
  450. mask = ctx->ops->mbox_stat_poll(ctx, POLLOUT | POLLWRNORM);
  451. spu_release(ctx);
  452. return mask;
  453. }
  454. static struct file_operations spufs_wbox_fops = {
  455. .open = spufs_pipe_open,
  456. .write = spufs_wbox_write,
  457. .poll = spufs_wbox_poll,
  458. .fasync = spufs_wbox_fasync,
  459. };
  460. static ssize_t spufs_wbox_stat_read(struct file *file, char __user *buf,
  461. size_t len, loff_t *pos)
  462. {
  463. struct spu_context *ctx = file->private_data;
  464. u32 wbox_stat;
  465. if (len < 4)
  466. return -EINVAL;
  467. spu_acquire(ctx);
  468. wbox_stat = (ctx->ops->mbox_stat_read(ctx) >> 8) & 0xff;
  469. spu_release(ctx);
  470. if (copy_to_user(buf, &wbox_stat, sizeof wbox_stat))
  471. return -EFAULT;
  472. return 4;
  473. }
  474. static struct file_operations spufs_wbox_stat_fops = {
  475. .open = spufs_pipe_open,
  476. .read = spufs_wbox_stat_read,
  477. };
  478. static int spufs_signal1_open(struct inode *inode, struct file *file)
  479. {
  480. struct spufs_inode_info *i = SPUFS_I(inode);
  481. struct spu_context *ctx = i->i_ctx;
  482. file->private_data = ctx;
  483. file->f_mapping = inode->i_mapping;
  484. ctx->signal1 = inode->i_mapping;
  485. return nonseekable_open(inode, file);
  486. }
  487. static ssize_t spufs_signal1_read(struct file *file, char __user *buf,
  488. size_t len, loff_t *pos)
  489. {
  490. struct spu_context *ctx = file->private_data;
  491. u32 data;
  492. if (len < 4)
  493. return -EINVAL;
  494. spu_acquire(ctx);
  495. data = ctx->ops->signal1_read(ctx);
  496. spu_release(ctx);
  497. if (copy_to_user(buf, &data, 4))
  498. return -EFAULT;
  499. return 4;
  500. }
  501. static ssize_t spufs_signal1_write(struct file *file, const char __user *buf,
  502. size_t len, loff_t *pos)
  503. {
  504. struct spu_context *ctx;
  505. u32 data;
  506. ctx = file->private_data;
  507. if (len < 4)
  508. return -EINVAL;
  509. if (copy_from_user(&data, buf, 4))
  510. return -EFAULT;
  511. spu_acquire(ctx);
  512. ctx->ops->signal1_write(ctx, data);
  513. spu_release(ctx);
  514. return 4;
  515. }
  516. #ifdef CONFIG_SPUFS_MMAP
  517. static struct page *spufs_signal1_mmap_nopage(struct vm_area_struct *vma,
  518. unsigned long address, int *type)
  519. {
  520. return spufs_ps_nopage(vma, address, type, 0x14000);
  521. }
  522. static struct vm_operations_struct spufs_signal1_mmap_vmops = {
  523. .nopage = spufs_signal1_mmap_nopage,
  524. };
  525. static int spufs_signal1_mmap(struct file *file, struct vm_area_struct *vma)
  526. {
  527. if (!(vma->vm_flags & VM_SHARED))
  528. return -EINVAL;
  529. vma->vm_flags |= VM_RESERVED;
  530. vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
  531. | _PAGE_NO_CACHE | _PAGE_GUARDED);
  532. vma->vm_ops = &spufs_signal1_mmap_vmops;
  533. return 0;
  534. }
  535. #endif
  536. static struct file_operations spufs_signal1_fops = {
  537. .open = spufs_signal1_open,
  538. .read = spufs_signal1_read,
  539. .write = spufs_signal1_write,
  540. #ifdef CONFIG_SPUFS_MMAP
  541. .mmap = spufs_signal1_mmap,
  542. #endif
  543. };
  544. static int spufs_signal2_open(struct inode *inode, struct file *file)
  545. {
  546. struct spufs_inode_info *i = SPUFS_I(inode);
  547. struct spu_context *ctx = i->i_ctx;
  548. file->private_data = ctx;
  549. file->f_mapping = inode->i_mapping;
  550. ctx->signal2 = inode->i_mapping;
  551. return nonseekable_open(inode, file);
  552. }
  553. static ssize_t spufs_signal2_read(struct file *file, char __user *buf,
  554. size_t len, loff_t *pos)
  555. {
  556. struct spu_context *ctx;
  557. u32 data;
  558. ctx = file->private_data;
  559. if (len < 4)
  560. return -EINVAL;
  561. spu_acquire(ctx);
  562. data = ctx->ops->signal2_read(ctx);
  563. spu_release(ctx);
  564. if (copy_to_user(buf, &data, 4))
  565. return -EFAULT;
  566. return 4;
  567. }
  568. static ssize_t spufs_signal2_write(struct file *file, const char __user *buf,
  569. size_t len, loff_t *pos)
  570. {
  571. struct spu_context *ctx;
  572. u32 data;
  573. ctx = file->private_data;
  574. if (len < 4)
  575. return -EINVAL;
  576. if (copy_from_user(&data, buf, 4))
  577. return -EFAULT;
  578. spu_acquire(ctx);
  579. ctx->ops->signal2_write(ctx, data);
  580. spu_release(ctx);
  581. return 4;
  582. }
  583. #ifdef CONFIG_SPUFS_MMAP
  584. static struct page *spufs_signal2_mmap_nopage(struct vm_area_struct *vma,
  585. unsigned long address, int *type)
  586. {
  587. return spufs_ps_nopage(vma, address, type, 0x1c000);
  588. }
  589. static struct vm_operations_struct spufs_signal2_mmap_vmops = {
  590. .nopage = spufs_signal2_mmap_nopage,
  591. };
  592. static int spufs_signal2_mmap(struct file *file, struct vm_area_struct *vma)
  593. {
  594. if (!(vma->vm_flags & VM_SHARED))
  595. return -EINVAL;
  596. /* FIXME: */
  597. vma->vm_flags |= VM_RESERVED;
  598. vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
  599. | _PAGE_NO_CACHE | _PAGE_GUARDED);
  600. vma->vm_ops = &spufs_signal2_mmap_vmops;
  601. return 0;
  602. }
  603. #endif
  604. static struct file_operations spufs_signal2_fops = {
  605. .open = spufs_signal2_open,
  606. .read = spufs_signal2_read,
  607. .write = spufs_signal2_write,
  608. #ifdef CONFIG_SPUFS_MMAP
  609. .mmap = spufs_signal2_mmap,
  610. #endif
  611. };
  612. static void spufs_signal1_type_set(void *data, u64 val)
  613. {
  614. struct spu_context *ctx = data;
  615. spu_acquire(ctx);
  616. ctx->ops->signal1_type_set(ctx, val);
  617. spu_release(ctx);
  618. }
  619. static u64 spufs_signal1_type_get(void *data)
  620. {
  621. struct spu_context *ctx = data;
  622. u64 ret;
  623. spu_acquire(ctx);
  624. ret = ctx->ops->signal1_type_get(ctx);
  625. spu_release(ctx);
  626. return ret;
  627. }
  628. DEFINE_SIMPLE_ATTRIBUTE(spufs_signal1_type, spufs_signal1_type_get,
  629. spufs_signal1_type_set, "%llu");
  630. static void spufs_signal2_type_set(void *data, u64 val)
  631. {
  632. struct spu_context *ctx = data;
  633. spu_acquire(ctx);
  634. ctx->ops->signal2_type_set(ctx, val);
  635. spu_release(ctx);
  636. }
  637. static u64 spufs_signal2_type_get(void *data)
  638. {
  639. struct spu_context *ctx = data;
  640. u64 ret;
  641. spu_acquire(ctx);
  642. ret = ctx->ops->signal2_type_get(ctx);
  643. spu_release(ctx);
  644. return ret;
  645. }
  646. DEFINE_SIMPLE_ATTRIBUTE(spufs_signal2_type, spufs_signal2_type_get,
  647. spufs_signal2_type_set, "%llu");
  648. #ifdef CONFIG_SPUFS_MMAP
  649. static struct page *spufs_mss_mmap_nopage(struct vm_area_struct *vma,
  650. unsigned long address, int *type)
  651. {
  652. return spufs_ps_nopage(vma, address, type, 0x0000);
  653. }
  654. static struct vm_operations_struct spufs_mss_mmap_vmops = {
  655. .nopage = spufs_mss_mmap_nopage,
  656. };
  657. /*
  658. * mmap support for problem state MFC DMA area [0x0000 - 0x0fff].
  659. * Mapping this area requires that the application have CAP_SYS_RAWIO,
  660. * as these registers require special care when read/writing.
  661. */
  662. static int spufs_mss_mmap(struct file *file, struct vm_area_struct *vma)
  663. {
  664. if (!(vma->vm_flags & VM_SHARED))
  665. return -EINVAL;
  666. if (!capable(CAP_SYS_RAWIO))
  667. return -EPERM;
  668. vma->vm_flags |= VM_RESERVED;
  669. vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
  670. | _PAGE_NO_CACHE | _PAGE_GUARDED);
  671. vma->vm_ops = &spufs_mss_mmap_vmops;
  672. return 0;
  673. }
  674. #endif
  675. static int spufs_mss_open(struct inode *inode, struct file *file)
  676. {
  677. struct spufs_inode_info *i = SPUFS_I(inode);
  678. file->private_data = i->i_ctx;
  679. return nonseekable_open(inode, file);
  680. }
  681. static struct file_operations spufs_mss_fops = {
  682. .open = spufs_mss_open,
  683. #ifdef CONFIG_SPUFS_MMAP
  684. .mmap = spufs_mss_mmap,
  685. #endif
  686. };
  687. #ifdef CONFIG_SPUFS_MMAP
  688. static struct page *spufs_mfc_mmap_nopage(struct vm_area_struct *vma,
  689. unsigned long address, int *type)
  690. {
  691. return spufs_ps_nopage(vma, address, type, 0x3000);
  692. }
  693. static struct vm_operations_struct spufs_mfc_mmap_vmops = {
  694. .nopage = spufs_mfc_mmap_nopage,
  695. };
  696. /*
  697. * mmap support for problem state MFC DMA area [0x0000 - 0x0fff].
  698. * Mapping this area requires that the application have CAP_SYS_RAWIO,
  699. * as these registers require special care when read/writing.
  700. */
  701. static int spufs_mfc_mmap(struct file *file, struct vm_area_struct *vma)
  702. {
  703. if (!(vma->vm_flags & VM_SHARED))
  704. return -EINVAL;
  705. if (!capable(CAP_SYS_RAWIO))
  706. return -EPERM;
  707. vma->vm_flags |= VM_RESERVED;
  708. vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
  709. | _PAGE_NO_CACHE | _PAGE_GUARDED);
  710. vma->vm_ops = &spufs_mfc_mmap_vmops;
  711. return 0;
  712. }
  713. #endif
  714. static int spufs_mfc_open(struct inode *inode, struct file *file)
  715. {
  716. struct spufs_inode_info *i = SPUFS_I(inode);
  717. struct spu_context *ctx = i->i_ctx;
  718. /* we don't want to deal with DMA into other processes */
  719. if (ctx->owner != current->mm)
  720. return -EINVAL;
  721. if (atomic_read(&inode->i_count) != 1)
  722. return -EBUSY;
  723. file->private_data = ctx;
  724. return nonseekable_open(inode, file);
  725. }
  726. /* interrupt-level mfc callback function. */
  727. void spufs_mfc_callback(struct spu *spu)
  728. {
  729. struct spu_context *ctx = spu->ctx;
  730. wake_up_all(&ctx->mfc_wq);
  731. pr_debug("%s %s\n", __FUNCTION__, spu->name);
  732. if (ctx->mfc_fasync) {
  733. u32 free_elements, tagstatus;
  734. unsigned int mask;
  735. /* no need for spu_acquire in interrupt context */
  736. free_elements = ctx->ops->get_mfc_free_elements(ctx);
  737. tagstatus = ctx->ops->read_mfc_tagstatus(ctx);
  738. mask = 0;
  739. if (free_elements & 0xffff)
  740. mask |= POLLOUT;
  741. if (tagstatus & ctx->tagwait)
  742. mask |= POLLIN;
  743. kill_fasync(&ctx->mfc_fasync, SIGIO, mask);
  744. }
  745. }
  746. static int spufs_read_mfc_tagstatus(struct spu_context *ctx, u32 *status)
  747. {
  748. /* See if there is one tag group is complete */
  749. /* FIXME we need locking around tagwait */
  750. *status = ctx->ops->read_mfc_tagstatus(ctx) & ctx->tagwait;
  751. ctx->tagwait &= ~*status;
  752. if (*status)
  753. return 1;
  754. /* enable interrupt waiting for any tag group,
  755. may silently fail if interrupts are already enabled */
  756. ctx->ops->set_mfc_query(ctx, ctx->tagwait, 1);
  757. return 0;
  758. }
  759. static ssize_t spufs_mfc_read(struct file *file, char __user *buffer,
  760. size_t size, loff_t *pos)
  761. {
  762. struct spu_context *ctx = file->private_data;
  763. int ret = -EINVAL;
  764. u32 status;
  765. if (size != 4)
  766. goto out;
  767. spu_acquire(ctx);
  768. if (file->f_flags & O_NONBLOCK) {
  769. status = ctx->ops->read_mfc_tagstatus(ctx);
  770. if (!(status & ctx->tagwait))
  771. ret = -EAGAIN;
  772. else
  773. ctx->tagwait &= ~status;
  774. } else {
  775. ret = spufs_wait(ctx->mfc_wq,
  776. spufs_read_mfc_tagstatus(ctx, &status));
  777. }
  778. spu_release(ctx);
  779. if (ret)
  780. goto out;
  781. ret = 4;
  782. if (copy_to_user(buffer, &status, 4))
  783. ret = -EFAULT;
  784. out:
  785. return ret;
  786. }
  787. static int spufs_check_valid_dma(struct mfc_dma_command *cmd)
  788. {
  789. pr_debug("queueing DMA %x %lx %x %x %x\n", cmd->lsa,
  790. cmd->ea, cmd->size, cmd->tag, cmd->cmd);
  791. switch (cmd->cmd) {
  792. case MFC_PUT_CMD:
  793. case MFC_PUTF_CMD:
  794. case MFC_PUTB_CMD:
  795. case MFC_GET_CMD:
  796. case MFC_GETF_CMD:
  797. case MFC_GETB_CMD:
  798. break;
  799. default:
  800. pr_debug("invalid DMA opcode %x\n", cmd->cmd);
  801. return -EIO;
  802. }
  803. if ((cmd->lsa & 0xf) != (cmd->ea &0xf)) {
  804. pr_debug("invalid DMA alignment, ea %lx lsa %x\n",
  805. cmd->ea, cmd->lsa);
  806. return -EIO;
  807. }
  808. switch (cmd->size & 0xf) {
  809. case 1:
  810. break;
  811. case 2:
  812. if (cmd->lsa & 1)
  813. goto error;
  814. break;
  815. case 4:
  816. if (cmd->lsa & 3)
  817. goto error;
  818. break;
  819. case 8:
  820. if (cmd->lsa & 7)
  821. goto error;
  822. break;
  823. case 0:
  824. if (cmd->lsa & 15)
  825. goto error;
  826. break;
  827. error:
  828. default:
  829. pr_debug("invalid DMA alignment %x for size %x\n",
  830. cmd->lsa & 0xf, cmd->size);
  831. return -EIO;
  832. }
  833. if (cmd->size > 16 * 1024) {
  834. pr_debug("invalid DMA size %x\n", cmd->size);
  835. return -EIO;
  836. }
  837. if (cmd->tag & 0xfff0) {
  838. /* we reserve the higher tag numbers for kernel use */
  839. pr_debug("invalid DMA tag\n");
  840. return -EIO;
  841. }
  842. if (cmd->class) {
  843. /* not supported in this version */
  844. pr_debug("invalid DMA class\n");
  845. return -EIO;
  846. }
  847. return 0;
  848. }
  849. static int spu_send_mfc_command(struct spu_context *ctx,
  850. struct mfc_dma_command cmd,
  851. int *error)
  852. {
  853. *error = ctx->ops->send_mfc_command(ctx, &cmd);
  854. if (*error == -EAGAIN) {
  855. /* wait for any tag group to complete
  856. so we have space for the new command */
  857. ctx->ops->set_mfc_query(ctx, ctx->tagwait, 1);
  858. /* try again, because the queue might be
  859. empty again */
  860. *error = ctx->ops->send_mfc_command(ctx, &cmd);
  861. if (*error == -EAGAIN)
  862. return 0;
  863. }
  864. return 1;
  865. }
  866. static ssize_t spufs_mfc_write(struct file *file, const char __user *buffer,
  867. size_t size, loff_t *pos)
  868. {
  869. struct spu_context *ctx = file->private_data;
  870. struct mfc_dma_command cmd;
  871. int ret = -EINVAL;
  872. if (size != sizeof cmd)
  873. goto out;
  874. ret = -EFAULT;
  875. if (copy_from_user(&cmd, buffer, sizeof cmd))
  876. goto out;
  877. ret = spufs_check_valid_dma(&cmd);
  878. if (ret)
  879. goto out;
  880. spu_acquire_runnable(ctx);
  881. if (file->f_flags & O_NONBLOCK) {
  882. ret = ctx->ops->send_mfc_command(ctx, &cmd);
  883. } else {
  884. int status;
  885. ret = spufs_wait(ctx->mfc_wq,
  886. spu_send_mfc_command(ctx, cmd, &status));
  887. if (status)
  888. ret = status;
  889. }
  890. spu_release(ctx);
  891. if (ret)
  892. goto out;
  893. ctx->tagwait |= 1 << cmd.tag;
  894. out:
  895. return ret;
  896. }
  897. static unsigned int spufs_mfc_poll(struct file *file,poll_table *wait)
  898. {
  899. struct spu_context *ctx = file->private_data;
  900. u32 free_elements, tagstatus;
  901. unsigned int mask;
  902. spu_acquire(ctx);
  903. ctx->ops->set_mfc_query(ctx, ctx->tagwait, 2);
  904. free_elements = ctx->ops->get_mfc_free_elements(ctx);
  905. tagstatus = ctx->ops->read_mfc_tagstatus(ctx);
  906. spu_release(ctx);
  907. poll_wait(file, &ctx->mfc_wq, wait);
  908. mask = 0;
  909. if (free_elements & 0xffff)
  910. mask |= POLLOUT | POLLWRNORM;
  911. if (tagstatus & ctx->tagwait)
  912. mask |= POLLIN | POLLRDNORM;
  913. pr_debug("%s: free %d tagstatus %d tagwait %d\n", __FUNCTION__,
  914. free_elements, tagstatus, ctx->tagwait);
  915. return mask;
  916. }
  917. static int spufs_mfc_flush(struct file *file, fl_owner_t id)
  918. {
  919. struct spu_context *ctx = file->private_data;
  920. int ret;
  921. spu_acquire(ctx);
  922. #if 0
  923. /* this currently hangs */
  924. ret = spufs_wait(ctx->mfc_wq,
  925. ctx->ops->set_mfc_query(ctx, ctx->tagwait, 2));
  926. if (ret)
  927. goto out;
  928. ret = spufs_wait(ctx->mfc_wq,
  929. ctx->ops->read_mfc_tagstatus(ctx) == ctx->tagwait);
  930. out:
  931. #else
  932. ret = 0;
  933. #endif
  934. spu_release(ctx);
  935. return ret;
  936. }
  937. static int spufs_mfc_fsync(struct file *file, struct dentry *dentry,
  938. int datasync)
  939. {
  940. return spufs_mfc_flush(file, NULL);
  941. }
  942. static int spufs_mfc_fasync(int fd, struct file *file, int on)
  943. {
  944. struct spu_context *ctx = file->private_data;
  945. return fasync_helper(fd, file, on, &ctx->mfc_fasync);
  946. }
  947. static struct file_operations spufs_mfc_fops = {
  948. .open = spufs_mfc_open,
  949. .read = spufs_mfc_read,
  950. .write = spufs_mfc_write,
  951. .poll = spufs_mfc_poll,
  952. .flush = spufs_mfc_flush,
  953. .fsync = spufs_mfc_fsync,
  954. .fasync = spufs_mfc_fasync,
  955. #ifdef CONFIG_SPUFS_MMAP
  956. .mmap = spufs_mfc_mmap,
  957. #endif
  958. };
  959. static void spufs_npc_set(void *data, u64 val)
  960. {
  961. struct spu_context *ctx = data;
  962. spu_acquire(ctx);
  963. ctx->ops->npc_write(ctx, val);
  964. spu_release(ctx);
  965. }
  966. static u64 spufs_npc_get(void *data)
  967. {
  968. struct spu_context *ctx = data;
  969. u64 ret;
  970. spu_acquire(ctx);
  971. ret = ctx->ops->npc_read(ctx);
  972. spu_release(ctx);
  973. return ret;
  974. }
  975. DEFINE_SIMPLE_ATTRIBUTE(spufs_npc_ops, spufs_npc_get, spufs_npc_set, "%llx\n")
  976. static void spufs_decr_set(void *data, u64 val)
  977. {
  978. struct spu_context *ctx = data;
  979. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  980. spu_acquire_saved(ctx);
  981. lscsa->decr.slot[0] = (u32) val;
  982. spu_release(ctx);
  983. }
  984. static u64 spufs_decr_get(void *data)
  985. {
  986. struct spu_context *ctx = data;
  987. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  988. u64 ret;
  989. spu_acquire_saved(ctx);
  990. ret = lscsa->decr.slot[0];
  991. spu_release(ctx);
  992. return ret;
  993. }
  994. DEFINE_SIMPLE_ATTRIBUTE(spufs_decr_ops, spufs_decr_get, spufs_decr_set,
  995. "%llx\n")
  996. static void spufs_decr_status_set(void *data, u64 val)
  997. {
  998. struct spu_context *ctx = data;
  999. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  1000. spu_acquire_saved(ctx);
  1001. lscsa->decr_status.slot[0] = (u32) val;
  1002. spu_release(ctx);
  1003. }
  1004. static u64 spufs_decr_status_get(void *data)
  1005. {
  1006. struct spu_context *ctx = data;
  1007. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  1008. u64 ret;
  1009. spu_acquire_saved(ctx);
  1010. ret = lscsa->decr_status.slot[0];
  1011. spu_release(ctx);
  1012. return ret;
  1013. }
  1014. DEFINE_SIMPLE_ATTRIBUTE(spufs_decr_status_ops, spufs_decr_status_get,
  1015. spufs_decr_status_set, "%llx\n")
  1016. static void spufs_spu_tag_mask_set(void *data, u64 val)
  1017. {
  1018. struct spu_context *ctx = data;
  1019. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  1020. spu_acquire_saved(ctx);
  1021. lscsa->tag_mask.slot[0] = (u32) val;
  1022. spu_release(ctx);
  1023. }
  1024. static u64 spufs_spu_tag_mask_get(void *data)
  1025. {
  1026. struct spu_context *ctx = data;
  1027. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  1028. u64 ret;
  1029. spu_acquire_saved(ctx);
  1030. ret = lscsa->tag_mask.slot[0];
  1031. spu_release(ctx);
  1032. return ret;
  1033. }
  1034. DEFINE_SIMPLE_ATTRIBUTE(spufs_spu_tag_mask_ops, spufs_spu_tag_mask_get,
  1035. spufs_spu_tag_mask_set, "%llx\n")
  1036. static void spufs_event_mask_set(void *data, u64 val)
  1037. {
  1038. struct spu_context *ctx = data;
  1039. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  1040. spu_acquire_saved(ctx);
  1041. lscsa->event_mask.slot[0] = (u32) val;
  1042. spu_release(ctx);
  1043. }
  1044. static u64 spufs_event_mask_get(void *data)
  1045. {
  1046. struct spu_context *ctx = data;
  1047. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  1048. u64 ret;
  1049. spu_acquire_saved(ctx);
  1050. ret = lscsa->event_mask.slot[0];
  1051. spu_release(ctx);
  1052. return ret;
  1053. }
  1054. DEFINE_SIMPLE_ATTRIBUTE(spufs_event_mask_ops, spufs_event_mask_get,
  1055. spufs_event_mask_set, "%llx\n")
  1056. static void spufs_srr0_set(void *data, u64 val)
  1057. {
  1058. struct spu_context *ctx = data;
  1059. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  1060. spu_acquire_saved(ctx);
  1061. lscsa->srr0.slot[0] = (u32) val;
  1062. spu_release(ctx);
  1063. }
  1064. static u64 spufs_srr0_get(void *data)
  1065. {
  1066. struct spu_context *ctx = data;
  1067. struct spu_lscsa *lscsa = ctx->csa.lscsa;
  1068. u64 ret;
  1069. spu_acquire_saved(ctx);
  1070. ret = lscsa->srr0.slot[0];
  1071. spu_release(ctx);
  1072. return ret;
  1073. }
  1074. DEFINE_SIMPLE_ATTRIBUTE(spufs_srr0_ops, spufs_srr0_get, spufs_srr0_set,
  1075. "%llx\n")
  1076. static u64 spufs_id_get(void *data)
  1077. {
  1078. struct spu_context *ctx = data;
  1079. u64 num;
  1080. spu_acquire(ctx);
  1081. if (ctx->state == SPU_STATE_RUNNABLE)
  1082. num = ctx->spu->number;
  1083. else
  1084. num = (unsigned int)-1;
  1085. spu_release(ctx);
  1086. return num;
  1087. }
  1088. DEFINE_SIMPLE_ATTRIBUTE(spufs_id_ops, spufs_id_get, 0, "0x%llx\n")
  1089. struct tree_descr spufs_dir_contents[] = {
  1090. { "mem", &spufs_mem_fops, 0666, },
  1091. { "regs", &spufs_regs_fops, 0666, },
  1092. { "mbox", &spufs_mbox_fops, 0444, },
  1093. { "ibox", &spufs_ibox_fops, 0444, },
  1094. { "wbox", &spufs_wbox_fops, 0222, },
  1095. { "mbox_stat", &spufs_mbox_stat_fops, 0444, },
  1096. { "ibox_stat", &spufs_ibox_stat_fops, 0444, },
  1097. { "wbox_stat", &spufs_wbox_stat_fops, 0444, },
  1098. { "signal1", &spufs_signal1_fops, 0666, },
  1099. { "signal2", &spufs_signal2_fops, 0666, },
  1100. { "signal1_type", &spufs_signal1_type, 0666, },
  1101. { "signal2_type", &spufs_signal2_type, 0666, },
  1102. { "mss", &spufs_mss_fops, 0666, },
  1103. { "mfc", &spufs_mfc_fops, 0666, },
  1104. { "cntl", &spufs_cntl_fops, 0666, },
  1105. { "npc", &spufs_npc_ops, 0666, },
  1106. { "fpcr", &spufs_fpcr_fops, 0666, },
  1107. { "decr", &spufs_decr_ops, 0666, },
  1108. { "decr_status", &spufs_decr_status_ops, 0666, },
  1109. { "spu_tag_mask", &spufs_spu_tag_mask_ops, 0666, },
  1110. { "event_mask", &spufs_event_mask_ops, 0666, },
  1111. { "srr0", &spufs_srr0_ops, 0666, },
  1112. { "phys-id", &spufs_id_ops, 0666, },
  1113. {},
  1114. };