aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-12-28 13:37:46 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-12-28 13:37:46 -0500
commit1842c7f260dd24dad2dd8eded80904d7a6c5525f (patch)
treeaff68702c9477c21b26284346ba98feebc91d849
parent29a09a7b138b1708de3d98a92fddcc18268084aa (diff)
parentec5d2dfe72cf4808ae4ecee03454a4d91dfcbe0c (diff)
Merge branch 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc
* 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc: [POWERPC] PS3: Fix printing of os-area magic numbers [POWERPC] Oprofile: Remove dependency on spufs module
-rw-r--r--arch/powerpc/platforms/cell/Kconfig5
-rw-r--r--arch/powerpc/platforms/cell/Makefile1
-rw-r--r--arch/powerpc/platforms/cell/spu_notify.c67
-rw-r--r--arch/powerpc/platforms/cell/spu_syscalls.c14
-rw-r--r--arch/powerpc/platforms/cell/spufs/context.c16
-rw-r--r--arch/powerpc/platforms/cell/spufs/sched.c29
-rw-r--r--arch/powerpc/platforms/cell/spufs/syscalls.c1
-rw-r--r--arch/powerpc/platforms/ps3/os-area.c40
-rw-r--r--include/asm-powerpc/spu.h4
9 files changed, 129 insertions, 48 deletions
diff --git a/arch/powerpc/platforms/cell/Kconfig b/arch/powerpc/platforms/cell/Kconfig
index e1e2f6a43019..3a963b4a9be0 100644
--- a/arch/powerpc/platforms/cell/Kconfig
+++ b/arch/powerpc/platforms/cell/Kconfig
@@ -88,3 +88,8 @@ config CBE_CPUFREQ_PMI
88 but also at lower core voltage. 88 but also at lower core voltage.
89 89
90endmenu 90endmenu
91
92config OPROFILE_CELL
93 def_bool y
94 depends on PPC_CELL_NATIVE && (OPROFILE = m || OPROFILE = y)
95
diff --git a/arch/powerpc/platforms/cell/Makefile b/arch/powerpc/platforms/cell/Makefile
index 61d12f183036..39d695cb9693 100644
--- a/arch/powerpc/platforms/cell/Makefile
+++ b/arch/powerpc/platforms/cell/Makefile
@@ -19,6 +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_notify.o \
22 spu_syscalls.o \ 23 spu_syscalls.o \
23 $(spu-priv1-y) \ 24 $(spu-priv1-y) \
24 $(spu-manage-y) \ 25 $(spu-manage-y) \
diff --git a/arch/powerpc/platforms/cell/spu_notify.c b/arch/powerpc/platforms/cell/spu_notify.c
new file mode 100644
index 000000000000..34d156959f39
--- /dev/null
+++ b/arch/powerpc/platforms/cell/spu_notify.c
@@ -0,0 +1,67 @@
1/*
2 * Move OProfile dependencies from spufs module to the kernel so it
3 * can run on non-cell PPC.
4 *
5 * Copyright (C) IBM 2005
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#undef DEBUG
23
24#include <linux/module.h>
25#include <asm/spu.h>
26#include "spufs/spufs.h"
27
28static BLOCKING_NOTIFIER_HEAD(spu_switch_notifier);
29
30void spu_switch_notify(struct spu *spu, struct spu_context *ctx)
31{
32 blocking_notifier_call_chain(&spu_switch_notifier,
33 ctx ? ctx->object_id : 0, spu);
34}
35EXPORT_SYMBOL_GPL(spu_switch_notify);
36
37int spu_switch_event_register(struct notifier_block *n)
38{
39 int ret;
40 ret = blocking_notifier_chain_register(&spu_switch_notifier, n);
41 if (!ret)
42 notify_spus_active();
43 return ret;
44}
45EXPORT_SYMBOL_GPL(spu_switch_event_register);
46
47int spu_switch_event_unregister(struct notifier_block *n)
48{
49 return blocking_notifier_chain_unregister(&spu_switch_notifier, n);
50}
51EXPORT_SYMBOL_GPL(spu_switch_event_unregister);
52
53void spu_set_profile_private_kref(struct spu_context *ctx,
54 struct kref *prof_info_kref,
55 void (* prof_info_release) (struct kref *kref))
56{
57 ctx->prof_priv_kref = prof_info_kref;
58 ctx->prof_priv_release = prof_info_release;
59}
60EXPORT_SYMBOL_GPL(spu_set_profile_private_kref);
61
62void *spu_get_profile_private_kref(struct spu_context *ctx)
63{
64 return ctx->prof_priv_kref;
65}
66EXPORT_SYMBOL_GPL(spu_get_profile_private_kref);
67
diff --git a/arch/powerpc/platforms/cell/spu_syscalls.c b/arch/powerpc/platforms/cell/spu_syscalls.c
index a9438b719fe8..75530d99eda6 100644
--- a/arch/powerpc/platforms/cell/spu_syscalls.c
+++ b/arch/powerpc/platforms/cell/spu_syscalls.c
@@ -145,6 +145,20 @@ int elf_coredump_extra_notes_write(struct file *file, loff_t *foffset)
145 return ret; 145 return ret;
146} 146}
147 147
148void notify_spus_active(void)
149{
150 struct spufs_calls *calls;
151
152 calls = spufs_calls_get();
153 if (!calls)
154 return;
155
156 calls->notify_spus_active();
157 spufs_calls_put(calls);
158
159 return;
160}
161
148int register_spu_syscalls(struct spufs_calls *calls) 162int register_spu_syscalls(struct spufs_calls *calls)
149{ 163{
150 if (spufs_calls) 164 if (spufs_calls)
diff --git a/arch/powerpc/platforms/cell/spufs/context.c b/arch/powerpc/platforms/cell/spufs/context.c
index 9cb081c26e71..adf0a030d6fe 100644
--- a/arch/powerpc/platforms/cell/spufs/context.c
+++ b/arch/powerpc/platforms/cell/spufs/context.c
@@ -190,19 +190,3 @@ void spu_release_saved(struct spu_context *ctx)
190 spu_release(ctx); 190 spu_release(ctx);
191} 191}
192 192
193void spu_set_profile_private_kref(struct spu_context *ctx,
194 struct kref *prof_info_kref,
195 void ( * prof_info_release) (struct kref *kref))
196{
197 ctx->prof_priv_kref = prof_info_kref;
198 ctx->prof_priv_release = prof_info_release;
199}
200EXPORT_SYMBOL_GPL(spu_set_profile_private_kref);
201
202void *spu_get_profile_private_kref(struct spu_context *ctx)
203{
204 return ctx->prof_priv_kref;
205}
206EXPORT_SYMBOL_GPL(spu_get_profile_private_kref);
207
208
diff --git a/arch/powerpc/platforms/cell/spufs/sched.c b/arch/powerpc/platforms/cell/spufs/sched.c
index 4d257b3f9336..6e2a45e60261 100644
--- a/arch/powerpc/platforms/cell/spufs/sched.c
+++ b/arch/powerpc/platforms/cell/spufs/sched.c
@@ -166,15 +166,7 @@ static int node_allowed(struct spu_context *ctx, int node)
166 return rval; 166 return rval;
167} 167}
168 168
169static BLOCKING_NOTIFIER_HEAD(spu_switch_notifier); 169void do_notify_spus_active(void)
170
171void spu_switch_notify(struct spu *spu, struct spu_context *ctx)
172{
173 blocking_notifier_call_chain(&spu_switch_notifier,
174 ctx ? ctx->object_id : 0, spu);
175}
176
177static void notify_spus_active(void)
178{ 170{
179 int node; 171 int node;
180 172
@@ -200,22 +192,15 @@ static void notify_spus_active(void)
200 mutex_unlock(&cbe_spu_info[node].list_mutex); 192 mutex_unlock(&cbe_spu_info[node].list_mutex);
201 } 193 }
202} 194}
195EXPORT_SYMBOL_GPL(do_notify_spus_active);
203 196
204int spu_switch_event_register(struct notifier_block * n) 197#ifndef MODULE
205{ 198void notify_spus_active(void)
206 int ret;
207 ret = blocking_notifier_chain_register(&spu_switch_notifier, n);
208 if (!ret)
209 notify_spus_active();
210 return ret;
211}
212EXPORT_SYMBOL_GPL(spu_switch_event_register);
213
214int spu_switch_event_unregister(struct notifier_block * n)
215{ 199{
216 return blocking_notifier_chain_unregister(&spu_switch_notifier, n); 200 do_notify_spus_active();
217} 201}
218EXPORT_SYMBOL_GPL(spu_switch_event_unregister); 202EXPORT_SYMBOL_GPL(notify_spus_active);
203#endif
219 204
220/** 205/**
221 * spu_bind_context - bind spu context to physical spu 206 * spu_bind_context - bind spu context to physical spu
diff --git a/arch/powerpc/platforms/cell/spufs/syscalls.c b/arch/powerpc/platforms/cell/spufs/syscalls.c
index 2c34f7170190..430404413178 100644
--- a/arch/powerpc/platforms/cell/spufs/syscalls.c
+++ b/arch/powerpc/platforms/cell/spufs/syscalls.c
@@ -86,5 +86,6 @@ struct spufs_calls spufs_calls = {
86 .spu_run = do_spu_run, 86 .spu_run = do_spu_run,
87 .coredump_extra_notes_size = spufs_coredump_extra_notes_size, 87 .coredump_extra_notes_size = spufs_coredump_extra_notes_size,
88 .coredump_extra_notes_write = spufs_coredump_extra_notes_write, 88 .coredump_extra_notes_write = spufs_coredump_extra_notes_write,
89 .notify_spus_active = do_notify_spus_active,
89 .owner = THIS_MODULE, 90 .owner = THIS_MODULE,
90}; 91};
diff --git a/arch/powerpc/platforms/ps3/os-area.c b/arch/powerpc/platforms/ps3/os-area.c
index 766685ab26f8..b9ea09d9d2fb 100644
--- a/arch/powerpc/platforms/ps3/os-area.c
+++ b/arch/powerpc/platforms/ps3/os-area.c
@@ -23,6 +23,7 @@
23#include <linux/workqueue.h> 23#include <linux/workqueue.h>
24#include <linux/fs.h> 24#include <linux/fs.h>
25#include <linux/syscalls.h> 25#include <linux/syscalls.h>
26#include <linux/ctype.h>
26 27
27#include <asm/lmb.h> 28#include <asm/lmb.h>
28 29
@@ -37,6 +38,8 @@ enum os_area_ldr_format {
37 HEADER_LDR_FORMAT_GZIP = 1, 38 HEADER_LDR_FORMAT_GZIP = 1,
38}; 39};
39 40
41#define OS_AREA_HEADER_MAGIC_NUM "cell_ext_os_area"
42
40/** 43/**
41 * struct os_area_header - os area header segment. 44 * struct os_area_header - os area header segment.
42 * @magic_num: Always 'cell_ext_os_area'. 45 * @magic_num: Always 'cell_ext_os_area'.
@@ -114,13 +117,11 @@ struct os_area_params {
114 u8 _reserved_5[8]; 117 u8 _reserved_5[8];
115}; 118};
116 119
117enum { 120#define OS_AREA_DB_MAGIC_NUM "-db-"
118 OS_AREA_DB_MAGIC_NUM = 0x2d64622dU,
119};
120 121
121/** 122/**
122 * struct os_area_db - Shared flash memory database. 123 * struct os_area_db - Shared flash memory database.
123 * @magic_num: Always '-db-' = 0x2d64622d. 124 * @magic_num: Always '-db-'.
124 * @version: os_area_db format version number. 125 * @version: os_area_db format version number.
125 * @index_64: byte offset of the database id index for 64 bit variables. 126 * @index_64: byte offset of the database id index for 64 bit variables.
126 * @count_64: number of usable 64 bit index entries 127 * @count_64: number of usable 64 bit index entries
@@ -135,7 +136,7 @@ enum {
135 */ 136 */
136 137
137struct os_area_db { 138struct os_area_db {
138 u32 magic_num; 139 u8 magic_num[4];
139 u16 version; 140 u16 version;
140 u16 _reserved_1; 141 u16 _reserved_1;
141 u16 index_64; 142 u16 index_64;
@@ -265,12 +266,26 @@ static void __init os_area_get_property(struct device_node *node,
265 prop->name); 266 prop->name);
266} 267}
267 268
269static void dump_field(char *s, const u8 *field, int size_of_field)
270{
271#if defined(DEBUG)
272 int i;
273
274 for (i = 0; i < size_of_field; i++)
275 s[i] = isprint(field[i]) ? field[i] : '.';
276 s[i] = 0;
277#endif
278}
279
268#define dump_header(_a) _dump_header(_a, __func__, __LINE__) 280#define dump_header(_a) _dump_header(_a, __func__, __LINE__)
269static void _dump_header(const struct os_area_header *h, const char *func, 281static void _dump_header(const struct os_area_header *h, const char *func,
270 int line) 282 int line)
271{ 283{
284 char str[sizeof(h->magic_num) + 1];
285
286 dump_field(str, h->magic_num, sizeof(h->magic_num));
272 pr_debug("%s:%d: h.magic_num: '%s'\n", func, line, 287 pr_debug("%s:%d: h.magic_num: '%s'\n", func, line,
273 h->magic_num); 288 str);
274 pr_debug("%s:%d: h.hdr_version: %u\n", func, line, 289 pr_debug("%s:%d: h.hdr_version: %u\n", func, line,
275 h->hdr_version); 290 h->hdr_version);
276 pr_debug("%s:%d: h.db_area_offset: %u\n", func, line, 291 pr_debug("%s:%d: h.db_area_offset: %u\n", func, line,
@@ -311,7 +326,8 @@ static void _dump_params(const struct os_area_params *p, const char *func,
311 326
312static int verify_header(const struct os_area_header *header) 327static int verify_header(const struct os_area_header *header)
313{ 328{
314 if (memcmp(header->magic_num, "cell_ext_os_area", 16)) { 329 if (memcmp(header->magic_num, OS_AREA_HEADER_MAGIC_NUM,
330 sizeof(header->magic_num))) {
315 pr_debug("%s:%d magic_num failed\n", __func__, __LINE__); 331 pr_debug("%s:%d magic_num failed\n", __func__, __LINE__);
316 return -1; 332 return -1;
317 } 333 }
@@ -331,7 +347,8 @@ static int verify_header(const struct os_area_header *header)
331 347
332static int db_verify(const struct os_area_db *db) 348static int db_verify(const struct os_area_db *db)
333{ 349{
334 if (db->magic_num != OS_AREA_DB_MAGIC_NUM) { 350 if (memcmp(db->magic_num, OS_AREA_DB_MAGIC_NUM,
351 sizeof(db->magic_num))) {
335 pr_debug("%s:%d magic_num failed\n", __func__, __LINE__); 352 pr_debug("%s:%d magic_num failed\n", __func__, __LINE__);
336 return -1; 353 return -1;
337 } 354 }
@@ -484,8 +501,11 @@ static int db_get_rtc_diff(const struct os_area_db *db, int64_t *rtc_diff)
484static void _dump_db(const struct os_area_db *db, const char *func, 501static void _dump_db(const struct os_area_db *db, const char *func,
485 int line) 502 int line)
486{ 503{
504 char str[sizeof(db->magic_num) + 1];
505
506 dump_field(str, db->magic_num, sizeof(db->magic_num));
487 pr_debug("%s:%d: db.magic_num: '%s'\n", func, line, 507 pr_debug("%s:%d: db.magic_num: '%s'\n", func, line,
488 (const char*)&db->magic_num); 508 str);
489 pr_debug("%s:%d: db.version: %u\n", func, line, 509 pr_debug("%s:%d: db.version: %u\n", func, line,
490 db->version); 510 db->version);
491 pr_debug("%s:%d: db.index_64: %u\n", func, line, 511 pr_debug("%s:%d: db.index_64: %u\n", func, line,
@@ -516,7 +536,7 @@ static void os_area_db_init(struct os_area_db *db)
516 536
517 memset(db, 0, sizeof(struct os_area_db)); 537 memset(db, 0, sizeof(struct os_area_db));
518 538
519 db->magic_num = OS_AREA_DB_MAGIC_NUM; 539 memcpy(db->magic_num, OS_AREA_DB_MAGIC_NUM, sizeof(db->magic_num));
520 db->version = 1; 540 db->version = 1;
521 db->index_64 = HEADER_SIZE; 541 db->index_64 = HEADER_SIZE;
522 db->count_64 = VALUES_64_COUNT; 542 db->count_64 = VALUES_64_COUNT;
diff --git a/include/asm-powerpc/spu.h b/include/asm-powerpc/spu.h
index b1accce77bb5..34b7807f068b 100644
--- a/include/asm-powerpc/spu.h
+++ b/include/asm-powerpc/spu.h
@@ -246,6 +246,7 @@ struct spufs_calls {
246 __u32 __user *ustatus); 246 __u32 __user *ustatus);
247 int (*coredump_extra_notes_size)(void); 247 int (*coredump_extra_notes_size)(void);
248 int (*coredump_extra_notes_write)(struct file *file, loff_t *foffset); 248 int (*coredump_extra_notes_write)(struct file *file, loff_t *foffset);
249 void (*notify_spus_active)(void);
249 struct module *owner; 250 struct module *owner;
250}; 251};
251 252
@@ -298,6 +299,9 @@ struct notifier_block;
298int spu_switch_event_register(struct notifier_block * n); 299int spu_switch_event_register(struct notifier_block * n);
299int spu_switch_event_unregister(struct notifier_block * n); 300int spu_switch_event_unregister(struct notifier_block * n);
300 301
302extern void notify_spus_active(void);
303extern void do_notify_spus_active(void);
304
301/* 305/*
302 * This defines the Local Store, Problem Area and Privlege Area of an SPU. 306 * This defines the Local Store, Problem Area and Privlege Area of an SPU.
303 */ 307 */