Index: linux-cg/arch/powerpc/platforms/cell/spu_base.c =================================================================== --- linux-cg.orig/arch/powerpc/platforms/cell/spu_base.c 2006-07-18 18:17:32.000000000 +0200 +++ linux-cg/arch/powerpc/platforms/cell/spu_base.c 2006-07-18 18:17:37.000000000 +0200 @@ -46,21 +46,21 @@ static int __spu_trap_invalid_dma(struct spu *spu) { pr_debug("%s\n", __FUNCTION__); - force_sig(SIGBUS, /* info, */ current); + spu->dma_callback(spu, SPE_EVENT_INVALID_DMA); return 0; } static int __spu_trap_dma_align(struct spu *spu) { pr_debug("%s\n", __FUNCTION__); - force_sig(SIGBUS, /* info, */ current); + spu->dma_callback(spu, SPE_EVENT_DMA_ALIGNMENT); return 0; } static int __spu_trap_error(struct spu *spu) { pr_debug("%s\n", __FUNCTION__); - force_sig(SIGILL, /* info, */ current); + spu->dma_callback(spu, SPE_EVENT_SPE_ERROR); return 0; } Index: linux-cg/arch/powerpc/platforms/cell/spufs/inode.c =================================================================== --- linux-cg.orig/arch/powerpc/platforms/cell/spufs/inode.c 2006-07-18 18:16:50.000000000 +0200 +++ linux-cg/arch/powerpc/platforms/cell/spufs/inode.c 2006-07-18 18:17:37.000000000 +0200 @@ -225,7 +225,8 @@ }; static int -spufs_mkdir(struct inode *dir, struct dentry *dentry, int mode) +spufs_mkdir(struct inode *dir, struct dentry *dentry, unsigned int flags, + int mode) { int ret; struct inode *inode; @@ -245,6 +246,8 @@ if (!ctx) goto out_iput; + ctx->flags = flags; + inode->i_op = &spufs_dir_inode_operations; inode->i_fop = &simple_dir_operations; ret = spufs_fill_dir(dentry, spufs_dir_contents, mode, ctx); @@ -305,7 +308,7 @@ goto out; /* all flags are reserved */ - if (flags) + if (flags & (~SPU_CREATE_FLAG_ALL)) goto out; dentry = lookup_create(nd, 1); @@ -318,7 +321,7 @@ goto out_dput; mode &= ~current->fs->umask; - ret = spufs_mkdir(nd->dentry->d_inode, dentry, mode & S_IRWXUGO); + ret = spufs_mkdir(nd->dentry->d_inode, dentry, flags, mode & S_IRWXUGO); if (ret) goto out_dput; Index: linux-cg/arch/powerpc/platforms/cell/spufs/sched.c =================================================================== --- linux-cg.orig/arch/powerpc/platforms/cell/spufs/sched.c 2006-07-18 18:17:30.000000000 +0200 +++ linux-cg/arch/powerpc/platforms/cell/spufs/sched.c 2006-07-18 18:17:37.000000000 +0200 @@ -101,7 +101,6 @@ spu->number, spu->node); spu->ctx = ctx; spu->flags = 0; - ctx->flags = 0; ctx->spu = spu; ctx->ops = &spu_hw_ops; spu->pid = current->pid; @@ -112,6 +111,7 @@ spu->wbox_callback = spufs_wbox_callback; spu->stop_callback = spufs_stop_callback; spu->mfc_callback = spufs_mfc_callback; + spu->dma_callback = spufs_dma_callback; mb(); spu_unmap_mappings(ctx); spu_restore(&ctx->csa, spu); @@ -133,12 +133,12 @@ spu->wbox_callback = NULL; spu->stop_callback = NULL; spu->mfc_callback = NULL; + spu->dma_callback = NULL; spu->mm = NULL; spu->pid = 0; spu->prio = MAX_PRIO; ctx->ops = &spu_backing_ops; ctx->spu = NULL; - ctx->flags = 0; spu->flags = 0; spu->ctx = NULL; } Index: linux-cg/arch/powerpc/platforms/cell/spufs/spufs.h =================================================================== --- linux-cg.orig/arch/powerpc/platforms/cell/spufs/spufs.h 2006-07-18 18:17:30.000000000 +0200 +++ linux-cg/arch/powerpc/platforms/cell/spufs/spufs.h 2006-07-18 18:17:37.000000000 +0200 @@ -67,7 +67,8 @@ u32 tagwait; struct spu_context_ops *ops; struct work_struct reap_work; - u64 flags; + unsigned long flags; + unsigned long event_return; }; struct mfc_dma_command { @@ -184,5 +185,6 @@ void spufs_wbox_callback(struct spu *spu); void spufs_stop_callback(struct spu *spu); void spufs_mfc_callback(struct spu *spu); +void spufs_dma_callback(struct spu *spu, int type); #endif Index: linux-cg/include/asm-powerpc/spu.h =================================================================== --- linux-cg.orig/include/asm-powerpc/spu.h 2006-07-18 18:17:33.000000000 +0200 +++ linux-cg/include/asm-powerpc/spu.h 2006-07-18 18:17:37.000000000 +0200 @@ -139,6 +139,7 @@ void (* ibox_callback)(struct spu *spu); void (* stop_callback)(struct spu *spu); void (* mfc_callback)(struct spu *spu); + void (* dma_callback)(struct spu *spu, int type); char irq_c0[8]; char irq_c1[8]; @@ -172,6 +173,19 @@ struct module *owner; } spufs_calls; +/* return status from spu_run, same as in libspe */ +#define SPE_EVENT_DMA_ALIGNMENT 0x0008 /*A DMA alignment error */ +#define SPE_EVENT_SPE_ERROR 0x0010 /*An illegal instruction error*/ +#define SPE_EVENT_SPE_DATA_SEGMENT 0x0020 /*A DMA segmentation error */ +#define SPE_EVENT_SPE_DATA_STORAGE 0x0040 /*A DMA storage error */ +#define SPE_EVENT_INVALID_DMA 0x0800 /* Invalid MFC DMA */ + +/* + * Flags for sys_spu_create. + */ +#define SPU_CREATE_EVENTS_ENABLED 0x0001 +#define SPU_CREATE_FLAG_ALL 0x0001 /* mask of all valid flags */ + #ifdef CONFIG_SPU_FS_MODULE int register_spu_syscalls(struct spufs_calls *calls); void unregister_spu_syscalls(struct spufs_calls *calls); Index: linux-cg/arch/powerpc/platforms/cell/spufs/run.c =================================================================== --- linux-cg.orig/arch/powerpc/platforms/cell/spufs/run.c 2006-07-18 18:17:20.000000000 +0200 +++ linux-cg/arch/powerpc/platforms/cell/spufs/run.c 2006-07-18 18:17:37.000000000 +0200 @@ -14,6 +14,26 @@ wake_up_all(&ctx->stop_wq); } +void spufs_dma_callback(struct spu *spu, int type) +{ + struct spu_context *ctx = spu->ctx; + + if (ctx->flags & SPU_CREATE_EVENTS_ENABLED) { + ctx->event_return |= type; + wake_up_all(&ctx->stop_wq); + } else { + switch (type) { + case SPE_EVENT_DMA_ALIGNMENT: + case SPE_EVENT_INVALID_DMA: + force_sig(SIGBUS, /* info, */ current); + break; + case SPE_EVENT_SPE_ERROR: + force_sig(SIGILL, /* info */ current); + break; + } + } +} + static inline int spu_stopped(struct spu_context *ctx, u32 * stat) { struct spu *spu; @@ -184,6 +204,7 @@ if (down_interruptible(&ctx->run_sema)) return -ERESTARTSYS; + ctx->event_return = 0; ret = spu_run_init(ctx, npc); if (ret) goto out; @@ -217,8 +238,7 @@ spu_yield(ctx); out: - /* events are not implemented yet */ - *event = 0; + *event = ctx->event_return; up(&ctx->run_sema); return ret; }