]> err.no Git - linux-2.6/blobdiff - arch/powerpc/platforms/cell/spufs/run.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394...
[linux-2.6] / arch / powerpc / platforms / cell / spufs / run.c
index 7cf5b298fa13887de893187b2c1f583f03b2f13c..57626600b1a4b5c7cb3d46d17ef214e5b5807d1d 100644 (file)
@@ -123,20 +123,15 @@ out:
        return ret;
 }
 
-static inline int spu_run_init(struct spu_context *ctx, u32 * npc)
+static int spu_run_init(struct spu_context *ctx, u32 * npc)
 {
-       int ret;
-       unsigned long runcntl = SPU_RUNCNTL_RUNNABLE;
-
-       ret = spu_acquire_runnable(ctx, 0);
-       if (ret)
-               return ret;
-
        if (ctx->flags & SPU_CREATE_ISOLATE) {
+               unsigned long runcntl;
+
                if (!(ctx->ops->status_read(ctx) & SPU_STATUS_ISOLATED_STATE)) {
-                       ret = spu_setup_isolated(ctx);
+                       int ret = spu_setup_isolated(ctx);
                        if (ret)
-                               spu_release(ctx);
+                               return ret;
                }
 
                /* 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)
                        (SPU_RUNCNTL_RUNNABLE | SPU_RUNCNTL_ISOLATE);
                if (runcntl == 0)
                        runcntl = SPU_RUNCNTL_RUNNABLE;
+               ctx->ops->runcntl_write(ctx, runcntl);
        } else {
                spu_start_tick(ctx);
                ctx->ops->npc_write(ctx, *npc);
+               ctx->ops->runcntl_write(ctx, SPU_RUNCNTL_RUNNABLE);
        }
 
-       ctx->ops->runcntl_write(ctx, runcntl);
-       return ret;
+       return 0;
 }
 
-static inline int spu_run_fini(struct spu_context *ctx, u32 * npc,
+static int spu_run_fini(struct spu_context *ctx, u32 * npc,
                               u32 * status)
 {
        int ret = 0;
@@ -170,19 +166,27 @@ static inline int spu_run_fini(struct spu_context *ctx, u32 * npc,
        return ret;
 }
 
-static inline int spu_reacquire_runnable(struct spu_context *ctx, u32 *npc,
+static int spu_reacquire_runnable(struct spu_context *ctx, u32 *npc,
                                         u32 *status)
 {
        int ret;
 
-       if ((ret = spu_run_fini(ctx, npc, status)) != 0)
+       ret = spu_run_fini(ctx, npc, status);
+       if (ret)
                return ret;
-       if (*status & (SPU_STATUS_STOPPED_BY_STOP |
-                      SPU_STATUS_STOPPED_BY_HALT)) {
+
+       if (*status & (SPU_STATUS_STOPPED_BY_STOP | SPU_STATUS_STOPPED_BY_HALT))
                return *status;
-       }
-       if ((ret = spu_run_init(ctx, npc)) != 0)
+
+       ret = spu_acquire_runnable(ctx, 0);
+       if (ret)
                return ret;
+
+       ret = spu_run_init(ctx, npc);
+       if (ret) {
+               spu_release(ctx);
+               return ret;
+       }
        return 0;
 }
 
@@ -234,17 +238,17 @@ int spu_process_callback(struct spu_context *ctx)
 {
        struct spu_syscall_block s;
        u32 ls_pointer, npc;
-       char *ls;
+       void __iomem *ls;
        long spu_ret;
        int ret;
 
        /* get syscall block from local store */
-       npc = ctx->ops->npc_read(ctx);
-       ls = ctx->ops->get_ls(ctx);
-       ls_pointer = *(u32*)(ls + npc);
+       npc = ctx->ops->npc_read(ctx) & ~3;
+       ls = (void __iomem *)ctx->ops->get_ls(ctx);
+       ls_pointer = in_be32(ls + npc);
        if (ls_pointer > (LS_SIZE - sizeof(s)))
                return -EFAULT;
-       memcpy(&s, ls + ls_pointer, sizeof (s));
+       memcpy_fromio(&s, ls + ls_pointer, sizeof(s));
 
        /* do actual syscall without pinning the spu */
        ret = 0;
@@ -264,7 +268,7 @@ int spu_process_callback(struct spu_context *ctx)
        }
 
        /* write result, jump over indirect pointer */
-       memcpy(ls + ls_pointer, &spu_ret, sizeof (spu_ret));
+       memcpy_toio(ls + ls_pointer, &spu_ret, sizeof(spu_ret));
        ctx->ops->npc_write(ctx, npc);
        ctx->ops->runcntl_write(ctx, SPU_RUNCNTL_RUNNABLE);
        return ret;
@@ -293,9 +297,16 @@ long spufs_run_spu(struct file *file, struct spu_context *ctx,
 
        ctx->ops->master_start(ctx);
        ctx->event_return = 0;
-       ret = spu_run_init(ctx, npc);
+
+       ret = spu_acquire_runnable(ctx, 0);
        if (ret)
+               return ret;
+
+       ret = spu_run_init(ctx, npc);
+       if (ret) {
+               spu_release(ctx);
                goto out;
+       }
 
        do {
                ret = spufs_wait(ctx->stop_wq, spu_stopped(ctx, &status));