Re: [PATCH]Add notification for active Cell SPU tasks -- updatedpatch

From: Maynard Johnson
Date: Fri Dec 08 2006 - 10:51:15 EST



Subject: Enable SPU switch notification to detect currently active SPU tasks.

From: Maynard Johnson <maynardj@xxxxxxxxxx>

This patch adds to the capability of spu_switch_event_register to notify the
caller of currently active SPU tasks. It also exports spu_switch_event_register
and spu_switch_event_unregister.

Signed-off-by: Maynard Johnson <mpjohn@xxxxxxxxxx>


Index: linux-2.6.19-rc6-arnd1+patches/arch/powerpc/platforms/cell/spufs/sched.c
===================================================================
--- linux-2.6.19-rc6-arnd1+patches.orig/arch/powerpc/platforms/cell/spufs/sched.c 2006-12-04 10:56:04.730698720 -0600
+++ linux-2.6.19-rc6-arnd1+patches/arch/powerpc/platforms/cell/spufs/sched.c 2006-12-08 09:04:40.558774376 -0600
@@ -84,15 +84,36 @@
ctx ? ctx->object_id : 0, spu);
}

+static void notify_spus_active(struct notifier_block * n)
+{
+ int node;
+ for (node = 0; node < MAX_NUMNODES; node++) {
+ struct spu *spu;
+ mutex_lock(&spu_prio->active_mutex[node]);
+ list_for_each_entry(spu, &spu_prio->active_list[node], list) {
+ struct spu_context *ctx = spu->ctx;
+ n->notifier_call(n, ctx ? ctx->object_id : 0, spu);
+ }
+ mutex_unlock(&spu_prio->active_mutex[node]);
+ }
+
+}
+
int spu_switch_event_register(struct notifier_block * n)
{
- return blocking_notifier_chain_register(&spu_switch_notifier, n);
+ int ret;
+ ret = blocking_notifier_chain_register(&spu_switch_notifier, n);
+ if (!ret)
+ notify_spus_active(n);
+ return ret;
}
+EXPORT_SYMBOL_GPL(spu_switch_event_register);

int spu_switch_event_unregister(struct notifier_block * n)
{
return blocking_notifier_chain_unregister(&spu_switch_notifier, n);
}
+EXPORT_SYMBOL_GPL(spu_switch_event_unregister);


static inline void bind_context(struct spu *spu, struct spu_context *ctx)