Lines Matching refs:ctx
164 struct spu_context *ctx = i->i_ctx; in spufs_mem_open() local
166 mutex_lock(&ctx->mapping_lock); in spufs_mem_open()
167 file->private_data = ctx; in spufs_mem_open()
169 ctx->local_store = inode->i_mapping; in spufs_mem_open()
170 mutex_unlock(&ctx->mapping_lock); in spufs_mem_open()
178 struct spu_context *ctx = i->i_ctx; in spufs_mem_release() local
180 mutex_lock(&ctx->mapping_lock); in spufs_mem_release()
182 ctx->local_store = NULL; in spufs_mem_release()
183 mutex_unlock(&ctx->mapping_lock); in spufs_mem_release()
188 __spufs_mem_read(struct spu_context *ctx, char __user *buffer, in __spufs_mem_read() argument
191 char *local_store = ctx->ops->get_ls(ctx); in __spufs_mem_read()
200 struct spu_context *ctx = file->private_data; in spufs_mem_read() local
203 ret = spu_acquire(ctx); in spufs_mem_read()
206 ret = __spufs_mem_read(ctx, buffer, size, pos); in spufs_mem_read()
207 spu_release(ctx); in spufs_mem_read()
216 struct spu_context *ctx = file->private_data; in spufs_mem_write() local
224 ret = spu_acquire(ctx); in spufs_mem_write()
228 local_store = ctx->ops->get_ls(ctx); in spufs_mem_write()
230 spu_release(ctx); in spufs_mem_write()
238 struct spu_context *ctx = vma->vm_file->private_data; in spufs_mem_mmap_fault() local
249 if (spu_acquire(ctx)) in spufs_mem_mmap_fault()
252 if (ctx->state == SPU_STATE_SAVED) { in spufs_mem_mmap_fault()
254 pfn = vmalloc_to_pfn(ctx->csa.lscsa->ls + offset); in spufs_mem_mmap_fault()
257 pfn = (ctx->spu->local_store_phys + offset) >> PAGE_SHIFT; in spufs_mem_mmap_fault()
261 spu_release(ctx); in spufs_mem_mmap_fault()
270 struct spu_context *ctx = vma->vm_file->private_data; in spufs_mem_mmap_access() local
276 if (spu_acquire(ctx)) in spufs_mem_mmap_access()
280 local_store = ctx->ops->get_ls(ctx); in spufs_mem_mmap_access()
285 spu_release(ctx); in spufs_mem_mmap_access()
320 struct spu_context *ctx = vma->vm_file->private_data; in spufs_ps_fault() local
324 spu_context_nospu_trace(spufs_ps_fault__enter, ctx); in spufs_ps_fault()
337 get_spu_context(ctx); in spufs_ps_fault()
347 if (spu_acquire(ctx)) in spufs_ps_fault()
350 if (ctx->state == SPU_STATE_SAVED) { in spufs_ps_fault()
352 spu_context_nospu_trace(spufs_ps_fault__sleep, ctx); in spufs_ps_fault()
353 ret = spufs_wait(ctx->run_wq, ctx->state == SPU_STATE_RUNNABLE); in spufs_ps_fault()
354 spu_context_trace(spufs_ps_fault__wake, ctx, ctx->spu); in spufs_ps_fault()
357 area = ctx->spu->problem_phys + ps_offs; in spufs_ps_fault()
360 spu_context_trace(spufs_ps_fault__insert, ctx, ctx->spu); in spufs_ps_fault()
364 spu_release(ctx); in spufs_ps_fault()
367 put_spu_context(ctx); in spufs_ps_fault()
402 struct spu_context *ctx = data; in spufs_cntl_get() local
405 ret = spu_acquire(ctx); in spufs_cntl_get()
408 *val = ctx->ops->status_read(ctx); in spufs_cntl_get()
409 spu_release(ctx); in spufs_cntl_get()
416 struct spu_context *ctx = data; in spufs_cntl_set() local
419 ret = spu_acquire(ctx); in spufs_cntl_set()
422 ctx->ops->runcntl_write(ctx, val); in spufs_cntl_set()
423 spu_release(ctx); in spufs_cntl_set()
431 struct spu_context *ctx = i->i_ctx; in spufs_cntl_open() local
433 mutex_lock(&ctx->mapping_lock); in spufs_cntl_open()
434 file->private_data = ctx; in spufs_cntl_open()
436 ctx->cntl = inode->i_mapping; in spufs_cntl_open()
437 mutex_unlock(&ctx->mapping_lock); in spufs_cntl_open()
446 struct spu_context *ctx = i->i_ctx; in spufs_cntl_release() local
450 mutex_lock(&ctx->mapping_lock); in spufs_cntl_release()
452 ctx->cntl = NULL; in spufs_cntl_release()
453 mutex_unlock(&ctx->mapping_lock); in spufs_cntl_release()
475 __spufs_regs_read(struct spu_context *ctx, char __user *buffer, in __spufs_regs_read() argument
478 struct spu_lscsa *lscsa = ctx->csa.lscsa; in __spufs_regs_read()
488 struct spu_context *ctx = file->private_data; in spufs_regs_read() local
492 if (*pos >= sizeof(ctx->csa.lscsa->gprs)) in spufs_regs_read()
495 ret = spu_acquire_saved(ctx); in spufs_regs_read()
498 ret = __spufs_regs_read(ctx, buffer, size, pos); in spufs_regs_read()
499 spu_release_saved(ctx); in spufs_regs_read()
507 struct spu_context *ctx = file->private_data; in spufs_regs_write() local
508 struct spu_lscsa *lscsa = ctx->csa.lscsa; in spufs_regs_write()
514 ret = spu_acquire_saved(ctx); in spufs_regs_write()
521 spu_release_saved(ctx); in spufs_regs_write()
533 __spufs_fpcr_read(struct spu_context *ctx, char __user * buffer, in __spufs_fpcr_read() argument
536 struct spu_lscsa *lscsa = ctx->csa.lscsa; in __spufs_fpcr_read()
546 struct spu_context *ctx = file->private_data; in spufs_fpcr_read() local
548 ret = spu_acquire_saved(ctx); in spufs_fpcr_read()
551 ret = __spufs_fpcr_read(ctx, buffer, size, pos); in spufs_fpcr_read()
552 spu_release_saved(ctx); in spufs_fpcr_read()
560 struct spu_context *ctx = file->private_data; in spufs_fpcr_write() local
561 struct spu_lscsa *lscsa = ctx->csa.lscsa; in spufs_fpcr_write()
567 ret = spu_acquire_saved(ctx); in spufs_fpcr_write()
574 spu_release_saved(ctx); in spufs_fpcr_write()
605 struct spu_context *ctx = file->private_data; in spufs_mbox_read() local
617 count = spu_acquire(ctx); in spufs_mbox_read()
623 ret = ctx->ops->mbox_read(ctx, &mbox_data); in spufs_mbox_read()
639 spu_release(ctx); in spufs_mbox_read()
656 struct spu_context *ctx = file->private_data; in spufs_mbox_stat_read() local
663 ret = spu_acquire(ctx); in spufs_mbox_stat_read()
667 mbox_stat = ctx->ops->mbox_stat_read(ctx) & 0xff; in spufs_mbox_stat_read()
669 spu_release(ctx); in spufs_mbox_stat_read()
684 size_t spu_ibox_read(struct spu_context *ctx, u32 *data) in spu_ibox_read() argument
686 return ctx->ops->ibox_read(ctx, data); in spu_ibox_read()
691 struct spu_context *ctx = file->private_data; in spufs_ibox_fasync() local
693 return fasync_helper(fd, file, on, &ctx->ibox_fasync); in spufs_ibox_fasync()
699 struct spu_context *ctx = spu->ctx; in spufs_ibox_callback() local
701 if (!ctx) in spufs_ibox_callback()
704 wake_up_all(&ctx->ibox_wq); in spufs_ibox_callback()
705 kill_fasync(&ctx->ibox_fasync, SIGIO, POLLIN); in spufs_ibox_callback()
723 struct spu_context *ctx = file->private_data; in spufs_ibox_read() local
735 count = spu_acquire(ctx); in spufs_ibox_read()
742 if (!spu_ibox_read(ctx, &ibox_data)) { in spufs_ibox_read()
747 count = spufs_wait(ctx->ibox_wq, spu_ibox_read(ctx, &ibox_data)); in spufs_ibox_read()
759 ret = ctx->ops->ibox_read(ctx, &ibox_data); in spufs_ibox_read()
773 spu_release(ctx); in spufs_ibox_read()
780 struct spu_context *ctx = file->private_data; in spufs_ibox_poll() local
783 poll_wait(file, &ctx->ibox_wq, wait); in spufs_ibox_poll()
789 mutex_lock(&ctx->state_mutex); in spufs_ibox_poll()
790 mask = ctx->ops->mbox_stat_poll(ctx, POLLIN | POLLRDNORM); in spufs_ibox_poll()
791 spu_release(ctx); in spufs_ibox_poll()
807 struct spu_context *ctx = file->private_data; in spufs_ibox_stat_read() local
814 ret = spu_acquire(ctx); in spufs_ibox_stat_read()
817 ibox_stat = (ctx->ops->mbox_stat_read(ctx) >> 16) & 0xff; in spufs_ibox_stat_read()
818 spu_release(ctx); in spufs_ibox_stat_read()
833 size_t spu_wbox_write(struct spu_context *ctx, u32 data) in spu_wbox_write() argument
835 return ctx->ops->wbox_write(ctx, data); in spu_wbox_write()
840 struct spu_context *ctx = file->private_data; in spufs_wbox_fasync() local
843 ret = fasync_helper(fd, file, on, &ctx->wbox_fasync); in spufs_wbox_fasync()
851 struct spu_context *ctx = spu->ctx; in spufs_wbox_callback() local
853 if (!ctx) in spufs_wbox_callback()
856 wake_up_all(&ctx->wbox_wq); in spufs_wbox_callback()
857 kill_fasync(&ctx->wbox_fasync, SIGIO, POLLOUT); in spufs_wbox_callback()
875 struct spu_context *ctx = file->private_data; in spufs_wbox_write() local
889 count = spu_acquire(ctx); in spufs_wbox_write()
899 if (!spu_wbox_write(ctx, wbox_data)) { in spufs_wbox_write()
904 count = spufs_wait(ctx->wbox_wq, spu_wbox_write(ctx, wbox_data)); in spufs_wbox_write()
917 ret = spu_wbox_write(ctx, wbox_data); in spufs_wbox_write()
923 spu_release(ctx); in spufs_wbox_write()
930 struct spu_context *ctx = file->private_data; in spufs_wbox_poll() local
933 poll_wait(file, &ctx->wbox_wq, wait); in spufs_wbox_poll()
939 mutex_lock(&ctx->state_mutex); in spufs_wbox_poll()
940 mask = ctx->ops->mbox_stat_poll(ctx, POLLOUT | POLLWRNORM); in spufs_wbox_poll()
941 spu_release(ctx); in spufs_wbox_poll()
957 struct spu_context *ctx = file->private_data; in spufs_wbox_stat_read() local
964 ret = spu_acquire(ctx); in spufs_wbox_stat_read()
967 wbox_stat = (ctx->ops->mbox_stat_read(ctx) >> 8) & 0xff; in spufs_wbox_stat_read()
968 spu_release(ctx); in spufs_wbox_stat_read()
985 struct spu_context *ctx = i->i_ctx; in spufs_signal1_open() local
987 mutex_lock(&ctx->mapping_lock); in spufs_signal1_open()
988 file->private_data = ctx; in spufs_signal1_open()
990 ctx->signal1 = inode->i_mapping; in spufs_signal1_open()
991 mutex_unlock(&ctx->mapping_lock); in spufs_signal1_open()
999 struct spu_context *ctx = i->i_ctx; in spufs_signal1_release() local
1001 mutex_lock(&ctx->mapping_lock); in spufs_signal1_release()
1003 ctx->signal1 = NULL; in spufs_signal1_release()
1004 mutex_unlock(&ctx->mapping_lock); in spufs_signal1_release()
1008 static ssize_t __spufs_signal1_read(struct spu_context *ctx, char __user *buf, in __spufs_signal1_read() argument
1017 if (ctx->csa.spu_chnlcnt_RW[3]) { in __spufs_signal1_read()
1018 data = ctx->csa.spu_chnldata_RW[3]; in __spufs_signal1_read()
1036 struct spu_context *ctx = file->private_data; in spufs_signal1_read() local
1038 ret = spu_acquire_saved(ctx); in spufs_signal1_read()
1041 ret = __spufs_signal1_read(ctx, buf, len, pos); in spufs_signal1_read()
1042 spu_release_saved(ctx); in spufs_signal1_read()
1050 struct spu_context *ctx; in spufs_signal1_write() local
1054 ctx = file->private_data; in spufs_signal1_write()
1062 ret = spu_acquire(ctx); in spufs_signal1_write()
1065 ctx->ops->signal1_write(ctx, data); in spufs_signal1_write()
1066 spu_release(ctx); in spufs_signal1_write()
1122 struct spu_context *ctx = i->i_ctx; in spufs_signal2_open() local
1124 mutex_lock(&ctx->mapping_lock); in spufs_signal2_open()
1125 file->private_data = ctx; in spufs_signal2_open()
1127 ctx->signal2 = inode->i_mapping; in spufs_signal2_open()
1128 mutex_unlock(&ctx->mapping_lock); in spufs_signal2_open()
1136 struct spu_context *ctx = i->i_ctx; in spufs_signal2_release() local
1138 mutex_lock(&ctx->mapping_lock); in spufs_signal2_release()
1140 ctx->signal2 = NULL; in spufs_signal2_release()
1141 mutex_unlock(&ctx->mapping_lock); in spufs_signal2_release()
1145 static ssize_t __spufs_signal2_read(struct spu_context *ctx, char __user *buf, in __spufs_signal2_read() argument
1154 if (ctx->csa.spu_chnlcnt_RW[4]) { in __spufs_signal2_read()
1155 data = ctx->csa.spu_chnldata_RW[4]; in __spufs_signal2_read()
1172 struct spu_context *ctx = file->private_data; in spufs_signal2_read() local
1175 ret = spu_acquire_saved(ctx); in spufs_signal2_read()
1178 ret = __spufs_signal2_read(ctx, buf, len, pos); in spufs_signal2_read()
1179 spu_release_saved(ctx); in spufs_signal2_read()
1187 struct spu_context *ctx; in spufs_signal2_write() local
1191 ctx = file->private_data; in spufs_signal2_write()
1199 ret = spu_acquire(ctx); in spufs_signal2_write()
1202 ctx->ops->signal2_write(ctx, data); in spufs_signal2_write()
1203 spu_release(ctx); in spufs_signal2_write()
1272 struct spu_context *ctx = data; \
1276 ret = spu_acquire(ctx); \
1279 *val = __get(ctx); \
1280 spu_release(ctx); \
1282 ret = spu_acquire_saved(ctx); \
1285 *val = __get(ctx); \
1286 spu_release_saved(ctx); \
1288 *val = __get(ctx); \
1296 struct spu_context *ctx = data; in spufs_signal1_type_set() local
1299 ret = spu_acquire(ctx); in spufs_signal1_type_set()
1302 ctx->ops->signal1_type_set(ctx, val); in spufs_signal1_type_set()
1303 spu_release(ctx); in spufs_signal1_type_set()
1308 static u64 spufs_signal1_type_get(struct spu_context *ctx) in spufs_signal1_type_get() argument
1310 return ctx->ops->signal1_type_get(ctx); in spufs_signal1_type_get()
1318 struct spu_context *ctx = data; in spufs_signal2_type_set() local
1321 ret = spu_acquire(ctx); in spufs_signal2_type_set()
1324 ctx->ops->signal2_type_set(ctx, val); in spufs_signal2_type_set()
1325 spu_release(ctx); in spufs_signal2_type_set()
1330 static u64 spufs_signal2_type_get(struct spu_context *ctx) in spufs_signal2_type_get() argument
1332 return ctx->ops->signal2_type_get(ctx); in spufs_signal2_type_get()
1369 struct spu_context *ctx = i->i_ctx; in spufs_mss_open() local
1373 mutex_lock(&ctx->mapping_lock); in spufs_mss_open()
1375 ctx->mss = inode->i_mapping; in spufs_mss_open()
1376 mutex_unlock(&ctx->mapping_lock); in spufs_mss_open()
1384 struct spu_context *ctx = i->i_ctx; in spufs_mss_release() local
1386 mutex_lock(&ctx->mapping_lock); in spufs_mss_release()
1388 ctx->mss = NULL; in spufs_mss_release()
1389 mutex_unlock(&ctx->mapping_lock); in spufs_mss_release()
1428 struct spu_context *ctx = i->i_ctx; in spufs_psmap_open() local
1430 mutex_lock(&ctx->mapping_lock); in spufs_psmap_open()
1433 ctx->psmap = inode->i_mapping; in spufs_psmap_open()
1434 mutex_unlock(&ctx->mapping_lock); in spufs_psmap_open()
1442 struct spu_context *ctx = i->i_ctx; in spufs_psmap_release() local
1444 mutex_lock(&ctx->mapping_lock); in spufs_psmap_release()
1446 ctx->psmap = NULL; in spufs_psmap_release()
1447 mutex_unlock(&ctx->mapping_lock); in spufs_psmap_release()
1491 struct spu_context *ctx = i->i_ctx; in spufs_mfc_open() local
1494 if (ctx->owner != current->mm) in spufs_mfc_open()
1500 mutex_lock(&ctx->mapping_lock); in spufs_mfc_open()
1501 file->private_data = ctx; in spufs_mfc_open()
1503 ctx->mfc = inode->i_mapping; in spufs_mfc_open()
1504 mutex_unlock(&ctx->mapping_lock); in spufs_mfc_open()
1512 struct spu_context *ctx = i->i_ctx; in spufs_mfc_release() local
1514 mutex_lock(&ctx->mapping_lock); in spufs_mfc_release()
1516 ctx->mfc = NULL; in spufs_mfc_release()
1517 mutex_unlock(&ctx->mapping_lock); in spufs_mfc_release()
1524 struct spu_context *ctx = spu->ctx; in spufs_mfc_callback() local
1526 if (!ctx) in spufs_mfc_callback()
1529 wake_up_all(&ctx->mfc_wq); in spufs_mfc_callback()
1532 if (ctx->mfc_fasync) { in spufs_mfc_callback()
1537 free_elements = ctx->ops->get_mfc_free_elements(ctx); in spufs_mfc_callback()
1538 tagstatus = ctx->ops->read_mfc_tagstatus(ctx); in spufs_mfc_callback()
1543 if (tagstatus & ctx->tagwait) in spufs_mfc_callback()
1546 kill_fasync(&ctx->mfc_fasync, SIGIO, mask); in spufs_mfc_callback()
1550 static int spufs_read_mfc_tagstatus(struct spu_context *ctx, u32 *status) in spufs_read_mfc_tagstatus() argument
1554 *status = ctx->ops->read_mfc_tagstatus(ctx) & ctx->tagwait; in spufs_read_mfc_tagstatus()
1555 ctx->tagwait &= ~*status; in spufs_read_mfc_tagstatus()
1561 ctx->ops->set_mfc_query(ctx, ctx->tagwait, 1); in spufs_read_mfc_tagstatus()
1568 struct spu_context *ctx = file->private_data; in spufs_mfc_read() local
1575 ret = spu_acquire(ctx); in spufs_mfc_read()
1581 status = ctx->ops->read_mfc_tagstatus(ctx); in spufs_mfc_read()
1582 if (!(status & ctx->tagwait)) in spufs_mfc_read()
1586 ctx->tagwait &= ~status; in spufs_mfc_read()
1588 ret = spufs_wait(ctx->mfc_wq, in spufs_mfc_read()
1589 spufs_read_mfc_tagstatus(ctx, &status)); in spufs_mfc_read()
1593 spu_release(ctx); in spufs_mfc_read()
1673 static int spu_send_mfc_command(struct spu_context *ctx, in spu_send_mfc_command() argument
1677 *error = ctx->ops->send_mfc_command(ctx, &cmd); in spu_send_mfc_command()
1681 ctx->ops->set_mfc_query(ctx, ctx->tagwait, 1); in spu_send_mfc_command()
1684 *error = ctx->ops->send_mfc_command(ctx, &cmd); in spu_send_mfc_command()
1694 struct spu_context *ctx = file->private_data; in spufs_mfc_write() local
1709 ret = spu_acquire(ctx); in spufs_mfc_write()
1713 ret = spufs_wait(ctx->run_wq, ctx->state == SPU_STATE_RUNNABLE); in spufs_mfc_write()
1718 ret = ctx->ops->send_mfc_command(ctx, &cmd); in spufs_mfc_write()
1721 ret = spufs_wait(ctx->mfc_wq, in spufs_mfc_write()
1722 spu_send_mfc_command(ctx, cmd, &status)); in spufs_mfc_write()
1732 ctx->tagwait |= 1 << cmd.tag; in spufs_mfc_write()
1736 spu_release(ctx); in spufs_mfc_write()
1743 struct spu_context *ctx = file->private_data; in spufs_mfc_poll() local
1747 poll_wait(file, &ctx->mfc_wq, wait); in spufs_mfc_poll()
1753 mutex_lock(&ctx->state_mutex); in spufs_mfc_poll()
1754 ctx->ops->set_mfc_query(ctx, ctx->tagwait, 2); in spufs_mfc_poll()
1755 free_elements = ctx->ops->get_mfc_free_elements(ctx); in spufs_mfc_poll()
1756 tagstatus = ctx->ops->read_mfc_tagstatus(ctx); in spufs_mfc_poll()
1757 spu_release(ctx); in spufs_mfc_poll()
1762 if (tagstatus & ctx->tagwait) in spufs_mfc_poll()
1766 free_elements, tagstatus, ctx->tagwait); in spufs_mfc_poll()
1773 struct spu_context *ctx = file->private_data; in spufs_mfc_flush() local
1776 ret = spu_acquire(ctx); in spufs_mfc_flush()
1781 ret = spufs_wait(ctx->mfc_wq, in spufs_mfc_flush()
1782 ctx->ops->set_mfc_query(ctx, ctx->tagwait, 2)); in spufs_mfc_flush()
1785 ret = spufs_wait(ctx->mfc_wq, in spufs_mfc_flush()
1786 ctx->ops->read_mfc_tagstatus(ctx) == ctx->tagwait); in spufs_mfc_flush()
1792 spu_release(ctx); in spufs_mfc_flush()
1811 struct spu_context *ctx = file->private_data; in spufs_mfc_fasync() local
1813 return fasync_helper(fd, file, on, &ctx->mfc_fasync); in spufs_mfc_fasync()
1831 struct spu_context *ctx = data; in spufs_npc_set() local
1834 ret = spu_acquire(ctx); in spufs_npc_set()
1837 ctx->ops->npc_write(ctx, val); in spufs_npc_set()
1838 spu_release(ctx); in spufs_npc_set()
1843 static u64 spufs_npc_get(struct spu_context *ctx) in spufs_npc_get() argument
1845 return ctx->ops->npc_read(ctx); in spufs_npc_get()
1852 struct spu_context *ctx = data; in spufs_decr_set() local
1853 struct spu_lscsa *lscsa = ctx->csa.lscsa; in spufs_decr_set()
1856 ret = spu_acquire_saved(ctx); in spufs_decr_set()
1860 spu_release_saved(ctx); in spufs_decr_set()
1865 static u64 spufs_decr_get(struct spu_context *ctx) in spufs_decr_get() argument
1867 struct spu_lscsa *lscsa = ctx->csa.lscsa; in spufs_decr_get()
1875 struct spu_context *ctx = data; in spufs_decr_status_set() local
1878 ret = spu_acquire_saved(ctx); in spufs_decr_status_set()
1882 ctx->csa.priv2.mfc_control_RW |= MFC_CNTL_DECREMENTER_RUNNING; in spufs_decr_status_set()
1884 ctx->csa.priv2.mfc_control_RW &= ~MFC_CNTL_DECREMENTER_RUNNING; in spufs_decr_status_set()
1885 spu_release_saved(ctx); in spufs_decr_status_set()
1890 static u64 spufs_decr_status_get(struct spu_context *ctx) in spufs_decr_status_get() argument
1892 if (ctx->csa.priv2.mfc_control_RW & MFC_CNTL_DECREMENTER_RUNNING) in spufs_decr_status_get()
1903 struct spu_context *ctx = data; in spufs_event_mask_set() local
1904 struct spu_lscsa *lscsa = ctx->csa.lscsa; in spufs_event_mask_set()
1907 ret = spu_acquire_saved(ctx); in spufs_event_mask_set()
1911 spu_release_saved(ctx); in spufs_event_mask_set()
1916 static u64 spufs_event_mask_get(struct spu_context *ctx) in spufs_event_mask_get() argument
1918 struct spu_lscsa *lscsa = ctx->csa.lscsa; in spufs_event_mask_get()
1926 static u64 spufs_event_status_get(struct spu_context *ctx) in spufs_event_status_get() argument
1928 struct spu_state *state = &ctx->csa; in spufs_event_status_get()
1940 struct spu_context *ctx = data; in spufs_srr0_set() local
1941 struct spu_lscsa *lscsa = ctx->csa.lscsa; in spufs_srr0_set()
1944 ret = spu_acquire_saved(ctx); in spufs_srr0_set()
1948 spu_release_saved(ctx); in spufs_srr0_set()
1953 static u64 spufs_srr0_get(struct spu_context *ctx) in spufs_srr0_get() argument
1955 struct spu_lscsa *lscsa = ctx->csa.lscsa; in spufs_srr0_get()
1961 static u64 spufs_id_get(struct spu_context *ctx) in spufs_id_get() argument
1965 if (ctx->state == SPU_STATE_RUNNABLE) in spufs_id_get()
1966 num = ctx->spu->number; in spufs_id_get()
1975 static u64 spufs_object_id_get(struct spu_context *ctx) in spufs_object_id_get() argument
1978 return ctx->object_id; in spufs_object_id_get()
1983 struct spu_context *ctx = data; in spufs_object_id_set() local
1984 ctx->object_id = id; in spufs_object_id_set()
1992 static u64 spufs_lslr_get(struct spu_context *ctx) in spufs_lslr_get() argument
1994 return ctx->csa.priv2.spu_lslr_RW; in spufs_lslr_get()
2002 struct spu_context *ctx = i->i_ctx; in spufs_info_open() local
2003 file->private_data = ctx; in spufs_info_open()
2009 struct spu_context *ctx = s->private; in spufs_caps_show() local
2011 if (!(ctx->flags & SPU_CREATE_NOSCHED)) in spufs_caps_show()
2013 if (!(ctx->flags & SPU_CREATE_ISOLATE)) in spufs_caps_show()
2030 static ssize_t __spufs_mbox_info_read(struct spu_context *ctx, in __spufs_mbox_info_read() argument
2036 if (!(ctx->csa.prob.mb_stat_R & 0x0000ff)) in __spufs_mbox_info_read()
2039 data = ctx->csa.prob.pu_mb_R; in __spufs_mbox_info_read()
2048 struct spu_context *ctx = file->private_data; in spufs_mbox_info_read() local
2053 ret = spu_acquire_saved(ctx); in spufs_mbox_info_read()
2056 spin_lock(&ctx->csa.register_lock); in spufs_mbox_info_read()
2057 ret = __spufs_mbox_info_read(ctx, buf, len, pos); in spufs_mbox_info_read()
2058 spin_unlock(&ctx->csa.register_lock); in spufs_mbox_info_read()
2059 spu_release_saved(ctx); in spufs_mbox_info_read()
2070 static ssize_t __spufs_ibox_info_read(struct spu_context *ctx, in __spufs_ibox_info_read() argument
2076 if (!(ctx->csa.prob.mb_stat_R & 0xff0000)) in __spufs_ibox_info_read()
2079 data = ctx->csa.priv2.puint_mb_R; in __spufs_ibox_info_read()
2087 struct spu_context *ctx = file->private_data; in spufs_ibox_info_read() local
2093 ret = spu_acquire_saved(ctx); in spufs_ibox_info_read()
2096 spin_lock(&ctx->csa.register_lock); in spufs_ibox_info_read()
2097 ret = __spufs_ibox_info_read(ctx, buf, len, pos); in spufs_ibox_info_read()
2098 spin_unlock(&ctx->csa.register_lock); in spufs_ibox_info_read()
2099 spu_release_saved(ctx); in spufs_ibox_info_read()
2110 static ssize_t __spufs_wbox_info_read(struct spu_context *ctx, in __spufs_wbox_info_read() argument
2117 wbox_stat = ctx->csa.prob.mb_stat_R; in __spufs_wbox_info_read()
2120 data[i] = ctx->csa.spu_mailbox_data[i]; in __spufs_wbox_info_read()
2130 struct spu_context *ctx = file->private_data; in spufs_wbox_info_read() local
2136 ret = spu_acquire_saved(ctx); in spufs_wbox_info_read()
2139 spin_lock(&ctx->csa.register_lock); in spufs_wbox_info_read()
2140 ret = __spufs_wbox_info_read(ctx, buf, len, pos); in spufs_wbox_info_read()
2141 spin_unlock(&ctx->csa.register_lock); in spufs_wbox_info_read()
2142 spu_release_saved(ctx); in spufs_wbox_info_read()
2153 static ssize_t __spufs_dma_info_read(struct spu_context *ctx, in __spufs_dma_info_read() argument
2160 info.dma_info_type = ctx->csa.priv2.spu_tag_status_query_RW; in __spufs_dma_info_read()
2161 info.dma_info_mask = ctx->csa.lscsa->tag_mask.slot[0]; in __spufs_dma_info_read()
2162 info.dma_info_status = ctx->csa.spu_chnldata_RW[24]; in __spufs_dma_info_read()
2163 info.dma_info_stall_and_notify = ctx->csa.spu_chnldata_RW[25]; in __spufs_dma_info_read()
2164 info.dma_info_atomic_command_status = ctx->csa.spu_chnldata_RW[27]; in __spufs_dma_info_read()
2167 spuqp = &ctx->csa.priv2.spuq[i]; in __spufs_dma_info_read()
2182 struct spu_context *ctx = file->private_data; in spufs_dma_info_read() local
2188 ret = spu_acquire_saved(ctx); in spufs_dma_info_read()
2191 spin_lock(&ctx->csa.register_lock); in spufs_dma_info_read()
2192 ret = __spufs_dma_info_read(ctx, buf, len, pos); in spufs_dma_info_read()
2193 spin_unlock(&ctx->csa.register_lock); in spufs_dma_info_read()
2194 spu_release_saved(ctx); in spufs_dma_info_read()
2205 static ssize_t __spufs_proxydma_info_read(struct spu_context *ctx, in __spufs_proxydma_info_read() argument
2219 info.proxydma_info_type = ctx->csa.prob.dma_querytype_RW; in __spufs_proxydma_info_read()
2220 info.proxydma_info_mask = ctx->csa.prob.dma_querymask_RW; in __spufs_proxydma_info_read()
2221 info.proxydma_info_status = ctx->csa.prob.dma_tagstatus_R; in __spufs_proxydma_info_read()
2224 puqp = &ctx->csa.priv2.puq[i]; in __spufs_proxydma_info_read()
2239 struct spu_context *ctx = file->private_data; in spufs_proxydma_info_read() local
2242 ret = spu_acquire_saved(ctx); in spufs_proxydma_info_read()
2245 spin_lock(&ctx->csa.register_lock); in spufs_proxydma_info_read()
2246 ret = __spufs_proxydma_info_read(ctx, buf, len, pos); in spufs_proxydma_info_read()
2247 spin_unlock(&ctx->csa.register_lock); in spufs_proxydma_info_read()
2248 spu_release_saved(ctx); in spufs_proxydma_info_read()
2261 struct spu_context *ctx = s->private; in spufs_show_tid() local
2263 seq_printf(s, "%d\n", ctx->tid); in spufs_show_tid()
2283 static unsigned long long spufs_acct_time(struct spu_context *ctx, in spufs_acct_time() argument
2286 unsigned long long time = ctx->stats.times[state]; in spufs_acct_time()
2297 if (ctx->spu && ctx->stats.util_state == state) { in spufs_acct_time()
2298 time += ktime_get_ns() - ctx->stats.tstamp; in spufs_acct_time()
2304 static unsigned long long spufs_slb_flts(struct spu_context *ctx) in spufs_slb_flts() argument
2306 unsigned long long slb_flts = ctx->stats.slb_flt; in spufs_slb_flts()
2308 if (ctx->state == SPU_STATE_RUNNABLE) { in spufs_slb_flts()
2309 slb_flts += (ctx->spu->stats.slb_flt - in spufs_slb_flts()
2310 ctx->stats.slb_flt_base); in spufs_slb_flts()
2316 static unsigned long long spufs_class2_intrs(struct spu_context *ctx) in spufs_class2_intrs() argument
2318 unsigned long long class2_intrs = ctx->stats.class2_intr; in spufs_class2_intrs()
2320 if (ctx->state == SPU_STATE_RUNNABLE) { in spufs_class2_intrs()
2321 class2_intrs += (ctx->spu->stats.class2_intr - in spufs_class2_intrs()
2322 ctx->stats.class2_intr_base); in spufs_class2_intrs()
2331 struct spu_context *ctx = s->private; in spufs_show_stat() local
2334 ret = spu_acquire(ctx); in spufs_show_stat()
2340 ctx_state_names[ctx->stats.util_state], in spufs_show_stat()
2341 spufs_acct_time(ctx, SPU_UTIL_USER), in spufs_show_stat()
2342 spufs_acct_time(ctx, SPU_UTIL_SYSTEM), in spufs_show_stat()
2343 spufs_acct_time(ctx, SPU_UTIL_IOWAIT), in spufs_show_stat()
2344 spufs_acct_time(ctx, SPU_UTIL_IDLE_LOADED), in spufs_show_stat()
2345 ctx->stats.vol_ctx_switch, in spufs_show_stat()
2346 ctx->stats.invol_ctx_switch, in spufs_show_stat()
2347 spufs_slb_flts(ctx), in spufs_show_stat()
2348 ctx->stats.hash_flt, in spufs_show_stat()
2349 ctx->stats.min_flt, in spufs_show_stat()
2350 ctx->stats.maj_flt, in spufs_show_stat()
2351 spufs_class2_intrs(ctx), in spufs_show_stat()
2352 ctx->stats.libassist); in spufs_show_stat()
2353 spu_release(ctx); in spufs_show_stat()
2369 static inline int spufs_switch_log_used(struct spu_context *ctx) in spufs_switch_log_used() argument
2371 return (ctx->switch_log->head - ctx->switch_log->tail) % in spufs_switch_log_used()
2375 static inline int spufs_switch_log_avail(struct spu_context *ctx) in spufs_switch_log_avail() argument
2377 return SWITCH_LOG_BUFSIZE - spufs_switch_log_used(ctx); in spufs_switch_log_avail()
2382 struct spu_context *ctx = SPUFS_I(inode)->i_ctx; in spufs_switch_log_open() local
2385 rc = spu_acquire(ctx); in spufs_switch_log_open()
2389 if (ctx->switch_log) { in spufs_switch_log_open()
2394 ctx->switch_log = kmalloc(sizeof(struct switch_log) + in spufs_switch_log_open()
2398 if (!ctx->switch_log) { in spufs_switch_log_open()
2403 ctx->switch_log->head = ctx->switch_log->tail = 0; in spufs_switch_log_open()
2404 init_waitqueue_head(&ctx->switch_log->wait); in spufs_switch_log_open()
2408 spu_release(ctx); in spufs_switch_log_open()
2414 struct spu_context *ctx = SPUFS_I(inode)->i_ctx; in spufs_switch_log_release() local
2417 rc = spu_acquire(ctx); in spufs_switch_log_release()
2421 kfree(ctx->switch_log); in spufs_switch_log_release()
2422 ctx->switch_log = NULL; in spufs_switch_log_release()
2423 spu_release(ctx); in spufs_switch_log_release()
2428 static int switch_log_sprint(struct spu_context *ctx, char *tbuf, int n) in switch_log_sprint() argument
2432 p = ctx->switch_log->log + ctx->switch_log->tail % SWITCH_LOG_BUFSIZE; in switch_log_sprint()
2447 struct spu_context *ctx = SPUFS_I(inode)->i_ctx; in spufs_switch_log_read() local
2453 error = spu_acquire(ctx); in spufs_switch_log_read()
2461 if (spufs_switch_log_used(ctx) == 0) { in spufs_switch_log_read()
2477 error = spufs_wait(ctx->switch_log->wait, in spufs_switch_log_read()
2478 spufs_switch_log_used(ctx) > 0); in spufs_switch_log_read()
2488 if (spufs_switch_log_used(ctx) == 0) in spufs_switch_log_read()
2493 width = switch_log_sprint(ctx, tbuf, sizeof(tbuf)); in spufs_switch_log_read()
2495 ctx->switch_log->tail = in spufs_switch_log_read()
2496 (ctx->switch_log->tail + 1) % in spufs_switch_log_read()
2509 spu_release(ctx); in spufs_switch_log_read()
2517 struct spu_context *ctx = SPUFS_I(inode)->i_ctx; in spufs_switch_log_poll() local
2521 poll_wait(file, &ctx->switch_log->wait, wait); in spufs_switch_log_poll()
2523 rc = spu_acquire(ctx); in spufs_switch_log_poll()
2527 if (spufs_switch_log_used(ctx) > 0) in spufs_switch_log_poll()
2530 spu_release(ctx); in spufs_switch_log_poll()
2548 void spu_switch_log_notify(struct spu *spu, struct spu_context *ctx, in spu_switch_log_notify() argument
2551 if (!ctx->switch_log) in spu_switch_log_notify()
2554 if (spufs_switch_log_avail(ctx) > 1) { in spu_switch_log_notify()
2557 p = ctx->switch_log->log + ctx->switch_log->head; in spu_switch_log_notify()
2564 ctx->switch_log->head = in spu_switch_log_notify()
2565 (ctx->switch_log->head + 1) % SWITCH_LOG_BUFSIZE; in spu_switch_log_notify()
2568 wake_up(&ctx->switch_log->wait); in spu_switch_log_notify()
2573 struct spu_context *ctx = s->private; in spufs_show_ctx() local
2576 mutex_lock(&ctx->state_mutex); in spufs_show_ctx()
2577 if (ctx->spu) { in spufs_show_ctx()
2578 struct spu *spu = ctx->spu; in spufs_show_ctx()
2585 struct spu_state *csa = &ctx->csa; in spufs_show_ctx()
2592 ctx->state == SPU_STATE_SAVED ? 'S' : 'R', in spufs_show_ctx()
2593 ctx->flags, in spufs_show_ctx()
2594 ctx->sched_flags, in spufs_show_ctx()
2595 ctx->prio, in spufs_show_ctx()
2596 ctx->time_slice, in spufs_show_ctx()
2597 ctx->spu ? ctx->spu->number : -1, in spufs_show_ctx()
2598 !list_empty(&ctx->rq) ? 'q' : ' ', in spufs_show_ctx()
2599 ctx->csa.class_0_pending, in spufs_show_ctx()
2600 ctx->csa.class_0_dar, in spufs_show_ctx()
2601 ctx->csa.class_1_dsisr, in spufs_show_ctx()
2603 ctx->ops->runcntl_read(ctx), in spufs_show_ctx()
2604 ctx->ops->status_read(ctx)); in spufs_show_ctx()
2606 mutex_unlock(&ctx->state_mutex); in spufs_show_ctx()