]> err.no Git - linux-2.6/blobdiff - arch/powerpc/platforms/cell/spufs/sched.c
Pull esi-support into release branch
[linux-2.6] / arch / powerpc / platforms / cell / spufs / sched.c
index 719ff27ce73e6b1851ef2de4fc150f99e491b0e3..1350294484b62e191a131daa99dbd6f8de51aab2 100644 (file)
@@ -26,7 +26,6 @@
 
 #undef DEBUG
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/sched.h>
@@ -43,6 +42,7 @@
 #include <asm/mmu_context.h>
 #include <asm/spu.h>
 #include <asm/spu_csa.h>
+#include <asm/spu_priv1.h>
 #include "spufs.h"
 
 #define SPU_MIN_TIMESLICE      (100 * HZ / 1000)
@@ -180,6 +180,7 @@ static inline void bind_context(struct spu *spu, struct spu_context *ctx)
        spu->ibox_callback = spufs_ibox_callback;
        spu->wbox_callback = spufs_wbox_callback;
        spu->stop_callback = spufs_stop_callback;
+       spu->mfc_callback = spufs_mfc_callback;
        mb();
        spu_unmap_mappings(ctx);
        spu_restore(&ctx->csa, spu);
@@ -197,6 +198,7 @@ static inline void unbind_context(struct spu *spu, struct spu_context *ctx)
        spu->ibox_callback = NULL;
        spu->wbox_callback = NULL;
        spu->stop_callback = NULL;
+       spu->mfc_callback = NULL;
        spu->mm = NULL;
        spu->pid = 0;
        spu->prio = MAX_PRIO;
@@ -214,14 +216,14 @@ static void spu_reaper(void *data)
 
        down_write(&ctx->state_sema);
        spu = ctx->spu;
-       if (spu && (ctx->flags & SPU_CONTEXT_PREEMPT)) {
+       if (spu && test_bit(SPU_CONTEXT_PREEMPT, &ctx->flags)) {
                if (atomic_read(&spu->rq->prio.nr_blocked)) {
                        pr_debug("%s: spu=%d\n", __func__, spu->number);
                        ctx->ops->runcntl_stop(ctx);
                        spu_deactivate(ctx);
                        wake_up_all(&ctx->stop_wq);
                } else {
-                       clear_bit(SPU_CONTEXT_PREEMPT_nr, &ctx->flags);
+                       clear_bit(SPU_CONTEXT_PREEMPT, &ctx->flags);
                }
        }
        up_write(&ctx->state_sema);
@@ -234,7 +236,7 @@ static void schedule_spu_reaper(struct spu_runqueue *rq, struct spu *spu)
        unsigned long now = jiffies;
        unsigned long expire = spu->timestamp + SPU_MIN_TIMESLICE;
 
-       set_bit(SPU_CONTEXT_PREEMPT_nr, &ctx->flags);
+       set_bit(SPU_CONTEXT_PREEMPT, &ctx->flags);
        INIT_WORK(&ctx->reap_work, spu_reaper, ctx);
        if (time_after(now, expire))
                schedule_work(&ctx->reap_work);
@@ -250,7 +252,7 @@ static void check_preempt_active(struct spu_runqueue *rq)
        list_for_each(p, &rq->active_list) {
                struct spu *spu = list_entry(p, struct spu, sched_list);
                struct spu_context *ctx = spu->ctx;
-               if (!(ctx->flags & SPU_CONTEXT_PREEMPT)) {
+               if (!test_bit(SPU_CONTEXT_PREEMPT, &ctx->flags)) {
                        if (!worst || (spu->prio > worst->prio)) {
                                worst = spu;
                        }
@@ -357,6 +359,11 @@ int spu_activate(struct spu_context *ctx, u64 flags)
        if (!spu)
                return (signal_pending(current)) ? -ERESTARTSYS : -EAGAIN;
        bind_context(spu, ctx);
+       /*
+        * We're likely to wait for interrupts on the same
+        * CPU that we are now on, so send them here.
+        */
+       spu_cpu_affinity_set(spu, raw_smp_processor_id());
        put_active_spu(spu);
        return 0;
 }