⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 file.c

📁 linux 内核源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
		ctx->csa.priv2.mfc_control_RW |= MFC_CNTL_DECREMENTER_RUNNING;	else		ctx->csa.priv2.mfc_control_RW &= ~MFC_CNTL_DECREMENTER_RUNNING;	spu_release_saved(ctx);}static u64 spufs_decr_status_get(struct spu_context *ctx){	if (ctx->csa.priv2.mfc_control_RW & MFC_CNTL_DECREMENTER_RUNNING)		return SPU_DECR_STATUS_RUNNING;	else		return 0;}DEFINE_SPUFS_ATTRIBUTE(spufs_decr_status_ops, spufs_decr_status_get,		       spufs_decr_status_set, "0x%llx\n",		       SPU_ATTR_ACQUIRE_SAVED);static void spufs_event_mask_set(void *data, u64 val){	struct spu_context *ctx = data;	struct spu_lscsa *lscsa = ctx->csa.lscsa;	spu_acquire_saved(ctx);	lscsa->event_mask.slot[0] = (u32) val;	spu_release_saved(ctx);}static u64 spufs_event_mask_get(struct spu_context *ctx){	struct spu_lscsa *lscsa = ctx->csa.lscsa;	return lscsa->event_mask.slot[0];}DEFINE_SPUFS_ATTRIBUTE(spufs_event_mask_ops, spufs_event_mask_get,		       spufs_event_mask_set, "0x%llx\n",		       SPU_ATTR_ACQUIRE_SAVED);static u64 spufs_event_status_get(struct spu_context *ctx){	struct spu_state *state = &ctx->csa;	u64 stat;	stat = state->spu_chnlcnt_RW[0];	if (stat)		return state->spu_chnldata_RW[0];	return 0;}DEFINE_SPUFS_ATTRIBUTE(spufs_event_status_ops, spufs_event_status_get,		       NULL, "0x%llx\n", SPU_ATTR_ACQUIRE_SAVED)static void spufs_srr0_set(void *data, u64 val){	struct spu_context *ctx = data;	struct spu_lscsa *lscsa = ctx->csa.lscsa;	spu_acquire_saved(ctx);	lscsa->srr0.slot[0] = (u32) val;	spu_release_saved(ctx);}static u64 spufs_srr0_get(struct spu_context *ctx){	struct spu_lscsa *lscsa = ctx->csa.lscsa;	return lscsa->srr0.slot[0];}DEFINE_SPUFS_ATTRIBUTE(spufs_srr0_ops, spufs_srr0_get, spufs_srr0_set,		       "0x%llx\n", SPU_ATTR_ACQUIRE_SAVED)static u64 spufs_id_get(struct spu_context *ctx){	u64 num;	if (ctx->state == SPU_STATE_RUNNABLE)		num = ctx->spu->number;	else		num = (unsigned int)-1;	return num;}DEFINE_SPUFS_ATTRIBUTE(spufs_id_ops, spufs_id_get, NULL, "0x%llx\n",		       SPU_ATTR_ACQUIRE)static u64 spufs_object_id_get(struct spu_context *ctx){	/* FIXME: Should there really be no locking here? */	return ctx->object_id;}static void spufs_object_id_set(void *data, u64 id){	struct spu_context *ctx = data;	ctx->object_id = id;}DEFINE_SPUFS_ATTRIBUTE(spufs_object_id_ops, spufs_object_id_get,		       spufs_object_id_set, "0x%llx\n", SPU_ATTR_NOACQUIRE);static u64 spufs_lslr_get(struct spu_context *ctx){	return ctx->csa.priv2.spu_lslr_RW;}DEFINE_SPUFS_ATTRIBUTE(spufs_lslr_ops, spufs_lslr_get, NULL, "0x%llx\n",		       SPU_ATTR_ACQUIRE_SAVED);static int spufs_info_open(struct inode *inode, struct file *file){	struct spufs_inode_info *i = SPUFS_I(inode);	struct spu_context *ctx = i->i_ctx;	file->private_data = ctx;	return 0;}static int spufs_caps_show(struct seq_file *s, void *private){	struct spu_context *ctx = s->private;	if (!(ctx->flags & SPU_CREATE_NOSCHED))		seq_puts(s, "sched\n");	if (!(ctx->flags & SPU_CREATE_ISOLATE))		seq_puts(s, "step\n");	return 0;}static int spufs_caps_open(struct inode *inode, struct file *file){	return single_open(file, spufs_caps_show, SPUFS_I(inode)->i_ctx);}static const struct file_operations spufs_caps_fops = {	.open		= spufs_caps_open,	.read		= seq_read,	.llseek		= seq_lseek,	.release	= single_release,};static ssize_t __spufs_mbox_info_read(struct spu_context *ctx,			char __user *buf, size_t len, loff_t *pos){	u32 mbox_stat;	u32 data;	mbox_stat = ctx->csa.prob.mb_stat_R;	if (mbox_stat & 0x0000ff) {		data = ctx->csa.prob.pu_mb_R;	}	return simple_read_from_buffer(buf, len, pos, &data, sizeof data);}static ssize_t spufs_mbox_info_read(struct file *file, char __user *buf,				   size_t len, loff_t *pos){	int ret;	struct spu_context *ctx = file->private_data;	if (!access_ok(VERIFY_WRITE, buf, len))		return -EFAULT;	spu_acquire_saved(ctx);	spin_lock(&ctx->csa.register_lock);	ret = __spufs_mbox_info_read(ctx, buf, len, pos);	spin_unlock(&ctx->csa.register_lock);	spu_release_saved(ctx);	return ret;}static const struct file_operations spufs_mbox_info_fops = {	.open = spufs_info_open,	.read = spufs_mbox_info_read,	.llseek  = generic_file_llseek,};static ssize_t __spufs_ibox_info_read(struct spu_context *ctx,				char __user *buf, size_t len, loff_t *pos){	u32 ibox_stat;	u32 data;	ibox_stat = ctx->csa.prob.mb_stat_R;	if (ibox_stat & 0xff0000) {		data = ctx->csa.priv2.puint_mb_R;	}	return simple_read_from_buffer(buf, len, pos, &data, sizeof data);}static ssize_t spufs_ibox_info_read(struct file *file, char __user *buf,				   size_t len, loff_t *pos){	struct spu_context *ctx = file->private_data;	int ret;	if (!access_ok(VERIFY_WRITE, buf, len))		return -EFAULT;	spu_acquire_saved(ctx);	spin_lock(&ctx->csa.register_lock);	ret = __spufs_ibox_info_read(ctx, buf, len, pos);	spin_unlock(&ctx->csa.register_lock);	spu_release_saved(ctx);	return ret;}static const struct file_operations spufs_ibox_info_fops = {	.open = spufs_info_open,	.read = spufs_ibox_info_read,	.llseek  = generic_file_llseek,};static ssize_t __spufs_wbox_info_read(struct spu_context *ctx,			char __user *buf, size_t len, loff_t *pos){	int i, cnt;	u32 data[4];	u32 wbox_stat;	wbox_stat = ctx->csa.prob.mb_stat_R;	cnt = 4 - ((wbox_stat & 0x00ff00) >> 8);	for (i = 0; i < cnt; i++) {		data[i] = ctx->csa.spu_mailbox_data[i];	}	return simple_read_from_buffer(buf, len, pos, &data,				cnt * sizeof(u32));}static ssize_t spufs_wbox_info_read(struct file *file, char __user *buf,				   size_t len, loff_t *pos){	struct spu_context *ctx = file->private_data;	int ret;	if (!access_ok(VERIFY_WRITE, buf, len))		return -EFAULT;	spu_acquire_saved(ctx);	spin_lock(&ctx->csa.register_lock);	ret = __spufs_wbox_info_read(ctx, buf, len, pos);	spin_unlock(&ctx->csa.register_lock);	spu_release_saved(ctx);	return ret;}static const struct file_operations spufs_wbox_info_fops = {	.open = spufs_info_open,	.read = spufs_wbox_info_read,	.llseek  = generic_file_llseek,};static ssize_t __spufs_dma_info_read(struct spu_context *ctx,			char __user *buf, size_t len, loff_t *pos){	struct spu_dma_info info;	struct mfc_cq_sr *qp, *spuqp;	int i;	info.dma_info_type = ctx->csa.priv2.spu_tag_status_query_RW;	info.dma_info_mask = ctx->csa.lscsa->tag_mask.slot[0];	info.dma_info_status = ctx->csa.spu_chnldata_RW[24];	info.dma_info_stall_and_notify = ctx->csa.spu_chnldata_RW[25];	info.dma_info_atomic_command_status = ctx->csa.spu_chnldata_RW[27];	for (i = 0; i < 16; i++) {		qp = &info.dma_info_command_data[i];		spuqp = &ctx->csa.priv2.spuq[i];		qp->mfc_cq_data0_RW = spuqp->mfc_cq_data0_RW;		qp->mfc_cq_data1_RW = spuqp->mfc_cq_data1_RW;		qp->mfc_cq_data2_RW = spuqp->mfc_cq_data2_RW;		qp->mfc_cq_data3_RW = spuqp->mfc_cq_data3_RW;	}	return simple_read_from_buffer(buf, len, pos, &info,				sizeof info);}static ssize_t spufs_dma_info_read(struct file *file, char __user *buf,			      size_t len, loff_t *pos){	struct spu_context *ctx = file->private_data;	int ret;	if (!access_ok(VERIFY_WRITE, buf, len))		return -EFAULT;	spu_acquire_saved(ctx);	spin_lock(&ctx->csa.register_lock);	ret = __spufs_dma_info_read(ctx, buf, len, pos);	spin_unlock(&ctx->csa.register_lock);	spu_release_saved(ctx);	return ret;}static const struct file_operations spufs_dma_info_fops = {	.open = spufs_info_open,	.read = spufs_dma_info_read,};static ssize_t __spufs_proxydma_info_read(struct spu_context *ctx,			char __user *buf, size_t len, loff_t *pos){	struct spu_proxydma_info info;	struct mfc_cq_sr *qp, *puqp;	int ret = sizeof info;	int i;	if (len < ret)		return -EINVAL;	if (!access_ok(VERIFY_WRITE, buf, len))		return -EFAULT;	info.proxydma_info_type = ctx->csa.prob.dma_querytype_RW;	info.proxydma_info_mask = ctx->csa.prob.dma_querymask_RW;	info.proxydma_info_status = ctx->csa.prob.dma_tagstatus_R;	for (i = 0; i < 8; i++) {		qp = &info.proxydma_info_command_data[i];		puqp = &ctx->csa.priv2.puq[i];		qp->mfc_cq_data0_RW = puqp->mfc_cq_data0_RW;		qp->mfc_cq_data1_RW = puqp->mfc_cq_data1_RW;		qp->mfc_cq_data2_RW = puqp->mfc_cq_data2_RW;		qp->mfc_cq_data3_RW = puqp->mfc_cq_data3_RW;	}	return simple_read_from_buffer(buf, len, pos, &info,				sizeof info);}static ssize_t spufs_proxydma_info_read(struct file *file, char __user *buf,				   size_t len, loff_t *pos){	struct spu_context *ctx = file->private_data;	int ret;	spu_acquire_saved(ctx);	spin_lock(&ctx->csa.register_lock);	ret = __spufs_proxydma_info_read(ctx, buf, len, pos);	spin_unlock(&ctx->csa.register_lock);	spu_release_saved(ctx);	return ret;}static const struct file_operations spufs_proxydma_info_fops = {	.open = spufs_info_open,	.read = spufs_proxydma_info_read,};static int spufs_show_tid(struct seq_file *s, void *private){	struct spu_context *ctx = s->private;	seq_printf(s, "%d\n", ctx->tid);	return 0;}static int spufs_tid_open(struct inode *inode, struct file *file){	return single_open(file, spufs_show_tid, SPUFS_I(inode)->i_ctx);}static const struct file_operations spufs_tid_fops = {	.open		= spufs_tid_open,	.read		= seq_read,	.llseek		= seq_lseek,	.release	= single_release,};static const char *ctx_state_names[] = {	"user", "system", "iowait", "loaded"};static unsigned long long spufs_acct_time(struct spu_context *ctx,		enum spu_utilization_state state){	struct timespec ts;	unsigned long long time = ctx->stats.times[state];	/*	 * In general, utilization statistics are updated by the controlling	 * thread as the spu context moves through various well defined	 * state transitions, but if the context is lazily loaded its	 * utilization statistics are not updated as the controlling thread	 * is not tightly coupled with the execution of the spu context.  We	 * calculate and apply the time delta from the last recorded state	 * of the spu context.	 */	if (ctx->spu && ctx->stats.util_state == state) {		ktime_get_ts(&ts);		time += timespec_to_ns(&ts) - ctx->stats.tstamp;	}	return time / NSEC_PER_MSEC;}static unsigned long long spufs_slb_flts(struct spu_context *ctx){	unsigned long long slb_flts = ctx->stats.slb_flt;	if (ctx->state == SPU_STATE_RUNNABLE) {		slb_flts += (ctx->spu->stats.slb_flt -			     ctx->stats.slb_flt_base);	}	return slb_flts;}static unsigned long long spufs_class2_intrs(struct spu_context *ctx){	unsigned long long class2_intrs = ctx->stats.class2_intr;	if (ctx->state == SPU_STATE_RUNNABLE) {		class2_intrs += (ctx->spu->stats.class2_intr -				 ctx->stats.class2_intr_base);	}	return class2_intrs;}static int spufs_show_stat(struct seq_file *s, void *private){	struct spu_context *ctx = s->private;	spu_acquire(ctx);	seq_printf(s, "%s %llu %llu %llu %llu "		      "%llu %llu %llu %llu %llu %llu %llu %llu\n",		ctx_state_names[ctx->stats.util_state],		spufs_acct_time(ctx, SPU_UTIL_USER),		spufs_acct_time(ctx, SPU_UTIL_SYSTEM),		spufs_acct_time(ctx, SPU_UTIL_IOWAIT),		spufs_acct_time(ctx, SPU_UTIL_IDLE_LOADED),		ctx->stats.vol_ctx_switch,		ctx->stats.invol_ctx_switch,		spufs_slb_flts(ctx),		ctx->stats.hash_flt,		ctx->stats.min_flt,		ctx->stats.maj_flt,		spufs_class2_intrs(ctx),		ctx->stats.libassist);	spu_release(ctx);	return 0;}static int spufs_stat_open(struct inode *inode, struct file *file){	return single_open(file, spufs_show_stat, SPUFS_I(inode)->i_ctx);}static const struct file_operations spufs_stat_fops = {	.open		= spufs_stat_open,	.read		= seq_read,	.llseek		= seq_lseek,	.release	= single_release,};struct tree_descr spufs_dir_contents[] = {	{ "capabilities", &spufs_caps_fops, 0444, },	{ "mem",  &spufs_mem_fops,  0666, },	{ "regs", &spufs_regs_fops,  0666, },	{ "mbox", &spufs_mbox_fops, 0444, },	{ "ibox", &spufs_ibox_fops, 0444, },	{ "wbox", &spufs_wbox_fops, 0222, },	{ "mbox_stat", &spufs_mbox_stat_fops, 0444, },	{ "ibox_stat", &spufs_ibox_stat_fops, 0444, },	{ "wbox_stat", &spufs_wbox_stat_fops, 0444, },	{ "signal1", &spufs_signal1_fops, 0666, },	{ "signal2", &spufs_signal2_fops, 0666, },	{ "signal1_type", &spufs_signal1_type, 0666, },	{ "signal2_type", &spufs_signal2_type, 0666, },	{ "cntl", &spufs_cntl_fops,  0666, },	{ "fpcr", &spufs_fpcr_fops, 0666, },	{ "lslr", &spufs_lslr_ops, 0444, },	{ "mfc", &spufs_mfc_fops, 0666, },	{ "mss", &spufs_mss_fops, 0666, },	{ "npc", &spufs_npc_ops, 0666, },	{ "srr0", &spufs_srr0_ops, 0666, },	{ "decr", &spufs_decr_ops, 0666, },	{ "decr_status", &spufs_decr_status_ops, 0666, },	{ "event_mask", &spufs_event_mask_ops, 0666, },	{ "event_status", &spufs_event_status_ops, 0444, },	{ "psmap", &spufs_psmap_fops, 0666, },	{ "phys-id", &spufs_id_ops, 0666, },	{ "object-id", &spufs_object_id_ops, 0666, },	{ "mbox_info", &spufs_mbox_info_fops, 0444, },	{ "ibox_info", &spufs_ibox_info_fops, 0444, },	{ "wbox_info", &spufs_wbox_info_fops, 0444, },	{ "dma_info", &spufs_dma_info_fops, 0444, },	{ "proxydma_info", &spufs_proxydma_info_fops, 0444, },	{ "tid", &spufs_tid_fops, 0444, },	{ "stat", &spufs_stat_fops, 0444, },	{},};struct tree_descr spufs_dir_nosched_contents[] = {	{ "capabilities", &spufs_caps_fops, 0444, },	{ "mem",  &spufs_mem_fops,  0666, },	{ "mbox", &spufs_mbox_fops, 0444, },	{ "ibox", &spufs_ibox_fops, 0444, },	{ "wbox", &spufs_wbox_fops, 0222, },	{ "mbox_stat", &spufs_mbox_stat_fops, 0444, },	{ "ibox_stat", &spufs_ibox_stat_fops, 0444, },	{ "wbox_stat", &spufs_wbox_stat_fops, 0444, },	{ "signal1", &spufs_signal1_nosched_fops, 0222, },	{ "signal2", &spufs_signal2_nosched_fops, 0222, },	{ "signal1_type", &spufs_signal1_type, 0666, },	{ "signal2_type", &spufs_signal2_type, 0666, },	{ "mss", &spufs_mss_fops, 0666, },	{ "mfc", &spufs_mfc_fops, 0666, },	{ "cntl", &spufs_cntl_fops,  0666, },	{ "npc", &spufs_npc_ops, 0666, },	{ "psmap", &spufs_psmap_fops, 0666, },	{ "phys-id", &spufs_id_ops, 0666, },	{ "object-id", &spufs_object_id_ops, 0666, },	{ "tid", &spufs_tid_fops, 0444, },	{ "stat", &spufs_stat_fops, 0444, },	{},};struct spufs_coredump_reader spufs_coredump_read[] = {	{ "regs", __spufs_regs_read, NULL, sizeof(struct spu_reg128[128])},	{ "fpcr", __spufs_fpcr_read, NULL, sizeof(struct spu_reg128) },	{ "lslr", NULL, spufs_lslr_get, 19 },	{ "decr", NULL, spufs_decr_get, 19 },	{ "decr_status", NULL, spufs_decr_status_get, 19 },	{ "mem", __spufs_mem_read, NULL, LS_SIZE, },	{ "signal1", __spufs_signal1_read, NULL, sizeof(u32) },	{ "signal1_type", NULL, spufs_signal1_type_get, 19 },	{ "signal2", __spufs_signal2_read, NULL, sizeof(u32) },	{ "signal2_type", NULL, spufs_signal2_type_get, 19 },	{ "event_mask", NULL, spufs_event_mask_get, 19 },	{ "event_status", NULL, spufs_event_status_get, 19 },	{ "mbox_info", __spufs_mbox_info_read, NULL, sizeof(u32) },	{ "ibox_info", __spufs_ibox_info_read, NULL, sizeof(u32) },	{ "wbox_info", __spufs_wbox_info_read, NULL, 4 * sizeof(u32)},	{ "dma_info", __spufs_dma_info_read, NULL, sizeof(struct spu_dma_info)},	{ "proxydma_info", __spufs_proxydma_info_read,			   NULL, sizeof(struct spu_proxydma_info)},	{ "object-id", NULL, spufs_object_id_get, 19 },	{ "npc", NULL, spufs_npc_get, 19 },	{ NULL },};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -