[Cbe-oss-dev] [PATCH] spufs: avoid using backing operation for wbox write
Andre Detsch
adetsch at br.ibm.com
Sat Aug 4 07:25:20 EST 2007
Subject: spufs: avoid using backing operation for wbox write
From: Andre Detsch <adetsch at br.ibm.com>
This patch disables the use of a backing operation for the execution
of a write on context's mailbox while is it not bound to a SPU.
The backing operation was consistently failing. Although the mailbox
information was correctly being restored to the SPU when the ctx was
rescheduled to run, SPU was not processing the data (keeping the SPU
task blocked on the MB read operation), most likely because of the
state of the internal event masks, some of them not writable from the
PPU-side.
With this patch, a mb write operation on a non-scheduled ctx is either
blocked until the ctx gets scheduled (if !O_NONBLOCK), or returns
EAGAIN (if O_NONBLOCK).
Signed-off-by: Andre Detsch <adetsch at br.ibm.com>
Index: linux-2.6.22/arch/powerpc/platforms/cell/spufs/backing_ops.c
===================================================================
--- linux-2.6.22.orig/arch/powerpc/platforms/cell/spufs/backing_ops.c
+++ linux-2.6.22/arch/powerpc/platforms/cell/spufs/backing_ops.c
@@ -148,31 +148,13 @@ static int spu_backing_ibox_read(struct
static int spu_backing_wbox_write(struct spu_context *ctx, u32 data)
{
- int ret;
-
- spin_lock(&ctx->csa.register_lock);
- if ((ctx->csa.prob.mb_stat_R) & 0x00ff00) {
- int slot = ctx->csa.spu_chnlcnt_RW[29];
- int avail = (ctx->csa.prob.mb_stat_R & 0x00ff00) >> 8;
-
- /* We have space to write wbox_data.
- * Implementation note: the depth
- * of spu_mb_W is currently 4.
- */
- BUG_ON(avail != (4 - slot));
- ctx->csa.spu_mailbox_data[slot] = data;
- ctx->csa.spu_chnlcnt_RW[29] = ++slot;
- ctx->csa.prob.mb_stat_R = (((4 - slot) & 0xff) << 8);
- gen_spu_event(ctx, MFC_SPU_MAILBOX_WRITTEN_EVENT);
- ret = 4;
- } else {
- /* make sure we get woken up by the interrupt when space
- becomes available */
- ctx->csa.priv1.int_mask_class2_RW |= 0x10;
- ret = 0;
- }
- spin_unlock(&ctx->csa.register_lock);
- return ret;
+ /*
+ * It is not safe to emulate a wbox write on a saved ctx.
+ * Returning 0 here forces the mb write operation to return
+ * -EAGAIN (in the case of a non-blocking operation) or to block
+ * until the context is scheduled to run (if blocking operation)
+ */
+ return 0;
}
static u32 spu_backing_signal1_read(struct spu_context *ctx)
Index: linux-2.6.22/arch/powerpc/platforms/cell/spufs/sched.c
===================================================================
--- linux-2.6.22.orig/arch/powerpc/platforms/cell/spufs/sched.c
+++ linux-2.6.22/arch/powerpc/platforms/cell/spufs/sched.c
@@ -400,6 +400,7 @@ static void spu_bind_context(struct spu
spu->timestamp = jiffies;
spu_cpu_affinity_set(spu, raw_smp_processor_id());
spu_switch_notify(spu, ctx);
+ wake_up_all(&ctx->wbox_wq);
spuctx_switch_state(ctx, SPUCTX_UTIL_LOADED);
}
More information about the cbe-oss-dev
mailing list