[Cbe-oss-dev] [PATCH 2:6] spufs: fix spu status read in spu_stopped

Christoph Hellwig hch at lst.de
Tue May 13 19:38:02 EST 2008


On Mon, May 12, 2008 at 02:37:04PM +0000, Luke Browning wrote:
> Fix spu status read in spu_stopped()
> 
> If the spu is stopping, re-read the register to get the stopped value.
> SPU status is a loop control variable in the calling routine.

Looks good, but I had a real hard time figuring out what the loop
actually did.  In fact I had to redo it a little to follow it, this
is what I ended up with:


Index: linux-2.6/arch/powerpc/platforms/cell/spufs/run.c
===================================================================
--- linux-2.6.orig/arch/powerpc/platforms/cell/spufs/run.c	2008-05-13 11:29:21.000000000 +0200
+++ linux-2.6/arch/powerpc/platforms/cell/spufs/run.c	2008-05-13 11:36:08.000000000 +0200
@@ -51,14 +51,22 @@ int spu_stopped(struct spu_context *ctx,
 	u64 dsisr;
 	u32 stopped;
 
-	*stat = ctx->ops->status_read(ctx);
+	stopped = SPU_STATUS_INVALID_INSTR | SPU_STATUS_SINGLE_STEP |
+		  SPU_STATUS_STOPPED_BY_HALT | SPU_STATUS_STOPPED_BY_STOP;
 
-	if (test_bit(SPU_SCHED_NOTIFY_ACTIVE, &ctx->sched_flags))
+ again:
+	*stat = ctx->ops->status_read(ctx);
+	if (*stat & stopped) {
+		/*
+		 * If the spu hasn't finished stopping we need to re-read
+		 * the register to get the stoped value.
+		 */
+		if (*stat & SPU_STATUS_RUNNING)
+			goto again;
 		return 1;
+	}
 
-	stopped = SPU_STATUS_INVALID_INSTR | SPU_STATUS_SINGLE_STEP |
-		SPU_STATUS_STOPPED_BY_HALT | SPU_STATUS_STOPPED_BY_STOP;
-	if (!(*stat & SPU_STATUS_RUNNING) && (*stat & stopped))
+	if (test_bit(SPU_SCHED_NOTIFY_ACTIVE, &ctx->sched_flags))
 		return 1;
 
 	dsisr = ctx->csa.class_0_dsisr;



More information about the cbe-oss-dev mailing list