]> err.no Git - linux-2.6/commitdiff
[POWERPC] spufs: Fix missing stop-and-signal
authorMasato Noguchi <Masato.Noguchi@jp.sony.com>
Mon, 20 Nov 2006 17:45:04 +0000 (18:45 +0100)
committerPaul Mackerras <paulus@samba.org>
Mon, 4 Dec 2006 09:39:55 +0000 (20:39 +1100)
When there is pending signals, current spufs_run_spu() always returns
-ERESTARTSYS and it is called again automatically.
But, if spe already stopped by stop-and-signal or halt instruction,
returning -ERESTARTSYS makes stop-and-signal/halt lost and
spu run over the end-point.

For your convenience, I attached a sample code to restage this bug.
If there is no bug, printed NPC will be 0x4000.

Signed-off-by: Masato Noguchi <Masato.Noguchi@jp.sony.com>
Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
arch/powerpc/platforms/cell/spufs/run.c

index 88a41d83a79befd17445b3d2cdc89f5511b26c8c..c88fd7f9ea740e92ab65936573aa2d53bbb60f67 100644 (file)
@@ -79,13 +79,7 @@ static inline int spu_run_fini(struct spu_context *ctx, u32 * npc,
 
        if (signal_pending(current))
                ret = -ERESTARTSYS;
-       if (unlikely(current->ptrace & PT_PTRACED)) {
-               if ((*status & SPU_STATUS_STOPPED_BY_STOP)
-                   && (*status >> SPU_STOP_STATUS_SHIFT) == 0x3fff) {
-                       force_sig(SIGTRAP, current);
-                       ret = -ERESTARTSYS;
-               }
-       }
+
        return ret;
 }
 
@@ -232,7 +226,7 @@ long spufs_run_spu(struct file *file, struct spu_context *ctx,
                if (unlikely(ctx->state != SPU_STATE_RUNNABLE)) {
                        ret = spu_reacquire_runnable(ctx, npc, &status);
                        if (ret)
-                               goto out;
+                               goto out2;
                        continue;
                }
                ret = spu_process_events(ctx);
@@ -242,10 +236,24 @@ long spufs_run_spu(struct file *file, struct spu_context *ctx,
 
        ctx->ops->runcntl_stop(ctx);
        ret = spu_run_fini(ctx, npc, &status);
-       if (!ret)
-               ret = status;
        spu_yield(ctx);
 
+out2:
+       if ((ret == 0) ||
+           ((ret == -ERESTARTSYS) &&
+            ((status & SPU_STATUS_STOPPED_BY_HALT) ||
+             ((status & SPU_STATUS_STOPPED_BY_STOP) &&
+              (status >> SPU_STOP_STATUS_SHIFT != 0x2104)))))
+               ret = status;
+
+       if (unlikely(current->ptrace & PT_PTRACED)) {
+               if ((status & SPU_STATUS_STOPPED_BY_STOP)
+                   && (status >> SPU_STOP_STATUS_SHIFT) == 0x3fff) {
+                       force_sig(SIGTRAP, current);
+                       ret = -ERESTARTSYS;
+               }
+       }
+
 out:
        *event = ctx->event_return;
        up(&ctx->run_sema);