[Cbe-oss-dev] [PATCH 1:11] spufs: fix spu status read in spu_stopped() [take 2]

Luke Browning lukebr at linux.vnet.ibm.com
Mon May 26 21:43:01 EST 2008


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.

Changed loop style based on Christoph Hellwig's comment.  

Added eieio() per CBEA specification of spu status register read.

Signed-off-by: Luke Browning <lukebrowning at us.ibm.com>
---
replaces previous patch.  fixed comment and changed to eieio() per Ellerman.
---

Index: linux-2.6.25/arch/powerpc/platforms/cell/spufs/run.c
===================================================================
--- linux-2.6.25.orig/arch/powerpc/platforms/cell/spufs/run.c
+++ linux-2.6.25/arch/powerpc/platforms/cell/spufs/run.c
@@ -51,14 +51,25 @@ 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))
+	/* Ensure that all spu status bits have been updated */
+	eieio();
+
+top:
+	*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 stopped value.
+		 */
+		if (*stat & SPU_STATUS_RUNNING)
+			goto top;
 		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