Lines Matching refs:gang
17 struct spu_gang *gang; in alloc_spu_gang() local
19 gang = kzalloc(sizeof *gang, GFP_KERNEL); in alloc_spu_gang()
20 if (!gang) in alloc_spu_gang()
23 kref_init(&gang->kref); in alloc_spu_gang()
24 mutex_init(&gang->mutex); in alloc_spu_gang()
25 mutex_init(&gang->aff_mutex); in alloc_spu_gang()
26 INIT_LIST_HEAD(&gang->list); in alloc_spu_gang()
27 INIT_LIST_HEAD(&gang->aff_list_head); in alloc_spu_gang()
30 return gang; in alloc_spu_gang()
35 struct spu_gang *gang; in destroy_spu_gang() local
36 gang = container_of(kref, struct spu_gang, kref); in destroy_spu_gang()
37 WARN_ON(gang->contexts || !list_empty(&gang->list)); in destroy_spu_gang()
38 kfree(gang); in destroy_spu_gang()
41 struct spu_gang *get_spu_gang(struct spu_gang *gang) in get_spu_gang() argument
43 kref_get(&gang->kref); in get_spu_gang()
44 return gang; in get_spu_gang()
47 int put_spu_gang(struct spu_gang *gang) in put_spu_gang() argument
49 return kref_put(&gang->kref, &destroy_spu_gang); in put_spu_gang()
52 void spu_gang_add_ctx(struct spu_gang *gang, struct spu_context *ctx) in spu_gang_add_ctx() argument
54 mutex_lock(&gang->mutex); in spu_gang_add_ctx()
55 ctx->gang = get_spu_gang(gang); in spu_gang_add_ctx()
56 list_add(&ctx->gang_list, &gang->list); in spu_gang_add_ctx()
57 gang->contexts++; in spu_gang_add_ctx()
58 mutex_unlock(&gang->mutex); in spu_gang_add_ctx()
61 void spu_gang_remove_ctx(struct spu_gang *gang, struct spu_context *ctx) in spu_gang_remove_ctx() argument
63 mutex_lock(&gang->mutex); in spu_gang_remove_ctx()
64 WARN_ON(ctx->gang != gang); in spu_gang_remove_ctx()
67 gang->aff_flags &= ~AFF_OFFSETS_SET; in spu_gang_remove_ctx()
70 gang->contexts--; in spu_gang_remove_ctx()
71 mutex_unlock(&gang->mutex); in spu_gang_remove_ctx()
73 put_spu_gang(gang); in spu_gang_remove_ctx()