Merge branch 'for-linus' of ssh://master.kernel.org/pub/scm/linux/kernel/git/ieee1394...
[pandora-kernel.git] / arch / powerpc / platforms / cell / spufs / inode.c
index 9e457be..8079983 100644 (file)
 #include <linux/parser.h>
 
 #include <asm/prom.h>
-#include <asm/spu_priv1.h>
-#include <asm/io.h>
 #include <asm/semaphore.h>
 #include <asm/spu.h>
 #include <asm/uaccess.h>
 
 #include "spufs.h"
 
-static kmem_cache_t *spufs_inode_cache;
-static char *isolated_loader;
+static struct kmem_cache *spufs_inode_cache;
+char *isolated_loader;
 
 static struct inode *
 spufs_alloc_inode(struct super_block *sb)
 {
        struct spufs_inode_info *ei;
 
-       ei = kmem_cache_alloc(spufs_inode_cache, SLAB_KERNEL);
+       ei = kmem_cache_alloc(spufs_inode_cache, GFP_KERNEL);
        if (!ei)
                return NULL;
 
@@ -67,7 +65,7 @@ spufs_destroy_inode(struct inode *inode)
 }
 
 static void
-spufs_init_once(void *p, kmem_cache_t * cachep, unsigned long flags)
+spufs_init_once(void *p, struct kmem_cache * cachep, unsigned long flags)
 {
        struct spufs_inode_info *ei = p;
 
@@ -207,7 +205,7 @@ static int spufs_dir_close(struct inode *inode, struct file *file)
        struct dentry *dir;
        int ret;
 
-       dir = file->f_dentry;
+       dir = file->f_path.dentry;
        parent = dir->d_parent->d_inode;
        ctx = SPUFS_I(dir->d_inode)->i_ctx;
 
@@ -222,11 +220,11 @@ static int spufs_dir_close(struct inode *inode, struct file *file)
        return dcache_dir_close(inode, file);
 }
 
