Skip to contentSkip to conversation

spufs: Use a system call instead of ioctl

PATCH In review Arnd Bergmann 1 participant 1 message Aug 25, 2005 ABI/API

lore
Share & tools
lore
#0 lore raw

PATCH 5/7 spufs: Use a system call instead of ioctl

This patch makes it possible to use a system call instead of an ioctl to run spu code on spufs.

This is only provided for reference, the current patch is unlikely to be used in future versions.

We planning to move to a model where creation/destruction of SPU threads as well as entering the execution is done with new system calls instead of mkdir, rmdir and this call.
This will make an SPU thread a property of a Linux user space thread instead of the global object that can be used by any process.

--

 arch/ppc64/kernel/misc.S   |    2 
 fs/spufs/Makefile          |    2 
 fs/spufs/file.c            |   12 +++++
 fs/spufs/spufs.h           |    2 
 fs/spufs/spurun.c          |   96 +++++++++++++++++++++++++++++++++++++++++++++
 include/asm-ppc/unistd.h   |    3 -
 include/asm-ppc64/unistd.h |    3 -
 include/linux/syscalls.h   |    3 +
 kernel/sys_ni.c            |    1 
 9 files changed, 121 insertions(+), 3 deletions(-)
arch/ppc64/kernel/misc.S +2 -0
@@ -1132,6 +1132,7 @@ _GLOBAL(sys_call_table32)
 	.llong .sys_inotify_init	/* 275 */
 	.llong .sys_inotify_add_watch
 	.llong .sys_inotify_rm_watch
+	.llong .sys_spu_run
 
 	.balign 8
 _GLOBAL(sys_call_table)
@@ -1413,3 +1414,4 @@ _GLOBAL(sys_call_table)
 	.llong .sys_inotify_init	/* 275 */
 	.llong .sys_inotify_add_watch
 	.llong .sys_inotify_rm_watch
+	.llong .sys_spu_run
fs/spufs/Makefile +2 -0
@@ -1,5 +1,7 @@
 obj-$(CONFIG_SPU_FS) += spufs.o
+syscall-$(CONFIG_SPU_FS) += spurun.o
 
+obj-y += $(syscall-y) $(syscall-m)
 spufs-y += inode.o file.o context.o switch.o
 
 # Rules to build switch.o with the help of SPU tool chain
fs/spufs/file.c +11 -1
@@ -406,6 +406,16 @@ out:
 	return ret;
 }
 
+static int spufs_run_open(struct inode *inode, struct file *file)
+{
+	struct spufs_inode_info *i = SPUFS_I(inode);
+	file->private_data = i->i_ctx;
+
+	i->i_spu_run = spufs_run_spu;
+
+	return nonseekable_open(inode, file);
+}
+
 struct spufs_run_arg {
 	u32 npc;    /* inout: Next Program Counter */
 	u32 status; /* out:   SPU status */
@@ -472,7 +482,7 @@ static long spufs_run_ioctl(struct file 
 }
 
 static struct file_operations spufs_run_fops = {
-	.open		= spufs_pipe_open,
+	.open		= spufs_run_open,
 	.unlocked_ioctl	= spufs_run_ioctl,
 	.compat_ioctl	= spufs_run_ioctl,
 	.read		= spufs_run_read,
fs/spufs/spufs.h +2 -0
@@ -46,6 +46,8 @@ struct spu_context {
 
 struct spufs_inode_info {
 	struct spu_context *i_ctx;
+	long (*i_spu_run)(struct file *filp, struct spu_context *ctx,
+		u32 *npc, u32 *result);
 	struct inode vfs_inode;
 };
 #define SPUFS_I(inode) \
fs/spufs/spurun.c +96 -0

96 lines not on this page · raw message

include/asm-ppc/unistd.h +2 -1
@@ -282,8 +282,9 @@
 #define __NR_inotify_init	275
 #define __NR_inotify_add_watch	276
 #define __NR_inotify_rm_watch	277
+#define __NR_spu_run		278
 
-#define __NR_syscalls		278
+#define __NR_syscalls		279
 
 #define __NR(n)	#n
 
include/asm-ppc64/unistd.h +2 -1
@@ -288,8 +288,9 @@
 #define __NR_inotify_init	275
 #define __NR_inotify_add_watch	276
 #define __NR_inotify_rm_watch	277
+#define __NR_spu_run		278
+#define __NR_syscalls		279
 
-#define __NR_syscalls		278
 #ifdef __KERNEL__
 #define NR_syscalls	__NR_syscalls
 #endif
include/linux/syscalls.h +3 -0
@@ -509,4 +509,7 @@ asmlinkage long sys_keyctl(int cmd, unsi
 asmlinkage long sys_ioprio_set(int which, int who, int ioprio);
 asmlinkage long sys_ioprio_get(int which, int who);
 
+asmlinkage long sys_spu_run(int fd, __u32 __user *unpc,
+				 __u32 __user *ustatus);
+
 #endif
kernel/sys_ni.c +1 -0
@@ -90,3 +90,4 @@ cond_syscall(sys_pciconfig_iobase);
 cond_syscall(sys32_ipc);
 cond_syscall(sys32_sysctl);
 cond_syscall(ppc_rtas);
+cond_syscall(sys_spu_run);