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
243 struct spu_state *csa = &ctx->csa; in spufs_mem_mmap_fault()
266 if (spu_acquire(ctx)) in spufs_mem_mmap_fault()
269 if (ctx->state == SPU_STATE_SAVED) { in spufs_mem_mmap_fault()
271 pfn = vmalloc_to_pfn(ctx->csa.lscsa->ls + offset); in spufs_mem_mmap_fault()
274 pfn = (ctx->spu->local_store_phys + offset) >> PAGE_SHIFT; in spufs_mem_mmap_fault()
278 spu_release(ctx); in spufs_mem_mmap_fault()
287 struct spu_context *ctx = vma->vm_file->private_data; in spufs_mem_mmap_access() local
293 if (spu_acquire(ctx)) in spufs_mem_mmap_access()
297 local_store = ctx->ops->get_ls(ctx); in spufs_mem_mmap_access()
302 spu_release(ctx); in spufs_mem_mmap_access()
314 struct spu_context *ctx = file->private_data; in spufs_mem_mmap() local
315 struct spu_state *csa = &ctx->csa; in spufs_mem_mmap()
344 struct spu_context *ctx = file->private_data; in spufs_get_unmapped_area() local
345 struct spu_state *csa = &ctx->csa; in spufs_get_unmapped_area()
375 struct spu_context *ctx = vma->vm_file->private_data; in spufs_ps_fault() local
379 spu_context_nospu_trace(spufs_ps_fault__enter, ctx); in spufs_ps_fault()
392 get_spu_context(ctx); in spufs_ps_fault()
402 if (spu_acquire(ctx)) in spufs_ps_fault()
405 if (ctx->state == SPU_STATE_SAVED) { in spufs_ps_fault()
407 spu_context_nospu_trace(spufs_ps_fault__sleep, ctx); in spufs_ps_fault()
408 ret = spufs_wait(ctx->run_wq, ctx->state == SPU_STATE_RUNNABLE); in spufs_ps_fault()
409 spu_context_trace(spufs_ps_fault__wake, ctx, ctx->spu); in spufs_ps_fault()
412 area = ctx->spu->problem_phys + ps_offs; in spufs_ps_fault()
415 spu_context_trace(spufs_ps_fault__insert, ctx, ctx->spu); in spufs_ps_fault()
419 spu_release(ctx); in spufs_ps_fault()
422 put_spu_context(ctx); in spufs_ps_fault()
457 struct spu_context *ctx = data; in spufs_cntl_get() local
460 ret = spu_acquire(ctx); in spufs_cntl_get()
463 *val = ctx->ops->status_read(ctx); in spufs_cntl_get()
464 spu_release(ctx); in spufs_cntl_get()
471 struct spu_context *ctx = data; in spufs_cntl_set() local
474 ret = spu_acquire(ctx); in spufs_cntl_set()
477 ctx->ops->runcntl_write(ctx, val); in spufs_cntl_set()
478 spu_release(ctx); in spufs_cntl_set()
486 struct spu_context *ctx = i->i_ctx; in spufs_cntl_open() local
488 mutex_lock(&ctx->mapping_lock); in spufs_cntl_open()
489 file->private_data = ctx; in spufs_cntl_open()
491 ctx->cntl = inode->i_mapping; in spufs_cntl_open()
492 mutex_unlock(&ctx->mapping_lock); in spufs_cntl_open()
501 struct spu_context *ctx = i->i_ctx; in spufs_cntl_release() local
505 mutex_lock(&ctx->mapping_lock); in spufs_cntl_release()
507 ctx->cntl = NULL; in spufs_cntl_release()
508 mutex_unlock(&ctx->mapping_lock); in spufs_cntl_release()
530 __spufs_regs_read(struct spu_context *ctx, char __user *buffer, in __spufs_regs_read() argument
533 struct spu_lscsa *lscsa = ctx->csa.lscsa; in __spufs_regs_read()
543 struct spu_context *ctx = file->private_data; in spufs_regs_read() local
547 if (*pos >= sizeof(ctx->csa.lscsa->gprs)) in spufs_regs_read()
550 ret = spu_acquire_saved(ctx); in spufs_regs_read()
553 ret = __spufs_regs_read(ctx, buffer, size, pos); in spufs_regs_read()
554 spu_release_saved(ctx); in spufs_regs_read()
562 struct spu_context *ctx = file->private_data; in spufs_regs_write() local
563 struct spu_lscsa *lscsa = ctx->csa.lscsa; in spufs_regs_write()
569 ret = spu_acquire_saved(ctx); in spufs_regs_write()
576 spu_release_saved(ctx); in spufs_regs_write()
588 __spufs_fpcr_read(struct spu_context *ctx, char __user * buffer, in __spufs_fpcr_read() argument
591 struct spu_lscsa *lscsa = ctx->csa.lscsa; in __spufs_fpcr_read()
601 struct spu_context *ctx = file->private_data; in spufs_fpcr_read() local
603 ret = spu_acquire_saved(ctx); in spufs_fpcr_read()
606 ret = __spufs_fpcr_read(ctx, buffer, size, pos); in spufs_fpcr_read()
607 spu_release_saved(ctx); in spufs_fpcr_read()
615 struct spu_context *ctx = file->private_data; in spufs_fpcr_write() local
616 struct spu_lscsa *lscsa = ctx->csa.lscsa; in spufs_fpcr_write()
622 ret = spu_acquire_saved(ctx); in spufs_fpcr_write()
629 spu_release_saved(ctx); in spufs_fpcr_write()
660 struct spu_context *ctx = file->private_data; in spufs_mbox_read() local
672 count = spu_acquire(ctx); in spufs_mbox_read()
678 ret = ctx->ops->mbox_read(ctx, &mbox_data); in spufs_mbox_read()
694 spu_release(ctx); in spufs_mbox_read()
711 struct spu_context *ctx = file->private_data; in spufs_mbox_stat_read() local
718 ret = spu_acquire(ctx); in spufs_mbox_stat_read()
722 mbox_stat = ctx->ops->mbox_stat_read(ctx) & 0xff; in spufs_mbox_stat_read()
724 spu_release(ctx); in spufs_mbox_stat_read()
739 size_t spu_ibox_read(struct spu_context *ctx, u32 *data) in spu_ibox_read() argument
741 return ctx->ops->ibox_read(ctx, data); in spu_ibox_read()
746 struct spu_context *ctx = file->private_data; in spufs_ibox_fasync() local
748 return fasync_helper(fd, file, on, &ctx->ibox_fasync); in spufs_ibox_fasync()
754 struct spu_context *ctx = spu->ctx; in spufs_ibox_callback() local
756 if (!ctx) in spufs_ibox_callback()
759 wake_up_all(&ctx->ibox_wq); in spufs_ibox_callback()
760 kill_fasync(&ctx->ibox_fasync, SIGIO, POLLIN); in spufs_ibox_callback()
778 struct spu_context *ctx = file->private_data; in spufs_ibox_read() local
790 count = spu_acquire(ctx); in spufs_ibox_read()
797 if (!spu_ibox_read(ctx, &ibox_data)) { in spufs_ibox_read()
802 count = spufs_wait(ctx->ibox_wq, spu_ibox_read(ctx, &ibox_data)); in spufs_ibox_read()
814 ret = ctx->ops->ibox_read(ctx, &ibox_data); in spufs_ibox_read()
828 spu_release(ctx); in spufs_ibox_read()
835 struct spu_context *ctx = file->private_data; in spufs_ibox_poll() local
838 poll_wait(file, &ctx->ibox_wq, wait); in spufs_ibox_poll()
844 mutex_lock(&ctx->state_mutex); in spufs_ibox_poll()
845 mask = ctx->ops->mbox_stat_poll(ctx, POLLIN | POLLRDNORM); in spufs_ibox_poll()
846 spu_release(ctx); in spufs_ibox_poll()
862 struct spu_context *ctx = file->private_data; in spufs_ibox_stat_read() local
869 ret = spu_acquire(ctx); in spufs_ibox_stat_read()
872 ibox_stat = (ctx->ops->mbox_stat_read(ctx) >> 16) & 0xff; in spufs_ibox_stat_read()
873 spu_release(ctx); in spufs_ibox_stat_read()
888 size_t spu_wbox_write(struct spu_context *ctx, u32 data) in spu_wbox_write() argument
890 return ctx->ops->wbox_write(ctx, data); in spu_wbox_write()
895 struct spu_context *ctx = file->private_data; in spufs_wbox_fasync() local
898 ret = fasync_helper(fd, file, on, &ctx->wbox_fasync); in spufs_wbox_fasync()
906 struct spu_context *ctx = spu->ctx; in spufs_wbox_callback() local
908 if (!ctx) in spufs_wbox_callback()
911 wake_up_all(&ctx->wbox_wq); in spufs_wbox_callback()
912 kill_fasync(&ctx->wbox_fasync, SIGIO, POLLOUT); in spufs_wbox_callback()
930 struct spu_context *ctx = file->private_data; in spufs_wbox_write() local
944 count = spu_acquire(ctx); in spufs_wbox_write()
954 if (!spu_wbox_write(ctx, wbox_data)) { in spufs_wbox_write()
959 count = spufs_wait(ctx->wbox_wq, spu_wbox_write(ctx, wbox_data)); in spufs_wbox_write()
972 ret = spu_wbox_write(ctx, wbox_data); in spufs_wbox_write()
978 spu_release(ctx); in spufs_wbox_write()
985 struct spu_context *ctx = file->private_data; in spufs_wbox_poll() local
988 poll_wait(file, &ctx->wbox_wq, wait); in spufs_wbox_poll()
994 mutex_lock(&ctx->state_mutex); in spufs_wbox_poll()
995 mask = ctx->ops->mbox_stat_poll(ctx, POLLOUT | POLLWRNORM); in spufs_wbox_poll()
996 spu_release(ctx); in spufs_wbox_poll()
1012 struct spu_context *ctx = file->private_data; in spufs_wbox_stat_read() local
1019 ret = spu_acquire(ctx); in spufs_wbox_stat_read()
1022 wbox_stat = (ctx->ops->mbox_stat_read(ctx) >> 8) & 0xff; in spufs_wbox_stat_read()
1023 spu_release(ctx); in spufs_wbox_stat_read()
1040 struct spu_context *ctx = i->i_ctx; in spufs_signal1_open() local
1042 mutex_lock(&ctx->mapping_lock); in spufs_signal1_open()
1043 file->private_data = ctx; in spufs_signal1_open()
1045 ctx->signal1 = inode->i_mapping; in spufs_signal1_open()
1046 mutex_unlock(&ctx->mapping_lock); in spufs_signal1_open()
1054 struct spu_context *ctx = i->i_ctx; in spufs_signal1_release() local
1056 mutex_lock(&ctx->mapping_lock); in spufs_signal1_release()
1058 ctx->signal1 = NULL; in spufs_signal1_release()
1059 mutex_unlock(&ctx->mapping_lock); in spufs_signal1_release()
1063 static ssize_t __spufs_signal1_read(struct spu_context *ctx, char __user *buf, in __spufs_signal1_read() argument
1072 if (ctx->csa.spu_chnlcnt_RW[3]) { in __spufs_signal1_read()
1073 data = ctx->csa.spu_chnldata_RW[3]; in __spufs_signal1_read()
1091 struct spu_context *ctx = file->private_data; in spufs_signal1_read() local
1093 ret = spu_acquire_saved(ctx); in spufs_signal1_read()
1096 ret = __spufs_signal1_read(ctx, buf, len, pos); in spufs_signal1_read()
1097 spu_release_saved(ctx); in spufs_signal1_read()
1105 struct spu_context *ctx; in spufs_signal1_write() local
1109 ctx = file->private_data; in spufs_signal1_write()
1117 ret = spu_acquire(ctx); in spufs_signal1_write()
1120 ctx->ops->signal1_write(ctx, data); in spufs_signal1_write()
1121 spu_release(ctx); in spufs_signal1_write()
1177 struct spu_context *ctx = i->i_ctx; in spufs_signal2_open() local
1179 mutex_lock(&ctx->mapping_lock); in spufs_signal2_open()
1180 file->private_data = ctx; in spufs_signal2_open()
1182 ctx->signal2 = inode->i_mapping; in spufs_signal2_open()
1183 mutex_unlock(&ctx->mapping_lock); in spufs_signal2_open()
1191 struct spu_context *ctx = i->i_ctx; in spufs_signal2_release() local
1193 mutex_lock(&ctx->mapping_lock); in spufs_signal2_release()
1195 ctx->signal2 = NULL; in spufs_signal2_release()
1196 mutex_unlock(&ctx->mapping_lock); in spufs_signal2_release()
1200 static ssize_t __spufs_signal2_read(struct spu_context *ctx, char __user *buf, in __spufs_signal2_read() argument
1209 if (ctx->csa.spu_chnlcnt_RW[4]) { in __spufs_signal2_read()
1210 data = ctx->csa.spu_chnldata_RW[4]; in __spufs_signal2_read()
1227 struct spu_context *ctx = file->private_data; in spufs_signal2_read() local
1230 ret = spu_acquire_saved(ctx); in spufs_signal2_read()
1233 ret = __spufs_signal2_read(ctx, buf, len, pos); in spufs_signal2_read()
1234 spu_release_saved(ctx); in spufs_signal2_read()
1242 struct spu_context *ctx; in spufs_signal2_write() local
1246 ctx = file->private_data; in spufs_signal2_write()
1254 ret = spu_acquire(ctx); in spufs_signal2_write()
1257 ctx->ops->signal2_write(ctx, data); in spufs_signal2_write()
1258 spu_release(ctx); in spufs_signal2_write()
1327 struct spu_context *ctx = data; \
1331 ret = spu_acquire(ctx); \
1334 *val = __get(ctx); \
1335 spu_release(ctx); \
1337 ret = spu_acquire_saved(ctx); \
1340 *val = __get(ctx); \
1341 spu_release_saved(ctx); \
1343 *val = __get(ctx); \
1351 struct spu_context *ctx = data; in spufs_signal1_type_set() local
1354 ret = spu_acquire(ctx); in spufs_signal1_type_set()
1357 ctx->ops->signal1_type_set(ctx, val); in spufs_signal1_type_set()
1358 spu_release(ctx); in spufs_signal1_type_set()
1363 static u64 spufs_signal1_type_get(struct spu_context *ctx) in spufs_signal1_type_get() argument
1365 return ctx->ops->signal1_type_get(ctx); in spufs_signal1_type_get()
1373 struct spu_context *ctx = data; in spufs_signal2_type_set() local
1376 ret = spu_acquire(ctx); in spufs_signal2_type_set()
1379 ctx->ops->signal2_type_set(ctx, val); in spufs_signal2_type_set()
1380 spu_release(ctx); in spufs_signal2_type_set()
1385 static u64 spufs_signal2_type_get(struct spu_context *ctx) in spufs_signal2_type_get() argument
1387 return ctx->ops->signal2_type_get(ctx); in spufs_signal2_type_get()
1424 struct spu_context *ctx = i->i_ctx; in spufs_mss_open() local
1428 mutex_lock(&ctx->mapping_lock); in spufs_mss_open()
1430 ctx->mss = inode->i_mapping; in spufs_mss_open()
1431 mutex_unlock(&ctx->mapping_lock); in spufs_mss_open()
1439 struct spu_context *ctx = i->i_ctx; in spufs_mss_release() local
1441 mutex_lock(&ctx->mapping_lock); in spufs_mss_release()
1443 ctx->mss = NULL; in spufs_mss_release()
1444 mutex_unlock(&ctx->mapping_lock); in spufs_mss_release()
1483 struct spu_context *ctx = i->i_ctx; in spufs_psmap_open() local
1485 mutex_lock(&ctx->mapping_lock); in spufs_psmap_open()
1488 ctx->psmap = inode->i_mapping; in spufs_psmap_open()
1489 mutex_unlock(&ctx->mapping_lock); in spufs_psmap_open()
1497 struct spu_context *ctx = i->i_ctx; in spufs_psmap_release() local
1499 mutex_lock(&ctx->mapping_lock); in spufs_psmap_release()
1501 ctx->psmap = NULL; in spufs_psmap_release()
1502 mutex_unlock(&ctx->mapping_lock); in spufs_psmap_release()
1546 struct spu_context *ctx = i->i_ctx; in spufs_mfc_open() local
1549 if (ctx->owner != current->mm) in spufs_mfc_open()
1555 mutex_lock(&ctx->mapping_lock); in spufs_mfc_open()
1556 file->private_data = ctx; in spufs_mfc_open()
1558 ctx->mfc = inode->i_mapping; in spufs_mfc_open()
1559 mutex_unlock(&ctx->mapping_lock); in spufs_mfc_open()
1567 struct spu_context *ctx = i->i_ctx; in spufs_mfc_release() local
1569 mutex_lock(&ctx->mapping_lock); in spufs_mfc_release()
1571 ctx->mfc = NULL; in spufs_mfc_release()
1572 mutex_unlock(&ctx->mapping_lock); in spufs_mfc_release()
1579 struct spu_context *ctx = spu->ctx; in spufs_mfc_callback() local
1581 if (!ctx) in spufs_mfc_callback()
1584 wake_up_all(&ctx->mfc_wq); in spufs_mfc_callback()
1587 if (ctx->mfc_fasync) { in spufs_mfc_callback()
1592 free_elements = ctx->ops->get_mfc_free_elements(ctx); in spufs_mfc_callback()
1593 tagstatus = ctx->ops->read_mfc_tagstatus(ctx); in spufs_mfc_callback()
1598 if (tagstatus & ctx->tagwait) in spufs_mfc_callback()
1601 kill_fasync(&ctx->mfc_fasync, SIGIO, mask); in spufs_mfc_callback()
1605 static int spufs_read_mfc_tagstatus(struct spu_context *ctx, u32 *status) in spufs_read_mfc_tagstatus() argument
1609 *status = ctx->ops->read_mfc_tagstatus(ctx) & ctx->tagwait; in spufs_read_mfc_tagstatus()
1610 ctx->tagwait &= ~*status; in spufs_read_mfc_tagstatus()
1616 ctx->ops->set_mfc_query(ctx, ctx->tagwait, 1); in spufs_read_mfc_tagstatus()
1623 struct spu_context *ctx = file->private_data; in spufs_mfc_read() local
1630 ret = spu_acquire(ctx); in spufs_mfc_read()
1636 status = ctx->ops->read_mfc_tagstatus(ctx); in spufs_mfc_read()
1637 if (!(status & ctx->tagwait)) in spufs_mfc_read()
1641 ctx->tagwait &= ~status; in spufs_mfc_read()
1643 ret = spufs_wait(ctx->mfc_wq, in spufs_mfc_read()
1644 spufs_read_mfc_tagstatus(ctx, &status)); in spufs_mfc_read()
1648 spu_release(ctx); in spufs_mfc_read()
1728 static int spu_send_mfc_command(struct spu_context *ctx, in spu_send_mfc_command() argument
1732 *error = ctx->ops->send_mfc_command(ctx, &cmd); in spu_send_mfc_command()
1736 ctx->ops->set_mfc_query(ctx, ctx->tagwait, 1); in spu_send_mfc_command()
1739 *error = ctx->ops->send_mfc_command(ctx, &cmd); in spu_send_mfc_command()
1749 struct spu_context *ctx = file->private_data; in spufs_mfc_write() local
1764 ret = spu_acquire(ctx); in spufs_mfc_write()
1768 ret = spufs_wait(ctx->run_wq, ctx->state == SPU_STATE_RUNNABLE); in spufs_mfc_write()
1773 ret = ctx->ops->send_mfc_command(ctx, &cmd); in spufs_mfc_write()
1776 ret = spufs_wait(ctx->mfc_wq, in spufs_mfc_write()
1777 spu_send_mfc_command(ctx, cmd, &status)); in spufs_mfc_write()
1787 ctx->tagwait |= 1 << cmd.tag; in spufs_mfc_write()
1791 spu_release(ctx); in spufs_mfc_write()
1798 struct spu_context *ctx = file->private_data; in spufs_mfc_poll() local
1802 poll_wait(file, &ctx->mfc_wq, wait); in spufs_mfc_poll()
1808 mutex_lock(&ctx->state_mutex); in spufs_mfc_poll()
1809 ctx->ops->set_mfc_query(ctx, ctx->tagwait, 2); in spufs_mfc_poll()
1810 free_elements = ctx->ops->get_mfc_free_elements(ctx); in spufs_mfc_poll()
1811 tagstatus = ctx->ops->read_mfc_tagstatus(ctx); in spufs_mfc_poll()
1812 spu_release(ctx); in spufs_mfc_poll()
1817 if (tagstatus & ctx->tagwait) in spufs_mfc_poll()
1821 free_elements, tagstatus, ctx->tagwait); in spufs_mfc_poll()
1828 struct spu_context *ctx = file->private_data; in spufs_mfc_flush() local
1831 ret = spu_acquire(ctx); in spufs_mfc_flush()
1836 ret = spufs_wait(ctx->mfc_wq, in spufs_mfc_flush()
1837 ctx->ops->set_mfc_query(ctx, ctx->tagwait, 2)); in spufs_mfc_flush()
1840 ret = spufs_wait(ctx->mfc_wq, in spufs_mfc_flush()
1841 ctx->ops->read_mfc_tagstatus(ctx) == ctx->tagwait); in spufs_mfc_flush()
1847 spu_release(ctx); in spufs_mfc_flush()
1866 struct spu_context *ctx = file->private_data; in spufs_mfc_fasync() local
1868 return fasync_helper(fd, file, on, &ctx->mfc_fasync); in spufs_mfc_fasync()
1886 struct spu_context *ctx = data; in spufs_npc_set() local
1889 ret = spu_acquire(ctx); in spufs_npc_set()
1892 ctx->ops->npc_write(ctx, val); in spufs_npc_set()
1893 spu_release(ctx); in spufs_npc_set()
1898 static u64 spufs_npc_get(struct spu_context *ctx) in spufs_npc_get() argument
1900 return ctx->ops->npc_read(ctx); in spufs_npc_get()
1907 struct spu_context *ctx = data; in spufs_decr_set() local
1908 struct spu_lscsa *lscsa = ctx->csa.lscsa; in spufs_decr_set()
1911 ret = spu_acquire_saved(ctx); in spufs_decr_set()
1915 spu_release_saved(ctx); in spufs_decr_set()
1920 static u64 spufs_decr_get(struct spu_context *ctx) in spufs_decr_get() argument
1922 struct spu_lscsa *lscsa = ctx->csa.lscsa; in spufs_decr_get()
1930 struct spu_context *ctx = data; in spufs_decr_status_set() local
1933 ret = spu_acquire_saved(ctx); in spufs_decr_status_set()
1937 ctx->csa.priv2.mfc_control_RW |= MFC_CNTL_DECREMENTER_RUNNING; in spufs_decr_status_set()
1939 ctx->csa.priv2.mfc_control_RW &= ~MFC_CNTL_DECREMENTER_RUNNING; in spufs_decr_status_set()
1940 spu_release_saved(ctx); in spufs_decr_status_set()
1945 static u64 spufs_decr_status_get(struct spu_context *ctx) in spufs_decr_status_get() argument
1947 if (ctx->csa.priv2.mfc_control_RW & MFC_CNTL_DECREMENTER_RUNNING) in spufs_decr_status_get()
1958 struct spu_context *ctx = data; in spufs_event_mask_set() local
1959 struct spu_lscsa *lscsa = ctx->csa.lscsa; in spufs_event_mask_set()
1962 ret = spu_acquire_saved(ctx); in spufs_event_mask_set()
1966 spu_release_saved(ctx); in spufs_event_mask_set()
1971 static u64 spufs_event_mask_get(struct spu_context *ctx) in spufs_event_mask_get() argument
1973 struct spu_lscsa *lscsa = ctx->csa.lscsa; in spufs_event_mask_get()
1981 static u64 spufs_event_status_get(struct spu_context *ctx) in spufs_event_status_get() argument
1983 struct spu_state *state = &ctx->csa; in spufs_event_status_get()
1995 struct spu_context *ctx = data; in spufs_srr0_set() local
1996 struct spu_lscsa *lscsa = ctx->csa.lscsa; in spufs_srr0_set()
1999 ret = spu_acquire_saved(ctx); in spufs_srr0_set()
2003 spu_release_saved(ctx); in spufs_srr0_set()
2008 static u64 spufs_srr0_get(struct spu_context *ctx) in spufs_srr0_get() argument
2010 struct spu_lscsa *lscsa = ctx->csa.lscsa; in spufs_srr0_get()
2016 static u64 spufs_id_get(struct spu_context *ctx) in spufs_id_get() argument
2020 if (ctx->state == SPU_STATE_RUNNABLE) in spufs_id_get()
2021 num = ctx->spu->number; in spufs_id_get()
2030 static u64 spufs_object_id_get(struct spu_context *ctx) in spufs_object_id_get() argument
2033 return ctx->object_id; in spufs_object_id_get()
2038 struct spu_context *ctx = data; in spufs_object_id_set() local
2039 ctx->object_id = id; in spufs_object_id_set()
2047 static u64 spufs_lslr_get(struct spu_context *ctx) in spufs_lslr_get() argument
2049 return ctx->csa.priv2.spu_lslr_RW; in spufs_lslr_get()
2057 struct spu_context *ctx = i->i_ctx; in spufs_info_open() local
2058 file->private_data = ctx; in spufs_info_open()
2064 struct spu_context *ctx = s->private; in spufs_caps_show() local
2066 if (!(ctx->flags & SPU_CREATE_NOSCHED)) in spufs_caps_show()
2068 if (!(ctx->flags & SPU_CREATE_ISOLATE)) in spufs_caps_show()
2085 static ssize_t __spufs_mbox_info_read(struct spu_context *ctx, in __spufs_mbox_info_read() argument
2091 if (!(ctx->csa.prob.mb_stat_R & 0x0000ff)) in __spufs_mbox_info_read()
2094 data = ctx->csa.prob.pu_mb_R; in __spufs_mbox_info_read()
2103 struct spu_context *ctx = file->private_data; in spufs_mbox_info_read() local
2108 ret = spu_acquire_saved(ctx); in spufs_mbox_info_read()
2111 spin_lock(&ctx->csa.register_lock); in spufs_mbox_info_read()
2112 ret = __spufs_mbox_info_read(ctx, buf, len, pos); in spufs_mbox_info_read()
2113 spin_unlock(&ctx->csa.register_lock); in spufs_mbox_info_read()
2114 spu_release_saved(ctx); in spufs_mbox_info_read()
2125 static ssize_t __spufs_ibox_info_read(struct spu_context *ctx, in __spufs_ibox_info_read() argument
2131 if (!(ctx->csa.prob.mb_stat_R & 0xff0000)) in __spufs_ibox_info_read()
2134 data = ctx->csa.priv2.puint_mb_R; in __spufs_ibox_info_read()
2142 struct spu_context *ctx = file->private_data; in spufs_ibox_info_read() local
2148 ret = spu_acquire_saved(ctx); in spufs_ibox_info_read()
2151 spin_lock(&ctx->csa.register_lock); in spufs_ibox_info_read()
2152 ret = __spufs_ibox_info_read(ctx, buf, len, pos); in spufs_ibox_info_read()
2153 spin_unlock(&ctx->csa.register_lock); in spufs_ibox_info_read()
2154 spu_release_saved(ctx); in spufs_ibox_info_read()
2165 static ssize_t __spufs_wbox_info_read(struct spu_context *ctx, in __spufs_wbox_info_read() argument
2172 wbox_stat = ctx->csa.prob.mb_stat_R; in __spufs_wbox_info_read()
2175 data[i] = ctx->csa.spu_mailbox_data[i]; in __spufs_wbox_info_read()
2185 struct spu_context *ctx = file->private_data; in spufs_wbox_info_read() local
2191 ret = spu_acquire_saved(ctx); in spufs_wbox_info_read()
2194 spin_lock(&ctx->csa.register_lock); in spufs_wbox_info_read()
2195 ret = __spufs_wbox_info_read(ctx, buf, len, pos); in spufs_wbox_info_read()
2196 spin_unlock(&ctx->csa.register_lock); in spufs_wbox_info_read()
2197 spu_release_saved(ctx); in spufs_wbox_info_read()
2208 static ssize_t __spufs_dma_info_read(struct spu_context *ctx, in __spufs_dma_info_read() argument
2215 info.dma_info_type = ctx->csa.priv2.spu_tag_status_query_RW; in __spufs_dma_info_read()
2216 info.dma_info_mask = ctx->csa.lscsa->tag_mask.slot[0]; in __spufs_dma_info_read()
2217 info.dma_info_status = ctx->csa.spu_chnldata_RW[24]; in __spufs_dma_info_read()
2218 info.dma_info_stall_and_notify = ctx->csa.spu_chnldata_RW[25]; in __spufs_dma_info_read()
2219 info.dma_info_atomic_command_status = ctx->csa.spu_chnldata_RW[27]; in __spufs_dma_info_read()
2222 spuqp = &ctx->csa.priv2.spuq[i]; in __spufs_dma_info_read()
2237 struct spu_context *ctx = file->private_data; in spufs_dma_info_read() local
2243 ret = spu_acquire_saved(ctx); in spufs_dma_info_read()
2246 spin_lock(&ctx->csa.register_lock); in spufs_dma_info_read()
2247 ret = __spufs_dma_info_read(ctx, buf, len, pos); in spufs_dma_info_read()
2248 spin_unlock(&ctx->csa.register_lock); in spufs_dma_info_read()
2249 spu_release_saved(ctx); in spufs_dma_info_read()
2260 static ssize_t __spufs_proxydma_info_read(struct spu_context *ctx, in __spufs_proxydma_info_read() argument
2274 info.proxydma_info_type = ctx->csa.prob.dma_querytype_RW; in __spufs_proxydma_info_read()
2275 info.proxydma_info_mask = ctx->csa.prob.dma_querymask_RW; in __spufs_proxydma_info_read()
2276 info.proxydma_info_status = ctx->csa.prob.dma_tagstatus_R; in __spufs_proxydma_info_read()
2279 puqp = &ctx->csa.priv2.puq[i]; in __spufs_proxydma_info_read()
2294 struct spu_context *ctx = file->private_data; in spufs_proxydma_info_read() local
2297 ret = spu_acquire_saved(ctx); in spufs_proxydma_info_read()
2300 spin_lock(&ctx->csa.register_lock); in spufs_proxydma_info_read()
2301 ret = __spufs_proxydma_info_read(ctx, buf, len, pos); in spufs_proxydma_info_read()
2302 spin_unlock(&ctx->csa.register_lock); in spufs_proxydma_info_read()
2303 spu_release_saved(ctx); in spufs_proxydma_info_read()
2316 struct spu_context *ctx = s->private; in spufs_show_tid() local
2318 seq_printf(s, "%d\n", ctx->tid); in spufs_show_tid()
2338 static unsigned long long spufs_acct_time(struct spu_context *ctx, in spufs_acct_time() argument
2341 unsigned long long time = ctx->stats.times[state]; in spufs_acct_time()
2352 if (ctx->spu && ctx->stats.util_state == state) { in spufs_acct_time()
2353 time += ktime_get_ns() - ctx->stats.tstamp; in spufs_acct_time()
2359 static unsigned long long spufs_slb_flts(struct spu_context *ctx) in spufs_slb_flts() argument
2361 unsigned long long slb_flts = ctx->stats.slb_flt; in spufs_slb_flts()
2363 if (ctx->state == SPU_STATE_RUNNABLE) { in spufs_slb_flts()
2364 slb_flts += (ctx->spu->stats.slb_flt - in spufs_slb_flts()
2365 ctx->stats.slb_flt_base); in spufs_slb_flts()
2371 static unsigned long long spufs_class2_intrs(struct spu_context *ctx) in spufs_class2_intrs() argument
2373 unsigned long long class2_intrs = ctx->stats.class2_intr; in spufs_class2_intrs()
2375 if (ctx->state == SPU_STATE_RUNNABLE) { in spufs_class2_intrs()
2376 class2_intrs += (ctx->spu->stats.class2_intr - in spufs_class2_intrs()
2377 ctx->stats.class2_intr_base); in spufs_class2_intrs()
2386 struct spu_context *ctx = s->private; in spufs_show_stat() local
2389 ret = spu_acquire(ctx); in spufs_show_stat()
2395 ctx_state_names[ctx->stats.util_state], in spufs_show_stat()
2396 spufs_acct_time(ctx, SPU_UTIL_USER), in spufs_show_stat()
2397 spufs_acct_time(ctx, SPU_UTIL_SYSTEM), in spufs_show_stat()
2398 spufs_acct_time(ctx, SPU_UTIL_IOWAIT), in spufs_show_stat()
2399 spufs_acct_time(ctx, SPU_UTIL_IDLE_LOADED), in spufs_show_stat()
2400 ctx->stats.vol_ctx_switch, in spufs_show_stat()
2401 ctx->stats.invol_ctx_switch, in spufs_show_stat()
2402 spufs_slb_flts(ctx), in spufs_show_stat()
2403 ctx->stats.hash_flt, in spufs_show_stat()
2404 ctx->stats.min_flt, in spufs_show_stat()
2405 ctx->stats.maj_flt, in spufs_show_stat()
2406 spufs_class2_intrs(ctx), in spufs_show_stat()
2407 ctx->stats.libassist); in spufs_show_stat()
2408 spu_release(ctx); in spufs_show_stat()
2424 static inline int spufs_switch_log_used(struct spu_context *ctx) in spufs_switch_log_used() argument
2426 return (ctx->switch_log->head - ctx->switch_log->tail) % in spufs_switch_log_used()
2430 static inline int spufs_switch_log_avail(struct spu_context *ctx) in spufs_switch_log_avail() argument
2432 return SWITCH_LOG_BUFSIZE - spufs_switch_log_used(ctx); in spufs_switch_log_avail()
2437 struct spu_context *ctx = SPUFS_I(inode)->i_ctx; in spufs_switch_log_open() local
2440 rc = spu_acquire(ctx); in spufs_switch_log_open()
2444 if (ctx->switch_log) { in spufs_switch_log_open()
2449 ctx->switch_log = kmalloc(sizeof(struct switch_log) + in spufs_switch_log_open()
2453 if (!ctx->switch_log) { in spufs_switch_log_open()
2458 ctx->switch_log->head = ctx->switch_log->tail = 0; in spufs_switch_log_open()
2459 init_waitqueue_head(&ctx->switch_log->wait); in spufs_switch_log_open()
2463 spu_release(ctx); in spufs_switch_log_open()
2469 struct spu_context *ctx = SPUFS_I(inode)->i_ctx; in spufs_switch_log_release() local
2472 rc = spu_acquire(ctx); in spufs_switch_log_release()
2476 kfree(ctx->switch_log); in spufs_switch_log_release()
2477 ctx->switch_log = NULL; in spufs_switch_log_release()
2478 spu_release(ctx); in spufs_switch_log_release()
2483 static int switch_log_sprint(struct spu_context *ctx, char *tbuf, int n) in switch_log_sprint() argument
2487 p = ctx->switch_log->log + ctx->switch_log->tail % SWITCH_LOG_BUFSIZE; in switch_log_sprint()
2502 struct spu_context *ctx = SPUFS_I(inode)->i_ctx; in spufs_switch_log_read() local
2508 error = spu_acquire(ctx); in spufs_switch_log_read()
2516 if (spufs_switch_log_used(ctx) == 0) { in spufs_switch_log_read()
2532 error = spufs_wait(ctx->switch_log->wait, in spufs_switch_log_read()
2533 spufs_switch_log_used(ctx) > 0); in spufs_switch_log_read()
2543 if (spufs_switch_log_used(ctx) == 0) in spufs_switch_log_read()
2548 width = switch_log_sprint(ctx, tbuf, sizeof(tbuf)); in spufs_switch_log_read()
2550 ctx->switch_log->tail = in spufs_switch_log_read()
2551 (ctx->switch_log->tail + 1) % in spufs_switch_log_read()
2564 spu_release(ctx); in spufs_switch_log_read()
2572 struct spu_context *ctx = SPUFS_I(inode)->i_ctx; in spufs_switch_log_poll() local
2576 poll_wait(file, &ctx->switch_log->wait, wait); in spufs_switch_log_poll()
2578 rc = spu_acquire(ctx); in spufs_switch_log_poll()
2582 if (spufs_switch_log_used(ctx) > 0) in spufs_switch_log_poll()
2585 spu_release(ctx); in spufs_switch_log_poll()
2603 void spu_switch_log_notify(struct spu *spu, struct spu_context *ctx, in spu_switch_log_notify() argument
2606 if (!ctx->switch_log) in spu_switch_log_notify()
2609 if (spufs_switch_log_avail(ctx) > 1) { in spu_switch_log_notify()
2612 p = ctx->switch_log->log + ctx->switch_log->head; in spu_switch_log_notify()
2619 ctx->switch_log->head = in spu_switch_log_notify()
2620 (ctx->switch_log->head + 1) % SWITCH_LOG_BUFSIZE; in spu_switch_log_notify()
2623 wake_up(&ctx->switch_log->wait); in spu_switch_log_notify()
2628 struct spu_context *ctx = s->private; in spufs_show_ctx() local
2631 mutex_lock(&ctx->state_mutex); in spufs_show_ctx()
2632 if (ctx->spu) { in spufs_show_ctx()
2633 struct spu *spu = ctx->spu; in spufs_show_ctx()
2640 struct spu_state *csa = &ctx->csa; in spufs_show_ctx()
2647 ctx->state == SPU_STATE_SAVED ? 'S' : 'R', in spufs_show_ctx()
2648 ctx->flags, in spufs_show_ctx()
2649 ctx->sched_flags, in spufs_show_ctx()
2650 ctx->prio, in spufs_show_ctx()
2651 ctx->time_slice, in spufs_show_ctx()
2652 ctx->spu ? ctx->spu->number : -1, in spufs_show_ctx()
2653 !list_empty(&ctx->rq) ? 'q' : ' ', in spufs_show_ctx()
2654 ctx->csa.class_0_pending, in spufs_show_ctx()
2655 ctx->csa.class_0_dar, in spufs_show_ctx()
2656 ctx->csa.class_1_dsisr, in spufs_show_ctx()
2658 ctx->ops->runcntl_read(ctx), in spufs_show_ctx()
2659 ctx->ops->status_read(ctx)); in spufs_show_ctx()
2661 mutex_unlock(&ctx->state_mutex); in spufs_show_ctx()