[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: Arnd Bergmann <arnd.bergmann@de.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>

authored by Arnd Bergmann and committed by Paul Mackerras e1dbff2b 772920e5

+25 -19
+25 -19
arch/powerpc/platforms/cell/spufs/file.c
··· 211 #define spufs_cntl_mmap NULL 212 #endif /* !SPUFS_MMAP_4K */ 213 214 static int spufs_cntl_open(struct inode *inode, struct file *file) 215 { 216 struct spufs_inode_info *i = SPUFS_I(inode); ··· 240 file->private_data = ctx; 241 file->f_mapping = inode->i_mapping; 242 ctx->cntl = inode->i_mapping; 243 - return 0; 244 - } 245 - 246 - static ssize_t 247 - spufs_cntl_read(struct file *file, char __user *buffer, 248 - size_t size, loff_t *pos) 249 - { 250 - /* FIXME: read from spu status */ 251 - return -EINVAL; 252 - } 253 - 254 - static ssize_t 255 - spufs_cntl_write(struct file *file, const char __user *buffer, 256 - size_t size, loff_t *pos) 257 - { 258 - /* FIXME: write to runctl bit */ 259 - return -EINVAL; 260 } 261 262 static struct file_operations spufs_cntl_fops = { 263 .open = spufs_cntl_open, 264 - .read = spufs_cntl_read, 265 - .write = spufs_cntl_write, 266 .mmap = spufs_cntl_mmap, 267 }; 268
··· 211 #define spufs_cntl_mmap NULL 212 #endif /* !SPUFS_MMAP_4K */ 213 214 + static u64 spufs_cntl_get(void *data) 215 + { 216 + struct spu_context *ctx = data; 217 + u64 val; 218 + 219 + spu_acquire(ctx); 220 + val = ctx->ops->status_read(ctx); 221 + spu_release(ctx); 222 + 223 + return val; 224 + } 225 + 226 + static void spufs_cntl_set(void *data, u64 val) 227 + { 228 + struct spu_context *ctx = data; 229 + 230 + spu_acquire(ctx); 231 + ctx->ops->runcntl_write(ctx, val); 232 + spu_release(ctx); 233 + } 234 + 235 static int spufs_cntl_open(struct inode *inode, struct file *file) 236 { 237 struct spufs_inode_info *i = SPUFS_I(inode); ··· 219 file->private_data = ctx; 220 file->f_mapping = inode->i_mapping; 221 ctx->cntl = inode->i_mapping; 222 + return simple_attr_open(inode, file, spufs_cntl_get, 223 + spufs_cntl_set, "0x%08lx"); 224 } 225 226 static struct file_operations spufs_cntl_fops = { 227 .open = spufs_cntl_open, 228 + .read = simple_attr_read, 229 + .write = simple_attr_write, 230 .mmap = spufs_cntl_mmap, 231 }; 232