[POWERPC] spufs: Use SPU master control to prevent wild SPU execution
[pandora-kernel.git] / arch / powerpc / platforms / cell / spufs / inode.c
1 /*
2  * SPU file system
3  *
4  * (C) Copyright IBM Deutschland Entwicklung GmbH 2005
5  *
6  * Author: Arnd Bergmann <arndb@de.ibm.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */
22
23 #include <linux/file.h>
24 #include <linux/fs.h>
25 #include <linux/backing-dev.h>
26 #include <linux/init.h>
27 #include <linux/ioctl.h>
28 #include <linux/module.h>
29 #include <linux/mount.h>
30 #include <linux/namei.h>
31 #include <linux/pagemap.h>
32 #include <linux/poll.h>
33 #include <linux/slab.h>
34 #include <linux/parser.h>
35
36 #include <asm/prom.h>
37 #include <asm/spu_priv1.h>
38 #include <asm/io.h>
39 #include <asm/semaphore.h>
40 #include <asm/spu.h>
41 #include <asm/uaccess.h>
42
43 #include "spufs.h"
44
45 static kmem_cache_t *spufs_inode_cache;
46 static char *isolated_loader;
47
48 static struct inode *
49 spufs_alloc_inode(struct super_block *sb)
50 {
51         struct spufs_inode_info *ei;
52
53         ei = kmem_cache_alloc(spufs_inode_cache, SLAB_KERNEL);
54         if (!ei)
55                 return NULL;
56
57         ei->i_gang = NULL;
58         ei->i_ctx = NULL;
59
60         return &ei->vfs_inode;
61 }
62
63 static void
64 spufs_destroy_inode(struct inode *inode)
65 {
66         kmem_cache_free(spufs_inode_cache, SPUFS_I(inode));
67 }
68
69 static void
70 spufs_init_once(void *p, kmem_cache_t * cachep, unsigned long flags)
71 {
72         struct spufs_inode_info *ei = p;
73
74         if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
75             SLAB_CTOR_CONSTRUCTOR) {
76                 inode_init_once(&ei->vfs_inode);
77         }
78 }
79
80 static struct inode *
81 spufs_new_inode(struct super_block *sb, int mode)
82 {
83         struct inode *inode;
84
85         inode = new_inode(sb);
86         if (!inode)
87                 goto out;
88
89         inode->i_mode = mode;
90         inode->i_uid = current->fsuid;
91         inode->i_gid = current->fsgid;
92         inode->i_blocks = 0;
93         inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
94 out:
95         return inode;
96 }
97
98 static int
99 spufs_setattr(struct dentry *dentry, struct iattr *attr)
100 {
101         struct inode *inode = dentry->d_inode;
102
103         if ((attr->ia_valid & ATTR_SIZE) &&
104             (attr->ia_size != inode->i_size))
105                 return -EINVAL;
106         return inode_setattr(inode, attr);
107 }
108
109
110 static int
111 spufs_new_file(struct super_block *sb, struct dentry *dentry,
112                 const struct file_operations *fops, int mode,
113                 struct spu_context *ctx)
114 {
115         static struct inode_operations spufs_file_iops = {
116                 .setattr = spufs_setattr,
117         };
118         struct inode *inode;
119         int ret;
120
121         ret = -ENOSPC;
122         inode = spufs_new_inode(sb, S_IFREG | mode);
123         if (!inode)
124                 goto out;
125
126         ret = 0;
127         inode->i_op = &spufs_file_iops;
128         inode->i_fop = fops;
129         inode->i_private = SPUFS_I(inode)->i_ctx = get_spu_context(ctx);
130         d_add(dentry, inode);
131 out:
132         return ret;
133 }
134
135 static void
136 spufs_delete_inode(struct inode *inode)
137 {
138         struct spufs_inode_info *ei = SPUFS_I(inode);
139
140         if (ei->i_ctx)
141                 put_spu_context(ei->i_ctx);
142         if (ei->i_gang)
143                 put_spu_gang(ei->i_gang);
144         clear_inode(inode);
145 }
146
147 static void spufs_prune_dir(struct dentry *dir)
148 {
149         struct dentry *dentry, *tmp;
150
151         mutex_lock(&dir->d_inode->i_mutex);
152         list_for_each_entry_safe(dentry, tmp, &dir->d_subdirs, d_u.d_child) {
153                 spin_lock(&dcache_lock);
154                 spin_lock(&dentry->d_lock);
155                 if (!(d_unhashed(dentry)) && dentry->d_inode) {
156                         dget_locked(dentry);
157                         __d_drop(dentry);
158                         spin_unlock(&dentry->d_lock);
159                         simple_unlink(dir->d_inode, dentry);
160                         spin_unlock(&dcache_lock);
161                         dput(dentry);
162                 } else {
163                         spin_unlock(&dentry->d_lock);
164                         spin_unlock(&dcache_lock);
165                 }
166         }
167         shrink_dcache_parent(dir);
168         mutex_unlock(&dir->d_inode->i_mutex);
169 }
170
171 /* Caller must hold parent->i_mutex */
172 static int spufs_rmdir(struct inode *parent, struct dentry *dir)
173 {
174         /* remove all entries */
175         spufs_prune_dir(dir);
176
177         return simple_rmdir(parent, dir);
178 }
179
180 static int spufs_fill_dir(struct dentry *dir, struct tree_descr *files,
181                           int mode, struct spu_context *ctx)
182 {
183         struct dentry *dentry;
184         int ret;
185
186         while (files->name && files->name[0]) {
187                 ret = -ENOMEM;
188                 dentry = d_alloc_name(dir, files->name);
189                 if (!dentry)
190                         goto out;
191                 ret = spufs_new_file(dir->d_sb, dentry, files->ops,
192                                         files->mode & mode, ctx);
193                 if (ret)
194                         goto out;
195                 files++;
196         }
197         return 0;
198 out:
199         spufs_prune_dir(dir);
200         return ret;
201 }
202
203 static int spufs_dir_close(struct inode *inode, struct file *file)
204 {
205         struct spu_context *ctx;
206         struct inode *parent;
207         struct dentry *dir;
208         int ret;
209
210         dir = file->f_dentry;
211         parent = dir->d_parent->d_inode;
212         ctx = SPUFS_I(dir->d_inode)->i_ctx;
213
214         mutex_lock(&parent->i_mutex);
215         ret = spufs_rmdir(parent, dir);
216         mutex_unlock(&parent->i_mutex);
217         WARN_ON(ret);
218
219         /* We have to give up the mm_struct */
220         spu_forget(ctx);
221
222         return dcache_dir_close(inode, file);
223 }
224
225 struct inode_operations spufs_dir_inode_operations = {
226         .lookup = simple_lookup,
227 };
228
229 struct file_operations spufs_context_fops = {
230         .open           = dcache_dir_open,
231         .release        = spufs_dir_close,
232         .llseek         = dcache_dir_lseek,
233         .read           = generic_read_dir,
234         .readdir        = dcache_readdir,
235         .fsync          = simple_sync_file,
236 };
237
238 static int spu_setup_isolated(struct spu_context *ctx)
239 {
240         int ret;
241         u64 __iomem *mfc_cntl;
242         u64 sr1;
243         u32 status;
244         unsigned long timeout;
245         const u32 status_loading = SPU_STATUS_RUNNING
246                 | SPU_STATUS_ISOLATED_STATE | SPU_STATUS_ISOLATED_LOAD_STATUS;
247
248         if (!isolated_loader)
249                 return -ENODEV;
250
251         /* prevent concurrent operation with spu_run */
252         down(&ctx->run_sema);
253         ctx->ops->master_start(ctx);
254
255         ret = spu_acquire_exclusive(ctx);
256         if (ret)
257                 goto out;
258
259         mfc_cntl = &ctx->spu->priv2->mfc_control_RW;
260
261         /* purge the MFC DMA queue to ensure no spurious accesses before we
262          * enter kernel mode */
263         timeout = jiffies + HZ;
264         out_be64(mfc_cntl, MFC_CNTL_PURGE_DMA_REQUEST);
265         while ((in_be64(mfc_cntl) & MFC_CNTL_PURGE_DMA_STATUS_MASK)
266                         != MFC_CNTL_PURGE_DMA_COMPLETE) {
267                 if (time_after(jiffies, timeout)) {
268                         printk(KERN_ERR "%s: timeout flushing MFC DMA queue\n",
269                                         __FUNCTION__);
270                         ret = -EIO;
271                         goto out_unlock;
272                 }
273                 cond_resched();
274         }
275
276         /* put the SPE in kernel mode to allow access to the loader */
277         sr1 = spu_mfc_sr1_get(ctx->spu);
278         sr1 &= ~MFC_STATE1_PROBLEM_STATE_MASK;
279         spu_mfc_sr1_set(ctx->spu, sr1);
280
281         /* start the loader */
282         ctx->ops->signal1_write(ctx, (unsigned long)isolated_loader >> 32);
283         ctx->ops->signal2_write(ctx,
284                         (unsigned long)isolated_loader & 0xffffffff);
285
286         ctx->ops->runcntl_write(ctx,
287                         SPU_RUNCNTL_RUNNABLE | SPU_RUNCNTL_ISOLATE);
288
289         ret = 0;
290         timeout = jiffies + HZ;
291         while (((status = ctx->ops->status_read(ctx)) & status_loading) ==
292                                 status_loading) {
293                 if (time_after(jiffies, timeout)) {
294                         printk(KERN_ERR "%s: timeout waiting for loader\n",
295                                         __FUNCTION__);
296                         ret = -EIO;
297                         goto out_drop_priv;
298                 }
299                 cond_resched();
300         }
301
302         if (!(status & SPU_STATUS_RUNNING)) {
303                 /* If isolated LOAD has failed: run SPU, we will get a stop-and
304                  * signal later. */
305                 pr_debug("%s: isolated LOAD failed\n", __FUNCTION__);
306                 ctx->ops->runcntl_write(ctx, SPU_RUNCNTL_RUNNABLE);
307                 ret = -EACCES;
308
309         } else if (!(status & SPU_STATUS_ISOLATED_STATE)) {
310                 /* This isn't allowed by the CBEA, but check anyway */
311                 pr_debug("%s: SPU fell out of isolated mode?\n", __FUNCTION__);
312                 ctx->ops->runcntl_write(ctx, SPU_RUNCNTL_STOP);
313                 ret = -EINVAL;
314         }
315
316 out_drop_priv:
317         /* Finished accessing the loader. Drop kernel mode */
318         sr1 |= MFC_STATE1_PROBLEM_STATE_MASK;
319         spu_mfc_sr1_set(ctx->spu, sr1);
320
321 out_unlock:
322         spu_release_exclusive(ctx);
323 out:
324         ctx->ops->master_stop(ctx);
325         up(&ctx->run_sema);
326         return ret;
327 }
328
329 int spu_recycle_isolated(struct spu_context *ctx)
330 {
331         return spu_setup_isolated(ctx);
332 }
333
334 static int
335 spufs_mkdir(struct inode *dir, struct dentry *dentry, unsigned int flags,
336                 int mode)
337 {
338         int ret;
339         struct inode *inode;
340         struct spu_context *ctx;
341
342         ret = -ENOSPC;
343         inode = spufs_new_inode(dir->i_sb, mode | S_IFDIR);
344         if (!inode)
345                 goto out;
346
347         if (dir->i_mode & S_ISGID) {
348                 inode->i_gid = dir->i_gid;
349                 inode->i_mode &= S_ISGID;
350         }
351         ctx = alloc_spu_context(SPUFS_I(dir)->i_gang); /* XXX gang */
352         SPUFS_I(inode)->i_ctx = ctx;
353         if (!ctx)
354                 goto out_iput;
355
356         ctx->flags = flags;
357         inode->i_op = &spufs_dir_inode_operations;
358         inode->i_fop = &simple_dir_operations;
359         if (flags & SPU_CREATE_NOSCHED)
360                 ret = spufs_fill_dir(dentry, spufs_dir_nosched_contents,
361                                          mode, ctx);
362         else
363                 ret = spufs_fill_dir(dentry, spufs_dir_contents, mode, ctx);
364
365         if (ret)
366                 goto out_free_ctx;
367
368         d_instantiate(dentry, inode);
369         dget(dentry);
370         dir->i_nlink++;
371         dentry->d_inode->i_nlink++;
372         goto out;
373
374 out_free_ctx:
375         put_spu_context(ctx);
376 out_iput:
377         iput(inode);
378 out:
379         return ret;
380 }
381
382 static int spufs_context_open(struct dentry *dentry, struct vfsmount *mnt)
383 {
384         int ret;
385         struct file *filp;
386
387         ret = get_unused_fd();
388         if (ret < 0) {
389                 dput(dentry);
390                 mntput(mnt);
391                 goto out;
392         }
393
394         filp = dentry_open(dentry, mnt, O_RDONLY);
395         if (IS_ERR(filp)) {
396                 put_unused_fd(ret);
397                 ret = PTR_ERR(filp);
398                 goto out;
399         }
400
401         filp->f_op = &spufs_context_fops;
402         fd_install(ret, filp);
403 out:
404         return ret;
405 }
406
407 static int spufs_create_context(struct inode *inode,
408                         struct dentry *dentry,
409                         struct vfsmount *mnt, int flags, int mode)
410 {
411         int ret;
412
413         ret = -EPERM;
414         if ((flags & SPU_CREATE_NOSCHED) &&
415             !capable(CAP_SYS_NICE))
416                 goto out_unlock;
417
418         ret = -EINVAL;
419         if ((flags & (SPU_CREATE_NOSCHED | SPU_CREATE_ISOLATE))
420             == SPU_CREATE_ISOLATE)
421                 goto out_unlock;
422
423         ret = spufs_mkdir(inode, dentry, flags, mode & S_IRWXUGO);
424         if (ret)
425                 goto out_unlock;
426
427         /*
428          * get references for dget and mntget, will be released
429          * in error path of *_open().
430          */
431         ret = spufs_context_open(dget(dentry), mntget(mnt));
432         if (ret < 0) {
433                 WARN_ON(spufs_rmdir(inode, dentry));
434                 mutex_unlock(&inode->i_mutex);
435                 spu_forget(SPUFS_I(dentry->d_inode)->i_ctx);
436                 goto out;
437         }
438
439 out_unlock:
440         mutex_unlock(&inode->i_mutex);
441 out:
442         if (ret >= 0 && (flags & SPU_CREATE_ISOLATE)) {
443                 int setup_err = spu_setup_isolated(
444                                 SPUFS_I(dentry->d_inode)->i_ctx);
445                 /* FIXME: clean up context again on failure to avoid
446                           leak. */
447                 if (setup_err)
448                         ret = setup_err;
449         }
450
451         dput(dentry);
452         return ret;
453 }
454
455 static int spufs_rmgang(struct inode *root, struct dentry *dir)
456 {
457         /* FIXME: this fails if the dir is not empty,
458                   which causes a leak of gangs. */
459         return simple_rmdir(root, dir);
460 }
461
462 static int spufs_gang_close(struct inode *inode, struct file *file)
463 {
464         struct inode *parent;
465         struct dentry *dir;
466         int ret;
467
468         dir = file->f_dentry;
469         parent = dir->d_parent->d_inode;
470
471         ret = spufs_rmgang(parent, dir);
472         WARN_ON(ret);
473
474         return dcache_dir_close(inode, file);
475 }
476
477 struct file_operations spufs_gang_fops = {
478         .open           = dcache_dir_open,
479         .release        = spufs_gang_close,
480         .llseek         = dcache_dir_lseek,
481         .read           = generic_read_dir,
482         .readdir        = dcache_readdir,
483         .fsync          = simple_sync_file,
484 };
485
486 static int
487 spufs_mkgang(struct inode *dir, struct dentry *dentry, int mode)
488 {
489         int ret;
490         struct inode *inode;
491         struct spu_gang *gang;
492
493         ret = -ENOSPC;
494         inode = spufs_new_inode(dir->i_sb, mode | S_IFDIR);
495         if (!inode)
496                 goto out;
497
498         ret = 0;
499         if (dir->i_mode & S_ISGID) {
500                 inode->i_gid = dir->i_gid;
501                 inode->i_mode &= S_ISGID;
502         }
503         gang = alloc_spu_gang();
504         SPUFS_I(inode)->i_ctx = NULL;
505         SPUFS_I(inode)->i_gang = gang;
506         if (!gang)
507                 goto out_iput;
508
509         inode->i_op = &spufs_dir_inode_operations;
510         inode->i_fop = &simple_dir_operations;
511
512         d_instantiate(dentry, inode);
513         dget(dentry);
514         dir->i_nlink++;
515         dentry->d_inode->i_nlink++;
516         return ret;
517
518 out_iput:
519         iput(inode);
520 out:
521         return ret;
522 }
523
524 static int spufs_gang_open(struct dentry *dentry, struct vfsmount *mnt)
525 {
526         int ret;
527         struct file *filp;
528
529         ret = get_unused_fd();
530         if (ret < 0) {
531                 dput(dentry);
532                 mntput(mnt);
533                 goto out;
534         }
535
536         filp = dentry_open(dentry, mnt, O_RDONLY);
537         if (IS_ERR(filp)) {
538                 put_unused_fd(ret);
539                 ret = PTR_ERR(filp);
540                 goto out;
541         }
542
543         filp->f_op = &spufs_gang_fops;
544         fd_install(ret, filp);
545 out:
546         return ret;
547 }
548
549 static int spufs_create_gang(struct inode *inode,
550                         struct dentry *dentry,
551                         struct vfsmount *mnt, int mode)
552 {
553         int ret;
554
555         ret = spufs_mkgang(inode, dentry, mode & S_IRWXUGO);
556         if (ret)
557                 goto out;
558
559         /*
560          * get references for dget and mntget, will be released
561          * in error path of *_open().
562          */
563         ret = spufs_gang_open(dget(dentry), mntget(mnt));
564         if (ret < 0)
565                 WARN_ON(spufs_rmgang(inode, dentry));
566
567 out:
568         mutex_unlock(&inode->i_mutex);
569         dput(dentry);
570         return ret;
571 }
572
573
574 static struct file_system_type spufs_type;
575
576 long spufs_create(struct nameidata *nd, unsigned int flags, mode_t mode)
577 {
578         struct dentry *dentry;
579         int ret;
580
581         ret = -EINVAL;
582         /* check if we are on spufs */
583         if (nd->dentry->d_sb->s_type != &spufs_type)
584                 goto out;
585
586         /* don't accept undefined flags */
587         if (flags & (~SPU_CREATE_FLAG_ALL))
588                 goto out;
589
590         /* only threads can be underneath a gang */
591         if (nd->dentry != nd->dentry->d_sb->s_root) {
592                 if ((flags & SPU_CREATE_GANG) ||
593                     !SPUFS_I(nd->dentry->d_inode)->i_gang)
594                         goto out;
595         }
596
597         dentry = lookup_create(nd, 1);
598         ret = PTR_ERR(dentry);
599         if (IS_ERR(dentry))
600                 goto out_dir;
601
602         ret = -EEXIST;
603         if (dentry->d_inode)
604                 goto out_dput;
605
606         mode &= ~current->fs->umask;
607
608         if (flags & SPU_CREATE_GANG)
609                 return spufs_create_gang(nd->dentry->d_inode,
610                                         dentry, nd->mnt, mode);
611         else
612                 return spufs_create_context(nd->dentry->d_inode,
613                                         dentry, nd->mnt, flags, mode);
614
615 out_dput:
616         dput(dentry);
617 out_dir:
618         mutex_unlock(&nd->dentry->d_inode->i_mutex);
619 out:
620         return ret;
621 }
622
623 /* File system initialization */
624 enum {
625         Opt_uid, Opt_gid, Opt_err,
626 };
627
628 static match_table_t spufs_tokens = {
629         { Opt_uid, "uid=%d" },
630         { Opt_gid, "gid=%d" },
631         { Opt_err, NULL  },
632 };
633
634 static int
635 spufs_parse_options(char *options, struct inode *root)
636 {
637         char *p;
638         substring_t args[MAX_OPT_ARGS];
639
640         while ((p = strsep(&options, ",")) != NULL) {
641                 int token, option;
642
643                 if (!*p)
644                         continue;
645
646                 token = match_token(p, spufs_tokens, args);
647                 switch (token) {
648                 case Opt_uid:
649                         if (match_int(&args[0], &option))
650                                 return 0;
651                         root->i_uid = option;
652                         break;
653                 case Opt_gid:
654                         if (match_int(&args[0], &option))
655                                 return 0;
656                         root->i_gid = option;
657                         break;
658                 default:
659                         return 0;
660                 }
661         }
662         return 1;
663 }
664
665 static void
666 spufs_init_isolated_loader(void)
667 {
668         struct device_node *dn;
669         const char *loader;
670         int size;
671
672         dn = of_find_node_by_path("/spu-isolation");
673         if (!dn)
674                 return;
675
676         loader = get_property(dn, "loader", &size);
677         if (!loader)
678                 return;
679
680         /* kmalloc should align on a 16 byte boundary..* */
681         isolated_loader = kmalloc(size, GFP_KERNEL);
682         if (!isolated_loader)
683                 return;
684
685         memcpy(isolated_loader, loader, size);
686         printk(KERN_INFO "spufs: SPU isolation mode enabled\n");
687 }
688
689 static int
690 spufs_create_root(struct super_block *sb, void *data)
691 {
692         struct inode *inode;
693         int ret;
694
695         ret = -ENOMEM;
696         inode = spufs_new_inode(sb, S_IFDIR | 0775);
697         if (!inode)
698                 goto out;
699
700         inode->i_op = &spufs_dir_inode_operations;
701         inode->i_fop = &simple_dir_operations;
702         SPUFS_I(inode)->i_ctx = NULL;
703
704         ret = -EINVAL;
705         if (!spufs_parse_options(data, inode))
706                 goto out_iput;
707
708         ret = -ENOMEM;
709         sb->s_root = d_alloc_root(inode);
710         if (!sb->s_root)
711                 goto out_iput;
712
713         return 0;
714 out_iput:
715         iput(inode);
716 out:
717         return ret;
718 }
719
720 static int
721 spufs_fill_super(struct super_block *sb, void *data, int silent)
722 {
723         static struct super_operations s_ops = {
724                 .alloc_inode = spufs_alloc_inode,
725                 .destroy_inode = spufs_destroy_inode,
726                 .statfs = simple_statfs,
727                 .delete_inode = spufs_delete_inode,
728                 .drop_inode = generic_delete_inode,
729         };
730
731         sb->s_maxbytes = MAX_LFS_FILESIZE;
732         sb->s_blocksize = PAGE_CACHE_SIZE;
733         sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
734         sb->s_magic = SPUFS_MAGIC;
735         sb->s_op = &s_ops;
736
737         return spufs_create_root(sb, data);
738 }
739
740 static int
741 spufs_get_sb(struct file_system_type *fstype, int flags,
742                 const char *name, void *data, struct vfsmount *mnt)
743 {
744         return get_sb_single(fstype, flags, data, spufs_fill_super, mnt);
745 }
746
747 static struct file_system_type spufs_type = {
748         .owner = THIS_MODULE,
749         .name = "spufs",
750         .get_sb = spufs_get_sb,
751         .kill_sb = kill_litter_super,
752 };
753
754 static int __init spufs_init(void)
755 {
756         int ret;
757         ret = -ENOMEM;
758         spufs_inode_cache = kmem_cache_create("spufs_inode_cache",
759                         sizeof(struct spufs_inode_info), 0,
760                         SLAB_HWCACHE_ALIGN, spufs_init_once, NULL);
761
762         if (!spufs_inode_cache)
763                 goto out;
764         if (spu_sched_init() != 0) {
765                 kmem_cache_destroy(spufs_inode_cache);
766                 goto out;
767         }
768         ret = register_filesystem(&spufs_type);
769         if (ret)
770                 goto out_cache;
771         ret = register_spu_syscalls(&spufs_calls);
772         if (ret)
773                 goto out_fs;
774
775         spufs_init_isolated_loader();
776         return 0;
777 out_fs:
778         unregister_filesystem(&spufs_type);
779 out_cache:
780         kmem_cache_destroy(spufs_inode_cache);
781 out:
782         return ret;
783 }
784 module_init(spufs_init);
785
786 static void __exit spufs_exit(void)
787 {
788         spu_sched_exit();
789         unregister_spu_syscalls(&spufs_calls);
790         unregister_filesystem(&spufs_type);
791         kmem_cache_destroy(spufs_inode_cache);
792 }
793 module_exit(spufs_exit);
794
795 MODULE_LICENSE("GPL");
796 MODULE_AUTHOR("Arnd Bergmann <arndb@de.ibm.com>");
797