linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / arch / powerpc / platforms / cell / spufs / context.c
index 36439c5..336f238 100644 (file)
 #include <asm/spu_csa.h>
 #include "spufs.h"
 
-struct spu_context *alloc_spu_context(void)
+struct spu_context *alloc_spu_context(struct address_space *local_store)
 {
        struct spu_context *ctx;
-       ctx = kzalloc(sizeof *ctx, GFP_KERNEL);
+       ctx = kmalloc(sizeof *ctx, GFP_KERNEL);
        if (!ctx)
                goto out;
        /* Binding to physical processor deferred
@@ -47,8 +47,11 @@ struct spu_context *alloc_spu_context(void)
        init_waitqueue_head(&ctx->ibox_wq);
        init_waitqueue_head(&ctx->wbox_wq);
        init_waitqueue_head(&ctx->stop_wq);
-       init_waitqueue_head(&ctx->mfc_wq);
+       ctx->ibox_fasync = NULL;
+       ctx->wbox_fasync = NULL;
        ctx->state = SPU_STATE_SAVED;
+       ctx->local_store = local_store;
+       ctx->spu = NULL;
        ctx->ops = &spu_backing_ops;
        ctx->owner = get_task_mm(current);
        goto out;
@@ -65,6 +68,8 @@ void destroy_spu_context(struct kref *kref)
        ctx = container_of(kref, struct spu_context, kref);
        down_write(&ctx->state_sema);
        spu_deactivate(ctx);
+       ctx->ibox_fasync = NULL;
+       ctx->wbox_fasync = NULL;
        up_write(&ctx->state_sema);
        spu_fini_csa(&ctx->csa);
        kfree(ctx);
@@ -104,16 +109,7 @@ void spu_release(struct spu_context *ctx)
 
 void spu_unmap_mappings(struct spu_context *ctx)
 {
-       if (ctx->local_store)
-               unmap_mapping_range(ctx->local_store, 0, LS_SIZE, 1);
-       if (ctx->mfc)
-               unmap_mapping_range(ctx->mfc, 0, 0x4000, 1);
-       if (ctx->cntl)
-               unmap_mapping_range(ctx->cntl, 0, 0x4000, 1);
-       if (ctx->signal1)
-               unmap_mapping_range(ctx->signal1, 0, 0x4000, 1);
-       if (ctx->signal2)
-               unmap_mapping_range(ctx->signal2, 0, 0x4000, 1);
+       unmap_mapping_range(ctx->local_store, 0, LS_SIZE, 1);
 }
 
 int spu_acquire_runnable(struct spu_context *ctx)