Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 38991
b: refs/heads/master
c: 6263203
h: refs/heads/master
i:
  38989: df433d7
  38987: ce2262e
  38983: 1f06908
  38975: dc63371
v: v3
  • Loading branch information
Arnd Bergmann authored and Paul Mackerras committed Oct 4, 2006
1 parent 4c96dc5 commit e03e508
Show file tree
Hide file tree
Showing 8 changed files with 304 additions and 43 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9add11daeee2f6d69f6b86237f197824332a4a3b
refs/heads/master: 6263203ed6e9ff107129a1ebe613290b342a4465
2 changes: 1 addition & 1 deletion trunk/arch/powerpc/platforms/cell/spufs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ obj-y += switch.o

obj-$(CONFIG_SPU_FS) += spufs.o
spufs-y += inode.o file.o context.o syscalls.o
spufs-y += sched.o backing_ops.o hw_ops.o run.o
spufs-y += sched.o backing_ops.o hw_ops.o run.o gang.o

# Rules to build switch.o with the help of SPU tool chain
SPU_CROSS := spu-
Expand Down
6 changes: 5 additions & 1 deletion trunk/arch/powerpc/platforms/cell/spufs/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <asm/spu_csa.h>
#include "spufs.h"

struct spu_context *alloc_spu_context(void)
struct spu_context *alloc_spu_context(struct spu_gang *gang)
{
struct spu_context *ctx;
ctx = kzalloc(sizeof *ctx, GFP_KERNEL);
Expand All @@ -51,6 +51,8 @@ struct spu_context *alloc_spu_context(void)
ctx->state = SPU_STATE_SAVED;
ctx->ops = &spu_backing_ops;
ctx->owner = get_task_mm(current);
if (gang)
spu_gang_add_ctx(gang, ctx);
goto out;
out_free:
kfree(ctx);
Expand All @@ -67,6 +69,8 @@ void destroy_spu_context(struct kref *kref)
spu_deactivate(ctx);
up_write(&ctx->state_sema);
spu_fini_csa(&ctx->csa);
if (ctx->gang)
spu_gang_remove_ctx(ctx->gang, ctx);
kfree(ctx);
}

Expand Down
81 changes: 81 additions & 0 deletions trunk/arch/powerpc/platforms/cell/spufs/gang.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* SPU file system
*
* (C) Copyright IBM Deutschland Entwicklung GmbH 2005
*
* Author: Arnd Bergmann <arndb@de.ibm.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include <linux/list.h>
#include <linux/slab.h>

#include "spufs.h"

struct spu_gang *alloc_spu_gang(void)
{
struct spu_gang *gang;

gang = kzalloc(sizeof *gang, GFP_KERNEL);
if (!gang)
goto out;

kref_init(&gang->kref);
mutex_init(&gang->mutex);
INIT_LIST_HEAD(&gang->list);

out:
return gang;
}

static void destroy_spu_gang(struct kref *kref)
{
struct spu_gang *gang;
gang = container_of(kref, struct spu_gang, kref);
WARN_ON(gang->contexts || !list_empty(&gang->list));
kfree(gang);
}

struct spu_gang *get_spu_gang(struct spu_gang *gang)
{
kref_get(&gang->kref);
return gang;
}

int put_spu_gang(struct spu_gang *gang)
{
return kref_put(&gang->kref, &destroy_spu_gang);
}

void spu_gang_add_ctx(struct spu_gang *gang, struct spu_context *ctx)
{
mutex_lock(&gang->mutex);
ctx->gang = get_spu_gang(gang);
list_add(&ctx->gang_list, &gang->list);
gang->contexts++;
mutex_unlock(&gang->mutex);
}

void spu_gang_remove_ctx(struct spu_gang *gang, struct spu_context *ctx)
{
mutex_lock(&gang->mutex);
WARN_ON(ctx->gang != gang);
list_del_init(&ctx->gang_list);
gang->contexts--;
mutex_unlock(&gang->mutex);

put_spu_gang(gang);
}
Loading

0 comments on commit e03e508

Please sign in to comment.