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>
33 #include <asm/semaphore.h>
35 #include <asm/spu_info.h>
36 #include <asm/uaccess.h>
40 #define SPUFS_MMAP_4K (PAGE_SIZE == 0x1000)
43 spufs_mem_open(struct inode *inode, struct file *file)
45 struct spufs_inode_info *i = SPUFS_I(inode);
46 struct spu_context *ctx = i->i_ctx;
48 spin_lock(&ctx->mapping_lock);
49 file->private_data = ctx;
51 ctx->local_store = inode->i_mapping;
52 spin_unlock(&ctx->mapping_lock);
57 spufs_mem_release(struct inode *inode, struct file *file)
59 struct spufs_inode_info *i = SPUFS_I(inode);
60 struct spu_context *ctx = i->i_ctx;
62 spin_lock(&ctx->mapping_lock);
64 ctx->local_store = NULL;
65 spin_unlock(&ctx->mapping_lock);
70 __spufs_mem_read(struct spu_context *ctx, char __user *buffer,
71 size_t size, loff_t *pos)
73 char *local_store = ctx->ops->get_ls(ctx);
74 return simple_read_from_buffer(buffer, size, pos, local_store,
79 spufs_mem_read(struct file *file, char __user *buffer,
80 size_t size, loff_t *pos)
82 struct spu_context *ctx = file->private_data;
86 ret = __spufs_mem_read(ctx, buffer, size, pos);
92 spufs_mem_write(struct file *file, const char __user *buffer,
93 size_t size, loff_t *ppos)
95 struct spu_context *ctx = file->private_data;
104 if (size > LS_SIZE - pos)
105 size = LS_SIZE - pos;
108 local_store = ctx->ops->get_ls(ctx);
109 ret = copy_from_user(local_store + pos, buffer, size);
118 static unsigned long spufs_mem_mmap_nopfn(struct vm_area_struct *vma,
119 unsigned long address)
121 struct spu_context *ctx = vma->vm_file->private_data;
122 unsigned long pfn, offset = address - vma->vm_start;
124 offset += vma->vm_pgoff << PAGE_SHIFT;
126 if (offset >= LS_SIZE)
131 if (ctx->state == SPU_STATE_SAVED) {
132 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
134 pfn = vmalloc_to_pfn(ctx->csa.lscsa->ls + offset);
136 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
138 pfn = (ctx->spu->local_store_phys + offset) >> PAGE_SHIFT;
140 vm_insert_pfn(vma, address, pfn);
144 return NOPFN_REFAULT;
148 static struct vm_operations_struct spufs_mem_mmap_vmops = {
149 .nopfn = spufs_mem_mmap_nopfn,
153 spufs_mem_mmap(struct file *file, struct vm_area_struct *vma)
155 if (!(vma->vm_flags & VM_SHARED))
158 vma->vm_flags |= VM_IO | VM_PFNMAP;
159 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
162 vma->vm_ops = &spufs_mem_mmap_vmops;
166 static const struct file_operations spufs_mem_fops = {
167 .open = spufs_mem_open,
168 .release = spufs_mem_release,
169 .read = spufs_mem_read,
170 .write = spufs_mem_write,
171 .llseek = generic_file_llseek,
172 .mmap = spufs_mem_mmap,
175 static unsigned long spufs_ps_nopfn(struct vm_area_struct *vma,
176 unsigned long address,
177 unsigned long ps_offs,
178 unsigned long ps_size)
180 struct spu_context *ctx = vma->vm_file->private_data;
181 unsigned long area, offset = address - vma->vm_start;
184 offset += vma->vm_pgoff << PAGE_SHIFT;
185 if (offset >= ps_size)
188 /* error here usually means a signal.. we might want to test
189 * the error code more precisely though
191 ret = spu_acquire_runnable(ctx, 0);
193 return NOPFN_REFAULT;
195 area = ctx->spu->problem_phys + ps_offs;
196 vm_insert_pfn(vma, address, (area + offset) >> PAGE_SHIFT);
199 return NOPFN_REFAULT;
203 static unsigned long spufs_cntl_mmap_nopfn(struct vm_area_struct *vma,
204 unsigned long address)
206 return spufs_ps_nopfn(vma, address, 0x4000, 0x1000);
209 static struct vm_operations_struct spufs_cntl_mmap_vmops = {
210 .nopfn = spufs_cntl_mmap_nopfn,
214 * mmap support for problem state control area [0x4000 - 0x4fff].
216 static int spufs_cntl_mmap(struct file *file, struct vm_area_struct *vma)
218 if (!(vma->vm_flags & VM_SHARED))
221 vma->vm_flags |= VM_IO | VM_PFNMAP;
222 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
223 | _PAGE_NO_CACHE | _PAGE_GUARDED);
225 vma->vm_ops = &spufs_cntl_mmap_vmops;
228 #else /* SPUFS_MMAP_4K */
229 #define spufs_cntl_mmap NULL
230 #endif /* !SPUFS_MMAP_4K */
232 static u64 spufs_cntl_get(void *data)
234 struct spu_context *ctx = data;
238 val = ctx->ops->status_read(ctx);
244 static void spufs_cntl_set(void *data, u64 val)
246 struct spu_context *ctx = data;
249 ctx->ops->runcntl_write(ctx, val);
253 static int spufs_cntl_open(struct inode *inode, struct file *file)
255 struct spufs_inode_info *i = SPUFS_I(inode);
256 struct spu_context *ctx = i->i_ctx;
258 spin_lock(&ctx->mapping_lock);
259 file->private_data = ctx;
261 ctx->cntl = inode->i_mapping;
262 spin_unlock(&ctx->mapping_lock);
263 return simple_attr_open(inode, file, spufs_cntl_get,
264 spufs_cntl_set, "0x%08lx");
268 spufs_cntl_release(struct inode *inode, struct file *file)
270 struct spufs_inode_info *i = SPUFS_I(inode);
271 struct spu_context *ctx = i->i_ctx;
273 simple_attr_close(inode, file);
275 spin_lock(&ctx->mapping_lock);
278 spin_unlock(&ctx->mapping_lock);
282 static const struct file_operations spufs_cntl_fops = {
283 .open = spufs_cntl_open,
284 .release = spufs_cntl_release,
285 .read = simple_attr_read,
286 .write = simple_attr_write,
287 .mmap = spufs_cntl_mmap,
291 spufs_regs_open(struct inode *inode, struct file *file)
293 struct spufs_inode_info *i = SPUFS_I(inode);
294 file->private_data = i->i_ctx;
299 __spufs_regs_read(struct spu_context *ctx, char __user *buffer,
300 size_t size, loff_t *pos)
302 struct spu_lscsa *lscsa = ctx->csa.lscsa;
303 return simple_read_from_buffer(buffer, size, pos,
304 lscsa->gprs, sizeof lscsa->gprs);
308 spufs_regs_read(struct file *file, char __user *buffer,
309 size_t size, loff_t *pos)
312 struct spu_context *ctx = file->private_data;
314 spu_acquire_saved(ctx);
315 ret = __spufs_regs_read(ctx, buffer, size, pos);
321 spufs_regs_write(struct file *file, const char __user *buffer,
322 size_t size, loff_t *pos)
324 struct spu_context *ctx = file->private_data;
325 struct spu_lscsa *lscsa = ctx->csa.lscsa;
328 size = min_t(ssize_t, sizeof lscsa->gprs - *pos, size);
333 spu_acquire_saved(ctx);
335 ret = copy_from_user(lscsa->gprs + *pos - size,
336 buffer, size) ? -EFAULT : size;
342 static const struct file_operations spufs_regs_fops = {
343 .open = spufs_regs_open,
344 .read = spufs_regs_read,
345 .write = spufs_regs_write,
346 .llseek = generic_file_llseek,
350 __spufs_fpcr_read(struct spu_context *ctx, char __user * buffer,
351 size_t size, loff_t * pos)
353 struct spu_lscsa *lscsa = ctx->csa.lscsa;
354 return simple_read_from_buffer(buffer, size, pos,
355 &lscsa->fpcr, sizeof(lscsa->fpcr));
359 spufs_fpcr_read(struct file *file, char __user * buffer,
360 size_t size, loff_t * pos)
363 struct spu_context *ctx = file->private_data;
365 spu_acquire_saved(ctx);
366 ret = __spufs_fpcr_read(ctx, buffer, size, pos);
372 spufs_fpcr_write(struct file *file, const char __user * buffer,
373 size_t size, loff_t * pos)
375 struct spu_context *ctx = file->private_data;
376 struct spu_lscsa *lscsa = ctx->csa.lscsa;
379 size = min_t(ssize_t, sizeof(lscsa->fpcr) - *pos, size);
384 spu_acquire_saved(ctx);
386 ret = copy_from_user((char *)&lscsa->fpcr + *pos - size,
387 buffer, size) ? -EFAULT : size;
393 static const struct file_operations spufs_fpcr_fops = {
394 .open = spufs_regs_open,
395 .read = spufs_fpcr_read,
396 .write = spufs_fpcr_write,
397 .llseek = generic_file_llseek,
400 /* generic open function for all pipe-like files */
401 static int spufs_pipe_open(struct inode *inode, struct file *file)
403 struct spufs_inode_info *i = SPUFS_I(inode);
404 file->private_data = i->i_ctx;
406 return nonseekable_open(inode, file);
410 * Read as many bytes from the mailbox as possible, until
411 * one of the conditions becomes true:
413 * - no more data available in the mailbox
414 * - end of the user provided buffer
415 * - end of the mapped area
417 static ssize_t spufs_mbox_read(struct file *file, char __user *buf,
418 size_t len, loff_t *pos)
420 struct spu_context *ctx = file->private_data;
421 u32 mbox_data, __user *udata;
427 if (!access_ok(VERIFY_WRITE, buf, len))
430 udata = (void __user *)buf;
433 for (count = 0; (count + 4) <= len; count += 4, udata++) {
435 ret = ctx->ops->mbox_read(ctx, &mbox_data);
440 * at the end of the mapped area, we can fault
441 * but still need to return the data we have
442 * read successfully so far.
444 ret = __put_user(mbox_data, udata);
459 static const struct file_operations spufs_mbox_fops = {
460 .open = spufs_pipe_open,
461 .read = spufs_mbox_read,
464 static ssize_t spufs_mbox_stat_read(struct file *file, char __user *buf,
465 size_t len, loff_t *pos)
467 struct spu_context *ctx = file->private_data;
475 mbox_stat = ctx->ops->mbox_stat_read(ctx) & 0xff;
479 if (copy_to_user(buf, &mbox_stat, sizeof mbox_stat))
485 static const struct file_operations spufs_mbox_stat_fops = {
486 .open = spufs_pipe_open,
487 .read = spufs_mbox_stat_read,
490 /* low-level ibox access function */
491 size_t spu_ibox_read(struct spu_context *ctx, u32 *data)
493 return ctx->ops->ibox_read(ctx, data);
496 static int spufs_ibox_fasync(int fd, struct file *file, int on)
498 struct spu_context *ctx = file->private_data;
500 return fasync_helper(fd, file, on, &ctx->ibox_fasync);
503 /* interrupt-level ibox callback function. */
504 void spufs_ibox_callback(struct spu *spu)
506 struct spu_context *ctx = spu->ctx;
508 wake_up_all(&ctx->ibox_wq);
509 kill_fasync(&ctx->ibox_fasync, SIGIO, POLLIN);
513 * Read as many bytes from the interrupt mailbox as possible, until
514 * one of the conditions becomes true:
516 * - no more data available in the mailbox
517 * - end of the user provided buffer
518 * - end of the mapped area
520 * If the file is opened without O_NONBLOCK, we wait here until
521 * any data is available, but return when we have been able to
524 static ssize_t spufs_ibox_read(struct file *file, char __user *buf,
525 size_t len, loff_t *pos)
527 struct spu_context *ctx = file->private_data;
528 u32 ibox_data, __user *udata;
534 if (!access_ok(VERIFY_WRITE, buf, len))
537 udata = (void __user *)buf;
541 /* wait only for the first element */
543 if (file->f_flags & O_NONBLOCK) {
544 if (!spu_ibox_read(ctx, &ibox_data))
547 count = spufs_wait(ctx->ibox_wq, spu_ibox_read(ctx, &ibox_data));
552 /* if we can't write at all, return -EFAULT */
553 count = __put_user(ibox_data, udata);
557 for (count = 4, udata++; (count + 4) <= len; count += 4, udata++) {
559 ret = ctx->ops->ibox_read(ctx, &ibox_data);
563 * at the end of the mapped area, we can fault
564 * but still need to return the data we have
565 * read successfully so far.
567 ret = __put_user(ibox_data, udata);
578 static unsigned int spufs_ibox_poll(struct file *file, poll_table *wait)
580 struct spu_context *ctx = file->private_data;
583 poll_wait(file, &ctx->ibox_wq, wait);
586 mask = ctx->ops->mbox_stat_poll(ctx, POLLIN | POLLRDNORM);
592 static const struct file_operations spufs_ibox_fops = {
593 .open = spufs_pipe_open,
594 .read = spufs_ibox_read,
595 .poll = spufs_ibox_poll,
596 .fasync = spufs_ibox_fasync,
599 static ssize_t spufs_ibox_stat_read(struct file *file, char __user *buf,
600 size_t len, loff_t *pos)
602 struct spu_context *ctx = file->private_data;
609 ibox_stat = (ctx->ops->mbox_stat_read(ctx) >> 16) & 0xff;
612 if (copy_to_user(buf, &ibox_stat, sizeof ibox_stat))
618 static const struct file_operations spufs_ibox_stat_fops = {
619 .open = spufs_pipe_open,
620 .read = spufs_ibox_stat_read,
623 /* low-level mailbox write */
624 size_t spu_wbox_write(struct spu_context *ctx, u32 data)
626 return ctx->ops->wbox_write(ctx, data);
629 static int spufs_wbox_fasync(int fd, struct file *file, int on)
631 struct spu_context *ctx = file->private_data;
634 ret = fasync_helper(fd, file, on, &ctx->wbox_fasync);
639 /* interrupt-level wbox callback function. */
640 void spufs_wbox_callback(struct spu *spu)
642 struct spu_context *ctx = spu->ctx;
644 wake_up_all(&ctx->wbox_wq);
645 kill_fasync(&ctx->wbox_fasync, SIGIO, POLLOUT);
649 * Write as many bytes to the interrupt mailbox as possible, until
650 * one of the conditions becomes true:
652 * - the mailbox is full
653 * - end of the user provided buffer
654 * - end of the mapped area
656 * If the file is opened without O_NONBLOCK, we wait here until
657 * space is availabyl, but return when we have been able to
660 static ssize_t spufs_wbox_write(struct file *file, const char __user *buf,
661 size_t len, loff_t *pos)
663 struct spu_context *ctx = file->private_data;
664 u32 wbox_data, __user *udata;
670 udata = (void __user *)buf;
671 if (!access_ok(VERIFY_READ, buf, len))
674 if (__get_user(wbox_data, udata))
680 * make sure we can at least write one element, by waiting
681 * in case of !O_NONBLOCK
684 if (file->f_flags & O_NONBLOCK) {
685 if (!spu_wbox_write(ctx, wbox_data))
688 count = spufs_wait(ctx->wbox_wq, spu_wbox_write(ctx, wbox_data));
694 /* write aѕ much as possible */
695 for (count = 4, udata++; (count + 4) <= len; count += 4, udata++) {
697 ret = __get_user(wbox_data, udata);
701 ret = spu_wbox_write(ctx, wbox_data);
711 static unsigned int spufs_wbox_poll(struct file *file, poll_table *wait)
713 struct spu_context *ctx = file->private_data;
716 poll_wait(file, &ctx->wbox_wq, wait);
719 mask = ctx->ops->mbox_stat_poll(ctx, POLLOUT | POLLWRNORM);
725 static const struct file_operations spufs_wbox_fops = {
726 .open = spufs_pipe_open,
727 .write = spufs_wbox_write,
728 .poll = spufs_wbox_poll,
729 .fasync = spufs_wbox_fasync,
732 static ssize_t spufs_wbox_stat_read(struct file *file, char __user *buf,
733 size_t len, loff_t *pos)
735 struct spu_context *ctx = file->private_data;
742 wbox_stat = (ctx->ops->mbox_stat_read(ctx) >> 8) & 0xff;
745 if (copy_to_user(buf, &wbox_stat, sizeof wbox_stat))
751 static const struct file_operations spufs_wbox_stat_fops = {
752 .open = spufs_pipe_open,
753 .read = spufs_wbox_stat_read,
756 static int spufs_signal1_open(struct inode *inode, struct file *file)
758 struct spufs_inode_info *i = SPUFS_I(inode);
759 struct spu_context *ctx = i->i_ctx;
761 spin_lock(&ctx->mapping_lock);
762 file->private_data = ctx;
764 ctx->signal1 = inode->i_mapping;
765 spin_unlock(&ctx->mapping_lock);
766 return nonseekable_open(inode, file);
770 spufs_signal1_release(struct inode *inode, struct file *file)
772 struct spufs_inode_info *i = SPUFS_I(inode);
773 struct spu_context *ctx = i->i_ctx;
775 spin_lock(&ctx->mapping_lock);
778 spin_unlock(&ctx->mapping_lock);
782 static ssize_t __spufs_signal1_read(struct spu_context *ctx, char __user *buf,
783 size_t len, loff_t *pos)
791 if (ctx->csa.spu_chnlcnt_RW[3]) {
792 data = ctx->csa.spu_chnldata_RW[3];
799 if (copy_to_user(buf, &data, 4))
806 static ssize_t spufs_signal1_read(struct file *file, char __user *buf,
807 size_t len, loff_t *pos)
810 struct spu_context *ctx = file->private_data;
812 spu_acquire_saved(ctx);
813 ret = __spufs_signal1_read(ctx, buf, len, pos);
819 static ssize_t spufs_signal1_write(struct file *file, const char __user *buf,
820 size_t len, loff_t *pos)
822 struct spu_context *ctx;
825 ctx = file->private_data;
830 if (copy_from_user(&data, buf, 4))
834 ctx->ops->signal1_write(ctx, data);
840 static unsigned long spufs_signal1_mmap_nopfn(struct vm_area_struct *vma,
841 unsigned long address)
843 #if PAGE_SIZE == 0x1000
844 return spufs_ps_nopfn(vma, address, 0x14000, 0x1000);
845 #elif PAGE_SIZE == 0x10000
846 /* For 64k pages, both signal1 and signal2 can be used to mmap the whole
847 * signal 1 and 2 area
849 return spufs_ps_nopfn(vma, address, 0x10000, 0x10000);
851 #error unsupported page size
855 static struct vm_operations_struct spufs_signal1_mmap_vmops = {
856 .nopfn = spufs_signal1_mmap_nopfn,
859 static int spufs_signal1_mmap(struct file *file, struct vm_area_struct *vma)
861 if (!(vma->vm_flags & VM_SHARED))
864 vma->vm_flags |= VM_IO | VM_PFNMAP;
865 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
866 | _PAGE_NO_CACHE | _PAGE_GUARDED);
868 vma->vm_ops = &spufs_signal1_mmap_vmops;
872 static const struct file_operations spufs_signal1_fops = {
873 .open = spufs_signal1_open,
874 .release = spufs_signal1_release,
875 .read = spufs_signal1_read,
876 .write = spufs_signal1_write,
877 .mmap = spufs_signal1_mmap,
880 static int spufs_signal2_open(struct inode *inode, struct file *file)
882 struct spufs_inode_info *i = SPUFS_I(inode);
883 struct spu_context *ctx = i->i_ctx;
885 spin_lock(&ctx->mapping_lock);
886 file->private_data = ctx;
888 ctx->signal2 = inode->i_mapping;
889 spin_unlock(&ctx->mapping_lock);
890 return nonseekable_open(inode, file);
894 spufs_signal2_release(struct inode *inode, struct file *file)
896 struct spufs_inode_info *i = SPUFS_I(inode);
897 struct spu_context *ctx = i->i_ctx;
899 spin_lock(&ctx->mapping_lock);
902 spin_unlock(&ctx->mapping_lock);
906 static ssize_t __spufs_signal2_read(struct spu_context *ctx, char __user *buf,
907 size_t len, loff_t *pos)
915 if (ctx->csa.spu_chnlcnt_RW[4]) {
916 data = ctx->csa.spu_chnldata_RW[4];
923 if (copy_to_user(buf, &data, 4))
930 static ssize_t spufs_signal2_read(struct file *file, char __user *buf,
931 size_t len, loff_t *pos)
933 struct spu_context *ctx = file->private_data;
936 spu_acquire_saved(ctx);
937 ret = __spufs_signal2_read(ctx, buf, len, pos);
943 static ssize_t spufs_signal2_write(struct file *file, const char __user *buf,
944 size_t len, loff_t *pos)
946 struct spu_context *ctx;
949 ctx = file->private_data;
954 if (copy_from_user(&data, buf, 4))
958 ctx->ops->signal2_write(ctx, data);
965 static unsigned long spufs_signal2_mmap_nopfn(struct vm_area_struct *vma,
966 unsigned long address)
968 #if PAGE_SIZE == 0x1000
969 return spufs_ps_nopfn(vma, address, 0x1c000, 0x1000);
970 #elif PAGE_SIZE == 0x10000
971 /* For 64k pages, both signal1 and signal2 can be used to mmap the whole
972 * signal 1 and 2 area
974 return spufs_ps_nopfn(vma, address, 0x10000, 0x10000);
976 #error unsupported page size
980 static struct vm_operations_struct spufs_signal2_mmap_vmops = {
981 .nopfn = spufs_signal2_mmap_nopfn,
984 static int spufs_signal2_mmap(struct file *file, struct vm_area_struct *vma)
986 if (!(vma->vm_flags & VM_SHARED))
989 vma->vm_flags |= VM_IO | VM_PFNMAP;
990 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
991 | _PAGE_NO_CACHE | _PAGE_GUARDED);
993 vma->vm_ops = &spufs_signal2_mmap_vmops;
996 #else /* SPUFS_MMAP_4K */
997 #define spufs_signal2_mmap NULL
998 #endif /* !SPUFS_MMAP_4K */
1000 static const struct file_operations spufs_signal2_fops = {
1001 .open = spufs_signal2_open,
1002 .release = spufs_signal2_release,
1003 .read = spufs_signal2_read,
1004 .write = spufs_signal2_write,
1005 .mmap = spufs_signal2_mmap,
1008 static void spufs_signal1_type_set(void *data, u64 val)
1010 struct spu_context *ctx = data;
1013 ctx->ops->signal1_type_set(ctx, val);
1017 static u64 __spufs_signal1_type_get(void *data)
1019 struct spu_context *ctx = data;
1020 return ctx->ops->signal1_type_get(ctx);
1023 static u64 spufs_signal1_type_get(void *data)
1025 struct spu_context *ctx = data;
1029 ret = __spufs_signal1_type_get(data);
1034 DEFINE_SIMPLE_ATTRIBUTE(spufs_signal1_type, spufs_signal1_type_get,
1035 spufs_signal1_type_set, "%llu");
1037 static void spufs_signal2_type_set(void *data, u64 val)
1039 struct spu_context *ctx = data;
1042 ctx->ops->signal2_type_set(ctx, val);
1046 static u64 __spufs_signal2_type_get(void *data)
1048 struct spu_context *ctx = data;
1049 return ctx->ops->signal2_type_get(ctx);
1052 static u64 spufs_signal2_type_get(void *data)
1054 struct spu_context *ctx = data;
1058 ret = __spufs_signal2_type_get(data);
1063 DEFINE_SIMPLE_ATTRIBUTE(spufs_signal2_type, spufs_signal2_type_get,
1064 spufs_signal2_type_set, "%llu");
1067 static unsigned long spufs_mss_mmap_nopfn(struct vm_area_struct *vma,
1068 unsigned long address)
1070 return spufs_ps_nopfn(vma, address, 0x0000, 0x1000);
1073 static struct vm_operations_struct spufs_mss_mmap_vmops = {
1074 .nopfn = spufs_mss_mmap_nopfn,
1078 * mmap support for problem state MFC DMA area [0x0000 - 0x0fff].
1080 static int spufs_mss_mmap(struct file *file, struct vm_area_struct *vma)
1082 if (!(vma->vm_flags & VM_SHARED))
1085 vma->vm_flags |= VM_IO | VM_PFNMAP;
1086 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
1087 | _PAGE_NO_CACHE | _PAGE_GUARDED);
1089 vma->vm_ops = &spufs_mss_mmap_vmops;
1092 #else /* SPUFS_MMAP_4K */
1093 #define spufs_mss_mmap NULL
1094 #endif /* !SPUFS_MMAP_4K */
1096 static int spufs_mss_open(struct inode *inode, struct file *file)
1098 struct spufs_inode_info *i = SPUFS_I(inode);
1099 struct spu_context *ctx = i->i_ctx;
1101 file->private_data = i->i_ctx;
1103 spin_lock(&ctx->mapping_lock);
1104 if (!i->i_openers++)
1105 ctx->mss = inode->i_mapping;
1106 spin_unlock(&ctx->mapping_lock);
1107 return nonseekable_open(inode, file);
1111 spufs_mss_release(struct inode *inode, struct file *file)
1113 struct spufs_inode_info *i = SPUFS_I(inode);
1114 struct spu_context *ctx = i->i_ctx;
1116 spin_lock(&ctx->mapping_lock);
1117 if (!--i->i_openers)
1119 spin_unlock(&ctx->mapping_lock);
1123 static const struct file_operations spufs_mss_fops = {
1124 .open = spufs_mss_open,
1125 .release = spufs_mss_release,
1126 .mmap = spufs_mss_mmap,
1129 static unsigned long spufs_psmap_mmap_nopfn(struct vm_area_struct *vma,
1130 unsigned long address)
1132 return spufs_ps_nopfn(vma, address, 0x0000, 0x20000);
1135 static struct vm_operations_struct spufs_psmap_mmap_vmops = {
1136 .nopfn = spufs_psmap_mmap_nopfn,
1140 * mmap support for full problem state area [0x00000 - 0x1ffff].
1142 static int spufs_psmap_mmap(struct file *file, struct vm_area_struct *vma)
1144 if (!(vma->vm_flags & VM_SHARED))
1147 vma->vm_flags |= VM_IO | VM_PFNMAP;
1148 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
1149 | _PAGE_NO_CACHE | _PAGE_GUARDED);
1151 vma->vm_ops = &spufs_psmap_mmap_vmops;
1155 static int spufs_psmap_open(struct inode *inode, struct file *file)
1157 struct spufs_inode_info *i = SPUFS_I(inode);
1158 struct spu_context *ctx = i->i_ctx;
1160 spin_lock(&ctx->mapping_lock);
1161 file->private_data = i->i_ctx;
1162 if (!i->i_openers++)
1163 ctx->psmap = inode->i_mapping;
1164 spin_unlock(&ctx->mapping_lock);
1165 return nonseekable_open(inode, file);
1169 spufs_psmap_release(struct inode *inode, struct file *file)
1171 struct spufs_inode_info *i = SPUFS_I(inode);
1172 struct spu_context *ctx = i->i_ctx;
1174 spin_lock(&ctx->mapping_lock);
1175 if (!--i->i_openers)
1177 spin_unlock(&ctx->mapping_lock);
1181 static const struct file_operations spufs_psmap_fops = {
1182 .open = spufs_psmap_open,
1183 .release = spufs_psmap_release,
1184 .mmap = spufs_psmap_mmap,
1189 static unsigned long spufs_mfc_mmap_nopfn(struct vm_area_struct *vma,
1190 unsigned long address)
1192 return spufs_ps_nopfn(vma, address, 0x3000, 0x1000);
1195 static struct vm_operations_struct spufs_mfc_mmap_vmops = {
1196 .nopfn = spufs_mfc_mmap_nopfn,
1200 * mmap support for problem state MFC DMA area [0x0000 - 0x0fff].
1202 static int spufs_mfc_mmap(struct file *file, struct vm_area_struct *vma)
1204 if (!(vma->vm_flags & VM_SHARED))
1207 vma->vm_flags |= VM_IO | VM_PFNMAP;
1208 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
1209 | _PAGE_NO_CACHE | _PAGE_GUARDED);
1211 vma->vm_ops = &spufs_mfc_mmap_vmops;
1214 #else /* SPUFS_MMAP_4K */
1215 #define spufs_mfc_mmap NULL
1216 #endif /* !SPUFS_MMAP_4K */
1218 static int spufs_mfc_open(struct inode *inode, struct file *file)
1220 struct spufs_inode_info *i = SPUFS_I(inode);
1221 struct spu_context *ctx = i->i_ctx;
1223 /* we don't want to deal with DMA into other processes */
1224 if (ctx->owner != current->mm)
1227 if (atomic_read(&inode->i_count) != 1)
1230 spin_lock(&ctx->mapping_lock);
1231 file->private_data = ctx;
1232 if (!i->i_openers++)
1233 ctx->mfc = inode->i_mapping;
1234 spin_unlock(&ctx->mapping_lock);
1235 return nonseekable_open(inode, file);
1239 spufs_mfc_release(struct inode *inode, struct file *file)
1241 struct spufs_inode_info *i = SPUFS_I(inode);
1242 struct spu_context *ctx = i->i_ctx;
1244 spin_lock(&ctx->mapping_lock);
1245 if (!--i->i_openers)
1247 spin_unlock(&ctx->mapping_lock);
1251 /* interrupt-level mfc callback function. */
1252 void spufs_mfc_callback(struct spu *spu)
1254 struct spu_context *ctx = spu->ctx;
1256 wake_up_all(&ctx->mfc_wq);
1258 pr_debug("%s %s\n", __FUNCTION__, spu->name);
1259 if (ctx->mfc_fasync) {
1260 u32 free_elements, tagstatus;
1263 /* no need for spu_acquire in interrupt context */
1264 free_elements = ctx->ops->get_mfc_free_elements(ctx);
1265 tagstatus = ctx->ops->read_mfc_tagstatus(ctx);
1268 if (free_elements & 0xffff)
1270 if (tagstatus & ctx->tagwait)
1273 kill_fasync(&ctx->mfc_fasync, SIGIO, mask);
1277 static int spufs_read_mfc_tagstatus(struct spu_context *ctx, u32 *status)
1279 /* See if there is one tag group is complete */
1280 /* FIXME we need locking around tagwait */
1281 *status = ctx->ops->read_mfc_tagstatus(ctx) & ctx->tagwait;
1282 ctx->tagwait &= ~*status;
1286 /* enable interrupt waiting for any tag group,
1287 may silently fail if interrupts are already enabled */
1288 ctx->ops->set_mfc_query(ctx, ctx->tagwait, 1);
1292 static ssize_t spufs_mfc_read(struct file *file, char __user *buffer,
1293 size_t size, loff_t *pos)
1295 struct spu_context *ctx = file->private_data;
1303 if (file->f_flags & O_NONBLOCK) {
1304 status = ctx->ops->read_mfc_tagstatus(ctx);
1305 if (!(status & ctx->tagwait))
1308 ctx->tagwait &= ~status;
1310 ret = spufs_wait(ctx->mfc_wq,
1311 spufs_read_mfc_tagstatus(ctx, &status));
1319 if (copy_to_user(buffer, &status, 4))
1326 static int spufs_check_valid_dma(struct mfc_dma_command *cmd)
1328 pr_debug("queueing DMA %x %lx %x %x %x\n", cmd->lsa,
1329 cmd->ea, cmd->size, cmd->tag, cmd->cmd);
1340 pr_debug("invalid DMA opcode %x\n", cmd->cmd);
1344 if ((cmd->lsa & 0xf) != (cmd->ea &0xf)) {
1345 pr_debug("invalid DMA alignment, ea %lx lsa %x\n",
1350 switch (cmd->size & 0xf) {
1371 pr_debug("invalid DMA alignment %x for size %x\n",
1372 cmd->lsa & 0xf, cmd->size);
1376 if (cmd->size > 16 * 1024) {
1377 pr_debug("invalid DMA size %x\n", cmd->size);
1381 if (cmd->tag & 0xfff0) {
1382 /* we reserve the higher tag numbers for kernel use */
1383 pr_debug("invalid DMA tag\n");
1388 /* not supported in this version */
1389 pr_debug("invalid DMA class\n");
1396 static int spu_send_mfc_command(struct spu_context *ctx,
1397 struct mfc_dma_command cmd,
1400 *error = ctx->ops->send_mfc_command(ctx, &cmd);
1401 if (*error == -EAGAIN) {
1402 /* wait for any tag group to complete
1403 so we have space for the new command */
1404 ctx->ops->set_mfc_query(ctx, ctx->tagwait, 1);
1405 /* try again, because the queue might be
1407 *error = ctx->ops->send_mfc_command(ctx, &cmd);
1408 if (*error == -EAGAIN)
1414 static ssize_t spufs_mfc_write(struct file *file, const char __user *buffer,
1415 size_t size, loff_t *pos)
1417 struct spu_context *ctx = file->private_data;
1418 struct mfc_dma_command cmd;
1421 if (size != sizeof cmd)
1425 if (copy_from_user(&cmd, buffer, sizeof cmd))
1428 ret = spufs_check_valid_dma(&cmd);
1432 ret = spu_acquire_runnable(ctx, 0);
1436 if (file->f_flags & O_NONBLOCK) {
1437 ret = ctx->ops->send_mfc_command(ctx, &cmd);
1440 ret = spufs_wait(ctx->mfc_wq,
1441 spu_send_mfc_command(ctx, cmd, &status));
1450 ctx->tagwait |= 1 << cmd.tag;
1457 static unsigned int spufs_mfc_poll(struct file *file,poll_table *wait)
1459 struct spu_context *ctx = file->private_data;
1460 u32 free_elements, tagstatus;
1464 ctx->ops->set_mfc_query(ctx, ctx->tagwait, 2);
1465 free_elements = ctx->ops->get_mfc_free_elements(ctx);
1466 tagstatus = ctx->ops->read_mfc_tagstatus(ctx);
1469 poll_wait(file, &ctx->mfc_wq, wait);
1472 if (free_elements & 0xffff)
1473 mask |= POLLOUT | POLLWRNORM;
1474 if (tagstatus & ctx->tagwait)
1475 mask |= POLLIN | POLLRDNORM;
1477 pr_debug("%s: free %d tagstatus %d tagwait %d\n", __FUNCTION__,
1478 free_elements, tagstatus, ctx->tagwait);
1483 static int spufs_mfc_flush(struct file *file, fl_owner_t id)
1485 struct spu_context *ctx = file->private_data;
1490 /* this currently hangs */
1491 ret = spufs_wait(ctx->mfc_wq,
1492 ctx->ops->set_mfc_query(ctx, ctx->tagwait, 2));
1495 ret = spufs_wait(ctx->mfc_wq,
1496 ctx->ops->read_mfc_tagstatus(ctx) == ctx->tagwait);
1506 static int spufs_mfc_fsync(struct file *file, struct dentry *dentry,
1509 return spufs_mfc_flush(file, NULL);
1512 static int spufs_mfc_fasync(int fd, struct file *file, int on)
1514 struct spu_context *ctx = file->private_data;
1516 return fasync_helper(fd, file, on, &ctx->mfc_fasync);
1519 static const struct file_operations spufs_mfc_fops = {
1520 .open = spufs_mfc_open,
1521 .release = spufs_mfc_release,
1522 .read = spufs_mfc_read,
1523 .write = spufs_mfc_write,
1524 .poll = spufs_mfc_poll,
1525 .flush = spufs_mfc_flush,
1526 .fsync = spufs_mfc_fsync,
1527 .fasync = spufs_mfc_fasync,
1528 .mmap = spufs_mfc_mmap,
1531 static void spufs_npc_set(void *data, u64 val)
1533 struct spu_context *ctx = data;
1535 ctx->ops->npc_write(ctx, val);
1539 static u64 spufs_npc_get(void *data)
1541 struct spu_context *ctx = data;
1544 ret = ctx->ops->npc_read(ctx);
1548 DEFINE_SIMPLE_ATTRIBUTE(spufs_npc_ops, spufs_npc_get, spufs_npc_set,
1551 static void spufs_decr_set(void *data, u64 val)
1553 struct spu_context *ctx = data;
1554 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1555 spu_acquire_saved(ctx);
1556 lscsa->decr.slot[0] = (u32) val;
1560 static u64 __spufs_decr_get(void *data)
1562 struct spu_context *ctx = data;
1563 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1564 return lscsa->decr.slot[0];
1567 static u64 spufs_decr_get(void *data)
1569 struct spu_context *ctx = data;
1571 spu_acquire_saved(ctx);
1572 ret = __spufs_decr_get(data);
1576 DEFINE_SIMPLE_ATTRIBUTE(spufs_decr_ops, spufs_decr_get, spufs_decr_set,
1579 static void spufs_decr_status_set(void *data, u64 val)
1581 struct spu_context *ctx = data;
1582 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1583 spu_acquire_saved(ctx);
1584 lscsa->decr_status.slot[0] = (u32) val;
1588 static u64 __spufs_decr_status_get(void *data)
1590 struct spu_context *ctx = data;
1591 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1592 return lscsa->decr_status.slot[0];
1595 static u64 spufs_decr_status_get(void *data)
1597 struct spu_context *ctx = data;
1599 spu_acquire_saved(ctx);
1600 ret = __spufs_decr_status_get(data);
1604 DEFINE_SIMPLE_ATTRIBUTE(spufs_decr_status_ops, spufs_decr_status_get,
1605 spufs_decr_status_set, "0x%llx\n")
1607 static void spufs_event_mask_set(void *data, u64 val)
1609 struct spu_context *ctx = data;
1610 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1611 spu_acquire_saved(ctx);
1612 lscsa->event_mask.slot[0] = (u32) val;
1616 static u64 __spufs_event_mask_get(void *data)
1618 struct spu_context *ctx = data;
1619 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1620 return lscsa->event_mask.slot[0];
1623 static u64 spufs_event_mask_get(void *data)
1625 struct spu_context *ctx = data;
1627 spu_acquire_saved(ctx);
1628 ret = __spufs_event_mask_get(data);
1632 DEFINE_SIMPLE_ATTRIBUTE(spufs_event_mask_ops, spufs_event_mask_get,
1633 spufs_event_mask_set, "0x%llx\n")
1635 static u64 __spufs_event_status_get(void *data)
1637 struct spu_context *ctx = data;
1638 struct spu_state *state = &ctx->csa;
1640 stat = state->spu_chnlcnt_RW[0];
1642 return state->spu_chnldata_RW[0];
1646 static u64 spufs_event_status_get(void *data)
1648 struct spu_context *ctx = data;
1651 spu_acquire_saved(ctx);
1652 ret = __spufs_event_status_get(data);
1656 DEFINE_SIMPLE_ATTRIBUTE(spufs_event_status_ops, spufs_event_status_get,
1659 static void spufs_srr0_set(void *data, u64 val)
1661 struct spu_context *ctx = data;
1662 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1663 spu_acquire_saved(ctx);
1664 lscsa->srr0.slot[0] = (u32) val;
1668 static u64 spufs_srr0_get(void *data)
1670 struct spu_context *ctx = data;
1671 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1673 spu_acquire_saved(ctx);
1674 ret = lscsa->srr0.slot[0];
1678 DEFINE_SIMPLE_ATTRIBUTE(spufs_srr0_ops, spufs_srr0_get, spufs_srr0_set,
1681 static u64 spufs_id_get(void *data)
1683 struct spu_context *ctx = data;
1687 if (ctx->state == SPU_STATE_RUNNABLE)
1688 num = ctx->spu->number;
1690 num = (unsigned int)-1;
1695 DEFINE_SIMPLE_ATTRIBUTE(spufs_id_ops, spufs_id_get, NULL, "0x%llx\n")
1697 static u64 __spufs_object_id_get(void *data)
1699 struct spu_context *ctx = data;
1700 return ctx->object_id;
1703 static u64 spufs_object_id_get(void *data)
1705 /* FIXME: Should there really be no locking here? */
1706 return __spufs_object_id_get(data);
1709 static void spufs_object_id_set(void *data, u64 id)
1711 struct spu_context *ctx = data;
1712 ctx->object_id = id;
1715 DEFINE_SIMPLE_ATTRIBUTE(spufs_object_id_ops, spufs_object_id_get,
1716 spufs_object_id_set, "0x%llx\n");
1718 static u64 __spufs_lslr_get(void *data)
1720 struct spu_context *ctx = data;
1721 return ctx->csa.priv2.spu_lslr_RW;
1724 static u64 spufs_lslr_get(void *data)
1726 struct spu_context *ctx = data;
1729 spu_acquire_saved(ctx);
1730 ret = __spufs_lslr_get(data);
1735 DEFINE_SIMPLE_ATTRIBUTE(spufs_lslr_ops, spufs_lslr_get, NULL, "0x%llx\n")
1737 static int spufs_info_open(struct inode *inode, struct file *file)
1739 struct spufs_inode_info *i = SPUFS_I(inode);
1740 struct spu_context *ctx = i->i_ctx;
1741 file->private_data = ctx;
1745 static ssize_t __spufs_mbox_info_read(struct spu_context *ctx,
1746 char __user *buf, size_t len, loff_t *pos)
1751 mbox_stat = ctx->csa.prob.mb_stat_R;
1752 if (mbox_stat & 0x0000ff) {
1753 data = ctx->csa.prob.pu_mb_R;
1756 return simple_read_from_buffer(buf, len, pos, &data, sizeof data);
1759 static ssize_t spufs_mbox_info_read(struct file *file, char __user *buf,
1760 size_t len, loff_t *pos)
1763 struct spu_context *ctx = file->private_data;
1765 if (!access_ok(VERIFY_WRITE, buf, len))
1768 spu_acquire_saved(ctx);
1769 spin_lock(&ctx->csa.register_lock);
1770 ret = __spufs_mbox_info_read(ctx, buf, len, pos);
1771 spin_unlock(&ctx->csa.register_lock);
1777 static const struct file_operations spufs_mbox_info_fops = {
1778 .open = spufs_info_open,
1779 .read = spufs_mbox_info_read,
1780 .llseek = generic_file_llseek,
1783 static ssize_t __spufs_ibox_info_read(struct spu_context *ctx,
1784 char __user *buf, size_t len, loff_t *pos)
1789 ibox_stat = ctx->csa.prob.mb_stat_R;
1790 if (ibox_stat & 0xff0000) {
1791 data = ctx->csa.priv2.puint_mb_R;
1794 return simple_read_from_buffer(buf, len, pos, &data, sizeof data);
1797 static ssize_t spufs_ibox_info_read(struct file *file, char __user *buf,
1798 size_t len, loff_t *pos)
1800 struct spu_context *ctx = file->private_data;
1803 if (!access_ok(VERIFY_WRITE, buf, len))
1806 spu_acquire_saved(ctx);
1807 spin_lock(&ctx->csa.register_lock);
1808 ret = __spufs_ibox_info_read(ctx, buf, len, pos);
1809 spin_unlock(&ctx->csa.register_lock);
1815 static const struct file_operations spufs_ibox_info_fops = {
1816 .open = spufs_info_open,
1817 .read = spufs_ibox_info_read,
1818 .llseek = generic_file_llseek,
1821 static ssize_t __spufs_wbox_info_read(struct spu_context *ctx,
1822 char __user *buf, size_t len, loff_t *pos)
1828 wbox_stat = ctx->csa.prob.mb_stat_R;
1829 cnt = 4 - ((wbox_stat & 0x00ff00) >> 8);
1830 for (i = 0; i < cnt; i++) {
1831 data[i] = ctx->csa.spu_mailbox_data[i];
1834 return simple_read_from_buffer(buf, len, pos, &data,
1838 static ssize_t spufs_wbox_info_read(struct file *file, char __user *buf,
1839 size_t len, loff_t *pos)
1841 struct spu_context *ctx = file->private_data;
1844 if (!access_ok(VERIFY_WRITE, buf, len))
1847 spu_acquire_saved(ctx);
1848 spin_lock(&ctx->csa.register_lock);
1849 ret = __spufs_wbox_info_read(ctx, buf, len, pos);
1850 spin_unlock(&ctx->csa.register_lock);
1856 static const struct file_operations spufs_wbox_info_fops = {
1857 .open = spufs_info_open,
1858 .read = spufs_wbox_info_read,
1859 .llseek = generic_file_llseek,
1862 static ssize_t __spufs_dma_info_read(struct spu_context *ctx,
1863 char __user *buf, size_t len, loff_t *pos)
1865 struct spu_dma_info info;
1866 struct mfc_cq_sr *qp, *spuqp;
1869 info.dma_info_type = ctx->csa.priv2.spu_tag_status_query_RW;
1870 info.dma_info_mask = ctx->csa.lscsa->tag_mask.slot[0];
1871 info.dma_info_status = ctx->csa.spu_chnldata_RW[24];
1872 info.dma_info_stall_and_notify = ctx->csa.spu_chnldata_RW[25];
1873 info.dma_info_atomic_command_status = ctx->csa.spu_chnldata_RW[27];
1874 for (i = 0; i < 16; i++) {
1875 qp = &info.dma_info_command_data[i];
1876 spuqp = &ctx->csa.priv2.spuq[i];
1878 qp->mfc_cq_data0_RW = spuqp->mfc_cq_data0_RW;
1879 qp->mfc_cq_data1_RW = spuqp->mfc_cq_data1_RW;
1880 qp->mfc_cq_data2_RW = spuqp->mfc_cq_data2_RW;
1881 qp->mfc_cq_data3_RW = spuqp->mfc_cq_data3_RW;
1884 return simple_read_from_buffer(buf, len, pos, &info,
1888 static ssize_t spufs_dma_info_read(struct file *file, char __user *buf,
1889 size_t len, loff_t *pos)
1891 struct spu_context *ctx = file->private_data;
1894 if (!access_ok(VERIFY_WRITE, buf, len))
1897 spu_acquire_saved(ctx);
1898 spin_lock(&ctx->csa.register_lock);
1899 ret = __spufs_dma_info_read(ctx, buf, len, pos);
1900 spin_unlock(&ctx->csa.register_lock);
1906 static const struct file_operations spufs_dma_info_fops = {
1907 .open = spufs_info_open,
1908 .read = spufs_dma_info_read,
1911 static ssize_t __spufs_proxydma_info_read(struct spu_context *ctx,
1912 char __user *buf, size_t len, loff_t *pos)
1914 struct spu_proxydma_info info;
1915 struct mfc_cq_sr *qp, *puqp;
1916 int ret = sizeof info;
1922 if (!access_ok(VERIFY_WRITE, buf, len))
1925 info.proxydma_info_type = ctx->csa.prob.dma_querytype_RW;
1926 info.proxydma_info_mask = ctx->csa.prob.dma_querymask_RW;
1927 info.proxydma_info_status = ctx->csa.prob.dma_tagstatus_R;
1928 for (i = 0; i < 8; i++) {
1929 qp = &info.proxydma_info_command_data[i];
1930 puqp = &ctx->csa.priv2.puq[i];
1932 qp->mfc_cq_data0_RW = puqp->mfc_cq_data0_RW;
1933 qp->mfc_cq_data1_RW = puqp->mfc_cq_data1_RW;
1934 qp->mfc_cq_data2_RW = puqp->mfc_cq_data2_RW;
1935 qp->mfc_cq_data3_RW = puqp->mfc_cq_data3_RW;
1938 return simple_read_from_buffer(buf, len, pos, &info,
1942 static ssize_t spufs_proxydma_info_read(struct file *file, char __user *buf,
1943 size_t len, loff_t *pos)
1945 struct spu_context *ctx = file->private_data;
1948 spu_acquire_saved(ctx);
1949 spin_lock(&ctx->csa.register_lock);
1950 ret = __spufs_proxydma_info_read(ctx, buf, len, pos);
1951 spin_unlock(&ctx->csa.register_lock);
1957 static const struct file_operations spufs_proxydma_info_fops = {
1958 .open = spufs_info_open,
1959 .read = spufs_proxydma_info_read,
1962 struct tree_descr spufs_dir_contents[] = {
1963 { "mem", &spufs_mem_fops, 0666, },
1964 { "regs", &spufs_regs_fops, 0666, },
1965 { "mbox", &spufs_mbox_fops, 0444, },
1966 { "ibox", &spufs_ibox_fops, 0444, },
1967 { "wbox", &spufs_wbox_fops, 0222, },
1968 { "mbox_stat", &spufs_mbox_stat_fops, 0444, },
1969 { "ibox_stat", &spufs_ibox_stat_fops, 0444, },
1970 { "wbox_stat", &spufs_wbox_stat_fops, 0444, },
1971 { "signal1", &spufs_signal1_fops, 0666, },
1972 { "signal2", &spufs_signal2_fops, 0666, },
1973 { "signal1_type", &spufs_signal1_type, 0666, },
1974 { "signal2_type", &spufs_signal2_type, 0666, },
1975 { "cntl", &spufs_cntl_fops, 0666, },
1976 { "fpcr", &spufs_fpcr_fops, 0666, },
1977 { "lslr", &spufs_lslr_ops, 0444, },
1978 { "mfc", &spufs_mfc_fops, 0666, },
1979 { "mss", &spufs_mss_fops, 0666, },
1980 { "npc", &spufs_npc_ops, 0666, },
1981 { "srr0", &spufs_srr0_ops, 0666, },
1982 { "decr", &spufs_decr_ops, 0666, },
1983 { "decr_status", &spufs_decr_status_ops, 0666, },
1984 { "event_mask", &spufs_event_mask_ops, 0666, },
1985 { "event_status", &spufs_event_status_ops, 0444, },
1986 { "psmap", &spufs_psmap_fops, 0666, },
1987 { "phys-id", &spufs_id_ops, 0666, },
1988 { "object-id", &spufs_object_id_ops, 0666, },
1989 { "mbox_info", &spufs_mbox_info_fops, 0444, },
1990 { "ibox_info", &spufs_ibox_info_fops, 0444, },
1991 { "wbox_info", &spufs_wbox_info_fops, 0444, },
1992 { "dma_info", &spufs_dma_info_fops, 0444, },
1993 { "proxydma_info", &spufs_proxydma_info_fops, 0444, },
1997 struct tree_descr spufs_dir_nosched_contents[] = {
1998 { "mem", &spufs_mem_fops, 0666, },
1999 { "mbox", &spufs_mbox_fops, 0444, },
2000 { "ibox", &spufs_ibox_fops, 0444, },
2001 { "wbox", &spufs_wbox_fops, 0222, },
2002 { "mbox_stat", &spufs_mbox_stat_fops, 0444, },
2003 { "ibox_stat", &spufs_ibox_stat_fops, 0444, },
2004 { "wbox_stat", &spufs_wbox_stat_fops, 0444, },
2005 { "signal1", &spufs_signal1_fops, 0666, },
2006 { "signal2", &spufs_signal2_fops, 0666, },
2007 { "signal1_type", &spufs_signal1_type, 0666, },
2008 { "signal2_type", &spufs_signal2_type, 0666, },
2009 { "mss", &spufs_mss_fops, 0666, },
2010 { "mfc", &spufs_mfc_fops, 0666, },
2011 { "cntl", &spufs_cntl_fops, 0666, },
2012 { "npc", &spufs_npc_ops, 0666, },
2013 { "psmap", &spufs_psmap_fops, 0666, },
2014 { "phys-id", &spufs_id_ops, 0666, },
2015 { "object-id", &spufs_object_id_ops, 0666, },
2019 struct spufs_coredump_reader spufs_coredump_read[] = {
2020 { "regs", __spufs_regs_read, NULL, 128 * 16 },
2021 { "fpcr", __spufs_fpcr_read, NULL, 16 },
2022 { "lslr", NULL, __spufs_lslr_get, 11 },
2023 { "decr", NULL, __spufs_decr_get, 11 },
2024 { "decr_status", NULL, __spufs_decr_status_get, 11 },
2025 { "mem", __spufs_mem_read, NULL, 256 * 1024, },
2026 { "signal1", __spufs_signal1_read, NULL, 4 },
2027 { "signal1_type", NULL, __spufs_signal1_type_get, 2 },
2028 { "signal2", __spufs_signal2_read, NULL, 4 },
2029 { "signal2_type", NULL, __spufs_signal2_type_get, 2 },
2030 { "event_mask", NULL, __spufs_event_mask_get, 8 },
2031 { "event_status", NULL, __spufs_event_status_get, 8 },
2032 { "mbox_info", __spufs_mbox_info_read, NULL, 4 },
2033 { "ibox_info", __spufs_ibox_info_read, NULL, 4 },
2034 { "wbox_info", __spufs_wbox_info_read, NULL, 16 },
2035 { "dma_info", __spufs_dma_info_read, NULL, 69 * 8 },
2036 { "proxydma_info", __spufs_proxydma_info_read, NULL, 35 * 8 },
2037 { "object-id", NULL, __spufs_object_id_get, 19 },
2040 int spufs_coredump_num_notes = ARRAY_SIZE(spufs_coredump_read) - 1;