]>
git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - arch/powerpc/platforms/cell/spufs/context.c
2 * SPU file system -- SPU context management
4 * (C) Copyright IBM Deutschland Entwicklung GmbH 2005
6 * Author: Arnd Bergmann <arndb@de.ibm.com>
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)
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.
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.
23 #include <linux/slab.h>
25 #include <asm/spu_csa.h>
28 struct spu_context
*alloc_spu_context(void)
30 struct spu_context
*ctx
;
31 ctx
= kmalloc(sizeof *ctx
, GFP_KERNEL
);
34 /* Future enhancement: do not call spu_alloc()
35 * here. This step should be deferred until
38 * More work needs to be done to read(),
39 * write(), mmap(), etc., so that operations
40 * are performed on CSA when the context is
41 * not currently being run. In this way we
42 * can support arbitrarily large number of
43 * entries in /spu, allow state queries, etc.
45 ctx
->spu
= spu_alloc();
48 spu_init_csa(&ctx
->csa
);
49 if (!ctx
->csa
.lscsa
) {
53 init_rwsem(&ctx
->backing_sema
);
54 spin_lock_init(&ctx
->mmio_lock
);
55 kref_init(&ctx
->kref
);
64 void destroy_spu_context(struct kref
*kref
)
66 struct spu_context
*ctx
;
67 ctx
= container_of(kref
, struct spu_context
, kref
);
70 spu_fini_csa(&ctx
->csa
);
74 struct spu_context
* get_spu_context(struct spu_context
*ctx
)
80 int put_spu_context(struct spu_context
*ctx
)
82 return kref_put(&ctx
->kref
, &destroy_spu_context
);