[Cbe-oss-dev] [PATCH 5/6] spufs: fix dma restart
Luke Browning
lukebr at linux.vnet.ibm.com
Thu Feb 7 04:43:40 EST 2008
Subject: spufs: DMA Restart after SIGSEGV
Based on an original patch 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 deactivated. It is regenerated on the
next system call.
Deactivation removes platform and hardware specific dependencies on
the use of master runcntl bits. Only the context save area is updated.
Signed-off-by: Luke Browning <lukebrowning at us.ibm.com>
Index: spufs/arch/powerpc/platforms/cell/spufs/backing_ops.c
===================================================================
--- spufs.orig/arch/powerpc/platforms/cell/spufs/backing_ops.c 2008-02-05 22:36:41.000000000 -0200
+++ spufs/arch/powerpc/platforms/cell/spufs/backing_ops.c 2008-02-06 14:30:00.000000000 -0200
@@ -373,7 +373,7 @@
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 = {
Index: spufs/arch/powerpc/platforms/cell/spufs/fault.c
===================================================================
--- spufs.orig/arch/powerpc/platforms/cell/spufs/fault.c 2008-02-05 22:38:18.000000000 -0200
+++ spufs/arch/powerpc/platforms/cell/spufs/fault.c 2008-02-06 14:36:45.000000000 -0200
@@ -53,9 +53,16 @@
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;
+ /*
+ * Deactivate so that the I/O operation takes place after
+ * the signal has been delivered. The application may need
+ * to change the access permissions on the page.
+ */
+ spu_deactivate(ctx);
+ ctx->ops->restart_dma(ctx);
break;
case SPE_EVENT_DMA_ALIGNMENT:
info.si_signo = SIGBUS;
More information about the cbe-oss-dev
mailing list