[Cbe-oss-dev] [PATCH 5:5] spusched: handle faults while the context switch pending flag is set

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


Handle faults while the context switch pending flag is set 

Page fault handlers don't set the mfc restart command if the context 
switch pending flag is set.  This patch introduces fault pending flag
that is set by the fault handler and read by the context switch code,
so that the latter can add the bit at the right spot, after it has
successfuly save the state of the mfc control register.  

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

---

Index: spufs/arch/powerpc/platforms/cell/spu_base.c
===================================================================
--- spufs.orig/arch/powerpc/platforms/cell/spu_base.c
+++ spufs/arch/powerpc/platforms/cell/spu_base.c
@@ -141,6 +141,10 @@ static void spu_restart_dma(struct spu *
 
 	if (!test_bit(SPU_CONTEXT_SWITCH_PENDING, &spu->flags))
 		out_be64(&priv2->mfc_control_RW, MFC_CNTL_RESTART_DMA_COMMAND);
+	else {
+		set_bit(SPU_CONTEXT_FAULT_PENDING, &spu->flags);
+		mb();
+	}
 }
 
 static inline void spu_load_slb(struct spu *spu, int slbe, struct spu_slb *slb)
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
@@ -139,6 +139,7 @@ static inline void disable_interrupts(st
 	 * via a simple load.
 	 */
 	set_bit(SPU_CONTEXT_SWITCH_PENDING, &spu->flags);
+	clear_bit(SPU_CONTEXT_FAULT_PENDING, &spu->flags);
 	synchronize_irq(spu->irqs[0]);
 	synchronize_irq(spu->irqs[1]);
 	synchronize_irq(spu->irqs[2]);
@@ -744,10 +745,14 @@ static inline void set_switch_active(str
 	/* Save, Step 48:
 	 * Restore, Step 23.
 	 *     Change the software context switch pending flag
-	 *     to context switch active.
+	 *     to context switch active.  This implementation does
+	 *     not uses a switch active flag.
 	 *
-	 *     This implementation does not uses a switch active flag.
+	 * Now that we have saved the mfc in the csa, we can add in the
+	 * restart command if an exception occurred.
 	 */
+	if (test_bit(SPU_CONTEXT_FAULT_PENDING, &spu->flags))
+		csa->priv2.mfc_control_RW |= MFC_CNTL_RESTART_DMA_COMMAND;
 	clear_bit(SPU_CONTEXT_SWITCH_PENDING, &spu->flags);
 	mb();
 }
Index: spufs/include/asm-powerpc/spu.h
===================================================================
--- spufs.orig/include/asm-powerpc/spu.h
+++ spufs/include/asm-powerpc/spu.h
@@ -100,6 +100,7 @@
 
 /* Flag indicating progress during context switch. */
 #define SPU_CONTEXT_SWITCH_PENDING	0UL
+#define SPU_CONTEXT_FAULT_PENDING	1UL
 
 struct spu_context;
 struct spu_runqueue;





More information about the cbe-oss-dev mailing list