diff options
author | Mark Nutter <mnutter@us.ibm.com> | 2005-11-15 15:53:49 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2006-01-08 22:49:16 -0500 |
commit | 5473af049d8b3556874174e61ce1986c9b5e8fa6 (patch) | |
tree | 53da74c13eb9125b85e85f9fc44981d3d1b41b49 /arch | |
parent | 67207b9664a8d603138ef1556141e6d0a102bea7 (diff) |
[PATCH] spufs: switchable spu contexts
Add some infrastructure for saving and restoring the context of an
SPE. This patch creates a new structure that can hold the whole
state of a physical SPE in memory. It also contains code that
avoids races during the context switch and the binary code that
is loaded to the SPU in order to access its registers.
The actual PPE- and SPE-side context switch code are two separate
patches.
Signed-off-by: Arnd Bergmann <arndb@de.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/platforms/cell/spu_base.c | 27 | ||||
-rw-r--r-- | arch/powerpc/platforms/cell/spufs/Makefile | 4 | ||||
-rw-r--r-- | arch/powerpc/platforms/cell/spufs/context.c | 18 | ||||
-rw-r--r-- | arch/powerpc/platforms/cell/spufs/spu_restore_dump.h_shipped | 231 | ||||
-rw-r--r-- | arch/powerpc/platforms/cell/spufs/spu_save_dump.h_shipped | 191 | ||||
-rw-r--r-- | arch/powerpc/platforms/cell/spufs/spufs.h | 2 | ||||
-rw-r--r-- | arch/powerpc/platforms/cell/spufs/switch.c | 174 |
7 files changed, 643 insertions, 4 deletions
diff --git a/arch/powerpc/platforms/cell/spu_base.c b/arch/powerpc/platforms/cell/spu_base.c index 9e9096590a07..44492d87cdf7 100644 --- a/arch/powerpc/platforms/cell/spu_base.c +++ b/arch/powerpc/platforms/cell/spu_base.c | |||
@@ -62,7 +62,9 @@ static int __spu_trap_error(struct spu *spu) | |||
62 | static void spu_restart_dma(struct spu *spu) | 62 | static void spu_restart_dma(struct spu *spu) |
63 | { | 63 | { |
64 | struct spu_priv2 __iomem *priv2 = spu->priv2; | 64 | struct spu_priv2 __iomem *priv2 = spu->priv2; |
65 | out_be64(&priv2->mfc_control_RW, MFC_CNTL_RESTART_DMA_COMMAND); | 65 | |
66 | if (!test_bit(SPU_CONTEXT_SWITCH_PENDING_nr, &spu->flags)) | ||
67 | out_be64(&priv2->mfc_control_RW, MFC_CNTL_RESTART_DMA_COMMAND); | ||
66 | } | 68 | } |
67 | 69 | ||
68 | static int __spu_trap_data_seg(struct spu *spu, unsigned long ea) | 70 | static int __spu_trap_data_seg(struct spu *spu, unsigned long ea) |
@@ -72,6 +74,11 @@ static int __spu_trap_data_seg(struct spu *spu, unsigned long ea) | |||
72 | 74 | ||
73 | pr_debug("%s\n", __FUNCTION__); | 75 | pr_debug("%s\n", __FUNCTION__); |
74 | 76 | ||
77 | if (test_bit(SPU_CONTEXT_SWITCH_ACTIVE_nr, &spu->flags)) { | ||
78 | printk("%s: invalid access during switch!\n", __func__); | ||
79 | return 1; | ||
80 | } | ||
81 | |||
75 | if (REGION_ID(ea) != USER_REGION_ID) { | 82 | if (REGION_ID(ea) != USER_REGION_ID) { |
76 | pr_debug("invalid region access at %016lx\n", ea); | 83 | pr_debug("invalid region access at %016lx\n", ea); |
77 | return 1; | 84 | return 1; |
@@ -98,6 +105,7 @@ static int __spu_trap_data_seg(struct spu *spu, unsigned long ea) | |||
98 | return 0; | 105 | return 0; |
99 | } | 106 | } |
100 | 107 | ||
108 | extern int hash_page(unsigned long ea, unsigned long access, unsigned long trap); //XXX | ||
101 | static int __spu_trap_data_map(struct spu *spu, unsigned long ea) | 109 | static int __spu_trap_data_map(struct spu *spu, unsigned long ea) |
102 | { | 110 | { |
103 | unsigned long dsisr; | 111 | unsigned long dsisr; |
@@ -107,8 +115,21 @@ static int __spu_trap_data_map(struct spu *spu, unsigned long ea) | |||
107 | priv1 = spu->priv1; | 115 | priv1 = spu->priv1; |
108 | dsisr = in_be64(&priv1->mfc_dsisr_RW); | 116 | dsisr = in_be64(&priv1->mfc_dsisr_RW); |
109 | 117 | ||
110 | wake_up(&spu->stop_wq); | 118 | /* Handle kernel space hash faults immediately. |
119 | User hash faults need to be deferred to process context. */ | ||
120 | if ((dsisr & MFC_DSISR_PTE_NOT_FOUND) | ||
121 | && REGION_ID(ea) != USER_REGION_ID | ||
122 | && hash_page(ea, _PAGE_PRESENT, 0x300) == 0) { | ||
123 | spu_restart_dma(spu); | ||
124 | return 0; | ||
125 | } | ||
126 | |||
127 | if (test_bit(SPU_CONTEXT_SWITCH_ACTIVE_nr, &spu->flags)) { | ||
128 | printk("%s: invalid access during switch!\n", __func__); | ||
129 | return 1; | ||
130 | } | ||
111 | 131 | ||
132 | wake_up(&spu->stop_wq); | ||
112 | return 0; | 133 | return 0; |
113 | } | 134 | } |
114 | 135 | ||
@@ -382,7 +403,6 @@ void spu_free(struct spu *spu) | |||
382 | } | 403 | } |
383 | EXPORT_SYMBOL(spu_free); | 404 | EXPORT_SYMBOL(spu_free); |
384 | 405 | ||
385 | extern int hash_page(unsigned long ea, unsigned long access, unsigned long trap); //XXX | ||
386 | static int spu_handle_mm_fault(struct spu *spu) | 406 | static int spu_handle_mm_fault(struct spu *spu) |
387 | { | 407 | { |
388 | struct spu_priv1 __iomem *priv1; | 408 | struct spu_priv1 __iomem *priv1; |
@@ -650,6 +670,7 @@ static int __init create_spu(struct device_node *spe) | |||
650 | spu->slb_replace = 0; | 670 | spu->slb_replace = 0; |
651 | spu->mm = NULL; | 671 | spu->mm = NULL; |
652 | spu->class_0_pending = 0; | 672 | spu->class_0_pending = 0; |
673 | spu->flags = 0UL; | ||
653 | spin_lock_init(&spu->register_lock); | 674 | spin_lock_init(&spu->register_lock); |
654 | 675 | ||
655 | out_be64(&spu->priv1->mfc_sdr_RW, mfspr(SPRN_SDR1)); | 676 | out_be64(&spu->priv1->mfc_sdr_RW, mfspr(SPRN_SDR1)); |
diff --git a/arch/powerpc/platforms/cell/spufs/Makefile b/arch/powerpc/platforms/cell/spufs/Makefile index 6f496e37bcb7..e70e3cc1158f 100644 --- a/arch/powerpc/platforms/cell/spufs/Makefile +++ b/arch/powerpc/platforms/cell/spufs/Makefile | |||
@@ -1,3 +1,5 @@ | |||
1 | obj-$(CONFIG_SPU_FS) += spufs.o | 1 | obj-$(CONFIG_SPU_FS) += spufs.o |
2 | 2 | ||
3 | spufs-y += inode.o file.o context.o syscalls.o | 3 | spufs-y += inode.o file.o context.o switch.o syscalls.o |
4 | |||
5 | $(obj)/switch.o: $(obj)/spu_save_dump.h $(obj)/spu_restore_dump.h | ||
diff --git a/arch/powerpc/platforms/cell/spufs/context.c b/arch/powerpc/platforms/cell/spufs/context.c index a69b85e2778a..41eea4576b6d 100644 --- a/arch/powerpc/platforms/cell/spufs/context.c +++ b/arch/powerpc/platforms/cell/spufs/context.c | |||
@@ -22,6 +22,7 @@ | |||
22 | 22 | ||
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | #include <asm/spu.h> | 24 | #include <asm/spu.h> |
25 | #include <asm/spu_csa.h> | ||
25 | #include "spufs.h" | 26 | #include "spufs.h" |
26 | 27 | ||
27 | struct spu_context *alloc_spu_context(void) | 28 | struct spu_context *alloc_spu_context(void) |
@@ -30,9 +31,25 @@ struct spu_context *alloc_spu_context(void) | |||
30 | ctx = kmalloc(sizeof *ctx, GFP_KERNEL); | 31 | ctx = kmalloc(sizeof *ctx, GFP_KERNEL); |
31 | if (!ctx) | 32 | if (!ctx) |
32 | goto out; | 33 | goto out; |
34 | /* Future enhancement: do not call spu_alloc() | ||
35 | * here. This step should be deferred until | ||
36 | * spu_run()!! | ||
37 | * | ||
38 | * More work needs to be done to read(), | ||
39 | * write(), mmap(), etc., so that operations | ||
40 | * are performed on CSA when the context is | ||
41 | * not currently being run. In this way we | ||
42 | * can support arbitrarily large number of | ||
43 | * entries in /spu, allow state queries, etc. | ||
44 | */ | ||
33 | ctx->spu = spu_alloc(); | 45 | ctx->spu = spu_alloc(); |
34 | if (!ctx->spu) | 46 | if (!ctx->spu) |
35 | goto out_free; | 47 | goto out_free; |
48 | spu_init_csa(&ctx->csa); | ||
49 | if (!ctx->csa.lscsa) { | ||
50 | spu_free(ctx->spu); | ||
51 | goto out_free; | ||
52 | } | ||
36 | init_rwsem(&ctx->backing_sema); | 53 | init_rwsem(&ctx->backing_sema); |
37 | spin_lock_init(&ctx->mmio_lock); | 54 | spin_lock_init(&ctx->mmio_lock); |
38 | kref_init(&ctx->kref); | 55 | kref_init(&ctx->kref); |
@@ -50,6 +67,7 @@ void destroy_spu_context(struct kref *kref) | |||
50 | ctx = container_of(kref, struct spu_context, kref); | 67 | ctx = container_of(kref, struct spu_context, kref); |
51 | if (ctx->spu) | 68 | if (ctx->spu) |
52 | spu_free(ctx->spu); | 69 | spu_free(ctx->spu); |
70 | spu_fini_csa(&ctx->csa); | ||
53 | kfree(ctx); | 71 | kfree(ctx); |
54 | } | 72 | } |
55 | 73 | ||
diff --git a/arch/powerpc/platforms/cell/spufs/spu_restore_dump.h_shipped b/arch/powerpc/platforms/cell/spufs/spu_restore_dump.h_shipped new file mode 100644 index 000000000000..1b2355ff7036 --- /dev/null +++ b/arch/powerpc/platforms/cell/spufs/spu_restore_dump.h_shipped | |||
@@ -0,0 +1,231 @@ | |||
1 | /* | ||
2 | * spu_restore_dump.h: Copyright (C) 2005 IBM. | ||
3 | * Hex-dump auto generated from spu_restore.c. | ||
4 | * Do not edit! | ||
5 | */ | ||
6 | static unsigned int spu_restore_code[] __page_aligned = { | ||
7 | 0x40800000, 0x409ff801, 0x24000080, 0x24fd8081, | ||
8 | 0x1cd80081, 0x33001180, 0x42030003, 0x33800284, | ||
9 | 0x1c010204, 0x40200000, 0x40200000, 0x40200000, | ||
10 | 0x34000190, 0x34004191, 0x34008192, 0x3400c193, | ||
11 | 0x141fc205, 0x23fffd84, 0x1c100183, 0x217ffa85, | ||
12 | 0x3080a000, 0x3080a201, 0x3080a402, 0x3080a603, | ||
13 | 0x3080a804, 0x3080aa05, 0x3080ac06, 0x3080ae07, | ||
14 | 0x3080b008, 0x3080b209, 0x3080b40a, 0x3080b60b, | ||
15 | 0x3080b80c, 0x3080ba0d, 0x3080bc0e, 0x3080be0f, | ||
16 | 0x00003ffc, 0x00000000, 0x00000000, 0x00000000, | ||
17 | 0x01a00182, 0x3ec00083, 0xb0a14103, 0x01a00204, | ||
18 | 0x3ec10082, 0x4202800e, 0x04000703, 0xb0a14202, | ||
19 | 0x21a00803, 0x3fbf028d, 0x3f20068d, 0x3fbe0682, | ||
20 | 0x3fe30102, 0x21a00882, 0x3f82028f, 0x3fe3078f, | ||
21 | 0x3fbf0784, 0x3f200204, 0x3fbe0204, 0x3fe30204, | ||
22 | 0x04000203, 0x21a00903, 0x40848002, 0x21a00982, | ||
23 | 0x40800003, 0x21a00a03, 0x40802002, 0x21a00a82, | ||
24 | 0x21a00083, 0x40800082, 0x21a00b02, 0x10002818, | ||
25 | 0x40a80002, 0x32800007, 0x4207000c, 0x18008208, | ||
26 | 0x40a0000b, 0x4080020a, 0x40800709, 0x00200000, | ||
27 | 0x42070002, 0x3ac30384, 0x1cffc489, 0x00200000, | ||
28 | 0x18008383, 0x38830382, 0x4cffc486, 0x3ac28185, | ||
29 | 0xb0408584, 0x28830382, 0x1c020387, 0x38828182, | ||
30 | 0xb0408405, 0x1802c408, 0x28828182, 0x217ff886, | ||
31 | 0x04000583, 0x21a00803, 0x3fbe0682, 0x3fe30102, | ||
32 | 0x04000106, 0x21a00886, 0x04000603, 0x21a00903, | ||
33 | 0x40803c02, 0x21a00982, 0x40800003, 0x04000184, | ||
34 | 0x21a00a04, 0x40802202, 0x21a00a82, 0x42028005, | ||
35 | 0x34208702, 0x21002282, 0x21a00804, 0x21a00886, | ||
36 | 0x3fbf0782, 0x3f200102, 0x3fbe0102, 0x3fe30102, | ||
37 | 0x21a00902, 0x40804003, 0x21a00983, 0x21a00a04, | ||
38 | 0x40805a02, 0x21a00a82, 0x40800083, 0x21a00b83, | ||
39 | 0x01a00c02, 0x01a00d83, 0x3420c282, 0x21a00e02, | ||
40 | 0x34210283, 0x21a00f03, 0x34200284, 0x77400200, | ||
41 | 0x3421c282, 0x21a00702, 0x34218283, 0x21a00083, | ||
42 | 0x34214282, 0x21a00b02, 0x4200480c, 0x00200000, | ||
43 | 0x1c010286, 0x34220284, 0x34220302, 0x0f608203, | ||
44 | 0x5c024204, 0x3b81810b, 0x42013c02, 0x00200000, | ||
45 | 0x18008185, 0x38808183, 0x3b814182, 0x21004e84, | ||
46 | 0x4020007f, 0x35000100, 0x000004e0, 0x000002a0, | ||
47 | 0x000002e8, 0x00000428, 0x00000360, 0x000002e8, | ||
48 | 0x000004a0, 0x00000468, 0x000003c8, 0x00000360, | ||
49 | 0x409ffe02, 0x30801203, 0x40800204, 0x3ec40085, | ||
50 | 0x10009c09, 0x3ac10606, 0xb060c105, 0x4020007f, | ||
51 | 0x4020007f, 0x20801203, 0x38810602, 0xb0408586, | ||
52 | 0x28810602, 0x32004180, 0x34204702, 0x21a00382, | ||
53 | 0x4020007f, 0x327fdc80, 0x409ffe02, 0x30801203, | ||
54 | 0x40800204, 0x3ec40087, 0x40800405, 0x00200000, | ||
55 | 0x40800606, 0x3ac10608, 0x3ac14609, 0x3ac1860a, | ||
56 | 0xb060c107, 0x20801203, 0x41004003, 0x38810602, | ||
57 | 0x4020007f, 0xb0408188, 0x4020007f, 0x28810602, | ||
58 | 0x41201002, 0x38814603, 0x10009c09, 0xb060c109, | ||
59 | 0x4020007f, 0x28814603, 0x41193f83, 0x38818602, | ||
60 | 0x60ffc003, 0xb040818a, 0x28818602, 0x32003080, | ||
61 | 0x409ffe02, 0x30801203, 0x40800204, 0x3ec40087, | ||
62 | 0x41201008, 0x10009c14, 0x40800405, 0x3ac10609, | ||
63 | 0x40800606, 0x3ac1460a, 0xb060c107, 0x3ac1860b, | ||
64 | 0x20801203, 0x38810602, 0xb0408409, 0x28810602, | ||
65 | 0x38814603, 0xb060c40a, 0x4020007f, 0x28814603, | ||
66 | 0x41193f83, 0x38818602, 0x60ffc003, 0xb040818b, | ||
67 | 0x28818602, 0x32002380, 0x409ffe02, 0x30801204, | ||
68 | 0x40800205, 0x3ec40083, 0x40800406, 0x3ac14607, | ||
69 | 0x3ac18608, 0xb0810103, 0x41004002, 0x20801204, | ||
70 | 0x4020007f, 0x38814603, 0x10009c0b, 0xb060c107, | ||
71 | 0x4020007f, 0x4020007f, 0x28814603, 0x38818602, | ||
72 | 0x4020007f, 0x4020007f, 0xb0408588, 0x28818602, | ||
73 | 0x4020007f, 0x32001780, 0x409ffe02, 0x1000640e, | ||
74 | 0x40800204, 0x30801203, 0x40800405, 0x3ec40087, | ||
75 | 0x40800606, 0x3ac10608, 0x3ac14609, 0x3ac1860a, | ||
76 | 0xb060c107, 0x20801203, 0x413d8003, 0x38810602, | ||
77 | 0x4020007f, 0x327fd780, 0x409ffe02, 0x10007f0c, | ||
78 | 0x40800205, 0x30801204, 0x40800406, 0x3ec40083, | ||
79 | 0x3ac14607, 0x3ac18608, 0xb0810103, 0x413d8002, | ||
80 | 0x20801204, 0x38814603, 0x4020007f, 0x327feb80, | ||
81 | 0x409ffe02, 0x30801203, 0x40800204, 0x3ec40087, | ||
82 | 0x40800405, 0x1000650a, 0x40800606, 0x3ac10608, | ||
83 | 0x3ac14609, 0x3ac1860a, 0xb060c107, 0x20801203, | ||
84 | 0x38810602, 0xb0408588, 0x4020007f, 0x327fc980, | ||
85 | 0x00400000, 0x40800003, 0x4020007f, 0x35000000, | ||
86 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
87 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
88 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
89 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
90 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
91 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
92 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
93 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
94 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
95 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
96 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
97 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
98 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
99 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
100 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
101 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
102 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
103 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
104 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
105 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
106 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
107 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
108 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
109 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
110 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
111 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
112 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
113 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
114 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
115 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
116 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
117 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
118 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
119 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
120 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
121 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
122 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
123 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
124 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
125 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
126 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
127 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
128 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
129 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
130 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
131 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
132 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
133 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
134 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
135 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
136 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
137 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
138 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
139 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
140 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
141 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
142 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
143 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
144 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
145 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
146 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
147 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
148 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
149 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
150 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
151 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
152 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
153 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
154 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
155 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
156 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
157 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
158 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
159 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
160 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
161 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
162 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
163 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
164 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
165 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
166 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
167 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
168 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
169 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
170 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
171 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
172 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
173 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
174 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
175 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
176 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
177 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
178 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
179 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
180 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
181 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
182 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
183 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
184 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
185 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
186 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
187 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
188 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
189 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
190 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
191 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
192 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
193 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
194 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
195 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
196 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
197 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
198 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
199 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
200 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
201 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
202 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
203 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
204 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
205 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
206 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
207 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
208 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
209 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
210 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
211 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
212 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
213 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
214 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
215 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
216 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
217 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
218 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
219 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
220 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
221 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
222 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
223 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
224 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
225 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
226 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
227 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
228 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
229 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
230 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
231 | }; | ||
diff --git a/arch/powerpc/platforms/cell/spufs/spu_save_dump.h_shipped b/arch/powerpc/platforms/cell/spufs/spu_save_dump.h_shipped new file mode 100644 index 000000000000..39e54003f1df --- /dev/null +++ b/arch/powerpc/platforms/cell/spufs/spu_save_dump.h_shipped | |||
@@ -0,0 +1,191 @@ | |||
1 | /* | ||
2 | * spu_save_dump.h: Copyright (C) 2005 IBM. | ||
3 | * Hex-dump auto generated from spu_save.c. | ||
4 | * Do not edit! | ||
5 | */ | ||
6 | static unsigned int spu_save_code[] __page_aligned = { | ||
7 | 0x20805000, 0x20805201, 0x20805402, 0x20805603, | ||
8 | 0x20805804, 0x20805a05, 0x20805c06, 0x20805e07, | ||
9 | 0x20806008, 0x20806209, 0x2080640a, 0x2080660b, | ||
10 | 0x2080680c, 0x20806a0d, 0x20806c0e, 0x20806e0f, | ||
11 | 0x4201c003, 0x33800184, 0x1c010204, 0x40200000, | ||
12 | 0x24000190, 0x24004191, 0x24008192, 0x2400c193, | ||
13 | 0x141fc205, 0x23fffd84, 0x1c100183, 0x217ffb85, | ||
14 | 0x40800000, 0x409ff801, 0x24000080, 0x24fd8081, | ||
15 | 0x1cd80081, 0x33000180, 0x00000000, 0x00000000, | ||
16 | 0x01a00182, 0x3ec00083, 0xb1c38103, 0x01a00204, | ||
17 | 0x3ec10082, 0x4201400d, 0xb1c38202, 0x01a00583, | ||
18 | 0x34218682, 0x3ed80684, 0xb0408184, 0x24218682, | ||
19 | 0x01a00603, 0x00200000, 0x34214682, 0x3ed40684, | ||
20 | 0xb0408184, 0x40800003, 0x24214682, 0x21a00083, | ||
21 | 0x40800082, 0x21a00b02, 0x4020007f, 0x1000251e, | ||
22 | 0x40a80002, 0x32800008, 0x4205c00c, 0x00200000, | ||
23 | 0x40a0000b, 0x3f82070f, 0x4080020a, 0x40800709, | ||
24 | 0x3fe3078f, 0x3fbf0783, 0x3f200183, 0x3fbe0183, | ||
25 | 0x3fe30187, 0x18008387, 0x4205c002, 0x3ac30404, | ||
26 | 0x1cffc489, 0x00200000, 0x18008403, 0x38830402, | ||
27 | 0x4cffc486, 0x3ac28185, 0xb0408584, 0x28830402, | ||
28 | 0x1c020408, 0x38828182, 0xb0408385, 0x1802c387, | ||
29 | 0x28828182, 0x217ff886, 0x04000582, 0x32800007, | ||
30 | 0x21a00802, 0x3fbf0705, 0x3f200285, 0x3fbe0285, | ||
31 | 0x3fe30285, 0x21a00885, 0x04000603, 0x21a00903, | ||
32 | 0x40803c02, 0x21a00982, 0x04000386, 0x21a00a06, | ||
33 | 0x40801202, 0x21a00a82, 0x73000003, 0x24200683, | ||
34 | 0x01a00404, 0x00200000, 0x34204682, 0x3ec40683, | ||
35 | 0xb0408203, 0x24204682, 0x01a00783, 0x00200000, | ||
36 | 0x3421c682, 0x3edc0684, 0xb0408184, 0x2421c682, | ||
37 | 0x21a00806, 0x21a00885, 0x3fbf0784, 0x3f200204, | ||
38 | 0x3fbe0204, 0x3fe30204, 0x21a00904, 0x40804002, | ||
39 | 0x21a00982, 0x21a00a06, 0x40805a02, 0x21a00a82, | ||
40 | 0x04000683, 0x21a00803, 0x21a00885, 0x21a00904, | ||
41 | 0x40848002, 0x21a00982, 0x21a00a06, 0x40801002, | ||
42 | 0x21a00a82, 0x21a00a06, 0x40806602, 0x00200000, | ||
43 | 0x35800009, 0x21a00a82, 0x40800083, 0x21a00b83, | ||
44 | 0x01a00c02, 0x01a00d83, 0x00003ffb, 0x40800003, | ||
45 | 0x4020007f, 0x35000000, 0x00000000, 0x00000000, | ||
46 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
47 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
48 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
49 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
50 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
51 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
52 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
53 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
54 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
55 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
56 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
57 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
58 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
59 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
60 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
61 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
62 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
63 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
64 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
65 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
66 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
67 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
68 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
69 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
70 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
71 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
72 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
73 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
74 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
75 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
76 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
77 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
78 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
79 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
80 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
81 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
82 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
83 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
84 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
85 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
86 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
87 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
88 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
89 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
90 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
91 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
92 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
93 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
94 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
95 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
96 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
97 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
98 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
99 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
100 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
101 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
102 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
103 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
104 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
105 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
106 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
107 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
108 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
109 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
110 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
111 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
112 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
113 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
114 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
115 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
116 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
117 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
118 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
119 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
120 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
121 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
122 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
123 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
124 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
125 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
126 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
127 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
128 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
129 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
130 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
131 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
132 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
133 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
134 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
135 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
136 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
137 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
138 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
139 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
140 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
141 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
142 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
143 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
144 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
145 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
146 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
147 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
148 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
149 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
150 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
151 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
152 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
153 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
154 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
155 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
156 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
157 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
158 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
159 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
160 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
161 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
162 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
163 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
164 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
165 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
166 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
167 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
168 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
169 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
170 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
171 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
172 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
173 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
174 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
175 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
176 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
177 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
178 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
179 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
180 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
181 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
182 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
183 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
184 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
185 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
186 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
187 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
188 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
189 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
190 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | ||
191 | }; | ||
diff --git a/arch/powerpc/platforms/cell/spufs/spufs.h b/arch/powerpc/platforms/cell/spufs/spufs.h index b37fe797ea1c..67aff57faf60 100644 --- a/arch/powerpc/platforms/cell/spufs/spufs.h +++ b/arch/powerpc/platforms/cell/spufs/spufs.h | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/fs.h> | 28 | #include <linux/fs.h> |
29 | 29 | ||
30 | #include <asm/spu.h> | 30 | #include <asm/spu.h> |
31 | #include <asm/spu_csa.h> | ||
31 | 32 | ||
32 | /* The magic number for our file system */ | 33 | /* The magic number for our file system */ |
33 | enum { | 34 | enum { |
@@ -36,6 +37,7 @@ enum { | |||
36 | 37 | ||
37 | struct spu_context { | 38 | struct spu_context { |
38 | struct spu *spu; /* pointer to a physical SPU */ | 39 | struct spu *spu; /* pointer to a physical SPU */ |
40 | struct spu_state csa; /* SPU context save area. */ | ||
39 | struct rw_semaphore backing_sema; /* protects the above */ | 41 | struct rw_semaphore backing_sema; /* protects the above */ |
40 | spinlock_t mmio_lock; /* protects mmio access */ | 42 | spinlock_t mmio_lock; /* protects mmio access */ |
41 | 43 | ||
diff --git a/arch/powerpc/platforms/cell/spufs/switch.c b/arch/powerpc/platforms/cell/spufs/switch.c new file mode 100644 index 000000000000..6804342e99c3 --- /dev/null +++ b/arch/powerpc/platforms/cell/spufs/switch.c | |||
@@ -0,0 +1,174 @@ | |||
1 | /* | ||
2 | * spu_switch.c | ||
3 | * | ||
4 | * (C) Copyright IBM Corp. 2005 | ||
5 | * | ||
6 | * Author: Mark Nutter <mnutter@us.ibm.com> | ||
7 | * | ||
8 | * Host-side part of SPU context switch sequence outlined in | ||
9 | * Synergistic Processor Element, Book IV. | ||
10 | * | ||
11 | * A fully premptive switch of an SPE is very expensive in terms | ||
12 | * of time and system resources. SPE Book IV indicates that SPE | ||
13 | * allocation should follow a "serially reusable device" model, | ||
14 | * in which the SPE is assigned a task until it completes. When | ||
15 | * this is not possible, this sequence may be used to premptively | ||
16 | * save, and then later (optionally) restore the context of a | ||
17 | * program executing on an SPE. | ||
18 | * | ||
19 | * | ||
20 | * This program is free software; you can redistribute it and/or modify | ||
21 | * it under the terms of the GNU General Public License as published by | ||
22 | * the Free Software Foundation; either version 2, or (at your option) | ||
23 | * any later version. | ||
24 | * | ||
25 | * This program is distributed in the hope that it will be useful, | ||
26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
28 | * GNU General Public License for more details. | ||
29 | * | ||
30 | * You should have received a copy of the GNU General Public License | ||
31 | * along with this program; if not, write to the Free Software | ||
32 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
33 | */ | ||
34 | |||
35 | #include <linux/config.h> | ||
36 | #include <linux/module.h> | ||
37 | #include <linux/errno.h> | ||
38 | #include <linux/sched.h> | ||
39 | #include <linux/kernel.h> | ||
40 | #include <linux/mm.h> | ||
41 | #include <linux/vmalloc.h> | ||
42 | #include <linux/smp.h> | ||
43 | #include <linux/smp_lock.h> | ||
44 | #include <linux/stddef.h> | ||
45 | #include <linux/unistd.h> | ||
46 | |||
47 | #include <asm/io.h> | ||
48 | #include <asm/spu.h> | ||
49 | #include <asm/spu_csa.h> | ||
50 | #include <asm/mmu_context.h> | ||
51 | |||
52 | #include "spu_save_dump.h" | ||
53 | #include "spu_restore_dump.h" | ||
54 | |||
55 | /** | ||
56 | * spu_save - SPU context save, with locking. | ||
57 | * @prev: pointer to SPU context save area, to be saved. | ||
58 | * @spu: pointer to SPU iomem structure. | ||
59 | * | ||
60 | * Acquire locks, perform the save operation then return. | ||
61 | */ | ||
62 | int spu_save(struct spu_state *prev, struct spu *spu) | ||
63 | { | ||
64 | /* XXX missing */ | ||
65 | |||
66 | return 0; | ||
67 | } | ||
68 | |||
69 | /** | ||
70 | * spu_restore - SPU context restore, with harvest and locking. | ||
71 | * @new: pointer to SPU context save area, to be restored. | ||
72 | * @spu: pointer to SPU iomem structure. | ||
73 | * | ||
74 | * Perform harvest + restore, as we may not be coming | ||
75 | * from a previous succesful save operation, and the | ||
76 | * hardware state is unknown. | ||
77 | */ | ||
78 | int spu_restore(struct spu_state *new, struct spu *spu) | ||
79 | { | ||
80 | /* XXX missing */ | ||
81 | |||
82 | return 0; | ||
83 | } | ||
84 | |||
85 | /** | ||
86 | * spu_switch - SPU context switch (save + restore). | ||
87 | * @prev: pointer to SPU context save area, to be saved. | ||
88 | * @new: pointer to SPU context save area, to be restored. | ||
89 | * @spu: pointer to SPU iomem structure. | ||
90 | * | ||
91 | * Perform save, then restore. Only harvest if the | ||
92 | * save fails, as cleanup is otherwise not needed. | ||
93 | */ | ||
94 | int spu_switch(struct spu_state *prev, struct spu_state *new, struct spu *spu) | ||
95 | { | ||
96 | /* XXX missing */ | ||
97 | |||
98 | return 0; | ||
99 | } | ||
100 | |||
101 | static void init_prob(struct spu_state *csa) | ||
102 | { | ||
103 | csa->spu_chnlcnt_RW[9] = 1; | ||
104 | csa->spu_chnlcnt_RW[21] = 16; | ||
105 | csa->spu_chnlcnt_RW[23] = 1; | ||
106 | csa->spu_chnlcnt_RW[28] = 1; | ||
107 | csa->spu_chnlcnt_RW[30] = 1; | ||
108 | csa->prob.spu_runcntl_RW = SPU_RUNCNTL_STOP; | ||
109 | } | ||
110 | |||
111 | static void init_priv1(struct spu_state *csa) | ||
112 | { | ||
113 | /* Enable decode, relocate, tlbie response, master runcntl. */ | ||
114 | csa->priv1.mfc_sr1_RW = MFC_STATE1_LOCAL_STORAGE_DECODE_MASK | | ||
115 | MFC_STATE1_MASTER_RUN_CONTROL_MASK | | ||
116 | MFC_STATE1_PROBLEM_STATE_MASK | | ||
117 | MFC_STATE1_RELOCATE_MASK | MFC_STATE1_BUS_TLBIE_MASK; | ||
118 | |||
119 | /* Set storage description. */ | ||
120 | csa->priv1.mfc_sdr_RW = mfspr(SPRN_SDR1); | ||
121 | |||
122 | /* Enable OS-specific set of interrupts. */ | ||
123 | csa->priv1.int_mask_class0_RW = CLASS0_ENABLE_DMA_ALIGNMENT_INTR | | ||
124 | CLASS0_ENABLE_INVALID_DMA_COMMAND_INTR | | ||
125 | CLASS0_ENABLE_SPU_ERROR_INTR; | ||
126 | csa->priv1.int_mask_class1_RW = CLASS1_ENABLE_SEGMENT_FAULT_INTR | | ||
127 | CLASS1_ENABLE_STORAGE_FAULT_INTR; | ||
128 | csa->priv1.int_mask_class2_RW = CLASS2_ENABLE_MAILBOX_INTR | | ||
129 | CLASS2_ENABLE_SPU_STOP_INTR | CLASS2_ENABLE_SPU_HALT_INTR; | ||
130 | } | ||
131 | |||
132 | static void init_priv2(struct spu_state *csa) | ||
133 | { | ||
134 | csa->priv2.spu_lslr_RW = LS_ADDR_MASK; | ||
135 | csa->priv2.mfc_control_RW = MFC_CNTL_RESUME_DMA_QUEUE | | ||
136 | MFC_CNTL_NORMAL_DMA_QUEUE_OPERATION | | ||
137 | MFC_CNTL_DMA_QUEUES_EMPTY_MASK; | ||
138 | } | ||
139 | |||
140 | /** | ||
141 | * spu_alloc_csa - allocate and initialize an SPU context save area. | ||
142 | * | ||
143 | * Allocate and initialize the contents of an SPU context save area. | ||
144 | * This includes enabling address translation, interrupt masks, etc., | ||
145 | * as appropriate for the given OS environment. | ||
146 | * | ||
147 | * Note that storage for the 'lscsa' is allocated separately, | ||
148 | * as it is by far the largest of the context save regions, | ||
149 | * and may need to be pinned or otherwise specially aligned. | ||
150 | */ | ||
151 | void spu_init_csa(struct spu_state *csa) | ||
152 | { | ||
153 | struct spu_lscsa *lscsa; | ||
154 | |||
155 | if (!csa) | ||
156 | return; | ||
157 | memset(csa, 0, sizeof(struct spu_state)); | ||
158 | |||
159 | lscsa = vmalloc(sizeof(struct spu_lscsa)); | ||
160 | if (!lscsa) | ||
161 | return; | ||
162 | |||
163 | memset(lscsa, 0, sizeof(struct spu_lscsa)); | ||
164 | csa->lscsa = lscsa; | ||
165 | |||
166 | init_prob(csa); | ||
167 | init_priv1(csa); | ||
168 | init_priv2(csa); | ||
169 | } | ||
170 | |||
171 | void spu_fini_csa(struct spu_state *csa) | ||
172 | { | ||
173 | vfree(csa->lscsa); | ||
174 | } | ||