Lines Matching refs:gang

270 static void aff_merge_remaining_ctxs(struct spu_gang *gang)  in aff_merge_remaining_ctxs()  argument
274 list_for_each_entry(ctx, &gang->aff_list_head, aff_list) { in aff_merge_remaining_ctxs()
276 list_add(&ctx->aff_list, &gang->aff_list_head); in aff_merge_remaining_ctxs()
278 gang->aff_flags |= AFF_MERGED; in aff_merge_remaining_ctxs()
281 static void aff_set_offsets(struct spu_gang *gang) in aff_set_offsets() argument
287 list_for_each_entry_reverse(ctx, &gang->aff_ref_ctx->aff_list, in aff_set_offsets()
289 if (&ctx->aff_list == &gang->aff_list_head) in aff_set_offsets()
295 list_for_each_entry(ctx, gang->aff_ref_ctx->aff_list.prev, aff_list) { in aff_set_offsets()
296 if (&ctx->aff_list == &gang->aff_list_head) in aff_set_offsets()
301 gang->aff_flags |= AFF_OFFSETS_SET; in aff_set_offsets()
334 if (spu->ctx && spu->ctx->gang && !spu->ctx->aff_offset in aff_ref_location()
335 && spu->ctx->gang->aff_ref_spu) in aff_ref_location()
336 available_spus -= spu->ctx->gang->contexts; in aff_ref_location()
339 if (available_spus < ctx->gang->contexts) { in aff_ref_location()
356 static void aff_set_ref_point_location(struct spu_gang *gang) in aff_set_ref_point_location() argument
362 mem_aff = gang->aff_ref_ctx->flags & SPU_CREATE_AFFINITY_MEM; in aff_set_ref_point_location()
366 list_for_each_entry(tmp, &gang->aff_list_head, aff_list) in aff_set_ref_point_location()
369 list_for_each_entry_reverse(ctx, &gang->aff_ref_ctx->aff_list, in aff_set_ref_point_location()
371 if (&ctx->aff_list == &gang->aff_list_head) in aff_set_ref_point_location()
376 gang->aff_ref_spu = aff_ref_location(gang->aff_ref_ctx, mem_aff, gs, in aff_set_ref_point_location()
412 struct spu_gang *gang = ctx->gang; in has_affinity() local
417 if (atomic_read(&ctx->gang->aff_sched_count) == 0) in has_affinity()
418 ctx->gang->aff_ref_spu = NULL; in has_affinity()
420 if (!gang->aff_ref_spu) { in has_affinity()
421 if (!(gang->aff_flags & AFF_MERGED)) in has_affinity()
422 aff_merge_remaining_ctxs(gang); in has_affinity()
423 if (!(gang->aff_flags & AFF_OFFSETS_SET)) in has_affinity()
424 aff_set_offsets(gang); in has_affinity()
425 aff_set_ref_point_location(gang); in has_affinity()
428 return gang->aff_ref_spu != NULL; in has_affinity()
447 if (ctx->gang) in spu_unbind_context()
453 atomic_dec_if_positive(&ctx->gang->aff_sched_count); in spu_unbind_context()
578 if (ctx->gang) { in spu_get_idle()
579 mutex_lock(&ctx->gang->aff_mutex); in spu_get_idle()
581 aff_ref_spu = ctx->gang->aff_ref_spu; in spu_get_idle()
582 atomic_inc(&ctx->gang->aff_sched_count); in spu_get_idle()
583 mutex_unlock(&ctx->gang->aff_mutex); in spu_get_idle()
592 atomic_dec(&ctx->gang->aff_sched_count); in spu_get_idle()
595 mutex_unlock(&ctx->gang->aff_mutex); in spu_get_idle()