aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorMichael Ellerman <michael@ellerman.id.au>2007-09-19 00:38:12 -0400
committerPaul Mackerras <paulus@samba.org>2007-09-19 01:12:19 -0400
commit48cad41f7ee7b8a9a8317a4abbdaf09bc68b4773 (patch)
tree9e31facfe272abed3aa34be36c7e5a70b7da095a /arch/powerpc
parent78810ff6723f20015373b1ba8dd981f24c62f680 (diff)
[POWERPC] spufs: Combine spufs_coredump_calls with spufs_calls
Because spufs might be built as a module, we can't have other parts of the kernel calling directly into it, we need stub routines that check first if the module is loaded. Currently we have two structures which hold callbacks for these stubs, the syscalls are in spufs_calls and the coredump calls are in spufs_coredump_calls. In both cases the logic for registering/unregistering is essentially the same, so we can simplify things by combining the two. Signed-off-by: Michael Ellerman <michael@ellerman.id.au> Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Acked-by: Arnd Bergmann <arnd.bergmann@de.ibm.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/platforms/cell/Makefile2
-rw-r--r--arch/powerpc/platforms/cell/spu_coredump.c83
-rw-r--r--arch/powerpc/platforms/cell/spu_syscalls.c30
-rw-r--r--arch/powerpc/platforms/cell/spufs/coredump.c10
-rw-r--r--arch/powerpc/platforms/cell/spufs/inode.c6
-rw-r--r--arch/powerpc/platforms/cell/spufs/spufs.h4
-rw-r--r--arch/powerpc/platforms/cell/spufs/syscalls.c2
7 files changed, 39 insertions, 98 deletions
diff --git a/arch/powerpc/platforms/cell/Makefile b/arch/powerpc/platforms/cell/Makefile
index 40f78e908953..61d12f183036 100644
--- a/arch/powerpc/platforms/cell/Makefile
+++ b/arch/powerpc/platforms/cell/Makefile
@@ -19,7 +19,7 @@ spu-manage-$(CONFIG_PPC_CELLEB) += spu_manage.o
19spu-manage-$(CONFIG_PPC_CELL_NATIVE) += spu_manage.o 19spu-manage-$(CONFIG_PPC_CELL_NATIVE) += spu_manage.o
20 20
21obj-$(CONFIG_SPU_BASE) += spu_callbacks.o spu_base.o \ 21obj-$(CONFIG_SPU_BASE) += spu_callbacks.o spu_base.o \
22 spu_coredump.o spu_syscalls.o \ 22 spu_syscalls.o \
23 $(spu-priv1-y) \ 23 $(spu-priv1-y) \
24 $(spu-manage-y) \ 24 $(spu-manage-y) \
25 spufs/ 25 spufs/
diff --git a/arch/powerpc/platforms/cell/spu_coredump.c b/arch/powerpc/platforms/cell/spu_coredump.c
deleted file mode 100644
index 656a8c52cd38..000000000000
--- a/arch/powerpc/platforms/cell/spu_coredump.c
+++ /dev/null
@@ -1,83 +0,0 @@
1/*
2 * SPU core dump code
3 *
4 * (C) Copyright 2006 IBM Corp.
5 *
6 * Author: Dwayne Grant McConnell <decimal@us.ibm.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#include <linux/file.h>
24#include <linux/module.h>
25#include <linux/syscalls.h>
26
27#include <asm/spu.h>
28
29static struct spu_coredump_calls *spu_coredump_calls;
30static DEFINE_MUTEX(spu_coredump_mutex);
31
32int arch_notes_size(void)
33{
34 int ret;
35
36 mutex_lock(&spu_coredump_mutex);
37
38 if (spu_coredump_calls && try_module_get(spu_coredump_calls->owner)) {
39 ret = spu_coredump_calls->arch_notes_size();
40 module_put(spu_coredump_calls->owner);
41 } else {
42 ret = 0;
43 }
44
45 mutex_unlock(&spu_coredump_mutex);
46
47 return ret;
48}
49
50void arch_write_notes(struct file *file)
51{
52 mutex_lock(&spu_coredump_mutex);
53 if (spu_coredump_calls && try_module_get(spu_coredump_calls->owner)) {
54 spu_coredump_calls->arch_write_notes(file);
55 module_put(spu_coredump_calls->owner);
56 }
57 mutex_unlock(&spu_coredump_mutex);
58}
59
60int register_arch_coredump_calls(struct spu_coredump_calls *calls)
61{
62 int ret = 0;
63
64
65 mutex_lock(&spu_coredump_mutex);
66 if (spu_coredump_calls)
67 ret = -EBUSY;
68 else
69 spu_coredump_calls = calls;
70 mutex_unlock(&spu_coredump_mutex);
71 return ret;
72}
73EXPORT_SYMBOL_GPL(register_arch_coredump_calls);
74
75void unregister_arch_coredump_calls(struct spu_coredump_calls *calls)
76{
77 BUG_ON(spu_coredump_calls != calls);
78
79 mutex_lock(&spu_coredump_mutex);
80 spu_coredump_calls = NULL;
81 mutex_unlock(&spu_coredump_mutex);
82}
83EXPORT_SYMBOL_GPL(unregister_arch_coredump_calls);
diff --git a/arch/powerpc/platforms/cell/spu_syscalls.c b/arch/powerpc/platforms/cell/spu_syscalls.c
index c0238dd9ff27..05841cdef4e1 100644
--- a/arch/powerpc/platforms/cell/spu_syscalls.c
+++ b/arch/powerpc/platforms/cell/spu_syscalls.c
@@ -2,6 +2,7 @@
2 * SPU file system -- system call stubs 2 * SPU file system -- system call stubs
3 * 3 *
4 * (C) Copyright IBM Deutschland Entwicklung GmbH 2005 4 * (C) Copyright IBM Deutschland Entwicklung GmbH 2005
5 * (C) Copyright 2006-2007, IBM Corporation
5 * 6 *
6 * Author: Arnd Bergmann <arndb@de.ibm.com> 7 * Author: Arnd Bergmann <arndb@de.ibm.com>
7 * 8 *
@@ -111,6 +112,35 @@ asmlinkage long sys_spu_run(int fd, __u32 __user *unpc, __u32 __user *ustatus)
111 return ret; 112 return ret;
112} 113}
113 114
115int arch_notes_size(void)
116{
117 struct spufs_calls *calls;
118 int ret;
119
120 calls = spufs_calls_get();
121 if (!calls)
122 return 0;
123
124 ret = calls->coredump_extra_notes_size();
125
126 spufs_calls_put(calls);
127
128 return ret;
129}
130
131void arch_write_notes(struct file *file)
132{
133 struct spufs_calls *calls;
134
135 calls = spufs_calls_get();
136 if (!calls)
137 return;
138
139 calls->coredump_extra_notes_write(file);
140
141 spufs_calls_put(calls);
142}
143
114int register_spu_syscalls(struct spufs_calls *calls) 144int register_spu_syscalls(struct spufs_calls *calls)
115{ 145{
116 if (spufs_calls) 146 if (spufs_calls)
diff --git a/arch/powerpc/platforms/cell/spufs/coredump.c b/arch/powerpc/platforms/cell/spufs/coredump.c
index fc988fd1ffb6..6c20e44dba63 100644
--- a/arch/powerpc/platforms/cell/spufs/coredump.c
+++ b/arch/powerpc/platforms/cell/spufs/coredump.c
@@ -122,7 +122,7 @@ static struct spu_context *coredump_next_context(int *fd)
122 return ctx; 122 return ctx;
123} 123}
124 124
125static int spufs_arch_notes_size(void) 125int spufs_coredump_extra_notes_size(void)
126{ 126{
127 struct spu_context *ctx; 127 struct spu_context *ctx;
128 int size = 0, rc, fd; 128 int size = 0, rc, fd;
@@ -185,7 +185,7 @@ out:
185 free_page((unsigned long)buf); 185 free_page((unsigned long)buf);
186} 186}
187 187
188static void spufs_arch_write_notes(struct file *file) 188void spufs_coredump_extra_notes_write(struct file *file)
189{ 189{
190 struct spu_context *ctx; 190 struct spu_context *ctx;
191 int fd, j; 191 int fd, j;
@@ -200,9 +200,3 @@ static void spufs_arch_write_notes(struct file *file)
200 spu_release_saved(ctx); 200 spu_release_saved(ctx);
201 } 201 }
202} 202}
203
204struct spu_coredump_calls spufs_coredump_calls = {
205 .arch_notes_size = spufs_arch_notes_size,
206 .arch_write_notes = spufs_arch_write_notes,
207 .owner = THIS_MODULE,
208};
diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
index e210a4b259fb..11098747d09b 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -790,16 +790,11 @@ static int __init spufs_init(void)
790 ret = register_spu_syscalls(&spufs_calls); 790 ret = register_spu_syscalls(&spufs_calls);
791 if (ret) 791 if (ret)
792 goto out_fs; 792 goto out_fs;
793 ret = register_arch_coredump_calls(&spufs_coredump_calls);
794 if (ret)
795 goto out_syscalls;
796 793
797 spufs_init_isolated_loader(); 794 spufs_init_isolated_loader();
798 795
799 return 0; 796 return 0;
800 797
801out_syscalls:
802 unregister_spu_syscalls(&spufs_calls);
803out_fs: 798out_fs:
804 unregister_filesystem(&spufs_type); 799 unregister_filesystem(&spufs_type);
805out_sched: 800out_sched:
@@ -815,7 +810,6 @@ static void __exit spufs_exit(void)
815{ 810{
816 spu_sched_exit(); 811 spu_sched_exit();
817 spufs_exit_isolated_loader(); 812 spufs_exit_isolated_loader();
818 unregister_arch_coredump_calls(&spufs_coredump_calls);
819 unregister_spu_syscalls(&spufs_calls); 813 unregister_spu_syscalls(&spufs_calls);
820 unregister_filesystem(&spufs_type); 814 unregister_filesystem(&spufs_type);
821 kmem_cache_destroy(spufs_inode_cache); 815 kmem_cache_destroy(spufs_inode_cache);
diff --git a/arch/powerpc/platforms/cell/spufs/spufs.h b/arch/powerpc/platforms/cell/spufs/spufs.h
index f869a4b488b0..c7b4e035de48 100644
--- a/arch/powerpc/platforms/cell/spufs/spufs.h
+++ b/arch/powerpc/platforms/cell/spufs/spufs.h
@@ -204,6 +204,10 @@ extern struct spufs_calls spufs_calls;
204long spufs_run_spu(struct spu_context *ctx, u32 *npc, u32 *status); 204long spufs_run_spu(struct spu_context *ctx, u32 *npc, u32 *status);
205long spufs_create(struct nameidata *nd, unsigned int flags, 205long spufs_create(struct nameidata *nd, unsigned int flags,
206 mode_t mode, struct file *filp); 206 mode_t mode, struct file *filp);
207/* ELF coredump callbacks for writing SPU ELF notes */
208extern int spufs_coredump_extra_notes_size(void);
209extern void spufs_coredump_extra_notes_write(struct file *file);
210
207extern const struct file_operations spufs_context_fops; 211extern const struct file_operations spufs_context_fops;
208 212
209/* gang management */ 213/* gang management */
diff --git a/arch/powerpc/platforms/cell/spufs/syscalls.c b/arch/powerpc/platforms/cell/spufs/syscalls.c
index 22b138dc335c..2c34f7170190 100644
--- a/arch/powerpc/platforms/cell/spufs/syscalls.c
+++ b/arch/powerpc/platforms/cell/spufs/syscalls.c
@@ -84,5 +84,7 @@ static long do_spu_create(const char __user *pathname, unsigned int flags,
84struct spufs_calls spufs_calls = { 84struct spufs_calls spufs_calls = {
85 .create_thread = do_spu_create, 85 .create_thread = do_spu_create,
86 .spu_run = do_spu_run, 86 .spu_run = do_spu_run,
87 .coredump_extra_notes_size = spufs_coredump_extra_notes_size,
88 .coredump_extra_notes_write = spufs_coredump_extra_notes_write,
87 .owner = THIS_MODULE, 89 .owner = THIS_MODULE,
88}; 90};