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/export.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/slab.h>
37 #include <asm/spu_info.h>
38 #include <linux/uaccess.h>
43 #define SPUFS_MMAP_4K (PAGE_SIZE == 0x1000)
45 /* Simple attribute files */
47 int (*get
)(void *, u64
*);
48 int (*set
)(void *, u64
);
49 char get_buf
[24]; /* enough to store a u64 and "\n\0" */
52 const char *fmt
; /* format for read operation */
53 struct mutex mutex
; /* protects access to these buffers */
56 static int spufs_attr_open(struct inode
*inode
, struct file
*file
,
57 int (*get
)(void *, u64
*), int (*set
)(void *, u64
),
60 struct spufs_attr
*attr
;
62 attr
= kmalloc(sizeof(*attr
), GFP_KERNEL
);
68 attr
->data
= inode
->i_private
;
70 mutex_init(&attr
->mutex
);
71 file
->private_data
= attr
;
73 return nonseekable_open(inode
, file
);
76 static int spufs_attr_release(struct inode
*inode
, struct file
*file
)
78 kfree(file
->private_data
);
82 static ssize_t
spufs_attr_read(struct file
*file
, char __user
*buf
,
83 size_t len
, loff_t
*ppos
)
85 struct spufs_attr
*attr
;
89 attr
= file
->private_data
;
93 ret
= mutex_lock_interruptible(&attr
->mutex
);
97 if (*ppos
) { /* continued read */
98 size
= strlen(attr
->get_buf
);
99 } else { /* first read */
101 ret
= attr
->get(attr
->data
, &val
);
105 size
= scnprintf(attr
->get_buf
, sizeof(attr
->get_buf
),
106 attr
->fmt
, (unsigned long long)val
);
109 ret
= simple_read_from_buffer(buf
, len
, ppos
, attr
->get_buf
, size
);
111 mutex_unlock(&attr
->mutex
);
115 static ssize_t
spufs_attr_write(struct file
*file
, const char __user
*buf
,
116 size_t len
, loff_t
*ppos
)
118 struct spufs_attr
*attr
;
123 attr
= file
->private_data
;
127 ret
= mutex_lock_interruptible(&attr
->mutex
);
132 size
= min(sizeof(attr
->set_buf
) - 1, len
);
133 if (copy_from_user(attr
->set_buf
, buf
, size
))
136 ret
= len
; /* claim we got the whole input */
137 attr
->set_buf
[size
] = '\0';
138 val
= simple_strtol(attr
->set_buf
, NULL
, 0);
139 attr
->set(attr
->data
, val
);
141 mutex_unlock(&attr
->mutex
);
145 #define DEFINE_SPUFS_SIMPLE_ATTRIBUTE(__fops, __get, __set, __fmt) \
146 static int __fops ## _open(struct inode *inode, struct file *file) \
148 __simple_attr_check_format(__fmt, 0ull); \
149 return spufs_attr_open(inode, file, __get, __set, __fmt); \
151 static const struct file_operations __fops = { \
152 .open = __fops ## _open, \
153 .release = spufs_attr_release, \
154 .read = spufs_attr_read, \
155 .write = spufs_attr_write, \
156 .llseek = generic_file_llseek, \
161 spufs_mem_open(struct inode
*inode
, struct file
*file
)
163 struct spufs_inode_info
*i
= SPUFS_I(inode
);
164 struct spu_context
*ctx
= i
->i_ctx
;
166 mutex_lock(&ctx
->mapping_lock
);
167 file
->private_data
= ctx
;
169 ctx
->local_store
= inode
->i_mapping
;
170 mutex_unlock(&ctx
->mapping_lock
);
175 spufs_mem_release(struct inode
*inode
, struct file
*file
)
177 struct spufs_inode_info
*i
= SPUFS_I(inode
);
178 struct spu_context
*ctx
= i
->i_ctx
;
180 mutex_lock(&ctx
->mapping_lock
);
182 ctx
->local_store
= NULL
;
183 mutex_unlock(&ctx
->mapping_lock
);
188 __spufs_mem_read(struct spu_context
*ctx
, char __user
*buffer
,
189 size_t size
, loff_t
*pos
)
191 char *local_store
= ctx
->ops
->get_ls(ctx
);
192 return simple_read_from_buffer(buffer
, size
, pos
, local_store
,
197 spufs_mem_read(struct file
*file
, char __user
*buffer
,
198 size_t size
, loff_t
*pos
)
200 struct spu_context
*ctx
= file
->private_data
;
203 ret
= spu_acquire(ctx
);
206 ret
= __spufs_mem_read(ctx
, buffer
, size
, pos
);
213 spufs_mem_write(struct file
*file
, const char __user
*buffer
,
214 size_t size
, loff_t
*ppos
)
216 struct spu_context
*ctx
= file
->private_data
;
224 ret
= spu_acquire(ctx
);
228 local_store
= ctx
->ops
->get_ls(ctx
);
229 size
= simple_write_to_buffer(local_store
, LS_SIZE
, ppos
, buffer
, size
);
236 spufs_mem_mmap_fault(struct vm_fault
*vmf
)
238 struct vm_area_struct
*vma
= vmf
->vma
;
239 struct spu_context
*ctx
= vma
->vm_file
->private_data
;
240 unsigned long pfn
, offset
;
242 offset
= vmf
->pgoff
<< PAGE_SHIFT
;
243 if (offset
>= LS_SIZE
)
244 return VM_FAULT_SIGBUS
;
246 pr_debug("spufs_mem_mmap_fault address=0x%lx, offset=0x%lx\n",
247 vmf
->address
, offset
);
249 if (spu_acquire(ctx
))
250 return VM_FAULT_NOPAGE
;
252 if (ctx
->state
== SPU_STATE_SAVED
) {
253 vma
->vm_page_prot
= pgprot_cached(vma
->vm_page_prot
);
254 pfn
= vmalloc_to_pfn(ctx
->csa
.lscsa
->ls
+ offset
);
256 vma
->vm_page_prot
= pgprot_noncached_wc(vma
->vm_page_prot
);
257 pfn
= (ctx
->spu
->local_store_phys
+ offset
) >> PAGE_SHIFT
;
259 vm_insert_pfn(vma
, vmf
->address
, pfn
);
263 return VM_FAULT_NOPAGE
;
266 static int spufs_mem_mmap_access(struct vm_area_struct
*vma
,
267 unsigned long address
,
268 void *buf
, int len
, int write
)
270 struct spu_context
*ctx
= vma
->vm_file
->private_data
;
271 unsigned long offset
= address
- vma
->vm_start
;
274 if (write
&& !(vma
->vm_flags
& VM_WRITE
))
276 if (spu_acquire(ctx
))
278 if ((offset
+ len
) > vma
->vm_end
)
279 len
= vma
->vm_end
- offset
;
280 local_store
= ctx
->ops
->get_ls(ctx
);
282 memcpy_toio(local_store
+ offset
, buf
, len
);
284 memcpy_fromio(buf
, local_store
+ offset
, len
);
289 static const struct vm_operations_struct spufs_mem_mmap_vmops
= {
290 .fault
= spufs_mem_mmap_fault
,
291 .access
= spufs_mem_mmap_access
,
294 static int spufs_mem_mmap(struct file
*file
, struct vm_area_struct
*vma
)
296 if (!(vma
->vm_flags
& VM_SHARED
))
299 vma
->vm_flags
|= VM_IO
| VM_PFNMAP
;
300 vma
->vm_page_prot
= pgprot_noncached_wc(vma
->vm_page_prot
);
302 vma
->vm_ops
= &spufs_mem_mmap_vmops
;
306 static const struct file_operations spufs_mem_fops
= {
307 .open
= spufs_mem_open
,
308 .release
= spufs_mem_release
,
309 .read
= spufs_mem_read
,
310 .write
= spufs_mem_write
,
311 .llseek
= generic_file_llseek
,
312 .mmap
= spufs_mem_mmap
,
315 static int spufs_ps_fault(struct vm_fault
*vmf
,
316 unsigned long ps_offs
,
317 unsigned long ps_size
)
319 struct spu_context
*ctx
= vmf
->vma
->vm_file
->private_data
;
320 unsigned long area
, offset
= vmf
->pgoff
<< PAGE_SHIFT
;
323 spu_context_nospu_trace(spufs_ps_fault__enter
, ctx
);
325 if (offset
>= ps_size
)
326 return VM_FAULT_SIGBUS
;
328 if (fatal_signal_pending(current
))
329 return VM_FAULT_SIGBUS
;
332 * Because we release the mmap_sem, the context may be destroyed while
333 * we're in spu_wait. Grab an extra reference so it isn't destroyed
336 get_spu_context(ctx
);
339 * We have to wait for context to be loaded before we have
340 * pages to hand out to the user, but we don't want to wait
341 * with the mmap_sem held.
342 * It is possible to drop the mmap_sem here, but then we need
343 * to return VM_FAULT_NOPAGE because the mappings may have
346 if (spu_acquire(ctx
))
349 if (ctx
->state
== SPU_STATE_SAVED
) {
350 up_read(¤t
->mm
->mmap_sem
);
351 spu_context_nospu_trace(spufs_ps_fault__sleep
, ctx
);
352 ret
= spufs_wait(ctx
->run_wq
, ctx
->state
== SPU_STATE_RUNNABLE
);
353 spu_context_trace(spufs_ps_fault__wake
, ctx
, ctx
->spu
);
354 down_read(¤t
->mm
->mmap_sem
);
356 area
= ctx
->spu
->problem_phys
+ ps_offs
;
357 vm_insert_pfn(vmf
->vma
, vmf
->address
, (area
+ offset
) >> PAGE_SHIFT
);
358 spu_context_trace(spufs_ps_fault__insert
, ctx
, ctx
->spu
);
365 put_spu_context(ctx
);
366 return VM_FAULT_NOPAGE
;
370 static int spufs_cntl_mmap_fault(struct vm_fault
*vmf
)
372 return spufs_ps_fault(vmf
, 0x4000, SPUFS_CNTL_MAP_SIZE
);
375 static const struct vm_operations_struct spufs_cntl_mmap_vmops
= {
376 .fault
= spufs_cntl_mmap_fault
,
380 * mmap support for problem state control area [0x4000 - 0x4fff].
382 static int spufs_cntl_mmap(struct file
*file
, struct vm_area_struct
*vma
)
384 if (!(vma
->vm_flags
& VM_SHARED
))
387 vma
->vm_flags
|= VM_IO
| VM_PFNMAP
;
388 vma
->vm_page_prot
= pgprot_noncached(vma
->vm_page_prot
);
390 vma
->vm_ops
= &spufs_cntl_mmap_vmops
;
393 #else /* SPUFS_MMAP_4K */
394 #define spufs_cntl_mmap NULL
395 #endif /* !SPUFS_MMAP_4K */
397 static int spufs_cntl_get(void *data
, u64
*val
)
399 struct spu_context
*ctx
= data
;
402 ret
= spu_acquire(ctx
);
405 *val
= ctx
->ops
->status_read(ctx
);
411 static int spufs_cntl_set(void *data
, u64 val
)
413 struct spu_context
*ctx
= data
;
416 ret
= spu_acquire(ctx
);
419 ctx
->ops
->runcntl_write(ctx
, val
);
425 static int spufs_cntl_open(struct inode
*inode
, struct file
*file
)
427 struct spufs_inode_info
*i
= SPUFS_I(inode
);
428 struct spu_context
*ctx
= i
->i_ctx
;
430 mutex_lock(&ctx
->mapping_lock
);
431 file
->private_data
= ctx
;
433 ctx
->cntl
= inode
->i_mapping
;
434 mutex_unlock(&ctx
->mapping_lock
);
435 return simple_attr_open(inode
, file
, spufs_cntl_get
,
436 spufs_cntl_set
, "0x%08lx");
440 spufs_cntl_release(struct inode
*inode
, struct file
*file
)
442 struct spufs_inode_info
*i
= SPUFS_I(inode
);
443 struct spu_context
*ctx
= i
->i_ctx
;
445 simple_attr_release(inode
, file
);
447 mutex_lock(&ctx
->mapping_lock
);
450 mutex_unlock(&ctx
->mapping_lock
);
454 static const struct file_operations spufs_cntl_fops
= {
455 .open
= spufs_cntl_open
,
456 .release
= spufs_cntl_release
,
457 .read
= simple_attr_read
,
458 .write
= simple_attr_write
,
459 .llseek
= generic_file_llseek
,
460 .mmap
= spufs_cntl_mmap
,
464 spufs_regs_open(struct inode
*inode
, struct file
*file
)
466 struct spufs_inode_info
*i
= SPUFS_I(inode
);
467 file
->private_data
= i
->i_ctx
;
472 __spufs_regs_read(struct spu_context
*ctx
, char __user
*buffer
,
473 size_t size
, loff_t
*pos
)
475 struct spu_lscsa
*lscsa
= ctx
->csa
.lscsa
;
476 return simple_read_from_buffer(buffer
, size
, pos
,
477 lscsa
->gprs
, sizeof lscsa
->gprs
);
481 spufs_regs_read(struct file
*file
, char __user
*buffer
,
482 size_t size
, loff_t
*pos
)
485 struct spu_context
*ctx
= file
->private_data
;
487 /* pre-check for file position: if we'd return EOF, there's no point
488 * causing a deschedule */
489 if (*pos
>= sizeof(ctx
->csa
.lscsa
->gprs
))
492 ret
= spu_acquire_saved(ctx
);
495 ret
= __spufs_regs_read(ctx
, buffer
, size
, pos
);
496 spu_release_saved(ctx
);
501 spufs_regs_write(struct file
*file
, const char __user
*buffer
,
502 size_t size
, loff_t
*pos
)
504 struct spu_context
*ctx
= file
->private_data
;
505 struct spu_lscsa
*lscsa
= ctx
->csa
.lscsa
;
508 if (*pos
>= sizeof(lscsa
->gprs
))
511 ret
= spu_acquire_saved(ctx
);
515 size
= simple_write_to_buffer(lscsa
->gprs
, sizeof(lscsa
->gprs
), pos
,
518 spu_release_saved(ctx
);
522 static const struct file_operations spufs_regs_fops
= {
523 .open
= spufs_regs_open
,
524 .read
= spufs_regs_read
,
525 .write
= spufs_regs_write
,
526 .llseek
= generic_file_llseek
,
530 __spufs_fpcr_read(struct spu_context
*ctx
, char __user
* buffer
,
531 size_t size
, loff_t
* pos
)
533 struct spu_lscsa
*lscsa
= ctx
->csa
.lscsa
;
534 return simple_read_from_buffer(buffer
, size
, pos
,
535 &lscsa
->fpcr
, sizeof(lscsa
->fpcr
));
539 spufs_fpcr_read(struct file
*file
, char __user
* buffer
,
540 size_t size
, loff_t
* pos
)
543 struct spu_context
*ctx
= file
->private_data
;
545 ret
= spu_acquire_saved(ctx
);
548 ret
= __spufs_fpcr_read(ctx
, buffer
, size
, pos
);
549 spu_release_saved(ctx
);
554 spufs_fpcr_write(struct file
*file
, const char __user
* buffer
,
555 size_t size
, loff_t
* pos
)
557 struct spu_context
*ctx
= file
->private_data
;
558 struct spu_lscsa
*lscsa
= ctx
->csa
.lscsa
;
561 if (*pos
>= sizeof(lscsa
->fpcr
))
564 ret
= spu_acquire_saved(ctx
);
568 size
= simple_write_to_buffer(&lscsa
->fpcr
, sizeof(lscsa
->fpcr
), pos
,
571 spu_release_saved(ctx
);
575 static const struct file_operations spufs_fpcr_fops
= {
576 .open
= spufs_regs_open
,
577 .read
= spufs_fpcr_read
,
578 .write
= spufs_fpcr_write
,
579 .llseek
= generic_file_llseek
,
582 /* generic open function for all pipe-like files */
583 static int spufs_pipe_open(struct inode
*inode
, struct file
*file
)
585 struct spufs_inode_info
*i
= SPUFS_I(inode
);
586 file
->private_data
= i
->i_ctx
;
588 return nonseekable_open(inode
, file
);
592 * Read as many bytes from the mailbox as possible, until
593 * one of the conditions becomes true:
595 * - no more data available in the mailbox
596 * - end of the user provided buffer
597 * - end of the mapped area
599 static ssize_t
spufs_mbox_read(struct file
*file
, char __user
*buf
,
600 size_t len
, loff_t
*pos
)
602 struct spu_context
*ctx
= file
->private_data
;
603 u32 mbox_data
, __user
*udata
;
609 if (!access_ok(VERIFY_WRITE
, buf
, len
))
612 udata
= (void __user
*)buf
;
614 count
= spu_acquire(ctx
);
618 for (count
= 0; (count
+ 4) <= len
; count
+= 4, udata
++) {
620 ret
= ctx
->ops
->mbox_read(ctx
, &mbox_data
);
625 * at the end of the mapped area, we can fault
626 * but still need to return the data we have
627 * read successfully so far.
629 ret
= __put_user(mbox_data
, udata
);
644 static const struct file_operations spufs_mbox_fops
= {
645 .open
= spufs_pipe_open
,
646 .read
= spufs_mbox_read
,
650 static ssize_t
spufs_mbox_stat_read(struct file
*file
, char __user
*buf
,
651 size_t len
, loff_t
*pos
)
653 struct spu_context
*ctx
= file
->private_data
;
660 ret
= spu_acquire(ctx
);
664 mbox_stat
= ctx
->ops
->mbox_stat_read(ctx
) & 0xff;
668 if (copy_to_user(buf
, &mbox_stat
, sizeof mbox_stat
))
674 static const struct file_operations spufs_mbox_stat_fops
= {
675 .open
= spufs_pipe_open
,
676 .read
= spufs_mbox_stat_read
,
680 /* low-level ibox access function */
681 size_t spu_ibox_read(struct spu_context
*ctx
, u32
*data
)
683 return ctx
->ops
->ibox_read(ctx
, data
);
686 /* interrupt-level ibox callback function. */
687 void spufs_ibox_callback(struct spu
*spu
)
689 struct spu_context
*ctx
= spu
->ctx
;
692 wake_up_all(&ctx
->ibox_wq
);
696 * Read as many bytes from the interrupt mailbox as possible, until
697 * one of the conditions becomes true:
699 * - no more data available in the mailbox
700 * - end of the user provided buffer
701 * - end of the mapped area
703 * If the file is opened without O_NONBLOCK, we wait here until
704 * any data is available, but return when we have been able to
707 static ssize_t
spufs_ibox_read(struct file
*file
, char __user
*buf
,
708 size_t len
, loff_t
*pos
)
710 struct spu_context
*ctx
= file
->private_data
;
711 u32 ibox_data
, __user
*udata
;
717 if (!access_ok(VERIFY_WRITE
, buf
, len
))
720 udata
= (void __user
*)buf
;
722 count
= spu_acquire(ctx
);
726 /* wait only for the first element */
728 if (file
->f_flags
& O_NONBLOCK
) {
729 if (!spu_ibox_read(ctx
, &ibox_data
)) {
734 count
= spufs_wait(ctx
->ibox_wq
, spu_ibox_read(ctx
, &ibox_data
));
739 /* if we can't write at all, return -EFAULT */
740 count
= __put_user(ibox_data
, udata
);
744 for (count
= 4, udata
++; (count
+ 4) <= len
; count
+= 4, udata
++) {
746 ret
= ctx
->ops
->ibox_read(ctx
, &ibox_data
);
750 * at the end of the mapped area, we can fault
751 * but still need to return the data we have
752 * read successfully so far.
754 ret
= __put_user(ibox_data
, udata
);
765 static unsigned int spufs_ibox_poll(struct file
*file
, poll_table
*wait
)
767 struct spu_context
*ctx
= file
->private_data
;
770 poll_wait(file
, &ctx
->ibox_wq
, wait
);
773 * For now keep this uninterruptible and also ignore the rule
774 * that poll should not sleep. Will be fixed later.
776 mutex_lock(&ctx
->state_mutex
);
777 mask
= ctx
->ops
->mbox_stat_poll(ctx
, POLLIN
| POLLRDNORM
);
783 static const struct file_operations spufs_ibox_fops
= {
784 .open
= spufs_pipe_open
,
785 .read
= spufs_ibox_read
,
786 .poll
= spufs_ibox_poll
,
790 static ssize_t
spufs_ibox_stat_read(struct file
*file
, char __user
*buf
,
791 size_t len
, loff_t
*pos
)
793 struct spu_context
*ctx
= file
->private_data
;
800 ret
= spu_acquire(ctx
);
803 ibox_stat
= (ctx
->ops
->mbox_stat_read(ctx
) >> 16) & 0xff;
806 if (copy_to_user(buf
, &ibox_stat
, sizeof ibox_stat
))
812 static const struct file_operations spufs_ibox_stat_fops
= {
813 .open
= spufs_pipe_open
,
814 .read
= spufs_ibox_stat_read
,
818 /* low-level mailbox write */
819 size_t spu_wbox_write(struct spu_context
*ctx
, u32 data
)
821 return ctx
->ops
->wbox_write(ctx
, data
);
824 /* interrupt-level wbox callback function. */
825 void spufs_wbox_callback(struct spu
*spu
)
827 struct spu_context
*ctx
= spu
->ctx
;
830 wake_up_all(&ctx
->wbox_wq
);
834 * Write as many bytes to the interrupt mailbox as possible, until
835 * one of the conditions becomes true:
837 * - the mailbox is full
838 * - end of the user provided buffer
839 * - end of the mapped area
841 * If the file is opened without O_NONBLOCK, we wait here until
842 * space is available, but return when we have been able to
845 static ssize_t
spufs_wbox_write(struct file
*file
, const char __user
*buf
,
846 size_t len
, loff_t
*pos
)
848 struct spu_context
*ctx
= file
->private_data
;
849 u32 wbox_data
, __user
*udata
;
855 udata
= (void __user
*)buf
;
856 if (!access_ok(VERIFY_READ
, buf
, len
))
859 if (__get_user(wbox_data
, udata
))
862 count
= spu_acquire(ctx
);
867 * make sure we can at least write one element, by waiting
868 * in case of !O_NONBLOCK
871 if (file
->f_flags
& O_NONBLOCK
) {
872 if (!spu_wbox_write(ctx
, wbox_data
)) {
877 count
= spufs_wait(ctx
->wbox_wq
, spu_wbox_write(ctx
, wbox_data
));
883 /* write as much as possible */
884 for (count
= 4, udata
++; (count
+ 4) <= len
; count
+= 4, udata
++) {
886 ret
= __get_user(wbox_data
, udata
);
890 ret
= spu_wbox_write(ctx
, wbox_data
);
901 static unsigned int spufs_wbox_poll(struct file
*file
, poll_table
*wait
)
903 struct spu_context
*ctx
= file
->private_data
;
906 poll_wait(file
, &ctx
->wbox_wq
, wait
);
909 * For now keep this uninterruptible and also ignore the rule
910 * that poll should not sleep. Will be fixed later.
912 mutex_lock(&ctx
->state_mutex
);
913 mask
= ctx
->ops
->mbox_stat_poll(ctx
, POLLOUT
| POLLWRNORM
);
919 static const struct file_operations spufs_wbox_fops
= {
920 .open
= spufs_pipe_open
,
921 .write
= spufs_wbox_write
,
922 .poll
= spufs_wbox_poll
,
926 static ssize_t
spufs_wbox_stat_read(struct file
*file
, char __user
*buf
,
927 size_t len
, loff_t
*pos
)
929 struct spu_context
*ctx
= file
->private_data
;
936 ret
= spu_acquire(ctx
);
939 wbox_stat
= (ctx
->ops
->mbox_stat_read(ctx
) >> 8) & 0xff;
942 if (copy_to_user(buf
, &wbox_stat
, sizeof wbox_stat
))
948 static const struct file_operations spufs_wbox_stat_fops
= {
949 .open
= spufs_pipe_open
,
950 .read
= spufs_wbox_stat_read
,
954 static int spufs_signal1_open(struct inode
*inode
, struct file
*file
)
956 struct spufs_inode_info
*i
= SPUFS_I(inode
);
957 struct spu_context
*ctx
= i
->i_ctx
;
959 mutex_lock(&ctx
->mapping_lock
);
960 file
->private_data
= ctx
;
962 ctx
->signal1
= inode
->i_mapping
;
963 mutex_unlock(&ctx
->mapping_lock
);
964 return nonseekable_open(inode
, file
);
968 spufs_signal1_release(struct inode
*inode
, struct file
*file
)
970 struct spufs_inode_info
*i
= SPUFS_I(inode
);
971 struct spu_context
*ctx
= i
->i_ctx
;
973 mutex_lock(&ctx
->mapping_lock
);
976 mutex_unlock(&ctx
->mapping_lock
);
980 static ssize_t
__spufs_signal1_read(struct spu_context
*ctx
, char __user
*buf
,
981 size_t len
, loff_t
*pos
)
989 if (ctx
->csa
.spu_chnlcnt_RW
[3]) {
990 data
= ctx
->csa
.spu_chnldata_RW
[3];
997 if (copy_to_user(buf
, &data
, 4))
1004 static ssize_t
spufs_signal1_read(struct file
*file
, char __user
*buf
,
1005 size_t len
, loff_t
*pos
)
1008 struct spu_context
*ctx
= file
->private_data
;
1010 ret
= spu_acquire_saved(ctx
);
1013 ret
= __spufs_signal1_read(ctx
, buf
, len
, pos
);
1014 spu_release_saved(ctx
);
1019 static ssize_t
spufs_signal1_write(struct file
*file
, const char __user
*buf
,
1020 size_t len
, loff_t
*pos
)
1022 struct spu_context
*ctx
;
1026 ctx
= file
->private_data
;
1031 if (copy_from_user(&data
, buf
, 4))
1034 ret
= spu_acquire(ctx
);
1037 ctx
->ops
->signal1_write(ctx
, data
);
1044 spufs_signal1_mmap_fault(struct vm_fault
*vmf
)
1046 #if SPUFS_SIGNAL_MAP_SIZE == 0x1000
1047 return spufs_ps_fault(vmf
, 0x14000, SPUFS_SIGNAL_MAP_SIZE
);
1048 #elif SPUFS_SIGNAL_MAP_SIZE == 0x10000
1049 /* For 64k pages, both signal1 and signal2 can be used to mmap the whole
1050 * signal 1 and 2 area
1052 return spufs_ps_fault(vmf
, 0x10000, SPUFS_SIGNAL_MAP_SIZE
);
1054 #error unsupported page size
1058 static const struct vm_operations_struct spufs_signal1_mmap_vmops
= {
1059 .fault
= spufs_signal1_mmap_fault
,
1062 static int spufs_signal1_mmap(struct file
*file
, struct vm_area_struct
*vma
)
1064 if (!(vma
->vm_flags
& VM_SHARED
))
1067 vma
->vm_flags
|= VM_IO
| VM_PFNMAP
;
1068 vma
->vm_page_prot
= pgprot_noncached(vma
->vm_page_prot
);
1070 vma
->vm_ops
= &spufs_signal1_mmap_vmops
;
1074 static const struct file_operations spufs_signal1_fops
= {
1075 .open
= spufs_signal1_open
,
1076 .release
= spufs_signal1_release
,
1077 .read
= spufs_signal1_read
,
1078 .write
= spufs_signal1_write
,
1079 .mmap
= spufs_signal1_mmap
,
1080 .llseek
= no_llseek
,
1083 static const struct file_operations spufs_signal1_nosched_fops
= {
1084 .open
= spufs_signal1_open
,
1085 .release
= spufs_signal1_release
,
1086 .write
= spufs_signal1_write
,
1087 .mmap
= spufs_signal1_mmap
,
1088 .llseek
= no_llseek
,
1091 static int spufs_signal2_open(struct inode
*inode
, struct file
*file
)
1093 struct spufs_inode_info
*i
= SPUFS_I(inode
);
1094 struct spu_context
*ctx
= i
->i_ctx
;
1096 mutex_lock(&ctx
->mapping_lock
);
1097 file
->private_data
= ctx
;
1098 if (!i
->i_openers
++)
1099 ctx
->signal2
= inode
->i_mapping
;
1100 mutex_unlock(&ctx
->mapping_lock
);
1101 return nonseekable_open(inode
, file
);
1105 spufs_signal2_release(struct inode
*inode
, struct file
*file
)
1107 struct spufs_inode_info
*i
= SPUFS_I(inode
);
1108 struct spu_context
*ctx
= i
->i_ctx
;
1110 mutex_lock(&ctx
->mapping_lock
);
1111 if (!--i
->i_openers
)
1112 ctx
->signal2
= NULL
;
1113 mutex_unlock(&ctx
->mapping_lock
);
1117 static ssize_t
__spufs_signal2_read(struct spu_context
*ctx
, char __user
*buf
,
1118 size_t len
, loff_t
*pos
)
1126 if (ctx
->csa
.spu_chnlcnt_RW
[4]) {
1127 data
= ctx
->csa
.spu_chnldata_RW
[4];
1134 if (copy_to_user(buf
, &data
, 4))
1141 static ssize_t
spufs_signal2_read(struct file
*file
, char __user
*buf
,
1142 size_t len
, loff_t
*pos
)
1144 struct spu_context
*ctx
= file
->private_data
;
1147 ret
= spu_acquire_saved(ctx
);
1150 ret
= __spufs_signal2_read(ctx
, buf
, len
, pos
);
1151 spu_release_saved(ctx
);
1156 static ssize_t
spufs_signal2_write(struct file
*file
, const char __user
*buf
,
1157 size_t len
, loff_t
*pos
)
1159 struct spu_context
*ctx
;
1163 ctx
= file
->private_data
;
1168 if (copy_from_user(&data
, buf
, 4))
1171 ret
= spu_acquire(ctx
);
1174 ctx
->ops
->signal2_write(ctx
, data
);
1182 spufs_signal2_mmap_fault(struct vm_fault
*vmf
)
1184 #if SPUFS_SIGNAL_MAP_SIZE == 0x1000
1185 return spufs_ps_fault(vmf
, 0x1c000, SPUFS_SIGNAL_MAP_SIZE
);
1186 #elif SPUFS_SIGNAL_MAP_SIZE == 0x10000
1187 /* For 64k pages, both signal1 and signal2 can be used to mmap the whole
1188 * signal 1 and 2 area
1190 return spufs_ps_fault(vmf
, 0x10000, SPUFS_SIGNAL_MAP_SIZE
);
1192 #error unsupported page size
1196 static const struct vm_operations_struct spufs_signal2_mmap_vmops
= {
1197 .fault
= spufs_signal2_mmap_fault
,
1200 static int spufs_signal2_mmap(struct file
*file
, struct vm_area_struct
*vma
)
1202 if (!(vma
->vm_flags
& VM_SHARED
))
1205 vma
->vm_flags
|= VM_IO
| VM_PFNMAP
;
1206 vma
->vm_page_prot
= pgprot_noncached(vma
->vm_page_prot
);
1208 vma
->vm_ops
= &spufs_signal2_mmap_vmops
;
1211 #else /* SPUFS_MMAP_4K */
1212 #define spufs_signal2_mmap NULL
1213 #endif /* !SPUFS_MMAP_4K */
1215 static const struct file_operations spufs_signal2_fops
= {
1216 .open
= spufs_signal2_open
,
1217 .release
= spufs_signal2_release
,
1218 .read
= spufs_signal2_read
,
1219 .write
= spufs_signal2_write
,
1220 .mmap
= spufs_signal2_mmap
,
1221 .llseek
= no_llseek
,
1224 static const struct file_operations spufs_signal2_nosched_fops
= {
1225 .open
= spufs_signal2_open
,
1226 .release
= spufs_signal2_release
,
1227 .write
= spufs_signal2_write
,
1228 .mmap
= spufs_signal2_mmap
,
1229 .llseek
= no_llseek
,
1233 * This is a wrapper around DEFINE_SIMPLE_ATTRIBUTE which does the
1234 * work of acquiring (or not) the SPU context before calling through
1235 * to the actual get routine. The set routine is called directly.
1237 #define SPU_ATTR_NOACQUIRE 0
1238 #define SPU_ATTR_ACQUIRE 1
1239 #define SPU_ATTR_ACQUIRE_SAVED 2
1241 #define DEFINE_SPUFS_ATTRIBUTE(__name, __get, __set, __fmt, __acquire) \
1242 static int __##__get(void *data, u64 *val) \
1244 struct spu_context *ctx = data; \
1247 if (__acquire == SPU_ATTR_ACQUIRE) { \
1248 ret = spu_acquire(ctx); \
1251 *val = __get(ctx); \
1253 } else if (__acquire == SPU_ATTR_ACQUIRE_SAVED) { \
1254 ret = spu_acquire_saved(ctx); \
1257 *val = __get(ctx); \
1258 spu_release_saved(ctx); \
1260 *val = __get(ctx); \
1264 DEFINE_SPUFS_SIMPLE_ATTRIBUTE(__name, __##__get, __set, __fmt);
1266 static int spufs_signal1_type_set(void *data
, u64 val
)
1268 struct spu_context
*ctx
= data
;
1271 ret
= spu_acquire(ctx
);
1274 ctx
->ops
->signal1_type_set(ctx
, val
);
1280 static u64
spufs_signal1_type_get(struct spu_context
*ctx
)
1282 return ctx
->ops
->signal1_type_get(ctx
);
1284 DEFINE_SPUFS_ATTRIBUTE(spufs_signal1_type
, spufs_signal1_type_get
,
1285 spufs_signal1_type_set
, "%llu\n", SPU_ATTR_ACQUIRE
);
1288 static int spufs_signal2_type_set(void *data
, u64 val
)
1290 struct spu_context
*ctx
= data
;
1293 ret
= spu_acquire(ctx
);
1296 ctx
->ops
->signal2_type_set(ctx
, val
);
1302 static u64
spufs_signal2_type_get(struct spu_context
*ctx
)
1304 return ctx
->ops
->signal2_type_get(ctx
);
1306 DEFINE_SPUFS_ATTRIBUTE(spufs_signal2_type
, spufs_signal2_type_get
,
1307 spufs_signal2_type_set
, "%llu\n", SPU_ATTR_ACQUIRE
);
1311 spufs_mss_mmap_fault(struct vm_fault
*vmf
)
1313 return spufs_ps_fault(vmf
, 0x0000, SPUFS_MSS_MAP_SIZE
);
1316 static const struct vm_operations_struct spufs_mss_mmap_vmops
= {
1317 .fault
= spufs_mss_mmap_fault
,
1321 * mmap support for problem state MFC DMA area [0x0000 - 0x0fff].
1323 static int spufs_mss_mmap(struct file
*file
, struct vm_area_struct
*vma
)
1325 if (!(vma
->vm_flags
& VM_SHARED
))
1328 vma
->vm_flags
|= VM_IO
| VM_PFNMAP
;
1329 vma
->vm_page_prot
= pgprot_noncached(vma
->vm_page_prot
);
1331 vma
->vm_ops
= &spufs_mss_mmap_vmops
;
1334 #else /* SPUFS_MMAP_4K */
1335 #define spufs_mss_mmap NULL
1336 #endif /* !SPUFS_MMAP_4K */
1338 static int spufs_mss_open(struct inode
*inode
, struct file
*file
)
1340 struct spufs_inode_info
*i
= SPUFS_I(inode
);
1341 struct spu_context
*ctx
= i
->i_ctx
;
1343 file
->private_data
= i
->i_ctx
;
1345 mutex_lock(&ctx
->mapping_lock
);
1346 if (!i
->i_openers
++)
1347 ctx
->mss
= inode
->i_mapping
;
1348 mutex_unlock(&ctx
->mapping_lock
);
1349 return nonseekable_open(inode
, file
);
1353 spufs_mss_release(struct inode
*inode
, struct file
*file
)
1355 struct spufs_inode_info
*i
= SPUFS_I(inode
);
1356 struct spu_context
*ctx
= i
->i_ctx
;
1358 mutex_lock(&ctx
->mapping_lock
);
1359 if (!--i
->i_openers
)
1361 mutex_unlock(&ctx
->mapping_lock
);
1365 static const struct file_operations spufs_mss_fops
= {
1366 .open
= spufs_mss_open
,
1367 .release
= spufs_mss_release
,
1368 .mmap
= spufs_mss_mmap
,
1369 .llseek
= no_llseek
,
1373 spufs_psmap_mmap_fault(struct vm_fault
*vmf
)
1375 return spufs_ps_fault(vmf
, 0x0000, SPUFS_PS_MAP_SIZE
);
1378 static const struct vm_operations_struct spufs_psmap_mmap_vmops
= {
1379 .fault
= spufs_psmap_mmap_fault
,
1383 * mmap support for full problem state area [0x00000 - 0x1ffff].
1385 static int spufs_psmap_mmap(struct file
*file
, struct vm_area_struct
*vma
)
1387 if (!(vma
->vm_flags
& VM_SHARED
))
1390 vma
->vm_flags
|= VM_IO
| VM_PFNMAP
;
1391 vma
->vm_page_prot
= pgprot_noncached(vma
->vm_page_prot
);
1393 vma
->vm_ops
= &spufs_psmap_mmap_vmops
;
1397 static int spufs_psmap_open(struct inode
*inode
, struct file
*file
)
1399 struct spufs_inode_info
*i
= SPUFS_I(inode
);
1400 struct spu_context
*ctx
= i
->i_ctx
;
1402 mutex_lock(&ctx
->mapping_lock
);
1403 file
->private_data
= i
->i_ctx
;
1404 if (!i
->i_openers
++)
1405 ctx
->psmap
= inode
->i_mapping
;
1406 mutex_unlock(&ctx
->mapping_lock
);
1407 return nonseekable_open(inode
, file
);
1411 spufs_psmap_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_psmap_fops
= {
1424 .open
= spufs_psmap_open
,
1425 .release
= spufs_psmap_release
,
1426 .mmap
= spufs_psmap_mmap
,
1427 .llseek
= no_llseek
,
1433 spufs_mfc_mmap_fault(struct vm_fault
*vmf
)
1435 return spufs_ps_fault(vmf
, 0x3000, SPUFS_MFC_MAP_SIZE
);
1438 static const struct vm_operations_struct spufs_mfc_mmap_vmops
= {
1439 .fault
= spufs_mfc_mmap_fault
,
1443 * mmap support for problem state MFC DMA area [0x0000 - 0x0fff].
1445 static int spufs_mfc_mmap(struct file
*file
, struct vm_area_struct
*vma
)
1447 if (!(vma
->vm_flags
& VM_SHARED
))
1450 vma
->vm_flags
|= VM_IO
| VM_PFNMAP
;
1451 vma
->vm_page_prot
= pgprot_noncached(vma
->vm_page_prot
);
1453 vma
->vm_ops
= &spufs_mfc_mmap_vmops
;
1456 #else /* SPUFS_MMAP_4K */
1457 #define spufs_mfc_mmap NULL
1458 #endif /* !SPUFS_MMAP_4K */
1460 static int spufs_mfc_open(struct inode
*inode
, struct file
*file
)
1462 struct spufs_inode_info
*i
= SPUFS_I(inode
);
1463 struct spu_context
*ctx
= i
->i_ctx
;
1465 /* we don't want to deal with DMA into other processes */
1466 if (ctx
->owner
!= current
->mm
)
1469 if (atomic_read(&inode
->i_count
) != 1)
1472 mutex_lock(&ctx
->mapping_lock
);
1473 file
->private_data
= ctx
;
1474 if (!i
->i_openers
++)
1475 ctx
->mfc
= inode
->i_mapping
;
1476 mutex_unlock(&ctx
->mapping_lock
);
1477 return nonseekable_open(inode
, file
);
1481 spufs_mfc_release(struct inode
*inode
, struct file
*file
)
1483 struct spufs_inode_info
*i
= SPUFS_I(inode
);
1484 struct spu_context
*ctx
= i
->i_ctx
;
1486 mutex_lock(&ctx
->mapping_lock
);
1487 if (!--i
->i_openers
)
1489 mutex_unlock(&ctx
->mapping_lock
);
1493 /* interrupt-level mfc callback function. */
1494 void spufs_mfc_callback(struct spu
*spu
)
1496 struct spu_context
*ctx
= spu
->ctx
;
1499 wake_up_all(&ctx
->mfc_wq
);
1502 static int spufs_read_mfc_tagstatus(struct spu_context
*ctx
, u32
*status
)
1504 /* See if there is one tag group is complete */
1505 /* FIXME we need locking around tagwait */
1506 *status
= ctx
->ops
->read_mfc_tagstatus(ctx
) & ctx
->tagwait
;
1507 ctx
->tagwait
&= ~*status
;
1511 /* enable interrupt waiting for any tag group,
1512 may silently fail if interrupts are already enabled */
1513 ctx
->ops
->set_mfc_query(ctx
, ctx
->tagwait
, 1);
1517 static ssize_t
spufs_mfc_read(struct file
*file
, char __user
*buffer
,
1518 size_t size
, loff_t
*pos
)
1520 struct spu_context
*ctx
= file
->private_data
;
1527 ret
= spu_acquire(ctx
);
1532 if (file
->f_flags
& O_NONBLOCK
) {
1533 status
= ctx
->ops
->read_mfc_tagstatus(ctx
);
1534 if (!(status
& ctx
->tagwait
))
1537 /* XXX(hch): shouldn't we clear ret here? */
1538 ctx
->tagwait
&= ~status
;
1540 ret
= spufs_wait(ctx
->mfc_wq
,
1541 spufs_read_mfc_tagstatus(ctx
, &status
));
1548 if (copy_to_user(buffer
, &status
, 4))
1555 static int spufs_check_valid_dma(struct mfc_dma_command
*cmd
)
1557 pr_debug("queueing DMA %x %llx %x %x %x\n", cmd
->lsa
,
1558 cmd
->ea
, cmd
->size
, cmd
->tag
, cmd
->cmd
);
1569 pr_debug("invalid DMA opcode %x\n", cmd
->cmd
);
1573 if ((cmd
->lsa
& 0xf) != (cmd
->ea
&0xf)) {
1574 pr_debug("invalid DMA alignment, ea %llx lsa %x\n",
1579 switch (cmd
->size
& 0xf) {
1600 pr_debug("invalid DMA alignment %x for size %x\n",
1601 cmd
->lsa
& 0xf, cmd
->size
);
1605 if (cmd
->size
> 16 * 1024) {
1606 pr_debug("invalid DMA size %x\n", cmd
->size
);
1610 if (cmd
->tag
& 0xfff0) {
1611 /* we reserve the higher tag numbers for kernel use */
1612 pr_debug("invalid DMA tag\n");
1617 /* not supported in this version */
1618 pr_debug("invalid DMA class\n");
1625 static int spu_send_mfc_command(struct spu_context
*ctx
,
1626 struct mfc_dma_command cmd
,
1629 *error
= ctx
->ops
->send_mfc_command(ctx
, &cmd
);
1630 if (*error
== -EAGAIN
) {
1631 /* wait for any tag group to complete
1632 so we have space for the new command */
1633 ctx
->ops
->set_mfc_query(ctx
, ctx
->tagwait
, 1);
1634 /* try again, because the queue might be
1636 *error
= ctx
->ops
->send_mfc_command(ctx
, &cmd
);
1637 if (*error
== -EAGAIN
)
1643 static ssize_t
spufs_mfc_write(struct file
*file
, const char __user
*buffer
,
1644 size_t size
, loff_t
*pos
)
1646 struct spu_context
*ctx
= file
->private_data
;
1647 struct mfc_dma_command cmd
;
1650 if (size
!= sizeof cmd
)
1654 if (copy_from_user(&cmd
, buffer
, sizeof cmd
))
1657 ret
= spufs_check_valid_dma(&cmd
);
1661 ret
= spu_acquire(ctx
);
1665 ret
= spufs_wait(ctx
->run_wq
, ctx
->state
== SPU_STATE_RUNNABLE
);
1669 if (file
->f_flags
& O_NONBLOCK
) {
1670 ret
= ctx
->ops
->send_mfc_command(ctx
, &cmd
);
1673 ret
= spufs_wait(ctx
->mfc_wq
,
1674 spu_send_mfc_command(ctx
, cmd
, &status
));
1684 ctx
->tagwait
|= 1 << cmd
.tag
;
1693 static unsigned int spufs_mfc_poll(struct file
*file
,poll_table
*wait
)
1695 struct spu_context
*ctx
= file
->private_data
;
1696 u32 free_elements
, tagstatus
;
1699 poll_wait(file
, &ctx
->mfc_wq
, wait
);
1702 * For now keep this uninterruptible and also ignore the rule
1703 * that poll should not sleep. Will be fixed later.
1705 mutex_lock(&ctx
->state_mutex
);
1706 ctx
->ops
->set_mfc_query(ctx
, ctx
->tagwait
, 2);
1707 free_elements
= ctx
->ops
->get_mfc_free_elements(ctx
);
1708 tagstatus
= ctx
->ops
->read_mfc_tagstatus(ctx
);
1712 if (free_elements
& 0xffff)
1713 mask
|= POLLOUT
| POLLWRNORM
;
1714 if (tagstatus
& ctx
->tagwait
)
1715 mask
|= POLLIN
| POLLRDNORM
;
1717 pr_debug("%s: free %d tagstatus %d tagwait %d\n", __func__
,
1718 free_elements
, tagstatus
, ctx
->tagwait
);
1723 static int spufs_mfc_flush(struct file
*file
, fl_owner_t id
)
1725 struct spu_context
*ctx
= file
->private_data
;
1728 ret
= spu_acquire(ctx
);
1732 /* this currently hangs */
1733 ret
= spufs_wait(ctx
->mfc_wq
,
1734 ctx
->ops
->set_mfc_query(ctx
, ctx
->tagwait
, 2));
1737 ret
= spufs_wait(ctx
->mfc_wq
,
1738 ctx
->ops
->read_mfc_tagstatus(ctx
) == ctx
->tagwait
);
1749 static int spufs_mfc_fsync(struct file
*file
, loff_t start
, loff_t end
, int datasync
)
1751 struct inode
*inode
= file_inode(file
);
1752 int err
= file_write_and_wait_range(file
, start
, end
);
1755 err
= spufs_mfc_flush(file
, NULL
);
1756 inode_unlock(inode
);
1761 static const struct file_operations spufs_mfc_fops
= {
1762 .open
= spufs_mfc_open
,
1763 .release
= spufs_mfc_release
,
1764 .read
= spufs_mfc_read
,
1765 .write
= spufs_mfc_write
,
1766 .poll
= spufs_mfc_poll
,
1767 .flush
= spufs_mfc_flush
,
1768 .fsync
= spufs_mfc_fsync
,
1769 .mmap
= spufs_mfc_mmap
,
1770 .llseek
= no_llseek
,
1773 static int spufs_npc_set(void *data
, u64 val
)
1775 struct spu_context
*ctx
= data
;
1778 ret
= spu_acquire(ctx
);
1781 ctx
->ops
->npc_write(ctx
, val
);
1787 static u64
spufs_npc_get(struct spu_context
*ctx
)
1789 return ctx
->ops
->npc_read(ctx
);
1791 DEFINE_SPUFS_ATTRIBUTE(spufs_npc_ops
, spufs_npc_get
, spufs_npc_set
,
1792 "0x%llx\n", SPU_ATTR_ACQUIRE
);
1794 static int spufs_decr_set(void *data
, u64 val
)
1796 struct spu_context
*ctx
= data
;
1797 struct spu_lscsa
*lscsa
= ctx
->csa
.lscsa
;
1800 ret
= spu_acquire_saved(ctx
);
1803 lscsa
->decr
.slot
[0] = (u32
) val
;
1804 spu_release_saved(ctx
);
1809 static u64
spufs_decr_get(struct spu_context
*ctx
)
1811 struct spu_lscsa
*lscsa
= ctx
->csa
.lscsa
;
1812 return lscsa
->decr
.slot
[0];
1814 DEFINE_SPUFS_ATTRIBUTE(spufs_decr_ops
, spufs_decr_get
, spufs_decr_set
,
1815 "0x%llx\n", SPU_ATTR_ACQUIRE_SAVED
);
1817 static int spufs_decr_status_set(void *data
, u64 val
)
1819 struct spu_context
*ctx
= data
;
1822 ret
= spu_acquire_saved(ctx
);
1826 ctx
->csa
.priv2
.mfc_control_RW
|= MFC_CNTL_DECREMENTER_RUNNING
;
1828 ctx
->csa
.priv2
.mfc_control_RW
&= ~MFC_CNTL_DECREMENTER_RUNNING
;
1829 spu_release_saved(ctx
);
1834 static u64
spufs_decr_status_get(struct spu_context
*ctx
)
1836 if (ctx
->csa
.priv2
.mfc_control_RW
& MFC_CNTL_DECREMENTER_RUNNING
)
1837 return SPU_DECR_STATUS_RUNNING
;
1841 DEFINE_SPUFS_ATTRIBUTE(spufs_decr_status_ops
, spufs_decr_status_get
,
1842 spufs_decr_status_set
, "0x%llx\n",
1843 SPU_ATTR_ACQUIRE_SAVED
);
1845 static int spufs_event_mask_set(void *data
, u64 val
)
1847 struct spu_context
*ctx
= data
;
1848 struct spu_lscsa
*lscsa
= ctx
->csa
.lscsa
;
1851 ret
= spu_acquire_saved(ctx
);
1854 lscsa
->event_mask
.slot
[0] = (u32
) val
;
1855 spu_release_saved(ctx
);
1860 static u64
spufs_event_mask_get(struct spu_context
*ctx
)
1862 struct spu_lscsa
*lscsa
= ctx
->csa
.lscsa
;
1863 return lscsa
->event_mask
.slot
[0];
1866 DEFINE_SPUFS_ATTRIBUTE(spufs_event_mask_ops
, spufs_event_mask_get
,
1867 spufs_event_mask_set
, "0x%llx\n",
1868 SPU_ATTR_ACQUIRE_SAVED
);
1870 static u64
spufs_event_status_get(struct spu_context
*ctx
)
1872 struct spu_state
*state
= &ctx
->csa
;
1874 stat
= state
->spu_chnlcnt_RW
[0];
1876 return state
->spu_chnldata_RW
[0];
1879 DEFINE_SPUFS_ATTRIBUTE(spufs_event_status_ops
, spufs_event_status_get
,
1880 NULL
, "0x%llx\n", SPU_ATTR_ACQUIRE_SAVED
)
1882 static int spufs_srr0_set(void *data
, u64 val
)
1884 struct spu_context
*ctx
= data
;
1885 struct spu_lscsa
*lscsa
= ctx
->csa
.lscsa
;
1888 ret
= spu_acquire_saved(ctx
);
1891 lscsa
->srr0
.slot
[0] = (u32
) val
;
1892 spu_release_saved(ctx
);
1897 static u64
spufs_srr0_get(struct spu_context
*ctx
)
1899 struct spu_lscsa
*lscsa
= ctx
->csa
.lscsa
;
1900 return lscsa
->srr0
.slot
[0];
1902 DEFINE_SPUFS_ATTRIBUTE(spufs_srr0_ops
, spufs_srr0_get
, spufs_srr0_set
,
1903 "0x%llx\n", SPU_ATTR_ACQUIRE_SAVED
)
1905 static u64
spufs_id_get(struct spu_context
*ctx
)
1909 if (ctx
->state
== SPU_STATE_RUNNABLE
)
1910 num
= ctx
->spu
->number
;
1912 num
= (unsigned int)-1;
1916 DEFINE_SPUFS_ATTRIBUTE(spufs_id_ops
, spufs_id_get
, NULL
, "0x%llx\n",
1919 static u64
spufs_object_id_get(struct spu_context
*ctx
)
1921 /* FIXME: Should there really be no locking here? */
1922 return ctx
->object_id
;
1925 static int spufs_object_id_set(void *data
, u64 id
)
1927 struct spu_context
*ctx
= data
;
1928 ctx
->object_id
= id
;
1933 DEFINE_SPUFS_ATTRIBUTE(spufs_object_id_ops
, spufs_object_id_get
,
1934 spufs_object_id_set
, "0x%llx\n", SPU_ATTR_NOACQUIRE
);
1936 static u64
spufs_lslr_get(struct spu_context
*ctx
)
1938 return ctx
->csa
.priv2
.spu_lslr_RW
;
1940 DEFINE_SPUFS_ATTRIBUTE(spufs_lslr_ops
, spufs_lslr_get
, NULL
, "0x%llx\n",
1941 SPU_ATTR_ACQUIRE_SAVED
);
1943 static int spufs_info_open(struct inode
*inode
, struct file
*file
)
1945 struct spufs_inode_info
*i
= SPUFS_I(inode
);
1946 struct spu_context
*ctx
= i
->i_ctx
;
1947 file
->private_data
= ctx
;
1951 static int spufs_caps_show(struct seq_file
*s
, void *private)
1953 struct spu_context
*ctx
= s
->private;
1955 if (!(ctx
->flags
& SPU_CREATE_NOSCHED
))
1956 seq_puts(s
, "sched\n");
1957 if (!(ctx
->flags
& SPU_CREATE_ISOLATE
))
1958 seq_puts(s
, "step\n");
1962 static int spufs_caps_open(struct inode
*inode
, struct file
*file
)
1964 return single_open(file
, spufs_caps_show
, SPUFS_I(inode
)->i_ctx
);
1967 static const struct file_operations spufs_caps_fops
= {
1968 .open
= spufs_caps_open
,
1970 .llseek
= seq_lseek
,
1971 .release
= single_release
,
1974 static ssize_t
__spufs_mbox_info_read(struct spu_context
*ctx
,
1975 char __user
*buf
, size_t len
, loff_t
*pos
)
1979 /* EOF if there's no entry in the mbox */
1980 if (!(ctx
->csa
.prob
.mb_stat_R
& 0x0000ff))
1983 data
= ctx
->csa
.prob
.pu_mb_R
;
1985 return simple_read_from_buffer(buf
, len
, pos
, &data
, sizeof data
);
1988 static ssize_t
spufs_mbox_info_read(struct file
*file
, char __user
*buf
,
1989 size_t len
, loff_t
*pos
)
1992 struct spu_context
*ctx
= file
->private_data
;
1994 if (!access_ok(VERIFY_WRITE
, buf
, len
))
1997 ret
= spu_acquire_saved(ctx
);
2000 spin_lock(&ctx
->csa
.register_lock
);
2001 ret
= __spufs_mbox_info_read(ctx
, buf
, len
, pos
);
2002 spin_unlock(&ctx
->csa
.register_lock
);
2003 spu_release_saved(ctx
);
2008 static const struct file_operations spufs_mbox_info_fops
= {
2009 .open
= spufs_info_open
,
2010 .read
= spufs_mbox_info_read
,
2011 .llseek
= generic_file_llseek
,
2014 static ssize_t
__spufs_ibox_info_read(struct spu_context
*ctx
,
2015 char __user
*buf
, size_t len
, loff_t
*pos
)
2019 /* EOF if there's no entry in the ibox */
2020 if (!(ctx
->csa
.prob
.mb_stat_R
& 0xff0000))
2023 data
= ctx
->csa
.priv2
.puint_mb_R
;
2025 return simple_read_from_buffer(buf
, len
, pos
, &data
, sizeof data
);
2028 static ssize_t
spufs_ibox_info_read(struct file
*file
, char __user
*buf
,
2029 size_t len
, loff_t
*pos
)
2031 struct spu_context
*ctx
= file
->private_data
;
2034 if (!access_ok(VERIFY_WRITE
, buf
, len
))
2037 ret
= spu_acquire_saved(ctx
);
2040 spin_lock(&ctx
->csa
.register_lock
);
2041 ret
= __spufs_ibox_info_read(ctx
, buf
, len
, pos
);
2042 spin_unlock(&ctx
->csa
.register_lock
);
2043 spu_release_saved(ctx
);
2048 static const struct file_operations spufs_ibox_info_fops
= {
2049 .open
= spufs_info_open
,
2050 .read
= spufs_ibox_info_read
,
2051 .llseek
= generic_file_llseek
,
2054 static ssize_t
__spufs_wbox_info_read(struct spu_context
*ctx
,
2055 char __user
*buf
, size_t len
, loff_t
*pos
)
2061 wbox_stat
= ctx
->csa
.prob
.mb_stat_R
;
2062 cnt
= 4 - ((wbox_stat
& 0x00ff00) >> 8);
2063 for (i
= 0; i
< cnt
; i
++) {
2064 data
[i
] = ctx
->csa
.spu_mailbox_data
[i
];
2067 return simple_read_from_buffer(buf
, len
, pos
, &data
,
2071 static ssize_t
spufs_wbox_info_read(struct file
*file
, char __user
*buf
,
2072 size_t len
, loff_t
*pos
)
2074 struct spu_context
*ctx
= file
->private_data
;
2077 if (!access_ok(VERIFY_WRITE
, buf
, len
))
2080 ret
= spu_acquire_saved(ctx
);
2083 spin_lock(&ctx
->csa
.register_lock
);
2084 ret
= __spufs_wbox_info_read(ctx
, buf
, len
, pos
);
2085 spin_unlock(&ctx
->csa
.register_lock
);
2086 spu_release_saved(ctx
);
2091 static const struct file_operations spufs_wbox_info_fops
= {
2092 .open
= spufs_info_open
,
2093 .read
= spufs_wbox_info_read
,
2094 .llseek
= generic_file_llseek
,
2097 static ssize_t
__spufs_dma_info_read(struct spu_context
*ctx
,
2098 char __user
*buf
, size_t len
, loff_t
*pos
)
2100 struct spu_dma_info info
;
2101 struct mfc_cq_sr
*qp
, *spuqp
;
2104 info
.dma_info_type
= ctx
->csa
.priv2
.spu_tag_status_query_RW
;
2105 info
.dma_info_mask
= ctx
->csa
.lscsa
->tag_mask
.slot
[0];
2106 info
.dma_info_status
= ctx
->csa
.spu_chnldata_RW
[24];
2107 info
.dma_info_stall_and_notify
= ctx
->csa
.spu_chnldata_RW
[25];
2108 info
.dma_info_atomic_command_status
= ctx
->csa
.spu_chnldata_RW
[27];
2109 for (i
= 0; i
< 16; i
++) {
2110 qp
= &info
.dma_info_command_data
[i
];
2111 spuqp
= &ctx
->csa
.priv2
.spuq
[i
];
2113 qp
->mfc_cq_data0_RW
= spuqp
->mfc_cq_data0_RW
;
2114 qp
->mfc_cq_data1_RW
= spuqp
->mfc_cq_data1_RW
;
2115 qp
->mfc_cq_data2_RW
= spuqp
->mfc_cq_data2_RW
;
2116 qp
->mfc_cq_data3_RW
= spuqp
->mfc_cq_data3_RW
;
2119 return simple_read_from_buffer(buf
, len
, pos
, &info
,
2123 static ssize_t
spufs_dma_info_read(struct file
*file
, char __user
*buf
,
2124 size_t len
, loff_t
*pos
)
2126 struct spu_context
*ctx
= file
->private_data
;
2129 if (!access_ok(VERIFY_WRITE
, buf
, len
))
2132 ret
= spu_acquire_saved(ctx
);
2135 spin_lock(&ctx
->csa
.register_lock
);
2136 ret
= __spufs_dma_info_read(ctx
, buf
, len
, pos
);
2137 spin_unlock(&ctx
->csa
.register_lock
);
2138 spu_release_saved(ctx
);
2143 static const struct file_operations spufs_dma_info_fops
= {
2144 .open
= spufs_info_open
,
2145 .read
= spufs_dma_info_read
,
2146 .llseek
= no_llseek
,
2149 static ssize_t
__spufs_proxydma_info_read(struct spu_context
*ctx
,
2150 char __user
*buf
, size_t len
, loff_t
*pos
)
2152 struct spu_proxydma_info info
;
2153 struct mfc_cq_sr
*qp
, *puqp
;
2154 int ret
= sizeof info
;
2160 if (!access_ok(VERIFY_WRITE
, buf
, len
))
2163 info
.proxydma_info_type
= ctx
->csa
.prob
.dma_querytype_RW
;
2164 info
.proxydma_info_mask
= ctx
->csa
.prob
.dma_querymask_RW
;
2165 info
.proxydma_info_status
= ctx
->csa
.prob
.dma_tagstatus_R
;
2166 for (i
= 0; i
< 8; i
++) {
2167 qp
= &info
.proxydma_info_command_data
[i
];
2168 puqp
= &ctx
->csa
.priv2
.puq
[i
];
2170 qp
->mfc_cq_data0_RW
= puqp
->mfc_cq_data0_RW
;
2171 qp
->mfc_cq_data1_RW
= puqp
->mfc_cq_data1_RW
;
2172 qp
->mfc_cq_data2_RW
= puqp
->mfc_cq_data2_RW
;
2173 qp
->mfc_cq_data3_RW
= puqp
->mfc_cq_data3_RW
;
2176 return simple_read_from_buffer(buf
, len
, pos
, &info
,
2180 static ssize_t
spufs_proxydma_info_read(struct file
*file
, char __user
*buf
,
2181 size_t len
, loff_t
*pos
)
2183 struct spu_context
*ctx
= file
->private_data
;
2186 ret
= spu_acquire_saved(ctx
);
2189 spin_lock(&ctx
->csa
.register_lock
);
2190 ret
= __spufs_proxydma_info_read(ctx
, buf
, len
, pos
);
2191 spin_unlock(&ctx
->csa
.register_lock
);
2192 spu_release_saved(ctx
);
2197 static const struct file_operations spufs_proxydma_info_fops
= {
2198 .open
= spufs_info_open
,
2199 .read
= spufs_proxydma_info_read
,
2200 .llseek
= no_llseek
,
2203 static int spufs_show_tid(struct seq_file
*s
, void *private)
2205 struct spu_context
*ctx
= s
->private;
2207 seq_printf(s
, "%d\n", ctx
->tid
);
2211 static int spufs_tid_open(struct inode
*inode
, struct file
*file
)
2213 return single_open(file
, spufs_show_tid
, SPUFS_I(inode
)->i_ctx
);
2216 static const struct file_operations spufs_tid_fops
= {
2217 .open
= spufs_tid_open
,
2219 .llseek
= seq_lseek
,
2220 .release
= single_release
,
2223 static const char *ctx_state_names
[] = {
2224 "user", "system", "iowait", "loaded"
2227 static unsigned long long spufs_acct_time(struct spu_context
*ctx
,
2228 enum spu_utilization_state state
)
2230 unsigned long long time
= ctx
->stats
.times
[state
];
2233 * In general, utilization statistics are updated by the controlling
2234 * thread as the spu context moves through various well defined
2235 * state transitions, but if the context is lazily loaded its
2236 * utilization statistics are not updated as the controlling thread
2237 * is not tightly coupled with the execution of the spu context. We
2238 * calculate and apply the time delta from the last recorded state
2239 * of the spu context.
2241 if (ctx
->spu
&& ctx
->stats
.util_state
== state
) {
2242 time
+= ktime_get_ns() - ctx
->stats
.tstamp
;
2245 return time
/ NSEC_PER_MSEC
;
2248 static unsigned long long spufs_slb_flts(struct spu_context
*ctx
)
2250 unsigned long long slb_flts
= ctx
->stats
.slb_flt
;
2252 if (ctx
->state
== SPU_STATE_RUNNABLE
) {
2253 slb_flts
+= (ctx
->spu
->stats
.slb_flt
-
2254 ctx
->stats
.slb_flt_base
);
2260 static unsigned long long spufs_class2_intrs(struct spu_context
*ctx
)
2262 unsigned long long class2_intrs
= ctx
->stats
.class2_intr
;
2264 if (ctx
->state
== SPU_STATE_RUNNABLE
) {
2265 class2_intrs
+= (ctx
->spu
->stats
.class2_intr
-
2266 ctx
->stats
.class2_intr_base
);
2269 return class2_intrs
;
2273 static int spufs_show_stat(struct seq_file
*s
, void *private)
2275 struct spu_context
*ctx
= s
->private;
2278 ret
= spu_acquire(ctx
);
2282 seq_printf(s
, "%s %llu %llu %llu %llu "
2283 "%llu %llu %llu %llu %llu %llu %llu %llu\n",
2284 ctx_state_names
[ctx
->stats
.util_state
],
2285 spufs_acct_time(ctx
, SPU_UTIL_USER
),
2286 spufs_acct_time(ctx
, SPU_UTIL_SYSTEM
),
2287 spufs_acct_time(ctx
, SPU_UTIL_IOWAIT
),
2288 spufs_acct_time(ctx
, SPU_UTIL_IDLE_LOADED
),
2289 ctx
->stats
.vol_ctx_switch
,
2290 ctx
->stats
.invol_ctx_switch
,
2291 spufs_slb_flts(ctx
),
2292 ctx
->stats
.hash_flt
,
2295 spufs_class2_intrs(ctx
),
2296 ctx
->stats
.libassist
);
2301 static int spufs_stat_open(struct inode
*inode
, struct file
*file
)
2303 return single_open(file
, spufs_show_stat
, SPUFS_I(inode
)->i_ctx
);
2306 static const struct file_operations spufs_stat_fops
= {
2307 .open
= spufs_stat_open
,
2309 .llseek
= seq_lseek
,
2310 .release
= single_release
,
2313 static inline int spufs_switch_log_used(struct spu_context
*ctx
)
2315 return (ctx
->switch_log
->head
- ctx
->switch_log
->tail
) %
2319 static inline int spufs_switch_log_avail(struct spu_context
*ctx
)
2321 return SWITCH_LOG_BUFSIZE
- spufs_switch_log_used(ctx
);
2324 static int spufs_switch_log_open(struct inode
*inode
, struct file
*file
)
2326 struct spu_context
*ctx
= SPUFS_I(inode
)->i_ctx
;
2329 rc
= spu_acquire(ctx
);
2333 if (ctx
->switch_log
) {
2338 ctx
->switch_log
= kmalloc(sizeof(struct switch_log
) +
2339 SWITCH_LOG_BUFSIZE
* sizeof(struct switch_log_entry
),
2342 if (!ctx
->switch_log
) {
2347 ctx
->switch_log
->head
= ctx
->switch_log
->tail
= 0;
2348 init_waitqueue_head(&ctx
->switch_log
->wait
);
2356 static int spufs_switch_log_release(struct inode
*inode
, struct file
*file
)
2358 struct spu_context
*ctx
= SPUFS_I(inode
)->i_ctx
;
2361 rc
= spu_acquire(ctx
);
2365 kfree(ctx
->switch_log
);
2366 ctx
->switch_log
= NULL
;
2372 static int switch_log_sprint(struct spu_context
*ctx
, char *tbuf
, int n
)
2374 struct switch_log_entry
*p
;
2376 p
= ctx
->switch_log
->log
+ ctx
->switch_log
->tail
% SWITCH_LOG_BUFSIZE
;
2378 return snprintf(tbuf
, n
, "%u.%09u %d %u %u %llu\n",
2379 (unsigned int) p
->tstamp
.tv_sec
,
2380 (unsigned int) p
->tstamp
.tv_nsec
,
2382 (unsigned int) p
->type
,
2383 (unsigned int) p
->val
,
2384 (unsigned long long) p
->timebase
);
2387 static ssize_t
spufs_switch_log_read(struct file
*file
, char __user
*buf
,
2388 size_t len
, loff_t
*ppos
)
2390 struct inode
*inode
= file_inode(file
);
2391 struct spu_context
*ctx
= SPUFS_I(inode
)->i_ctx
;
2392 int error
= 0, cnt
= 0;
2397 error
= spu_acquire(ctx
);
2405 if (spufs_switch_log_used(ctx
) == 0) {
2407 /* If there's data ready to go, we can
2408 * just return straight away */
2411 } else if (file
->f_flags
& O_NONBLOCK
) {
2416 /* spufs_wait will drop the mutex and
2417 * re-acquire, but since we're in read(), the
2418 * file cannot be _released (and so
2419 * ctx->switch_log is stable).
2421 error
= spufs_wait(ctx
->switch_log
->wait
,
2422 spufs_switch_log_used(ctx
) > 0);
2424 /* On error, spufs_wait returns without the
2425 * state mutex held */
2429 /* We may have had entries read from underneath
2430 * us while we dropped the mutex in spufs_wait,
2432 if (spufs_switch_log_used(ctx
) == 0)
2437 width
= switch_log_sprint(ctx
, tbuf
, sizeof(tbuf
));
2439 ctx
->switch_log
->tail
=
2440 (ctx
->switch_log
->tail
+ 1) %
2443 /* If the record is greater than space available return
2444 * partial buffer (so far) */
2447 error
= copy_to_user(buf
+ cnt
, tbuf
, width
);
2455 return cnt
== 0 ? error
: cnt
;
2458 static unsigned int spufs_switch_log_poll(struct file
*file
, poll_table
*wait
)
2460 struct inode
*inode
= file_inode(file
);
2461 struct spu_context
*ctx
= SPUFS_I(inode
)->i_ctx
;
2462 unsigned int mask
= 0;
2465 poll_wait(file
, &ctx
->switch_log
->wait
, wait
);
2467 rc
= spu_acquire(ctx
);
2471 if (spufs_switch_log_used(ctx
) > 0)
2479 static const struct file_operations spufs_switch_log_fops
= {
2480 .open
= spufs_switch_log_open
,
2481 .read
= spufs_switch_log_read
,
2482 .poll
= spufs_switch_log_poll
,
2483 .release
= spufs_switch_log_release
,
2484 .llseek
= no_llseek
,
2488 * Log a context switch event to a switch log reader.
2490 * Must be called with ctx->state_mutex held.
2492 void spu_switch_log_notify(struct spu
*spu
, struct spu_context
*ctx
,
2495 if (!ctx
->switch_log
)
2498 if (spufs_switch_log_avail(ctx
) > 1) {
2499 struct switch_log_entry
*p
;
2501 p
= ctx
->switch_log
->log
+ ctx
->switch_log
->head
;
2502 ktime_get_ts(&p
->tstamp
);
2503 p
->timebase
= get_tb();
2504 p
->spu_id
= spu
? spu
->number
: -1;
2508 ctx
->switch_log
->head
=
2509 (ctx
->switch_log
->head
+ 1) % SWITCH_LOG_BUFSIZE
;
2512 wake_up(&ctx
->switch_log
->wait
);
2515 static int spufs_show_ctx(struct seq_file
*s
, void *private)
2517 struct spu_context
*ctx
= s
->private;
2520 mutex_lock(&ctx
->state_mutex
);
2522 struct spu
*spu
= ctx
->spu
;
2523 struct spu_priv2 __iomem
*priv2
= spu
->priv2
;
2525 spin_lock_irq(&spu
->register_lock
);
2526 mfc_control_RW
= in_be64(&priv2
->mfc_control_RW
);
2527 spin_unlock_irq(&spu
->register_lock
);
2529 struct spu_state
*csa
= &ctx
->csa
;
2531 mfc_control_RW
= csa
->priv2
.mfc_control_RW
;
2534 seq_printf(s
, "%c flgs(%lx) sflgs(%lx) pri(%d) ts(%d) spu(%02d)"
2535 " %c %llx %llx %llx %llx %x %x\n",
2536 ctx
->state
== SPU_STATE_SAVED
? 'S' : 'R',
2541 ctx
->spu
? ctx
->spu
->number
: -1,
2542 !list_empty(&ctx
->rq
) ? 'q' : ' ',
2543 ctx
->csa
.class_0_pending
,
2544 ctx
->csa
.class_0_dar
,
2545 ctx
->csa
.class_1_dsisr
,
2547 ctx
->ops
->runcntl_read(ctx
),
2548 ctx
->ops
->status_read(ctx
));
2550 mutex_unlock(&ctx
->state_mutex
);
2555 static int spufs_ctx_open(struct inode
*inode
, struct file
*file
)
2557 return single_open(file
, spufs_show_ctx
, SPUFS_I(inode
)->i_ctx
);
2560 static const struct file_operations spufs_ctx_fops
= {
2561 .open
= spufs_ctx_open
,
2563 .llseek
= seq_lseek
,
2564 .release
= single_release
,
2567 const struct spufs_tree_descr spufs_dir_contents
[] = {
2568 { "capabilities", &spufs_caps_fops
, 0444, },
2569 { "mem", &spufs_mem_fops
, 0666, LS_SIZE
, },
2570 { "regs", &spufs_regs_fops
, 0666, sizeof(struct spu_reg128
[128]), },
2571 { "mbox", &spufs_mbox_fops
, 0444, },
2572 { "ibox", &spufs_ibox_fops
, 0444, },
2573 { "wbox", &spufs_wbox_fops
, 0222, },
2574 { "mbox_stat", &spufs_mbox_stat_fops
, 0444, sizeof(u32
), },
2575 { "ibox_stat", &spufs_ibox_stat_fops
, 0444, sizeof(u32
), },
2576 { "wbox_stat", &spufs_wbox_stat_fops
, 0444, sizeof(u32
), },
2577 { "signal1", &spufs_signal1_fops
, 0666, },
2578 { "signal2", &spufs_signal2_fops
, 0666, },
2579 { "signal1_type", &spufs_signal1_type
, 0666, },
2580 { "signal2_type", &spufs_signal2_type
, 0666, },
2581 { "cntl", &spufs_cntl_fops
, 0666, },
2582 { "fpcr", &spufs_fpcr_fops
, 0666, sizeof(struct spu_reg128
), },
2583 { "lslr", &spufs_lslr_ops
, 0444, },
2584 { "mfc", &spufs_mfc_fops
, 0666, },
2585 { "mss", &spufs_mss_fops
, 0666, },
2586 { "npc", &spufs_npc_ops
, 0666, },
2587 { "srr0", &spufs_srr0_ops
, 0666, },
2588 { "decr", &spufs_decr_ops
, 0666, },
2589 { "decr_status", &spufs_decr_status_ops
, 0666, },
2590 { "event_mask", &spufs_event_mask_ops
, 0666, },
2591 { "event_status", &spufs_event_status_ops
, 0444, },
2592 { "psmap", &spufs_psmap_fops
, 0666, SPUFS_PS_MAP_SIZE
, },
2593 { "phys-id", &spufs_id_ops
, 0666, },
2594 { "object-id", &spufs_object_id_ops
, 0666, },
2595 { "mbox_info", &spufs_mbox_info_fops
, 0444, sizeof(u32
), },
2596 { "ibox_info", &spufs_ibox_info_fops
, 0444, sizeof(u32
), },
2597 { "wbox_info", &spufs_wbox_info_fops
, 0444, sizeof(u32
), },
2598 { "dma_info", &spufs_dma_info_fops
, 0444,
2599 sizeof(struct spu_dma_info
), },
2600 { "proxydma_info", &spufs_proxydma_info_fops
, 0444,
2601 sizeof(struct spu_proxydma_info
)},
2602 { "tid", &spufs_tid_fops
, 0444, },
2603 { "stat", &spufs_stat_fops
, 0444, },
2604 { "switch_log", &spufs_switch_log_fops
, 0444 },
2608 const struct spufs_tree_descr spufs_dir_nosched_contents
[] = {
2609 { "capabilities", &spufs_caps_fops
, 0444, },
2610 { "mem", &spufs_mem_fops
, 0666, LS_SIZE
, },
2611 { "mbox", &spufs_mbox_fops
, 0444, },
2612 { "ibox", &spufs_ibox_fops
, 0444, },
2613 { "wbox", &spufs_wbox_fops
, 0222, },
2614 { "mbox_stat", &spufs_mbox_stat_fops
, 0444, sizeof(u32
), },
2615 { "ibox_stat", &spufs_ibox_stat_fops
, 0444, sizeof(u32
), },
2616 { "wbox_stat", &spufs_wbox_stat_fops
, 0444, sizeof(u32
), },
2617 { "signal1", &spufs_signal1_nosched_fops
, 0222, },
2618 { "signal2", &spufs_signal2_nosched_fops
, 0222, },
2619 { "signal1_type", &spufs_signal1_type
, 0666, },
2620 { "signal2_type", &spufs_signal2_type
, 0666, },
2621 { "mss", &spufs_mss_fops
, 0666, },
2622 { "mfc", &spufs_mfc_fops
, 0666, },
2623 { "cntl", &spufs_cntl_fops
, 0666, },
2624 { "npc", &spufs_npc_ops
, 0666, },
2625 { "psmap", &spufs_psmap_fops
, 0666, SPUFS_PS_MAP_SIZE
, },
2626 { "phys-id", &spufs_id_ops
, 0666, },
2627 { "object-id", &spufs_object_id_ops
, 0666, },
2628 { "tid", &spufs_tid_fops
, 0444, },
2629 { "stat", &spufs_stat_fops
, 0444, },
2633 const struct spufs_tree_descr spufs_dir_debug_contents
[] = {
2634 { ".ctx", &spufs_ctx_fops
, 0444, },
2638 const struct spufs_coredump_reader spufs_coredump_read
[] = {
2639 { "regs", __spufs_regs_read
, NULL
, sizeof(struct spu_reg128
[128])},
2640 { "fpcr", __spufs_fpcr_read
, NULL
, sizeof(struct spu_reg128
) },
2641 { "lslr", NULL
, spufs_lslr_get
, 19 },
2642 { "decr", NULL
, spufs_decr_get
, 19 },
2643 { "decr_status", NULL
, spufs_decr_status_get
, 19 },
2644 { "mem", __spufs_mem_read
, NULL
, LS_SIZE
, },
2645 { "signal1", __spufs_signal1_read
, NULL
, sizeof(u32
) },
2646 { "signal1_type", NULL
, spufs_signal1_type_get
, 19 },
2647 { "signal2", __spufs_signal2_read
, NULL
, sizeof(u32
) },
2648 { "signal2_type", NULL
, spufs_signal2_type_get
, 19 },
2649 { "event_mask", NULL
, spufs_event_mask_get
, 19 },
2650 { "event_status", NULL
, spufs_event_status_get
, 19 },
2651 { "mbox_info", __spufs_mbox_info_read
, NULL
, sizeof(u32
) },
2652 { "ibox_info", __spufs_ibox_info_read
, NULL
, sizeof(u32
) },
2653 { "wbox_info", __spufs_wbox_info_read
, NULL
, 4 * sizeof(u32
)},
2654 { "dma_info", __spufs_dma_info_read
, NULL
, sizeof(struct spu_dma_info
)},
2655 { "proxydma_info", __spufs_proxydma_info_read
,
2656 NULL
, sizeof(struct spu_proxydma_info
)},
2657 { "object-id", NULL
, spufs_object_id_get
, 19 },
2658 { "npc", NULL
, spufs_npc_get
, 19 },