Lines Matching refs:gang
258 static void aff_merge_remaining_ctxs(struct spu_gang *gang) in aff_merge_remaining_ctxs() argument
262 list_for_each_entry(ctx, &gang->aff_list_head, aff_list) { in aff_merge_remaining_ctxs()
264 list_add(&ctx->aff_list, &gang->aff_list_head); in aff_merge_remaining_ctxs()
266 gang->aff_flags |= AFF_MERGED; in aff_merge_remaining_ctxs()
269 static void aff_set_offsets(struct spu_gang *gang) in aff_set_offsets() argument
275 list_for_each_entry_reverse(ctx, &gang->aff_ref_ctx->aff_list, in aff_set_offsets()
277 if (&ctx->aff_list == &gang->aff_list_head) in aff_set_offsets()
283 list_for_each_entry(ctx, gang->aff_ref_ctx->aff_list.prev, aff_list) { in aff_set_offsets()
284 if (&ctx->aff_list == &gang->aff_list_head) in aff_set_offsets()
289 gang->aff_flags |= AFF_OFFSETS_SET; in aff_set_offsets()
322 if (spu->ctx && spu->ctx->gang && !spu->ctx->aff_offset in aff_ref_location()
323 && spu->ctx->gang->aff_ref_spu) in aff_ref_location()
324 available_spus -= spu->ctx->gang->contexts; in aff_ref_location()
327 if (available_spus < ctx->gang->contexts) { in aff_ref_location()
344 static void aff_set_ref_point_location(struct spu_gang *gang) in aff_set_ref_point_location() argument
350 mem_aff = gang->aff_ref_ctx->flags & SPU_CREATE_AFFINITY_MEM; in aff_set_ref_point_location()
354 list_for_each_entry(tmp, &gang->aff_list_head, aff_list) in aff_set_ref_point_location()
357 list_for_each_entry_reverse(ctx, &gang->aff_ref_ctx->aff_list, in aff_set_ref_point_location()
359 if (&ctx->aff_list == &gang->aff_list_head) in aff_set_ref_point_location()
364 gang->aff_ref_spu = aff_ref_location(gang->aff_ref_ctx, mem_aff, gs, in aff_set_ref_point_location()
400 struct spu_gang *gang = ctx->gang; in has_affinity() local
405 if (atomic_read(&ctx->gang->aff_sched_count) == 0) in has_affinity()
406 ctx->gang->aff_ref_spu = NULL; in has_affinity()
408 if (!gang->aff_ref_spu) { in has_affinity()
409 if (!(gang->aff_flags & AFF_MERGED)) in has_affinity()
410 aff_merge_remaining_ctxs(gang); in has_affinity()
411 if (!(gang->aff_flags & AFF_OFFSETS_SET)) in has_affinity()
412 aff_set_offsets(gang); in has_affinity()
413 aff_set_ref_point_location(gang); in has_affinity()
416 return gang->aff_ref_spu != NULL; in has_affinity()
435 if (ctx->gang) in spu_unbind_context()
441 atomic_dec_if_positive(&ctx->gang->aff_sched_count); in spu_unbind_context()
566 if (ctx->gang) { in spu_get_idle()
567 mutex_lock(&ctx->gang->aff_mutex); in spu_get_idle()
569 aff_ref_spu = ctx->gang->aff_ref_spu; in spu_get_idle()
570 atomic_inc(&ctx->gang->aff_sched_count); in spu_get_idle()
571 mutex_unlock(&ctx->gang->aff_mutex); in spu_get_idle()
580 atomic_dec(&ctx->gang->aff_sched_count); in spu_get_idle()
583 mutex_unlock(&ctx->gang->aff_mutex); in spu_get_idle()