-struct inode_operations spufs_dir_inode_operations = {
+const struct inode_operations spufs_dir_inode_operations = {
        .lookup = simple_lookup,
 };
 
-struct file_operations spufs_context_fops = {
+const struct file_operations spufs_context_fops = {
        .open           = dcache_dir_open,
        .release        = spufs_dir_close,
        .llseek         = dcache_dir_lseek,
@@ -234,95 +232,7 @@ struct file_operations spufs_context_fops = {
        .readdir        = dcache_readdir,
        .fsync          = simple_sync_file,
 };
-
-static int spu_setup_isolated(struct spu_context *ctx)
-{
-       int ret;
-       u64 __iomem *mfc_cntl;
-       u64 sr1;
-       u32 status;
-       unsigned long timeout;
-       const u32 status_loading = SPU_STATUS_RUNNING
-               | SPU_STATUS_ISOLATED_STATE | SPU_STATUS_ISOLATED_LOAD_STATUS;
-
-       if (!isolated_loader)
-               return -ENODEV;
-
-       if ((ret = spu_acquire_exclusive(ctx)) != 0)
-               return ret;
-
-       mfc_cntl = &ctx->spu->priv2->mfc_control_RW;
-
-       /* purge the MFC DMA queue to ensure no spurious accesses before we
-        * enter kernel mode */
-       timeout = jiffies + HZ;
-       out_be64(mfc_cntl, MFC_CNTL_PURGE_DMA_REQUEST);
-       while ((in_be64(mfc_cntl) & MFC_CNTL_PURGE_DMA_STATUS_MASK)
-                       != MFC_CNTL_PURGE_DMA_COMPLETE) {
-               if (time_after(jiffies, timeout)) {
-                       printk(KERN_ERR "%s: timeout flushing MFC DMA queue\n",
-                                       __FUNCTION__);
-                       ret = -EIO;
-                       goto out_unlock;
-               }
-               cond_resched();
-       }
-
-       /* put the SPE in kernel mode to allow access to the loader */
-       sr1 = spu_mfc_sr1_get(ctx->spu);
-       sr1 &= ~MFC_STATE1_PROBLEM_STATE_MASK;
-       spu_mfc_sr1_set(ctx->spu, sr1);
-
-       /* start the loader */
-       ctx->ops->signal1_write(ctx, (unsigned long)isolated_loader >> 32);
-       ctx->ops->signal2_write(ctx,
-                       (unsigned long)isolated_loader & 0xffffffff);
-
-       ctx->ops->runcntl_write(ctx,
-                       SPU_RUNCNTL_RUNNABLE | SPU_RUNCNTL_ISOLATE);
-
-       ret = 0;
-       timeout = jiffies + HZ;
-       while (((status = ctx->ops->status_read(ctx)) & status_loading) ==
-                               status_loading) {
-               if (time_after(jiffies, timeout)) {
-                       printk(KERN_ERR "%s: timeout waiting for loader\n",
-                                       __FUNCTION__);
-                       ret = -EIO;
-                       goto out_drop_priv;
-               }
-               cond_resched();
-       }
-
-       if (!(status & SPU_STATUS_RUNNING)) {
-               /* If isolated LOAD has failed: run SPU, we will get a stop-and
-                * signal later. */
-               pr_debug("%s: isolated LOAD failed\n", __FUNCTION__);
-               ctx->ops->runcntl_write(ctx, SPU_RUNCNTL_RUNNABLE);
-               ret = -EACCES;
-
-       } else if (!(status & SPU_STATUS_ISOLATED_STATE)) {
-               /* This isn't allowed by the CBEA, but check anyway */
-               pr_debug("%s: SPU fell out of isolated mode?\n", __FUNCTION__);
-               ctx->ops->runcntl_write(ctx, SPU_RUNCNTL_STOP);
-               ret = -EINVAL;
-       }
-
-out_drop_priv:
-       /* Finished accessing the loader. Drop kernel mode */
-       sr1 |= MFC_STATE1_PROBLEM_STATE_MASK;
-       spu_mfc_sr1_set(ctx->spu, sr1);
-
-out_unlock:
-       spu_release_exclusive(ctx);
-       return ret;
-}
-
-int spu_recycle_isolated(struct spu_context *ctx)
-{
-       ctx->ops->runcntl_stop(ctx);
-       return spu_setup_isolated(ctx);
-}
+EXPORT_SYMBOL_GPL(spufs_context_fops);
 
 static int
 spufs_mkdir(struct inode *dir, struct dentry *dentry, unsigned int flags,
@@ -413,6 +323,10 @@ static int spufs_create_context(struct inode *inode,
            == SPU_CREATE_ISOLATE)
                goto out_unlock;
 
+       ret = -ENODEV;
+       if ((flags & SPU_CREATE_ISOLATE) && !isolated_loader)
+               goto out_unlock;
+
        ret = spufs_mkdir(inode, dentry, flags, mode & S_IRWXUGO);
        if (ret)
                goto out_unlock;
@@ -432,13 +346,6 @@ static int spufs_create_context(struct inode *inode,
 out_unlock:
        mutex_unlock(&inode->i_mutex);
 out:
-       if (ret >= 0 && (flags & SPU_CREATE_ISOLATE)) {
-               int setup_err = spu_setup_isolated(
-                               SPUFS_I(dentry->d_inode)->i_ctx);
-               if (setup_err)
-                       ret = setup_err;
-       }
-
        dput(dentry);
        return ret;
 }
@@ -456,7 +363,7 @@ static int spufs_gang_close(struct inode *inode, struct file *file)
        struct dentry *dir;
        int ret;
 
-       dir = file->f_dentry;
+       dir = file->f_path.dentry;
        parent = dir->d_parent->d_inode;
 
        ret = spufs_rmgang(parent, dir);
@@ -465,7 +372,7 @@ static int spufs_gang_close(struct inode *inode, struct file *file)
        return dcache_dir_close(inode, file);
 }
 
-struct file_operations spufs_gang_fops = {
+const struct file_operations spufs_gang_fops = {
        .open           = dcache_dir_open,
        .release        = spufs_gang_close,
        .llseek         = dcache_dir_lseek,
@@ -745,6 +652,7 @@ static struct file_system_type spufs_type = {
 static int __init spufs_init(void)
 {
        int ret;
+
        ret = -ENOMEM;
        spufs_inode_cache = kmem_cache_create("spufs_inode_cache",
                        sizeof(struct spufs_inode_info), 0,
@@ -760,10 +668,14 @@ static int __init spufs_init(void)
        if (ret)
                goto out_cache;
        ret = register_spu_syscalls(&spufs_calls);
+       if (ret)
+               goto out_fs;
+       ret = register_arch_coredump_calls(&spufs_coredump_calls);
        if (ret)
                goto out_fs;
 
        spufs_init_isolated_loader();
+
        return 0;
 out_fs:
        unregister_filesystem(&spufs_type);
@@ -777,6 +689,7 @@ module_init(spufs_init);
 static void __exit spufs_exit(void)
 {
        spu_sched_exit();
+       unregister_arch_coredump_calls(&spufs_coredump_calls);
        unregister_spu_syscalls(&spufs_calls);
        unregister_filesystem(&spufs_type);
        kmem_cache_destroy(spufs_inode_cache);