[Cbe-oss-dev] [PATCH 1:5] spusched: fix the save of the mfc-control-register in context switch code

Luke Browning lukebr at linux.vnet.ibm.com
Mon Apr 28 04:41:44 EST 2008


Fix the save of the mfc-control-register in context switch code

The mfc state 'suspending' is transitional and should be handled the
same as the 'suspended' state.  The flag MFC_CNTL_SUSPEND_DMA_QUEUE 
is added to the csa so that the mfc will be suspended when the
context is resumed.  The context that suspended the mfc is 
responsible for continuing it.

Note:  if the MASK flag is specified the operational state of the
MFC is not changed and command bits to suspend or continue the MFC
are ignored.

Note: the restart command is intended to be used when the mfc is
in a 'normal' operation state, not the suspended state.  SPU exceptions
suspend the mfc but this is not reflected in the operational state
of the mfc.  It remains 'normal'.

Signed-off-by: Luke Browning <lukebr at linux.vnet.ibm.com>

---

Index: spufs/arch/powerpc/platforms/cell/spufs/switch.c
===================================================================
--- spufs.orig/arch/powerpc/platforms/cell/spufs/switch.c
+++ spufs/arch/powerpc/platforms/cell/spufs/switch.c
@@ -177,6 +177,11 @@ static inline void save_mfc_cntl(struct 
 
 	/* Save, Step 8:
 	 *     Suspend DMA and save MFC_CNTL.
+	 *
+	 * Add the suspend command to the saved state if the operational
+	 * state is suspending or suspended, so that it will be restored
+	 * in the same state.  The code that suspended it is responsible
+	 * for continuing it.
 	 */
 	switch (in_be64(&priv2->mfc_control_RW) &
 	       MFC_CNTL_SUSPEND_DMA_STATUS_MASK) {
@@ -184,17 +189,12 @@ static inline void save_mfc_cntl(struct 
 		POLL_WHILE_FALSE((in_be64(&priv2->mfc_control_RW) &
 				  MFC_CNTL_SUSPEND_DMA_STATUS_MASK) ==
 				 MFC_CNTL_SUSPEND_COMPLETE);
-		if (csa)
-			csa->priv2.mfc_control_RW =
-				in_be64(&priv2->mfc_control_RW) |
-				MFC_CNTL_SUSPEND_DMA_QUEUE |
-				MFC_CNTL_SUSPEND_MASK;
-
-		break;
+	/* Fall through */
 	case MFC_CNTL_SUSPEND_COMPLETE:
 		if (csa)
 			csa->priv2.mfc_control_RW =
-				in_be64(&priv2->mfc_control_RW);
+				in_be64(&priv2->mfc_control_RW) |
+				MFC_CNTL_SUSPEND_DMA_QUEUE;
 		break;
 	case MFC_CNTL_NORMAL_DMA_QUEUE_OPERATION:
 		out_be64(&priv2->mfc_control_RW, MFC_CNTL_SUSPEND_DMA_QUEUE);
@@ -1734,15 +1734,17 @@ static inline void restore_mfc_cntl(stru
 	 */
 	out_be64(&priv2->mfc_control_RW, csa->priv2.mfc_control_RW);
 	eieio();
+
 	/*
-	 * FIXME: this is to restart a DMA that we were processing
-	 *        before the save. better remember the fault information
-	 *        in the csa instead.
+	 * The queue is put back into the same state that was evident
+	 * prior to the context switch.  The suspend flag is added to
+	 * the saved state in the csa, if the operational state was
+	 * suspending or suspended.  In this case, the code that suspended
+	 * the mfc is responsible for continuing it.  Note that SPE faults
+	 * do not change the operational state of the spu.  In fact,
+	 * the mfc restart command has no affect if the operational
+	 * state of the mfc is not 'normal'.
 	 */
-	if ((csa->priv2.mfc_control_RW & MFC_CNTL_SUSPEND_DMA_QUEUE_MASK)) {
-		out_be64(&priv2->mfc_control_RW, MFC_CNTL_RESTART_DMA_COMMAND);
-		eieio();
-	}
 }
 
 static inline void enable_user_access(struct spu_state *csa, struct spu *spu)





More information about the cbe-oss-dev mailing list