Commit e1dbff2b authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Paul Mackerras

[POWERPC] spufs: add support for read/write on cntl

Writing to cntl can be used to stop execution on the
spu and to restart it, reading from cntl gives the
contents of the current status register.

The access is always in ascii, as for most other files.

This was always meant to be there, but we had a little
problem with writing to runctl so it was left out so
far.
Signed-off-by: default avatarArnd Bergmann <arnd.bergmann@de.ibm.com>
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
parent 772920e5
...@@ -211,37 +211,43 @@ static int spufs_cntl_mmap(struct file *file, struct vm_area_struct *vma) ...@@ -211,37 +211,43 @@ static int spufs_cntl_mmap(struct file *file, struct vm_area_struct *vma)
#define spufs_cntl_mmap NULL #define spufs_cntl_mmap NULL
#endif /* !SPUFS_MMAP_4K */ #endif /* !SPUFS_MMAP_4K */
static int spufs_cntl_open(struct inode *inode, struct file *file) static u64 spufs_cntl_get(void *data)
{ {
struct spufs_inode_info *i = SPUFS_I(inode); struct spu_context *ctx = data;
struct spu_context *ctx = i->i_ctx; u64 val;
file->private_data = ctx; spu_acquire(ctx);
file->f_mapping = inode->i_mapping; val = ctx->ops->status_read(ctx);
ctx->cntl = inode->i_mapping; spu_release(ctx);
return 0;
return val;
} }
static ssize_t static void spufs_cntl_set(void *data, u64 val)
spufs_cntl_read(struct file *file, char __user *buffer,
size_t size, loff_t *pos)
{ {
/* FIXME: read from spu status */ struct spu_context *ctx = data;
return -EINVAL;
spu_acquire(ctx);
ctx->ops->runcntl_write(ctx, val);
spu_release(ctx);
} }
static ssize_t static int spufs_cntl_open(struct inode *inode, struct file *file)
spufs_cntl_write(struct file *file, const char __user *buffer,
size_t size, loff_t *pos)
{ {
/* FIXME: write to runctl bit */ struct spufs_inode_info *i = SPUFS_I(inode);
return -EINVAL; struct spu_context *ctx = i->i_ctx;
file->private_data = ctx;
file->f_mapping = inode->i_mapping;
ctx->cntl = inode->i_mapping;
return simple_attr_open(inode, file, spufs_cntl_get,
spufs_cntl_set, "0x%08lx");
} }
static struct file_operations spufs_cntl_fops = { static struct file_operations spufs_cntl_fops = {
.open = spufs_cntl_open, .open = spufs_cntl_open,
.read = spufs_cntl_read, .read = simple_attr_read,
.write = spufs_cntl_write, .write = simple_attr_write,
.mmap = spufs_cntl_mmap, .mmap = spufs_cntl_mmap,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment