aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2007-04-23 15:08:27 -0400
committerArnd Bergmann <arnd@klappe.arndb.de>2007-04-23 15:18:59 -0400
commitaa45e2569ffe963dfbbbfddfdccd12afe69b2d65 (patch)
treee579b3a2481fd11d38232f092bd491c444a556ce /arch
parentfe8a29db5bce1b5bd1ceb85fd153fac52cdab7b2 (diff)
[POWERPC] spufs: various run.c cleanups
- remove the spu_acquire_runnable from spu_run_init. I need to opencode it in spufs_run_spu in the next patch - remove various inline attributes, we don't really want to inline long functions with multiple callsites - cleanup return values and runcntl_write calls in spu_run_init - use normal kernel codingstyle in spu_reacquire_runnable Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/platforms/cell/spufs/run.c51
1 files changed, 31 insertions, 20 deletions
diff --git a/arch/powerpc/platforms/cell/spufs/run.c b/arch/powerpc/platforms/cell/spufs/run.c
index b5e7bdee1bc2..57626600b1a4 100644
--- a/arch/powerpc/platforms/cell/spufs/run.c
+++ b/arch/powerpc/platforms/cell/spufs/run.c
@@ -123,20 +123,15 @@ out:
123 return ret; 123 return ret;
124} 124}
125 125
126static inline int spu_run_init(struct spu_context *ctx, u32 * npc) 126static int spu_run_init(struct spu_context *ctx, u32 * npc)
127{ 127{
128 int ret;
129 unsigned long runcntl = SPU_RUNCNTL_RUNNABLE;
130
131 ret = spu_acquire_runnable(ctx, 0);
132 if (ret)
133 return ret;
134
135 if (ctx->flags & SPU_CREATE_ISOLATE) { 128 if (ctx->flags & SPU_CREATE_ISOLATE) {
129 unsigned long runcntl;
130
136 if (!(ctx->ops->status_read(ctx) & SPU_STATUS_ISOLATED_STATE)) { 131 if (!(ctx->ops->status_read(ctx) & SPU_STATUS_ISOLATED_STATE)) {
137 ret = spu_setup_isolated(ctx); 132 int ret = spu_setup_isolated(ctx);
138 if (ret) 133 if (ret)
139 spu_release(ctx); 134 return ret;
140 } 135 }
141 136
142 /* if userspace has set the runcntrl register (eg, to issue an 137 /* if userspace has set the runcntrl register (eg, to issue an
@@ -145,16 +140,17 @@ static inline int spu_run_init(struct spu_context *ctx, u32 * npc)
145 (SPU_RUNCNTL_RUNNABLE | SPU_RUNCNTL_ISOLATE); 140 (SPU_RUNCNTL_RUNNABLE | SPU_RUNCNTL_ISOLATE);
146 if (runcntl == 0) 141 if (runcntl == 0)
147 runcntl = SPU_RUNCNTL_RUNNABLE; 142 runcntl = SPU_RUNCNTL_RUNNABLE;
143 ctx->ops->runcntl_write(ctx, runcntl);
148 } else { 144 } else {
149 spu_start_tick(ctx); 145 spu_start_tick(ctx);
150 ctx->ops->npc_write(ctx, *npc); 146 ctx->ops->npc_write(ctx, *npc);
147 ctx->ops->runcntl_write(ctx, SPU_RUNCNTL_RUNNABLE);
151 } 148 }
152 149
153 ctx->ops->runcntl_write(ctx, runcntl); 150 return 0;
154 return ret;
155} 151}
156 152
157static inline int spu_run_fini(struct spu_context *ctx, u32 * npc, 153static int spu_run_fini(struct spu_context *ctx, u32 * npc,
158 u32 * status) 154 u32 * status)
159{ 155{
160 int ret = 0; 156 int ret = 0;
@@ -170,19 +166,27 @@ static inline int spu_run_fini(struct spu_context *ctx, u32 * npc,
170 return ret; 166 return ret;
171} 167}
172 168
173static inline int spu_reacquire_runnable(struct spu_context *ctx, u32 *npc, 169static int spu_reacquire_runnable(struct spu_context *ctx, u32 *npc,
174 u32 *status) 170 u32 *status)
175{ 171{
176 int ret; 172 int ret;
177 173
178 if ((ret = spu_run_fini(ctx, npc, status)) != 0) 174 ret = spu_run_fini(ctx, npc, status);
175 if (ret)
179 return ret; 176 return ret;
180 if (*status & (SPU_STATUS_STOPPED_BY_STOP | 177
181 SPU_STATUS_STOPPED_BY_HALT)) { 178 if (*status & (SPU_STATUS_STOPPED_BY_STOP | SPU_STATUS_STOPPED_BY_HALT))
182 return *status; 179 return *status;
183 } 180
184 if ((ret = spu_run_init(ctx, npc)) != 0) 181 ret = spu_acquire_runnable(ctx, 0);
182 if (ret)
185 return ret; 183 return ret;
184
185 ret = spu_run_init(ctx, npc);
186 if (ret) {
187 spu_release(ctx);
188 return ret;
189 }
186 return 0; 190 return 0;
187} 191}
188 192
@@ -293,9 +297,16 @@ long spufs_run_spu(struct file *file, struct spu_context *ctx,
293 297
294 ctx->ops->master_start(ctx); 298 ctx->ops->master_start(ctx);
295 ctx->event_return = 0; 299 ctx->event_return = 0;
296 ret = spu_run_init(ctx, npc); 300
301 ret = spu_acquire_runnable(ctx, 0);
297 if (ret) 302 if (ret)
303 return ret;
304
305 ret = spu_run_init(ctx, npc);
306 if (ret) {
307 spu_release(ctx);
298 goto out; 308 goto out;
309 }
299 310
300 do { 311 do {
301 ret = spufs_wait(ctx->stop_wq, spu_stopped(ctx, &status)); 312 ret = spufs_wait(ctx->stop_wq, spu_stopped(ctx, &status));