2 * SPU file system -- file contents
4 * (C) Copyright IBM Deutschland Entwicklung GmbH 2005
6 * Author: Arnd Bergmann <arndb@de.ibm.com>
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)
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.
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.
26 #include <linux/ioctl.h>
27 #include <linux/module.h>
28 #include <linux/pagemap.h>
29 #include <linux/poll.h>
30 #include <linux/ptrace.h>
31 #include <linux/seq_file.h>
32 #include <linux/marker.h>
37 #include <asm/spu_info.h>
38 #include <asm/uaccess.h>
42 #define SPUFS_MMAP_4K (PAGE_SIZE == 0x1000)
44 /* Simple attribute files */
46 int (*get)(void *, u64 *);
47 int (*set)(void *, u64);
48 char get_buf[24]; /* enough to store a u64 and "\n\0" */
51 const char *fmt; /* format for read operation */
52 struct mutex mutex; /* protects access to these buffers */
55 static int spufs_attr_open(struct inode *inode, struct file *file,
56 int (*get)(void *, u64 *), int (*set)(void *, u64),
59 struct spufs_attr *attr;
61 attr = kmalloc(sizeof(*attr), GFP_KERNEL);
67 attr->data = inode->i_private;
69 mutex_init(&attr->mutex);
70 file->private_data = attr;
72 return nonseekable_open(inode, file);
75 static int spufs_attr_release(struct inode *inode, struct file *file)
77 kfree(file->private_data);
81 static ssize_t spufs_attr_read(struct file *file, char __user *buf,
82 size_t len, loff_t *ppos)
84 struct spufs_attr *attr;
88 attr = file->private_data;
92 ret = mutex_lock_interruptible(&attr->mutex);
96 if (*ppos) { /* continued read */
97 size = strlen(attr->get_buf);
98 } else { /* first read */
100 ret = attr->get(attr->data, &val);
104 size = scnprintf(attr->get_buf, sizeof(attr->get_buf),
105 attr->fmt, (unsigned long long)val);
108 ret = simple_read_from_buffer(buf, len, ppos, attr->get_buf, size);
110 mutex_unlock(&attr->mutex);
114 static ssize_t spufs_attr_write(struct file *file, const char __user *buf,
115 size_t len, loff_t *ppos)
117 struct spufs_attr *attr;
122 attr = file->private_data;
126 ret = mutex_lock_interruptible(&attr->mutex);
131 size = min(sizeof(attr->set_buf) - 1, len);
132 if (copy_from_user(attr->set_buf, buf, size))
135 ret = len; /* claim we got the whole input */
136 attr->set_buf[size] = '\0';
137 val = simple_strtol(attr->set_buf, NULL, 0);
138 attr->set(attr->data, val);
140 mutex_unlock(&attr->mutex);
144 #define DEFINE_SPUFS_SIMPLE_ATTRIBUTE(__fops, __get, __set, __fmt) \
145 static int __fops ## _open(struct inode *inode, struct file *file) \
147 __simple_attr_check_format(__fmt, 0ull); \
148 return spufs_attr_open(inode, file, __get, __set, __fmt); \
150 static struct file_operations __fops = { \
151 .owner = THIS_MODULE, \
152 .open = __fops ## _open, \
153 .release = spufs_attr_release, \
154 .read = spufs_attr_read, \
155 .write = spufs_attr_write, \
160 spufs_mem_open(struct inode *inode, struct file *file)
162 struct spufs_inode_info *i = SPUFS_I(inode);
163 struct spu_context *ctx = i->i_ctx;
165 mutex_lock(&ctx->mapping_lock);
166 file->private_data = ctx;
168 ctx->local_store = inode->i_mapping;
169 mutex_unlock(&ctx->mapping_lock);
174 spufs_mem_release(struct inode *inode, struct file *file)
176 struct spufs_inode_info *i = SPUFS_I(inode);
177 struct spu_context *ctx = i->i_ctx;
179 mutex_lock(&ctx->mapping_lock);
181 ctx->local_store = NULL;
182 mutex_unlock(&ctx->mapping_lock);
187 __spufs_mem_read(struct spu_context *ctx, char __user *buffer,
188 size_t size, loff_t *pos)
190 char *local_store = ctx->ops->get_ls(ctx);
191 return simple_read_from_buffer(buffer, size, pos, local_store,
196 spufs_mem_read(struct file *file, char __user *buffer,
197 size_t size, loff_t *pos)
199 struct spu_context *ctx = file->private_data;
202 ret = spu_acquire(ctx);
205 ret = __spufs_mem_read(ctx, buffer, size, pos);
212 spufs_mem_write(struct file *file, const char __user *buffer,
213 size_t size, loff_t *ppos)
215 struct spu_context *ctx = file->private_data;
224 if (size > LS_SIZE - pos)
225 size = LS_SIZE - pos;
227 ret = spu_acquire(ctx);
231 local_store = ctx->ops->get_ls(ctx);
232 ret = copy_from_user(local_store + pos, buffer, size);
242 spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
244 struct spu_context *ctx = vma->vm_file->private_data;
245 unsigned long address = (unsigned long)vmf->virtual_address;
246 unsigned long pfn, offset;
248 #ifdef CONFIG_SPU_FS_64K_LS
249 struct spu_state *csa = &ctx->csa;
252 /* Check what page size we are using */
253 psize = get_slice_psize(vma->vm_mm, address);
255 /* Some sanity checking */
256 BUG_ON(csa->use_big_pages != (psize == MMU_PAGE_64K));
258 /* Wow, 64K, cool, we need to align the address though */
259 if (csa->use_big_pages) {
260 BUG_ON(vma->vm_start & 0xffff);
261 address &= ~0xfffful;
263 #endif /* CONFIG_SPU_FS_64K_LS */
265 offset = vmf->pgoff << PAGE_SHIFT;
266 if (offset >= LS_SIZE)
267 return VM_FAULT_SIGBUS;
269 pr_debug("spufs_mem_mmap_fault address=0x%lx, offset=0x%lx\n",
272 if (spu_acquire(ctx))
273 return VM_FAULT_NOPAGE;
275 if (ctx->state == SPU_STATE_SAVED) {
276 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
278 pfn = vmalloc_to_pfn(ctx->csa.lscsa->ls + offset);
280 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
282 pfn = (ctx->spu->local_store_phys + offset) >> PAGE_SHIFT;
284 vm_insert_pfn(vma, address, pfn);
288 return VM_FAULT_NOPAGE;
292 static struct vm_operations_struct spufs_mem_mmap_vmops = {
293 .fault = spufs_mem_mmap_fault,
296 static int spufs_mem_mmap(struct file *file, struct vm_area_struct *vma)
298 #ifdef CONFIG_SPU_FS_64K_LS
299 struct spu_context *ctx = file->private_data;
300 struct spu_state *csa = &ctx->csa;
302 /* Sanity check VMA alignment */
303 if (csa->use_big_pages) {
304 pr_debug("spufs_mem_mmap 64K, start=0x%lx, end=0x%lx,"
305 " pgoff=0x%lx\n", vma->vm_start, vma->vm_end,
307 if (vma->vm_start & 0xffff)
309 if (vma->vm_pgoff & 0xf)
312 #endif /* CONFIG_SPU_FS_64K_LS */
314 if (!(vma->vm_flags & VM_SHARED))
317 vma->vm_flags |= VM_IO | VM_PFNMAP;
318 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
321 vma->vm_ops = &spufs_mem_mmap_vmops;
325 #ifdef CONFIG_SPU_FS_64K_LS
326 static unsigned long spufs_get_unmapped_area(struct file *file,
327 unsigned long addr, unsigned long len, unsigned long pgoff,
330 struct spu_context *ctx = file->private_data;
331 struct spu_state *csa = &ctx->csa;
333 /* If not using big pages, fallback to normal MM g_u_a */
334 if (!csa->use_big_pages)
335 return current->mm->get_unmapped_area(file, addr, len,
338 /* Else, try to obtain a 64K pages slice */
339 return slice_get_unmapped_area(addr, len, flags,
342 #endif /* CONFIG_SPU_FS_64K_LS */
344 static const struct file_operations spufs_mem_fops = {
345 .open = spufs_mem_open,
346 .release = spufs_mem_release,
347 .read = spufs_mem_read,
348 .write = spufs_mem_write,
349 .llseek = generic_file_llseek,
350 .mmap = spufs_mem_mmap,
351 #ifdef CONFIG_SPU_FS_64K_LS
352 .get_unmapped_area = spufs_get_unmapped_area,
356 static int spufs_ps_fault(struct vm_area_struct *vma,
357 struct vm_fault *vmf,
358 unsigned long ps_offs,
359 unsigned long ps_size)
361 struct spu_context *ctx = vma->vm_file->private_data;
362 unsigned long area, offset = vmf->pgoff << PAGE_SHIFT;
365 spu_context_nospu_trace(spufs_ps_fault__enter, ctx);
367 if (offset >= ps_size)
368 return VM_FAULT_SIGBUS;
371 * Because we release the mmap_sem, the context may be destroyed while
372 * we're in spu_wait. Grab an extra reference so it isn't destroyed
375 get_spu_context(ctx);
378 * We have to wait for context to be loaded before we have
379 * pages to hand out to the user, but we don't want to wait
380 * with the mmap_sem held.
381 * It is possible to drop the mmap_sem here, but then we need
382 * to return VM_FAULT_NOPAGE because the mappings may have
385 if (spu_acquire(ctx))
388 if (ctx->state == SPU_STATE_SAVED) {
389 up_read(¤t->mm->mmap_sem);
390 spu_context_nospu_trace(spufs_ps_fault__sleep, ctx);
391 ret = spufs_wait(ctx->run_wq, ctx->state == SPU_STATE_RUNNABLE);
392 spu_context_trace(spufs_ps_fault__wake, ctx, ctx->spu);
393 down_read(¤t->mm->mmap_sem);
395 area = ctx->spu->problem_phys + ps_offs;
396 vm_insert_pfn(vma, (unsigned long)vmf->virtual_address,
397 (area + offset) >> PAGE_SHIFT);
398 spu_context_trace(spufs_ps_fault__insert, ctx, ctx->spu);
405 put_spu_context(ctx);
406 return VM_FAULT_NOPAGE;
410 static int spufs_cntl_mmap_fault(struct vm_area_struct *vma,
411 struct vm_fault *vmf)
413 return spufs_ps_fault(vma, vmf, 0x4000, SPUFS_CNTL_MAP_SIZE);
416 static struct vm_operations_struct spufs_cntl_mmap_vmops = {
417 .fault = spufs_cntl_mmap_fault,
421 * mmap support for problem state control area [0x4000 - 0x4fff].
423 static int spufs_cntl_mmap(struct file *file, struct vm_area_struct *vma)
425 if (!(vma->vm_flags & VM_SHARED))
428 vma->vm_flags |= VM_IO | VM_PFNMAP;
429 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
430 | _PAGE_NO_CACHE | _PAGE_GUARDED);
432 vma->vm_ops = &spufs_cntl_mmap_vmops;
435 #else /* SPUFS_MMAP_4K */
436 #define spufs_cntl_mmap NULL
437 #endif /* !SPUFS_MMAP_4K */
439 static int spufs_cntl_get(void *data, u64 *val)
441 struct spu_context *ctx = data;
444 ret = spu_acquire(ctx);
447 *val = ctx->ops->status_read(ctx);
453 static int spufs_cntl_set(void *data, u64 val)
455 struct spu_context *ctx = data;
458 ret = spu_acquire(ctx);
461 ctx->ops->runcntl_write(ctx, val);
467 static int spufs_cntl_open(struct inode *inode, struct file *file)
469 struct spufs_inode_info *i = SPUFS_I(inode);
470 struct spu_context *ctx = i->i_ctx;
472 mutex_lock(&ctx->mapping_lock);
473 file->private_data = ctx;
475 ctx->cntl = inode->i_mapping;
476 mutex_unlock(&ctx->mapping_lock);
477 return simple_attr_open(inode, file, spufs_cntl_get,
478 spufs_cntl_set, "0x%08lx");
482 spufs_cntl_release(struct inode *inode, struct file *file)
484 struct spufs_inode_info *i = SPUFS_I(inode);
485 struct spu_context *ctx = i->i_ctx;
487 simple_attr_release(inode, file);
489 mutex_lock(&ctx->mapping_lock);
492 mutex_unlock(&ctx->mapping_lock);
496 static const struct file_operations spufs_cntl_fops = {
497 .open = spufs_cntl_open,
498 .release = spufs_cntl_release,
499 .read = simple_attr_read,
500 .write = simple_attr_write,
501 .mmap = spufs_cntl_mmap,
505 spufs_regs_open(struct inode *inode, struct file *file)
507 struct spufs_inode_info *i = SPUFS_I(inode);
508 file->private_data = i->i_ctx;
513 __spufs_regs_read(struct spu_context *ctx, char __user *buffer,
514 size_t size, loff_t *pos)
516 struct spu_lscsa *lscsa = ctx->csa.lscsa;
517 return simple_read_from_buffer(buffer, size, pos,
518 lscsa->gprs, sizeof lscsa->gprs);
522 spufs_regs_read(struct file *file, char __user *buffer,
523 size_t size, loff_t *pos)
526 struct spu_context *ctx = file->private_data;
528 ret = spu_acquire_saved(ctx);
531 ret = __spufs_regs_read(ctx, buffer, size, pos);
532 spu_release_saved(ctx);
537 spufs_regs_write(struct file *file, const char __user *buffer,
538 size_t size, loff_t *pos)
540 struct spu_context *ctx = file->private_data;
541 struct spu_lscsa *lscsa = ctx->csa.lscsa;
544 size = min_t(ssize_t, sizeof lscsa->gprs - *pos, size);
549 ret = spu_acquire_saved(ctx);
553 ret = copy_from_user(lscsa->gprs + *pos - size,
554 buffer, size) ? -EFAULT : size;
556 spu_release_saved(ctx);
560 static const struct file_operations spufs_regs_fops = {
561 .open = spufs_regs_open,
562 .read = spufs_regs_read,
563 .write = spufs_regs_write,
564 .llseek = generic_file_llseek,
568 __spufs_fpcr_read(struct spu_context *ctx, char __user * buffer,
569 size_t size, loff_t * pos)
571 struct spu_lscsa *lscsa = ctx->csa.lscsa;
572 return simple_read_from_buffer(buffer, size, pos,
573 &lscsa->fpcr, sizeof(lscsa->fpcr));
577 spufs_fpcr_read(struct file *file, char __user * buffer,
578 size_t size, loff_t * pos)
581 struct spu_context *ctx = file->private_data;
583 ret = spu_acquire_saved(ctx);
586 ret = __spufs_fpcr_read(ctx, buffer, size, pos);
587 spu_release_saved(ctx);
592 spufs_fpcr_write(struct file *file, const char __user * buffer,
593 size_t size, loff_t * pos)
595 struct spu_context *ctx = file->private_data;
596 struct spu_lscsa *lscsa = ctx->csa.lscsa;
599 size = min_t(ssize_t, sizeof(lscsa->fpcr) - *pos, size);
603 ret = spu_acquire_saved(ctx);
608 ret = copy_from_user((char *)&lscsa->fpcr + *pos - size,
609 buffer, size) ? -EFAULT : size;
611 spu_release_saved(ctx);
615 static const struct file_operations spufs_fpcr_fops = {
616 .open = spufs_regs_open,
617 .read = spufs_fpcr_read,
618 .write = spufs_fpcr_write,
619 .llseek = generic_file_llseek,
622 /* generic open function for all pipe-like files */
623 static int spufs_pipe_open(struct inode *inode, struct file *file)
625 struct spufs_inode_info *i = SPUFS_I(inode);
626 file->private_data = i->i_ctx;
628 return nonseekable_open(inode, file);
632 * Read as many bytes from the mailbox as possible, until
633 * one of the conditions becomes true:
635 * - no more data available in the mailbox
636 * - end of the user provided buffer
637 * - end of the mapped area
639 static ssize_t spufs_mbox_read(struct file *file, char __user *buf,
640 size_t len, loff_t *pos)
642 struct spu_context *ctx = file->private_data;
643 u32 mbox_data, __user *udata;
649 if (!access_ok(VERIFY_WRITE, buf, len))
652 udata = (void __user *)buf;
654 count = spu_acquire(ctx);
658 for (count = 0; (count + 4) <= len; count += 4, udata++) {
660 ret = ctx->ops->mbox_read(ctx, &mbox_data);
665 * at the end of the mapped area, we can fault
666 * but still need to return the data we have
667 * read successfully so far.
669 ret = __put_user(mbox_data, udata);
684 static const struct file_operations spufs_mbox_fops = {
685 .open = spufs_pipe_open,
686 .read = spufs_mbox_read,
689 static ssize_t spufs_mbox_stat_read(struct file *file, char __user *buf,
690 size_t len, loff_t *pos)
692 struct spu_context *ctx = file->private_data;
699 ret = spu_acquire(ctx);
703 mbox_stat = ctx->ops->mbox_stat_read(ctx) & 0xff;
707 if (copy_to_user(buf, &mbox_stat, sizeof mbox_stat))
713 static const struct file_operations spufs_mbox_stat_fops = {
714 .open = spufs_pipe_open,
715 .read = spufs_mbox_stat_read,
718 /* low-level ibox access function */
719 size_t spu_ibox_read(struct spu_context *ctx, u32 *data)
721 return ctx->ops->ibox_read(ctx, data);
724 static int spufs_ibox_fasync(int fd, struct file *file, int on)
726 struct spu_context *ctx = file->private_data;
728 return fasync_helper(fd, file, on, &ctx->ibox_fasync);
731 /* interrupt-level ibox callback function. */
732 void spufs_ibox_callback(struct spu *spu)
734 struct spu_context *ctx = spu->ctx;
739 wake_up_all(&ctx->ibox_wq);
740 kill_fasync(&ctx->ibox_fasync, SIGIO, POLLIN);
744 * Read as many bytes from the interrupt mailbox as possible, until
745 * one of the conditions becomes true:
747 * - no more data available in the mailbox
748 * - end of the user provided buffer
749 * - end of the mapped area
751 * If the file is opened without O_NONBLOCK, we wait here until
752 * any data is available, but return when we have been able to
755 static ssize_t spufs_ibox_read(struct file *file, char __user *buf,
756 size_t len, loff_t *pos)
758 struct spu_context *ctx = file->private_data;
759 u32 ibox_data, __user *udata;
765 if (!access_ok(VERIFY_WRITE, buf, len))
768 udata = (void __user *)buf;
770 count = spu_acquire(ctx);
774 /* wait only for the first element */
776 if (file->f_flags & O_NONBLOCK) {
777 if (!spu_ibox_read(ctx, &ibox_data)) {
782 count = spufs_wait(ctx->ibox_wq, spu_ibox_read(ctx, &ibox_data));
787 /* if we can't write at all, return -EFAULT */
788 count = __put_user(ibox_data, udata);
792 for (count = 4, udata++; (count + 4) <= len; count += 4, udata++) {
794 ret = ctx->ops->ibox_read(ctx, &ibox_data);
798 * at the end of the mapped area, we can fault
799 * but still need to return the data we have
800 * read successfully so far.
802 ret = __put_user(ibox_data, udata);
813 static unsigned int spufs_ibox_poll(struct file *file, poll_table *wait)
815 struct spu_context *ctx = file->private_data;
818 poll_wait(file, &ctx->ibox_wq, wait);
821 * For now keep this uninterruptible and also ignore the rule
822 * that poll should not sleep. Will be fixed later.
824 mutex_lock(&ctx->state_mutex);
825 mask = ctx->ops->mbox_stat_poll(ctx, POLLIN | POLLRDNORM);
831 static const struct file_operations spufs_ibox_fops = {
832 .open = spufs_pipe_open,
833 .read = spufs_ibox_read,
834 .poll = spufs_ibox_poll,
835 .fasync = spufs_ibox_fasync,
838 static ssize_t spufs_ibox_stat_read(struct file *file, char __user *buf,
839 size_t len, loff_t *pos)
841 struct spu_context *ctx = file->private_data;
848 ret = spu_acquire(ctx);
851 ibox_stat = (ctx->ops->mbox_stat_read(ctx) >> 16) & 0xff;
854 if (copy_to_user(buf, &ibox_stat, sizeof ibox_stat))
860 static const struct file_operations spufs_ibox_stat_fops = {
861 .open = spufs_pipe_open,
862 .read = spufs_ibox_stat_read,
865 /* low-level mailbox write */
866 size_t spu_wbox_write(struct spu_context *ctx, u32 data)
868 return ctx->ops->wbox_write(ctx, data);
871 static int spufs_wbox_fasync(int fd, struct file *file, int on)
873 struct spu_context *ctx = file->private_data;
876 ret = fasync_helper(fd, file, on, &ctx->wbox_fasync);
881 /* interrupt-level wbox callback function. */
882 void spufs_wbox_callback(struct spu *spu)
884 struct spu_context *ctx = spu->ctx;
889 wake_up_all(&ctx->wbox_wq);
890 kill_fasync(&ctx->wbox_fasync, SIGIO, POLLOUT);
894 * Write as many bytes to the interrupt mailbox as possible, until
895 * one of the conditions becomes true:
897 * - the mailbox is full
898 * - end of the user provided buffer
899 * - end of the mapped area
901 * If the file is opened without O_NONBLOCK, we wait here until
902 * space is availabyl, but return when we have been able to
905 static ssize_t spufs_wbox_write(struct file *file, const char __user *buf,
906 size_t len, loff_t *pos)
908 struct spu_context *ctx = file->private_data;
909 u32 wbox_data, __user *udata;
915 udata = (void __user *)buf;
916 if (!access_ok(VERIFY_READ, buf, len))
919 if (__get_user(wbox_data, udata))
922 count = spu_acquire(ctx);
927 * make sure we can at least write one element, by waiting
928 * in case of !O_NONBLOCK
931 if (file->f_flags & O_NONBLOCK) {
932 if (!spu_wbox_write(ctx, wbox_data)) {
937 count = spufs_wait(ctx->wbox_wq, spu_wbox_write(ctx, wbox_data));
943 /* write as much as possible */
944 for (count = 4, udata++; (count + 4) <= len; count += 4, udata++) {
946 ret = __get_user(wbox_data, udata);
950 ret = spu_wbox_write(ctx, wbox_data);
961 static unsigned int spufs_wbox_poll(struct file *file, poll_table *wait)
963 struct spu_context *ctx = file->private_data;
966 poll_wait(file, &ctx->wbox_wq, wait);
969 * For now keep this uninterruptible and also ignore the rule
970 * that poll should not sleep. Will be fixed later.
972 mutex_lock(&ctx->state_mutex);
973 mask = ctx->ops->mbox_stat_poll(ctx, POLLOUT | POLLWRNORM);
979 static const struct file_operations spufs_wbox_fops = {
980 .open = spufs_pipe_open,
981 .write = spufs_wbox_write,
982 .poll = spufs_wbox_poll,
983 .fasync = spufs_wbox_fasync,
986 static ssize_t spufs_wbox_stat_read(struct file *file, char __user *buf,
987 size_t len, loff_t *pos)
989 struct spu_context *ctx = file->private_data;
996 ret = spu_acquire(ctx);
999 wbox_stat = (ctx->ops->mbox_stat_read(ctx) >> 8) & 0xff;
1002 if (copy_to_user(buf, &wbox_stat, sizeof wbox_stat))
1008 static const struct file_operations spufs_wbox_stat_fops = {
1009 .open = spufs_pipe_open,
1010 .read = spufs_wbox_stat_read,
1013 static int spufs_signal1_open(struct inode *inode, struct file *file)
1015 struct spufs_inode_info *i = SPUFS_I(inode);
1016 struct spu_context *ctx = i->i_ctx;
1018 mutex_lock(&ctx->mapping_lock);
1019 file->private_data = ctx;
1020 if (!i->i_openers++)
1021 ctx->signal1 = inode->i_mapping;
1022 mutex_unlock(&ctx->mapping_lock);
1023 return nonseekable_open(inode, file);
1027 spufs_signal1_release(struct inode *inode, struct file *file)
1029 struct spufs_inode_info *i = SPUFS_I(inode);
1030 struct spu_context *ctx = i->i_ctx;
1032 mutex_lock(&ctx->mapping_lock);
1033 if (!--i->i_openers)
1034 ctx->signal1 = NULL;
1035 mutex_unlock(&ctx->mapping_lock);
1039 static ssize_t __spufs_signal1_read(struct spu_context *ctx, char __user *buf,
1040 size_t len, loff_t *pos)
1048 if (ctx->csa.spu_chnlcnt_RW[3]) {
1049 data = ctx->csa.spu_chnldata_RW[3];
1056 if (copy_to_user(buf, &data, 4))
1063 static ssize_t spufs_signal1_read(struct file *file, char __user *buf,
1064 size_t len, loff_t *pos)
1067 struct spu_context *ctx = file->private_data;
1069 ret = spu_acquire_saved(ctx);
1072 ret = __spufs_signal1_read(ctx, buf, len, pos);
1073 spu_release_saved(ctx);
1078 static ssize_t spufs_signal1_write(struct file *file, const char __user *buf,
1079 size_t len, loff_t *pos)
1081 struct spu_context *ctx;
1085 ctx = file->private_data;
1090 if (copy_from_user(&data, buf, 4))
1093 ret = spu_acquire(ctx);
1096 ctx->ops->signal1_write(ctx, data);
1103 spufs_signal1_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
1105 #if SPUFS_SIGNAL_MAP_SIZE == 0x1000
1106 return spufs_ps_fault(vma, vmf, 0x14000, SPUFS_SIGNAL_MAP_SIZE);
1107 #elif SPUFS_SIGNAL_MAP_SIZE == 0x10000
1108 /* For 64k pages, both signal1 and signal2 can be used to mmap the whole
1109 * signal 1 and 2 area
1111 return spufs_ps_fault(vma, vmf, 0x10000, SPUFS_SIGNAL_MAP_SIZE);
1113 #error unsupported page size
1117 static struct vm_operations_struct spufs_signal1_mmap_vmops = {
1118 .fault = spufs_signal1_mmap_fault,
1121 static int spufs_signal1_mmap(struct file *file, struct vm_area_struct *vma)
1123 if (!(vma->vm_flags & VM_SHARED))
1126 vma->vm_flags |= VM_IO | VM_PFNMAP;
1127 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
1128 | _PAGE_NO_CACHE | _PAGE_GUARDED);
1130 vma->vm_ops = &spufs_signal1_mmap_vmops;
1134 static const struct file_operations spufs_signal1_fops = {
1135 .open = spufs_signal1_open,
1136 .release = spufs_signal1_release,
1137 .read = spufs_signal1_read,
1138 .write = spufs_signal1_write,
1139 .mmap = spufs_signal1_mmap,
1142 static const struct file_operations spufs_signal1_nosched_fops = {
1143 .open = spufs_signal1_open,
1144 .release = spufs_signal1_release,
1145 .write = spufs_signal1_write,
1146 .mmap = spufs_signal1_mmap,
1149 static int spufs_signal2_open(struct inode *inode, struct file *file)
1151 struct spufs_inode_info *i = SPUFS_I(inode);
1152 struct spu_context *ctx = i->i_ctx;
1154 mutex_lock(&ctx->mapping_lock);
1155 file->private_data = ctx;
1156 if (!i->i_openers++)
1157 ctx->signal2 = inode->i_mapping;
1158 mutex_unlock(&ctx->mapping_lock);
1159 return nonseekable_open(inode, file);
1163 spufs_signal2_release(struct inode *inode, struct file *file)
1165 struct spufs_inode_info *i = SPUFS_I(inode);
1166 struct spu_context *ctx = i->i_ctx;
1168 mutex_lock(&ctx->mapping_lock);
1169 if (!--i->i_openers)
1170 ctx->signal2 = NULL;
1171 mutex_unlock(&ctx->mapping_lock);
1175 static ssize_t __spufs_signal2_read(struct spu_context *ctx, char __user *buf,
1176 size_t len, loff_t *pos)
1184 if (ctx->csa.spu_chnlcnt_RW[4]) {
1185 data = ctx->csa.spu_chnldata_RW[4];
1192 if (copy_to_user(buf, &data, 4))
1199 static ssize_t spufs_signal2_read(struct file *file, char __user *buf,
1200 size_t len, loff_t *pos)
1202 struct spu_context *ctx = file->private_data;
1205 ret = spu_acquire_saved(ctx);
1208 ret = __spufs_signal2_read(ctx, buf, len, pos);
1209 spu_release_saved(ctx);
1214 static ssize_t spufs_signal2_write(struct file *file, const char __user *buf,
1215 size_t len, loff_t *pos)
1217 struct spu_context *ctx;
1221 ctx = file->private_data;
1226 if (copy_from_user(&data, buf, 4))
1229 ret = spu_acquire(ctx);
1232 ctx->ops->signal2_write(ctx, data);
1240 spufs_signal2_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
1242 #if SPUFS_SIGNAL_MAP_SIZE == 0x1000
1243 return spufs_ps_fault(vma, vmf, 0x1c000, SPUFS_SIGNAL_MAP_SIZE);
1244 #elif SPUFS_SIGNAL_MAP_SIZE == 0x10000
1245 /* For 64k pages, both signal1 and signal2 can be used to mmap the whole
1246 * signal 1 and 2 area
1248 return spufs_ps_fault(vma, vmf, 0x10000, SPUFS_SIGNAL_MAP_SIZE);
1250 #error unsupported page size
1254 static struct vm_operations_struct spufs_signal2_mmap_vmops = {
1255 .fault = spufs_signal2_mmap_fault,
1258 static int spufs_signal2_mmap(struct file *file, struct vm_area_struct *vma)
1260 if (!(vma->vm_flags & VM_SHARED))
1263 vma->vm_flags |= VM_IO | VM_PFNMAP;
1264 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
1265 | _PAGE_NO_CACHE | _PAGE_GUARDED);
1267 vma->vm_ops = &spufs_signal2_mmap_vmops;
1270 #else /* SPUFS_MMAP_4K */
1271 #define spufs_signal2_mmap NULL
1272 #endif /* !SPUFS_MMAP_4K */
1274 static const struct file_operations spufs_signal2_fops = {
1275 .open = spufs_signal2_open,
1276 .release = spufs_signal2_release,
1277 .read = spufs_signal2_read,
1278 .write = spufs_signal2_write,
1279 .mmap = spufs_signal2_mmap,
1282 static const struct file_operations spufs_signal2_nosched_fops = {
1283 .open = spufs_signal2_open,
1284 .release = spufs_signal2_release,
1285 .write = spufs_signal2_write,
1286 .mmap = spufs_signal2_mmap,
1290 * This is a wrapper around DEFINE_SIMPLE_ATTRIBUTE which does the
1291 * work of acquiring (or not) the SPU context before calling through
1292 * to the actual get routine. The set routine is called directly.
1294 #define SPU_ATTR_NOACQUIRE 0
1295 #define SPU_ATTR_ACQUIRE 1
1296 #define SPU_ATTR_ACQUIRE_SAVED 2
1298 #define DEFINE_SPUFS_ATTRIBUTE(__name, __get, __set, __fmt, __acquire) \
1299 static int __##__get(void *data, u64 *val) \
1301 struct spu_context *ctx = data; \
1304 if (__acquire == SPU_ATTR_ACQUIRE) { \
1305 ret = spu_acquire(ctx); \
1308 *val = __get(ctx); \
1310 } else if (__acquire == SPU_ATTR_ACQUIRE_SAVED) { \
1311 ret = spu_acquire_saved(ctx); \
1314 *val = __get(ctx); \
1315 spu_release_saved(ctx); \
1317 *val = __get(ctx); \
1321 DEFINE_SPUFS_SIMPLE_ATTRIBUTE(__name, __##__get, __set, __fmt);
1323 static int spufs_signal1_type_set(void *data, u64 val)
1325 struct spu_context *ctx = data;
1328 ret = spu_acquire(ctx);
1331 ctx->ops->signal1_type_set(ctx, val);
1337 static u64 spufs_signal1_type_get(struct spu_context *ctx)
1339 return ctx->ops->signal1_type_get(ctx);
1341 DEFINE_SPUFS_ATTRIBUTE(spufs_signal1_type, spufs_signal1_type_get,
1342 spufs_signal1_type_set, "%llu\n", SPU_ATTR_ACQUIRE);
1345 static int spufs_signal2_type_set(void *data, u64 val)
1347 struct spu_context *ctx = data;
1350 ret = spu_acquire(ctx);
1353 ctx->ops->signal2_type_set(ctx, val);
1359 static u64 spufs_signal2_type_get(struct spu_context *ctx)
1361 return ctx->ops->signal2_type_get(ctx);
1363 DEFINE_SPUFS_ATTRIBUTE(spufs_signal2_type, spufs_signal2_type_get,
1364 spufs_signal2_type_set, "%llu\n", SPU_ATTR_ACQUIRE);
1368 spufs_mss_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
1370 return spufs_ps_fault(vma, vmf, 0x0000, SPUFS_MSS_MAP_SIZE);
1373 static struct vm_operations_struct spufs_mss_mmap_vmops = {
1374 .fault = spufs_mss_mmap_fault,
1378 * mmap support for problem state MFC DMA area [0x0000 - 0x0fff].
1380 static int spufs_mss_mmap(struct file *file, struct vm_area_struct *vma)
1382 if (!(vma->vm_flags & VM_SHARED))
1385 vma->vm_flags |= VM_IO | VM_PFNMAP;
1386 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
1387 | _PAGE_NO_CACHE | _PAGE_GUARDED);
1389 vma->vm_ops = &spufs_mss_mmap_vmops;
1392 #else /* SPUFS_MMAP_4K */
1393 #define spufs_mss_mmap NULL
1394 #endif /* !SPUFS_MMAP_4K */
1396 static int spufs_mss_open(struct inode *inode, struct file *file)
1398 struct spufs_inode_info *i = SPUFS_I(inode);
1399 struct spu_context *ctx = i->i_ctx;
1401 file->private_data = i->i_ctx;
1403 mutex_lock(&ctx->mapping_lock);
1404 if (!i->i_openers++)
1405 ctx->mss = inode->i_mapping;
1406 mutex_unlock(&ctx->mapping_lock);
1407 return nonseekable_open(inode, file);
1411 spufs_mss_release(struct inode *inode, struct file *file)
1413 struct spufs_inode_info *i = SPUFS_I(inode);
1414 struct spu_context *ctx = i->i_ctx;
1416 mutex_lock(&ctx->mapping_lock);
1417 if (!--i->i_openers)
1419 mutex_unlock(&ctx->mapping_lock);
1423 static const struct file_operations spufs_mss_fops = {
1424 .open = spufs_mss_open,
1425 .release = spufs_mss_release,
1426 .mmap = spufs_mss_mmap,
1430 spufs_psmap_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
1432 return spufs_ps_fault(vma, vmf, 0x0000, SPUFS_PS_MAP_SIZE);
1435 static struct vm_operations_struct spufs_psmap_mmap_vmops = {
1436 .fault = spufs_psmap_mmap_fault,
1440 * mmap support for full problem state area [0x00000 - 0x1ffff].
1442 static int spufs_psmap_mmap(struct file *file, struct vm_area_struct *vma)
1444 if (!(vma->vm_flags & VM_SHARED))
1447 vma->vm_flags |= VM_IO | VM_PFNMAP;
1448 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
1449 | _PAGE_NO_CACHE | _PAGE_GUARDED);
1451 vma->vm_ops = &spufs_psmap_mmap_vmops;
1455 static int spufs_psmap_open(struct inode *inode, struct file *file)
1457 struct spufs_inode_info *i = SPUFS_I(inode);
1458 struct spu_context *ctx = i->i_ctx;
1460 mutex_lock(&ctx->mapping_lock);
1461 file->private_data = i->i_ctx;
1462 if (!i->i_openers++)
1463 ctx->psmap = inode->i_mapping;
1464 mutex_unlock(&ctx->mapping_lock);
1465 return nonseekable_open(inode, file);
1469 spufs_psmap_release(struct inode *inode, struct file *file)
1471 struct spufs_inode_info *i = SPUFS_I(inode);
1472 struct spu_context *ctx = i->i_ctx;
1474 mutex_lock(&ctx->mapping_lock);
1475 if (!--i->i_openers)
1477 mutex_unlock(&ctx->mapping_lock);
1481 static const struct file_operations spufs_psmap_fops = {
1482 .open = spufs_psmap_open,
1483 .release = spufs_psmap_release,
1484 .mmap = spufs_psmap_mmap,
1490 spufs_mfc_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
1492 return spufs_ps_fault(vma, vmf, 0x3000, SPUFS_MFC_MAP_SIZE);
1495 static struct vm_operations_struct spufs_mfc_mmap_vmops = {
1496 .fault = spufs_mfc_mmap_fault,
1500 * mmap support for problem state MFC DMA area [0x0000 - 0x0fff].
1502 static int spufs_mfc_mmap(struct file *file, struct vm_area_struct *vma)
1504 if (!(vma->vm_flags & VM_SHARED))
1507 vma->vm_flags |= VM_IO | VM_PFNMAP;
1508 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
1509 | _PAGE_NO_CACHE | _PAGE_GUARDED);
1511 vma->vm_ops = &spufs_mfc_mmap_vmops;
1514 #else /* SPUFS_MMAP_4K */
1515 #define spufs_mfc_mmap NULL
1516 #endif /* !SPUFS_MMAP_4K */
1518 static int spufs_mfc_open(struct inode *inode, struct file *file)
1520 struct spufs_inode_info *i = SPUFS_I(inode);
1521 struct spu_context *ctx = i->i_ctx;
1523 /* we don't want to deal with DMA into other processes */
1524 if (ctx->owner != current->mm)
1527 if (atomic_read(&inode->i_count) != 1)
1530 mutex_lock(&ctx->mapping_lock);
1531 file->private_data = ctx;
1532 if (!i->i_openers++)
1533 ctx->mfc = inode->i_mapping;
1534 mutex_unlock(&ctx->mapping_lock);
1535 return nonseekable_open(inode, file);
1539 spufs_mfc_release(struct inode *inode, struct file *file)
1541 struct spufs_inode_info *i = SPUFS_I(inode);
1542 struct spu_context *ctx = i->i_ctx;
1544 mutex_lock(&ctx->mapping_lock);
1545 if (!--i->i_openers)
1547 mutex_unlock(&ctx->mapping_lock);
1551 /* interrupt-level mfc callback function. */
1552 void spufs_mfc_callback(struct spu *spu)
1554 struct spu_context *ctx = spu->ctx;
1559 wake_up_all(&ctx->mfc_wq);
1561 pr_debug("%s %s\n", __func__, spu->name);
1562 if (ctx->mfc_fasync) {
1563 u32 free_elements, tagstatus;
1566 /* no need for spu_acquire in interrupt context */
1567 free_elements = ctx->ops->get_mfc_free_elements(ctx);
1568 tagstatus = ctx->ops->read_mfc_tagstatus(ctx);
1571 if (free_elements & 0xffff)
1573 if (tagstatus & ctx->tagwait)
1576 kill_fasync(&ctx->mfc_fasync, SIGIO, mask);
1580 static int spufs_read_mfc_tagstatus(struct spu_context *ctx, u32 *status)
1582 /* See if there is one tag group is complete */
1583 /* FIXME we need locking around tagwait */
1584 *status = ctx->ops->read_mfc_tagstatus(ctx) & ctx->tagwait;
1585 ctx->tagwait &= ~*status;
1589 /* enable interrupt waiting for any tag group,
1590 may silently fail if interrupts are already enabled */
1591 ctx->ops->set_mfc_query(ctx, ctx->tagwait, 1);
1595 static ssize_t spufs_mfc_read(struct file *file, char __user *buffer,
1596 size_t size, loff_t *pos)
1598 struct spu_context *ctx = file->private_data;
1605 ret = spu_acquire(ctx);
1610 if (file->f_flags & O_NONBLOCK) {
1611 status = ctx->ops->read_mfc_tagstatus(ctx);
1612 if (!(status & ctx->tagwait))
1615 /* XXX(hch): shouldn't we clear ret here? */
1616 ctx->tagwait &= ~status;
1618 ret = spufs_wait(ctx->mfc_wq,
1619 spufs_read_mfc_tagstatus(ctx, &status));
1626 if (copy_to_user(buffer, &status, 4))
1633 static int spufs_check_valid_dma(struct mfc_dma_command *cmd)
1635 pr_debug("queueing DMA %x %lx %x %x %x\n", cmd->lsa,
1636 cmd->ea, cmd->size, cmd->tag, cmd->cmd);
1647 pr_debug("invalid DMA opcode %x\n", cmd->cmd);
1651 if ((cmd->lsa & 0xf) != (cmd->ea &0xf)) {
1652 pr_debug("invalid DMA alignment, ea %lx lsa %x\n",
1657 switch (cmd->size & 0xf) {
1678 pr_debug("invalid DMA alignment %x for size %x\n",
1679 cmd->lsa & 0xf, cmd->size);
1683 if (cmd->size > 16 * 1024) {
1684 pr_debug("invalid DMA size %x\n", cmd->size);
1688 if (cmd->tag & 0xfff0) {
1689 /* we reserve the higher tag numbers for kernel use */
1690 pr_debug("invalid DMA tag\n");
1695 /* not supported in this version */
1696 pr_debug("invalid DMA class\n");
1703 static int spu_send_mfc_command(struct spu_context *ctx,
1704 struct mfc_dma_command cmd,
1707 *error = ctx->ops->send_mfc_command(ctx, &cmd);
1708 if (*error == -EAGAIN) {
1709 /* wait for any tag group to complete
1710 so we have space for the new command */
1711 ctx->ops->set_mfc_query(ctx, ctx->tagwait, 1);
1712 /* try again, because the queue might be
1714 *error = ctx->ops->send_mfc_command(ctx, &cmd);
1715 if (*error == -EAGAIN)
1721 static ssize_t spufs_mfc_write(struct file *file, const char __user *buffer,
1722 size_t size, loff_t *pos)
1724 struct spu_context *ctx = file->private_data;
1725 struct mfc_dma_command cmd;
1728 if (size != sizeof cmd)
1732 if (copy_from_user(&cmd, buffer, sizeof cmd))
1735 ret = spufs_check_valid_dma(&cmd);
1739 ret = spu_acquire(ctx);
1743 ret = spufs_wait(ctx->run_wq, ctx->state == SPU_STATE_RUNNABLE);
1747 if (file->f_flags & O_NONBLOCK) {
1748 ret = ctx->ops->send_mfc_command(ctx, &cmd);
1751 ret = spufs_wait(ctx->mfc_wq,
1752 spu_send_mfc_command(ctx, cmd, &status));
1762 ctx->tagwait |= 1 << cmd.tag;
1771 static unsigned int spufs_mfc_poll(struct file *file,poll_table *wait)
1773 struct spu_context *ctx = file->private_data;
1774 u32 free_elements, tagstatus;
1777 poll_wait(file, &ctx->mfc_wq, wait);
1780 * For now keep this uninterruptible and also ignore the rule
1781 * that poll should not sleep. Will be fixed later.
1783 mutex_lock(&ctx->state_mutex);
1784 ctx->ops->set_mfc_query(ctx, ctx->tagwait, 2);
1785 free_elements = ctx->ops->get_mfc_free_elements(ctx);
1786 tagstatus = ctx->ops->read_mfc_tagstatus(ctx);
1790 if (free_elements & 0xffff)
1791 mask |= POLLOUT | POLLWRNORM;
1792 if (tagstatus & ctx->tagwait)
1793 mask |= POLLIN | POLLRDNORM;
1795 pr_debug("%s: free %d tagstatus %d tagwait %d\n", __func__,
1796 free_elements, tagstatus, ctx->tagwait);
1801 static int spufs_mfc_flush(struct file *file, fl_owner_t id)
1803 struct spu_context *ctx = file->private_data;
1806 ret = spu_acquire(ctx);
1810 /* this currently hangs */
1811 ret = spufs_wait(ctx->mfc_wq,
1812 ctx->ops->set_mfc_query(ctx, ctx->tagwait, 2));
1815 ret = spufs_wait(ctx->mfc_wq,
1816 ctx->ops->read_mfc_tagstatus(ctx) == ctx->tagwait);
1827 static int spufs_mfc_fsync(struct file *file, struct dentry *dentry,
1830 return spufs_mfc_flush(file, NULL);
1833 static int spufs_mfc_fasync(int fd, struct file *file, int on)
1835 struct spu_context *ctx = file->private_data;
1837 return fasync_helper(fd, file, on, &ctx->mfc_fasync);
1840 static const struct file_operations spufs_mfc_fops = {
1841 .open = spufs_mfc_open,
1842 .release = spufs_mfc_release,
1843 .read = spufs_mfc_read,
1844 .write = spufs_mfc_write,
1845 .poll = spufs_mfc_poll,
1846 .flush = spufs_mfc_flush,
1847 .fsync = spufs_mfc_fsync,
1848 .fasync = spufs_mfc_fasync,
1849 .mmap = spufs_mfc_mmap,
1852 static int spufs_npc_set(void *data, u64 val)
1854 struct spu_context *ctx = data;
1857 ret = spu_acquire(ctx);
1860 ctx->ops->npc_write(ctx, val);
1866 static u64 spufs_npc_get(struct spu_context *ctx)
1868 return ctx->ops->npc_read(ctx);
1870 DEFINE_SPUFS_ATTRIBUTE(spufs_npc_ops, spufs_npc_get, spufs_npc_set,
1871 "0x%llx\n", SPU_ATTR_ACQUIRE);
1873 static int spufs_decr_set(void *data, u64 val)
1875 struct spu_context *ctx = data;
1876 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1879 ret = spu_acquire_saved(ctx);
1882 lscsa->decr.slot[0] = (u32) val;
1883 spu_release_saved(ctx);
1888 static u64 spufs_decr_get(struct spu_context *ctx)
1890 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1891 return lscsa->decr.slot[0];
1893 DEFINE_SPUFS_ATTRIBUTE(spufs_decr_ops, spufs_decr_get, spufs_decr_set,
1894 "0x%llx\n", SPU_ATTR_ACQUIRE_SAVED);
1896 static int spufs_decr_status_set(void *data, u64 val)
1898 struct spu_context *ctx = data;
1901 ret = spu_acquire_saved(ctx);
1905 ctx->csa.priv2.mfc_control_RW |= MFC_CNTL_DECREMENTER_RUNNING;
1907 ctx->csa.priv2.mfc_control_RW &= ~MFC_CNTL_DECREMENTER_RUNNING;
1908 spu_release_saved(ctx);
1913 static u64 spufs_decr_status_get(struct spu_context *ctx)
1915 if (ctx->csa.priv2.mfc_control_RW & MFC_CNTL_DECREMENTER_RUNNING)
1916 return SPU_DECR_STATUS_RUNNING;
1920 DEFINE_SPUFS_ATTRIBUTE(spufs_decr_status_ops, spufs_decr_status_get,
1921 spufs_decr_status_set, "0x%llx\n",
1922 SPU_ATTR_ACQUIRE_SAVED);
1924 static int spufs_event_mask_set(void *data, u64 val)
1926 struct spu_context *ctx = data;
1927 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1930 ret = spu_acquire_saved(ctx);
1933 lscsa->event_mask.slot[0] = (u32) val;
1934 spu_release_saved(ctx);
1939 static u64 spufs_event_mask_get(struct spu_context *ctx)
1941 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1942 return lscsa->event_mask.slot[0];
1945 DEFINE_SPUFS_ATTRIBUTE(spufs_event_mask_ops, spufs_event_mask_get,
1946 spufs_event_mask_set, "0x%llx\n",
1947 SPU_ATTR_ACQUIRE_SAVED);
1949 static u64 spufs_event_status_get(struct spu_context *ctx)
1951 struct spu_state *state = &ctx->csa;
1953 stat = state->spu_chnlcnt_RW[0];
1955 return state->spu_chnldata_RW[0];
1958 DEFINE_SPUFS_ATTRIBUTE(spufs_event_status_ops, spufs_event_status_get,
1959 NULL, "0x%llx\n", SPU_ATTR_ACQUIRE_SAVED)
1961 static int spufs_srr0_set(void *data, u64 val)
1963 struct spu_context *ctx = data;
1964 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1967 ret = spu_acquire_saved(ctx);
1970 lscsa->srr0.slot[0] = (u32) val;
1971 spu_release_saved(ctx);
1976 static u64 spufs_srr0_get(struct spu_context *ctx)
1978 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1979 return lscsa->srr0.slot[0];
1981 DEFINE_SPUFS_ATTRIBUTE(spufs_srr0_ops, spufs_srr0_get, spufs_srr0_set,
1982 "0x%llx\n", SPU_ATTR_ACQUIRE_SAVED)
1984 static u64 spufs_id_get(struct spu_context *ctx)
1988 if (ctx->state == SPU_STATE_RUNNABLE)
1989 num = ctx->spu->number;
1991 num = (unsigned int)-1;
1995 DEFINE_SPUFS_ATTRIBUTE(spufs_id_ops, spufs_id_get, NULL, "0x%llx\n",
1998 static u64 spufs_object_id_get(struct spu_context *ctx)
2000 /* FIXME: Should there really be no locking here? */
2001 return ctx->object_id;
2004 static int spufs_object_id_set(void *data, u64 id)
2006 struct spu_context *ctx = data;
2007 ctx->object_id = id;
2012 DEFINE_SPUFS_ATTRIBUTE(spufs_object_id_ops, spufs_object_id_get,
2013 spufs_object_id_set, "0x%llx\n", SPU_ATTR_NOACQUIRE);
2015 static u64 spufs_lslr_get(struct spu_context *ctx)
2017 return ctx->csa.priv2.spu_lslr_RW;
2019 DEFINE_SPUFS_ATTRIBUTE(spufs_lslr_ops, spufs_lslr_get, NULL, "0x%llx\n",
2020 SPU_ATTR_ACQUIRE_SAVED);
2022 static int spufs_info_open(struct inode *inode, struct file *file)
2024 struct spufs_inode_info *i = SPUFS_I(inode);
2025 struct spu_context *ctx = i->i_ctx;
2026 file->private_data = ctx;
2030 static int spufs_caps_show(struct seq_file *s, void *private)
2032 struct spu_context *ctx = s->private;
2034 if (!(ctx->flags & SPU_CREATE_NOSCHED))
2035 seq_puts(s, "sched\n");
2036 if (!(ctx->flags & SPU_CREATE_ISOLATE))
2037 seq_puts(s, "step\n");
2041 static int spufs_caps_open(struct inode *inode, struct file *file)
2043 return single_open(file, spufs_caps_show, SPUFS_I(inode)->i_ctx);
2046 static const struct file_operations spufs_caps_fops = {
2047 .open = spufs_caps_open,
2049 .llseek = seq_lseek,
2050 .release = single_release,
2053 static ssize_t __spufs_mbox_info_read(struct spu_context *ctx,
2054 char __user *buf, size_t len, loff_t *pos)
2058 /* EOF if there's no entry in the mbox */
2059 if (!(ctx->csa.prob.mb_stat_R & 0x0000ff))
2062 data = ctx->csa.prob.pu_mb_R;
2064 return simple_read_from_buffer(buf, len, pos, &data, sizeof data);
2067 static ssize_t spufs_mbox_info_read(struct file *file, char __user *buf,
2068 size_t len, loff_t *pos)
2071 struct spu_context *ctx = file->private_data;
2073 if (!access_ok(VERIFY_WRITE, buf, len))
2076 ret = spu_acquire_saved(ctx);
2079 spin_lock(&ctx->csa.register_lock);
2080 ret = __spufs_mbox_info_read(ctx, buf, len, pos);
2081 spin_unlock(&ctx->csa.register_lock);
2082 spu_release_saved(ctx);
2087 static const struct file_operations spufs_mbox_info_fops = {
2088 .open = spufs_info_open,
2089 .read = spufs_mbox_info_read,
2090 .llseek = generic_file_llseek,
2093 static ssize_t __spufs_ibox_info_read(struct spu_context *ctx,
2094 char __user *buf, size_t len, loff_t *pos)
2098 /* EOF if there's no entry in the ibox */
2099 if (!(ctx->csa.prob.mb_stat_R & 0xff0000))
2102 data = ctx->csa.priv2.puint_mb_R;
2104 return simple_read_from_buffer(buf, len, pos, &data, sizeof data);
2107 static ssize_t spufs_ibox_info_read(struct file *file, char __user *buf,
2108 size_t len, loff_t *pos)
2110 struct spu_context *ctx = file->private_data;
2113 if (!access_ok(VERIFY_WRITE, buf, len))
2116 ret = spu_acquire_saved(ctx);
2119 spin_lock(&ctx->csa.register_lock);
2120 ret = __spufs_ibox_info_read(ctx, buf, len, pos);
2121 spin_unlock(&ctx->csa.register_lock);
2122 spu_release_saved(ctx);
2127 static const struct file_operations spufs_ibox_info_fops = {
2128 .open = spufs_info_open,
2129 .read = spufs_ibox_info_read,
2130 .llseek = generic_file_llseek,
2133 static ssize_t __spufs_wbox_info_read(struct spu_context *ctx,
2134 char __user *buf, size_t len, loff_t *pos)
2140 wbox_stat = ctx->csa.prob.mb_stat_R;
2141 cnt = 4 - ((wbox_stat & 0x00ff00) >> 8);
2142 for (i = 0; i < cnt; i++) {
2143 data[i] = ctx->csa.spu_mailbox_data[i];
2146 return simple_read_from_buffer(buf, len, pos, &data,
2150 static ssize_t spufs_wbox_info_read(struct file *file, char __user *buf,
2151 size_t len, loff_t *pos)
2153 struct spu_context *ctx = file->private_data;
2156 if (!access_ok(VERIFY_WRITE, buf, len))
2159 ret = spu_acquire_saved(ctx);
2162 spin_lock(&ctx->csa.register_lock);
2163 ret = __spufs_wbox_info_read(ctx, buf, len, pos);
2164 spin_unlock(&ctx->csa.register_lock);
2165 spu_release_saved(ctx);
2170 static const struct file_operations spufs_wbox_info_fops = {
2171 .open = spufs_info_open,
2172 .read = spufs_wbox_info_read,
2173 .llseek = generic_file_llseek,
2176 static ssize_t __spufs_dma_info_read(struct spu_context *ctx,
2177 char __user *buf, size_t len, loff_t *pos)
2179 struct spu_dma_info info;
2180 struct mfc_cq_sr *qp, *spuqp;
2183 info.dma_info_type = ctx->csa.priv2.spu_tag_status_query_RW;
2184 info.dma_info_mask = ctx->csa.lscsa->tag_mask.slot[0];
2185 info.dma_info_status = ctx->csa.spu_chnldata_RW[24];
2186 info.dma_info_stall_and_notify = ctx->csa.spu_chnldata_RW[25];
2187 info.dma_info_atomic_command_status = ctx->csa.spu_chnldata_RW[27];
2188 for (i = 0; i < 16; i++) {
2189 qp = &info.dma_info_command_data[i];
2190 spuqp = &ctx->csa.priv2.spuq[i];
2192 qp->mfc_cq_data0_RW = spuqp->mfc_cq_data0_RW;
2193 qp->mfc_cq_data1_RW = spuqp->mfc_cq_data1_RW;
2194 qp->mfc_cq_data2_RW = spuqp->mfc_cq_data2_RW;
2195 qp->mfc_cq_data3_RW = spuqp->mfc_cq_data3_RW;
2198 return simple_read_from_buffer(buf, len, pos, &info,
2202 static ssize_t spufs_dma_info_read(struct file *file, char __user *buf,
2203 size_t len, loff_t *pos)
2205 struct spu_context *ctx = file->private_data;
2208 if (!access_ok(VERIFY_WRITE, buf, len))
2211 ret = spu_acquire_saved(ctx);
2214 spin_lock(&ctx->csa.register_lock);
2215 ret = __spufs_dma_info_read(ctx, buf, len, pos);
2216 spin_unlock(&ctx->csa.register_lock);
2217 spu_release_saved(ctx);
2222 static const struct file_operations spufs_dma_info_fops = {
2223 .open = spufs_info_open,
2224 .read = spufs_dma_info_read,
2227 static ssize_t __spufs_proxydma_info_read(struct spu_context *ctx,
2228 char __user *buf, size_t len, loff_t *pos)
2230 struct spu_proxydma_info info;
2231 struct mfc_cq_sr *qp, *puqp;
2232 int ret = sizeof info;
2238 if (!access_ok(VERIFY_WRITE, buf, len))
2241 info.proxydma_info_type = ctx->csa.prob.dma_querytype_RW;
2242 info.proxydma_info_mask = ctx->csa.prob.dma_querymask_RW;
2243 info.proxydma_info_status = ctx->csa.prob.dma_tagstatus_R;
2244 for (i = 0; i < 8; i++) {
2245 qp = &info.proxydma_info_command_data[i];
2246 puqp = &ctx->csa.priv2.puq[i];
2248 qp->mfc_cq_data0_RW = puqp->mfc_cq_data0_RW;
2249 qp->mfc_cq_data1_RW = puqp->mfc_cq_data1_RW;
2250 qp->mfc_cq_data2_RW = puqp->mfc_cq_data2_RW;
2251 qp->mfc_cq_data3_RW = puqp->mfc_cq_data3_RW;
2254 return simple_read_from_buffer(buf, len, pos, &info,
2258 static ssize_t spufs_proxydma_info_read(struct file *file, char __user *buf,
2259 size_t len, loff_t *pos)
2261 struct spu_context *ctx = file->private_data;
2264 ret = spu_acquire_saved(ctx);
2267 spin_lock(&ctx->csa.register_lock);
2268 ret = __spufs_proxydma_info_read(ctx, buf, len, pos);
2269 spin_unlock(&ctx->csa.register_lock);
2270 spu_release_saved(ctx);
2275 static const struct file_operations spufs_proxydma_info_fops = {
2276 .open = spufs_info_open,
2277 .read = spufs_proxydma_info_read,
2280 static int spufs_show_tid(struct seq_file *s, void *private)
2282 struct spu_context *ctx = s->private;
2284 seq_printf(s, "%d\n", ctx->tid);
2288 static int spufs_tid_open(struct inode *inode, struct file *file)
2290 return single_open(file, spufs_show_tid, SPUFS_I(inode)->i_ctx);
2293 static const struct file_operations spufs_tid_fops = {
2294 .open = spufs_tid_open,
2296 .llseek = seq_lseek,
2297 .release = single_release,
2300 static const char *ctx_state_names[] = {
2301 "user", "system", "iowait", "loaded"
2304 static unsigned long long spufs_acct_time(struct spu_context *ctx,
2305 enum spu_utilization_state state)
2308 unsigned long long time = ctx->stats.times[state];
2311 * In general, utilization statistics are updated by the controlling
2312 * thread as the spu context moves through various well defined
2313 * state transitions, but if the context is lazily loaded its
2314 * utilization statistics are not updated as the controlling thread
2315 * is not tightly coupled with the execution of the spu context. We
2316 * calculate and apply the time delta from the last recorded state
2317 * of the spu context.
2319 if (ctx->spu && ctx->stats.util_state == state) {
2321 time += timespec_to_ns(&ts) - ctx->stats.tstamp;
2324 return time / NSEC_PER_MSEC;
2327 static unsigned long long spufs_slb_flts(struct spu_context *ctx)
2329 unsigned long long slb_flts = ctx->stats.slb_flt;
2331 if (ctx->state == SPU_STATE_RUNNABLE) {
2332 slb_flts += (ctx->spu->stats.slb_flt -
2333 ctx->stats.slb_flt_base);
2339 static unsigned long long spufs_class2_intrs(struct spu_context *ctx)
2341 unsigned long long class2_intrs = ctx->stats.class2_intr;
2343 if (ctx->state == SPU_STATE_RUNNABLE) {
2344 class2_intrs += (ctx->spu->stats.class2_intr -
2345 ctx->stats.class2_intr_base);
2348 return class2_intrs;
2352 static int spufs_show_stat(struct seq_file *s, void *private)
2354 struct spu_context *ctx = s->private;
2357 ret = spu_acquire(ctx);
2361 seq_printf(s, "%s %llu %llu %llu %llu "
2362 "%llu %llu %llu %llu %llu %llu %llu %llu\n",
2363 ctx_state_names[ctx->stats.util_state],
2364 spufs_acct_time(ctx, SPU_UTIL_USER),
2365 spufs_acct_time(ctx, SPU_UTIL_SYSTEM),
2366 spufs_acct_time(ctx, SPU_UTIL_IOWAIT),
2367 spufs_acct_time(ctx, SPU_UTIL_IDLE_LOADED),
2368 ctx->stats.vol_ctx_switch,
2369 ctx->stats.invol_ctx_switch,
2370 spufs_slb_flts(ctx),
2371 ctx->stats.hash_flt,
2374 spufs_class2_intrs(ctx),
2375 ctx->stats.libassist);
2380 static int spufs_stat_open(struct inode *inode, struct file *file)
2382 return single_open(file, spufs_show_stat, SPUFS_I(inode)->i_ctx);
2385 static const struct file_operations spufs_stat_fops = {
2386 .open = spufs_stat_open,
2388 .llseek = seq_lseek,
2389 .release = single_release,
2392 static inline int spufs_switch_log_used(struct spu_context *ctx)
2394 return (ctx->switch_log->head - ctx->switch_log->tail) %
2398 static inline int spufs_switch_log_avail(struct spu_context *ctx)
2400 return SWITCH_LOG_BUFSIZE - spufs_switch_log_used(ctx);
2403 static int spufs_switch_log_open(struct inode *inode, struct file *file)
2405 struct spu_context *ctx = SPUFS_I(inode)->i_ctx;
2408 * We (ab-)use the mapping_lock here because it serves the similar
2409 * purpose for synchronizing open/close elsewhere. Maybe it should
2410 * be renamed eventually.
2412 mutex_lock(&ctx->mapping_lock);
2413 if (ctx->switch_log) {
2414 spin_lock(&ctx->switch_log->lock);
2415 ctx->switch_log->head = 0;
2416 ctx->switch_log->tail = 0;
2417 spin_unlock(&ctx->switch_log->lock);
2420 * We allocate the switch log data structures on first open.
2421 * They will never be free because we assume a context will
2422 * be traced until it goes away.
2424 ctx->switch_log = kzalloc(sizeof(struct switch_log) +
2425 SWITCH_LOG_BUFSIZE * sizeof(struct switch_log_entry),
2427 if (!ctx->switch_log)
2429 spin_lock_init(&ctx->switch_log->lock);
2430 init_waitqueue_head(&ctx->switch_log->wait);
2432 mutex_unlock(&ctx->mapping_lock);
2436 mutex_unlock(&ctx->mapping_lock);
2440 static int switch_log_sprint(struct spu_context *ctx, char *tbuf, int n)
2442 struct switch_log_entry *p;
2444 p = ctx->switch_log->log + ctx->switch_log->tail % SWITCH_LOG_BUFSIZE;
2446 return snprintf(tbuf, n, "%u.%09u %d %u %u %llu\n",
2447 (unsigned int) p->tstamp.tv_sec,
2448 (unsigned int) p->tstamp.tv_nsec,
2450 (unsigned int) p->type,
2451 (unsigned int) p->val,
2452 (unsigned long long) p->timebase);
2455 static ssize_t spufs_switch_log_read(struct file *file, char __user *buf,
2456 size_t len, loff_t *ppos)
2458 struct inode *inode = file->f_path.dentry->d_inode;
2459 struct spu_context *ctx = SPUFS_I(inode)->i_ctx;
2460 int error = 0, cnt = 0;
2462 if (!buf || len < 0)
2469 if (file->f_flags & O_NONBLOCK) {
2470 if (spufs_switch_log_used(ctx) <= 0)
2471 return cnt ? cnt : -EAGAIN;
2473 /* Wait for data in buffer */
2474 error = wait_event_interruptible(ctx->switch_log->wait,
2475 spufs_switch_log_used(ctx) > 0);
2480 spin_lock(&ctx->switch_log->lock);
2481 if (ctx->switch_log->head == ctx->switch_log->tail) {
2482 /* multiple readers race? */
2483 spin_unlock(&ctx->switch_log->lock);
2487 width = switch_log_sprint(ctx, tbuf, sizeof(tbuf));
2489 ctx->switch_log->tail =
2490 (ctx->switch_log->tail + 1) %
2494 spin_unlock(&ctx->switch_log->lock);
2497 * If the record is greater than space available return
2498 * partial buffer (so far)
2503 error = copy_to_user(buf + cnt, tbuf, width);
2509 return cnt == 0 ? error : cnt;
2512 static unsigned int spufs_switch_log_poll(struct file *file, poll_table *wait)
2514 struct inode *inode = file->f_path.dentry->d_inode;
2515 struct spu_context *ctx = SPUFS_I(inode)->i_ctx;
2516 unsigned int mask = 0;
2518 poll_wait(file, &ctx->switch_log->wait, wait);
2520 if (spufs_switch_log_used(ctx) > 0)
2526 static const struct file_operations spufs_switch_log_fops = {
2527 .owner = THIS_MODULE,
2528 .open = spufs_switch_log_open,
2529 .read = spufs_switch_log_read,
2530 .poll = spufs_switch_log_poll,
2533 void spu_switch_log_notify(struct spu *spu, struct spu_context *ctx,
2536 if (!ctx->switch_log)
2539 spin_lock(&ctx->switch_log->lock);
2540 if (spufs_switch_log_avail(ctx) > 1) {
2541 struct switch_log_entry *p;
2543 p = ctx->switch_log->log + ctx->switch_log->head;
2544 ktime_get_ts(&p->tstamp);
2545 p->timebase = get_tb();
2546 p->spu_id = spu ? spu->number : -1;
2550 ctx->switch_log->head =
2551 (ctx->switch_log->head + 1) % SWITCH_LOG_BUFSIZE;
2553 spin_unlock(&ctx->switch_log->lock);
2555 wake_up(&ctx->switch_log->wait);
2558 static int spufs_show_ctx(struct seq_file *s, void *private)
2560 struct spu_context *ctx = s->private;
2563 mutex_lock(&ctx->state_mutex);
2565 struct spu *spu = ctx->spu;
2566 struct spu_priv2 __iomem *priv2 = spu->priv2;
2568 spin_lock_irq(&spu->register_lock);
2569 mfc_control_RW = in_be64(&priv2->mfc_control_RW);
2570 spin_unlock_irq(&spu->register_lock);
2572 struct spu_state *csa = &ctx->csa;
2574 mfc_control_RW = csa->priv2.mfc_control_RW;
2577 seq_printf(s, "%c flgs(%lx) sflgs(%lx) pri(%d) ts(%d) spu(%02d)"
2578 " %c %lx %lx %lx %lx %x %x\n",
2579 ctx->state == SPU_STATE_SAVED ? 'S' : 'R',
2584 ctx->spu ? ctx->spu->number : -1,
2585 !list_empty(&ctx->rq) ? 'q' : ' ',
2586 ctx->csa.class_0_pending,
2587 ctx->csa.class_0_dar,
2588 ctx->csa.class_1_dsisr,
2590 ctx->ops->runcntl_read(ctx),
2591 ctx->ops->status_read(ctx));
2593 mutex_unlock(&ctx->state_mutex);
2598 static int spufs_ctx_open(struct inode *inode, struct file *file)
2600 return single_open(file, spufs_show_ctx, SPUFS_I(inode)->i_ctx);
2603 static const struct file_operations spufs_ctx_fops = {
2604 .open = spufs_ctx_open,
2606 .llseek = seq_lseek,
2607 .release = single_release,
2610 struct spufs_tree_descr spufs_dir_contents[] = {
2611 { "capabilities", &spufs_caps_fops, 0444, },
2612 { "mem", &spufs_mem_fops, 0666, LS_SIZE, },
2613 { "regs", &spufs_regs_fops, 0666, sizeof(struct spu_reg128[128]), },
2614 { "mbox", &spufs_mbox_fops, 0444, },
2615 { "ibox", &spufs_ibox_fops, 0444, },
2616 { "wbox", &spufs_wbox_fops, 0222, },
2617 { "mbox_stat", &spufs_mbox_stat_fops, 0444, sizeof(u32), },
2618 { "ibox_stat", &spufs_ibox_stat_fops, 0444, sizeof(u32), },
2619 { "wbox_stat", &spufs_wbox_stat_fops, 0444, sizeof(u32), },
2620 { "signal1", &spufs_signal1_fops, 0666, },
2621 { "signal2", &spufs_signal2_fops, 0666, },
2622 { "signal1_type", &spufs_signal1_type, 0666, },
2623 { "signal2_type", &spufs_signal2_type, 0666, },
2624 { "cntl", &spufs_cntl_fops, 0666, },
2625 { "fpcr", &spufs_fpcr_fops, 0666, sizeof(struct spu_reg128), },
2626 { "lslr", &spufs_lslr_ops, 0444, },
2627 { "mfc", &spufs_mfc_fops, 0666, },
2628 { "mss", &spufs_mss_fops, 0666, },
2629 { "npc", &spufs_npc_ops, 0666, },
2630 { "srr0", &spufs_srr0_ops, 0666, },
2631 { "decr", &spufs_decr_ops, 0666, },
2632 { "decr_status", &spufs_decr_status_ops, 0666, },
2633 { "event_mask", &spufs_event_mask_ops, 0666, },
2634 { "event_status", &spufs_event_status_ops, 0444, },
2635 { "psmap", &spufs_psmap_fops, 0666, SPUFS_PS_MAP_SIZE, },
2636 { "phys-id", &spufs_id_ops, 0666, },
2637 { "object-id", &spufs_object_id_ops, 0666, },
2638 { "mbox_info", &spufs_mbox_info_fops, 0444, sizeof(u32), },
2639 { "ibox_info", &spufs_ibox_info_fops, 0444, sizeof(u32), },
2640 { "wbox_info", &spufs_wbox_info_fops, 0444, sizeof(u32), },
2641 { "dma_info", &spufs_dma_info_fops, 0444,
2642 sizeof(struct spu_dma_info), },
2643 { "proxydma_info", &spufs_proxydma_info_fops, 0444,
2644 sizeof(struct spu_proxydma_info)},
2645 { "tid", &spufs_tid_fops, 0444, },
2646 { "stat", &spufs_stat_fops, 0444, },
2647 { "switch_log", &spufs_switch_log_fops, 0444 },
2651 struct spufs_tree_descr spufs_dir_nosched_contents[] = {
2652 { "capabilities", &spufs_caps_fops, 0444, },
2653 { "mem", &spufs_mem_fops, 0666, LS_SIZE, },
2654 { "mbox", &spufs_mbox_fops, 0444, },
2655 { "ibox", &spufs_ibox_fops, 0444, },
2656 { "wbox", &spufs_wbox_fops, 0222, },
2657 { "mbox_stat", &spufs_mbox_stat_fops, 0444, sizeof(u32), },
2658 { "ibox_stat", &spufs_ibox_stat_fops, 0444, sizeof(u32), },
2659 { "wbox_stat", &spufs_wbox_stat_fops, 0444, sizeof(u32), },
2660 { "signal1", &spufs_signal1_nosched_fops, 0222, },
2661 { "signal2", &spufs_signal2_nosched_fops, 0222, },
2662 { "signal1_type", &spufs_signal1_type, 0666, },
2663 { "signal2_type", &spufs_signal2_type, 0666, },
2664 { "mss", &spufs_mss_fops, 0666, },
2665 { "mfc", &spufs_mfc_fops, 0666, },
2666 { "cntl", &spufs_cntl_fops, 0666, },
2667 { "npc", &spufs_npc_ops, 0666, },
2668 { "psmap", &spufs_psmap_fops, 0666, SPUFS_PS_MAP_SIZE, },
2669 { "phys-id", &spufs_id_ops, 0666, },
2670 { "object-id", &spufs_object_id_ops, 0666, },
2671 { "tid", &spufs_tid_fops, 0444, },
2672 { "stat", &spufs_stat_fops, 0444, },
2676 struct spufs_tree_descr spufs_dir_debug_contents[] = {
2677 { ".ctx", &spufs_ctx_fops, 0444, },
2681 struct spufs_coredump_reader spufs_coredump_read[] = {
2682 { "regs", __spufs_regs_read, NULL, sizeof(struct spu_reg128[128])},
2683 { "fpcr", __spufs_fpcr_read, NULL, sizeof(struct spu_reg128) },
2684 { "lslr", NULL, spufs_lslr_get, 19 },
2685 { "decr", NULL, spufs_decr_get, 19 },
2686 { "decr_status", NULL, spufs_decr_status_get, 19 },
2687 { "mem", __spufs_mem_read, NULL, LS_SIZE, },
2688 { "signal1", __spufs_signal1_read, NULL, sizeof(u32) },
2689 { "signal1_type", NULL, spufs_signal1_type_get, 19 },
2690 { "signal2", __spufs_signal2_read, NULL, sizeof(u32) },
2691 { "signal2_type", NULL, spufs_signal2_type_get, 19 },
2692 { "event_mask", NULL, spufs_event_mask_get, 19 },
2693 { "event_status", NULL, spufs_event_status_get, 19 },
2694 { "mbox_info", __spufs_mbox_info_read, NULL, sizeof(u32) },
2695 { "ibox_info", __spufs_ibox_info_read, NULL, sizeof(u32) },
2696 { "wbox_info", __spufs_wbox_info_read, NULL, 4 * sizeof(u32)},
2697 { "dma_info", __spufs_dma_info_read, NULL, sizeof(struct spu_dma_info)},
2698 { "proxydma_info", __spufs_proxydma_info_read,
2699 NULL, sizeof(struct spu_proxydma_info)},
2700 { "object-id", NULL, spufs_object_id_get, 19 },
2701 { "npc", NULL, spufs_npc_get, 19 },