~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/powerpc/platforms/cell/spufs/gang.c

Version: ~ [ linux-5.4-rc7 ] ~ [ linux-5.3.10 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.83 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.153 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.200 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.200 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.76 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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/list.h>
 24 #include <linux/slab.h>
 25 
 26 #include "spufs.h"
 27 
 28 struct spu_gang *alloc_spu_gang(void)
 29 {
 30         struct spu_gang *gang;
 31 
 32         gang = kzalloc(sizeof *gang, GFP_KERNEL);
 33         if (!gang)
 34                 goto out;
 35 
 36         kref_init(&gang->kref);
 37         mutex_init(&gang->mutex);
 38         mutex_init(&gang->aff_mutex);
 39         INIT_LIST_HEAD(&gang->list);
 40         INIT_LIST_HEAD(&gang->aff_list_head);
 41 
 42 out:
 43         return gang;
 44 }
 45 
 46 static void destroy_spu_gang(struct kref *kref)
 47 {
 48         struct spu_gang *gang;
 49         gang = container_of(kref, struct spu_gang, kref);
 50         WARN_ON(gang->contexts || !list_empty(&gang->list));
 51         kfree(gang);
 52 }
 53 
 54 struct spu_gang *get_spu_gang(struct spu_gang *gang)
 55 {
 56         kref_get(&gang->kref);
 57         return gang;
 58 }
 59 
 60 int put_spu_gang(struct spu_gang *gang)
 61 {
 62         return kref_put(&gang->kref, &destroy_spu_gang);
 63 }
 64 
 65 void spu_gang_add_ctx(struct spu_gang *gang, struct spu_context *ctx)
 66 {
 67         mutex_lock(&gang->mutex);
 68         ctx->gang = get_spu_gang(gang);
 69         list_add(&ctx->gang_list, &gang->list);
 70         gang->contexts++;
 71         mutex_unlock(&gang->mutex);
 72 }
 73 
 74 void spu_gang_remove_ctx(struct spu_gang *gang, struct spu_context *ctx)
 75 {
 76         mutex_lock(&gang->mutex);
 77         WARN_ON(ctx->gang != gang);
 78         if (!list_empty(&ctx->aff_list)) {
 79                 list_del_init(&ctx->aff_list);
 80                 gang->aff_flags &= ~AFF_OFFSETS_SET;
 81         }
 82         list_del_init(&ctx->gang_list);
 83         gang->contexts--;
 84         mutex_unlock(&gang->mutex);
 85 
 86         put_spu_gang(gang);
 87 }
 88 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp