[Cbe-oss-dev] [PATCH] spufs: fix missing stop-and-signal

Masato Noguchi Masato.Noguchi at jp.sony.com
Thu Nov 16 16:51:26 EST 2006


This patch fixes missing stop-and-signal problem.

When there is pending signals, current spufs_run_spu() always returns 
-ERESTERTSYS 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 at jp.sony.com>
---

 run.c |   28 ++++++++++++++++++----------
 1 files changed, 18 insertions(+), 10 deletions(-)


Index: linux-2.6.19-rc5-arnd1/arch/powerpc/platforms/cell/spufs/run.c
===================================================================
--- linux-2.6.19-rc5-arnd1.orig/arch/powerpc/platforms/cell/spufs/run.c	2006-11-15 08:44:49.000000000 -0500
+++ linux-2.6.19-rc5-arnd1/arch/powerpc/platforms/cell/spufs/run.c	2006-11-15 08:53:37.000000000 -0500
@@ -100,13 +100,7 @@
 
 	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;
 }
 
@@ -254,7 +248,7 @@
 		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);
@@ -263,10 +257,24 @@
 				      SPU_STATUS_STOPPED_BY_HALT)));
 
 	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:
 	ctx->ops->master_stop(ctx);
 	*event = ctx->event_return;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: stopcount.c
Type: application/octet-stream
Size: 1450 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/cbe-oss-dev/attachments/20061116/4f070451/attachment.obj>


More information about the cbe-oss-dev mailing list