[Cbe-oss-dev] [RFC] spufs: DMA Restart after SIGSEGV

Andre Detsch adetsch at br.ibm.com
Mon Dec 10 23:30:24 EST 2007


Subject: spufs: DMA Restart after SIGSEGV
From: Andre Detsch <adetsch at br.ibm.com>

This patch fixes the behavior of spufs when a spu tries
a DMA operation based on a wrong / unavailable address.

Instead of just generating a SIGBUS signal, spufs now
generates a SIGSEGV signal and restart the problematic DMA operation
after the execution of the application's signal handler. This allows
applications to employ user-level paging systems.

Although the restart_dma function is called before the application's
signal handler, the operation is not actually performed at this time,
since the spu context is already stopped. The operation only takes
place when spu_run is restarted (which happens automatically).

Signed-off-by: Andre Detsch <adetsch at br.ibm.com>


Index: linux-2.6/arch/powerpc/platforms/cell/spufs/fault.c
===================================================================
--- linux-2.6.orig/arch/powerpc/platforms/cell/spufs/fault.c
+++ linux-2.6/arch/powerpc/platforms/cell/spufs/fault.c
@@ -115,9 +115,10 @@ static void spufs_handle_dma_error(struc
 			info.si_code = BUS_OBJERR;
 			break;
 		case SPE_EVENT_SPE_DATA_STORAGE:
-			info.si_signo = SIGBUS;
+			info.si_signo = SIGSEGV;
 			info.si_addr = (void __user *)ea;
-			info.si_code = BUS_ADRERR;
+			info.si_code = SEGV_ACCERR;
+			ctx->ops->restart_dma(ctx);
 			break;
 		case SPE_EVENT_DMA_ALIGNMENT:
 			info.si_signo = SIGBUS;
Index: linux-2.6/arch/powerpc/platforms/cell/spufs/backing_ops.c
===================================================================
--- linux-2.6.orig/arch/powerpc/platforms/cell/spufs/backing_ops.c
+++ linux-2.6/arch/powerpc/platforms/cell/spufs/backing_ops.c
@@ -367,7 +367,7 @@ static int spu_backing_send_mfc_command(

 static void spu_backing_restart_dma(struct spu_context *ctx)
 {
-	/* nothing to do here */
+	ctx->csa.priv2.mfc_control_RW |= MFC_CNTL_RESTART_DMA_COMMAND;
 }

 struct spu_context_ops spu_backing_ops = {



More information about the cbe-oss-dev mailing list