Lines Matching refs:gang
254 static void aff_merge_remaining_ctxs(struct spu_gang *gang) in aff_merge_remaining_ctxs() argument
258 list_for_each_entry(ctx, &gang->aff_list_head, aff_list) { in aff_merge_remaining_ctxs()
260 list_add(&ctx->aff_list, &gang->aff_list_head); in aff_merge_remaining_ctxs()
262 gang->aff_flags |= AFF_MERGED; in aff_merge_remaining_ctxs()
265 static void aff_set_offsets(struct spu_gang *gang) in aff_set_offsets() argument
271 list_for_each_entry_reverse(ctx, &gang->aff_ref_ctx->aff_list, in aff_set_offsets()
273 if (&ctx->aff_list == &gang->aff_list_head) in aff_set_offsets()
279 list_for_each_entry(ctx, gang->aff_ref_ctx->aff_list.prev, aff_list) { in aff_set_offsets()
280 if (&ctx->aff_list == &gang->aff_list_head) in aff_set_offsets()
285 gang->aff_flags |= AFF_OFFSETS_SET; in aff_set_offsets()
318 if (spu->ctx && spu->ctx->gang && !spu->ctx->aff_offset in aff_ref_location()
319 && spu->ctx->gang->aff_ref_spu) in aff_ref_location()
320 available_spus -= spu->ctx->gang->contexts; in aff_ref_location()
323 if (available_spus < ctx->gang->contexts) { in aff_ref_location()
340 static void aff_set_ref_point_location(struct spu_gang *gang) in aff_set_ref_point_location() argument
346 mem_aff = gang->aff_ref_ctx->flags & SPU_CREATE_AFFINITY_MEM; in aff_set_ref_point_location()
350 list_for_each_entry(tmp, &gang->aff_list_head, aff_list) in aff_set_ref_point_location()
353 list_for_each_entry_reverse(ctx, &gang->aff_ref_ctx->aff_list, in aff_set_ref_point_location()
355 if (&ctx->aff_list == &gang->aff_list_head) in aff_set_ref_point_location()
360 gang->aff_ref_spu = aff_ref_location(gang->aff_ref_ctx, mem_aff, gs, in aff_set_ref_point_location()
396 struct spu_gang *gang = ctx->gang; in has_affinity() local
401 if (atomic_read(&ctx->gang->aff_sched_count) == 0) in has_affinity()
402 ctx->gang->aff_ref_spu = NULL; in has_affinity()
404 if (!gang->aff_ref_spu) { in has_affinity()
405 if (!(gang->aff_flags & AFF_MERGED)) in has_affinity()
406 aff_merge_remaining_ctxs(gang); in has_affinity()
407 if (!(gang->aff_flags & AFF_OFFSETS_SET)) in has_affinity()
408 aff_set_offsets(gang); in has_affinity()
409 aff_set_ref_point_location(gang); in has_affinity()
412 return gang->aff_ref_spu != NULL; in has_affinity()
431 if (ctx->gang) in spu_unbind_context()
437 atomic_dec_if_positive(&ctx->gang->aff_sched_count); in spu_unbind_context()
561 if (ctx->gang) { in spu_get_idle()
562 mutex_lock(&ctx->gang->aff_mutex); in spu_get_idle()
564 aff_ref_spu = ctx->gang->aff_ref_spu; in spu_get_idle()
565 atomic_inc(&ctx->gang->aff_sched_count); in spu_get_idle()
566 mutex_unlock(&ctx->gang->aff_mutex); in spu_get_idle()
575 atomic_dec(&ctx->gang->aff_sched_count); in spu_get_idle()
578 mutex_unlock(&ctx->gang->aff_mutex); in spu_get_idle()