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

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

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-or-later
  2 /*
  3  * SPU file system
  4  *
  5  * (C) Copyright IBM Deutschland Entwicklung GmbH 2005
  6  *
  7  * Author: Arnd Bergmann <arndb@de.ibm.com>
  8  */
  9 
 10 #include <linux/list.h>
 11 #include <linux/slab.h>
 12 
 13 #include "spufs.h"
 14 
 15 struct spu_gang *alloc_spu_gang(void)
 16 {
 17         struct spu_gang *gang;
 18 
 19         gang = kzalloc(sizeof *gang, GFP_KERNEL);
 20         if (!gang)
 21                 goto out;
 22 
 23         kref_init(&gang->kref);
 24         mutex_init(&gang->mutex);
 25         mutex_init(&gang->aff_mutex);
 26         INIT_LIST_HEAD(&gang->list);
 27         INIT_LIST_HEAD(&gang->aff_list_head);
 28 
 29 out:
 30         return gang;
 31 }
 32 
 33 static void destroy_spu_gang(struct kref *kref)
 34 {
 35         struct spu_gang *gang;
 36         gang = container_of(kref, struct spu_gang, kref);
 37         WARN_ON(gang->contexts || !list_empty(&gang->list));
 38         kfree(gang);
 39 }
 40 
 41 struct spu_gang *get_spu_gang(struct spu_gang *gang)
 42 {
 43         kref_get(&gang->kref);
 44         return gang;
 45 }
 46 
 47 int put_spu_gang(struct spu_gang *gang)
 48 {
 49         return kref_put(&gang->kref, &destroy_spu_gang);
 50 }
 51 
 52 void spu_gang_add_ctx(struct spu_gang *gang, struct spu_context *ctx)
 53 {
 54         mutex_lock(&gang->mutex);
 55         ctx->gang = get_spu_gang(gang);
 56         list_add(&ctx->gang_list, &gang->list);
 57         gang->contexts++;
 58         mutex_unlock(&gang->mutex);
 59 }
 60 
 61 void spu_gang_remove_ctx(struct spu_gang *gang, struct spu_context *ctx)
 62 {
 63         mutex_lock(&gang->mutex);
 64         WARN_ON(ctx->gang != gang);
 65         if (!list_empty(&ctx->aff_list)) {
 66                 list_del_init(&ctx->aff_list);
 67                 gang->aff_flags &= ~AFF_OFFSETS_SET;
 68         }
 69         list_del_init(&ctx->gang_list);
 70         gang->contexts--;
 71         mutex_unlock(&gang->mutex);
 72 
 73         put_spu_gang(gang);
 74 }
 75 

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

kernel.org | git.kernel.org | LWN.net | Project Home | 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.

sflogo.php