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>
27 struct spu_context *alloc_spu_context(void)
29 struct spu_context *ctx;
30 ctx = kmalloc(sizeof *ctx, GFP_KERNEL);
33 ctx->spu = spu_alloc();
36 init_rwsem(&ctx->backing_sema);
37 spin_lock_init(&ctx->mmio_lock);
38 kref_init(&ctx->kref);
47 void destroy_spu_context(struct kref *kref)
49 struct spu_context *ctx;
50 ctx = container_of(kref, struct spu_context, kref);
56 struct spu_context * get_spu_context(struct spu_context *ctx)
62 int put_spu_context(struct spu_context *ctx)
64 return kref_put(&ctx->kref, &destroy_spu_context);