• Home
  • Raw
  • Download

Lines Matching refs:spu

142 		node = ctx->spu->node;  in spu_update_sched_info()
186 struct spu *spu; in do_notify_spus_active() local
189 list_for_each_entry(spu, &cbe_spu_info[node].spus, cbe_list) { in do_notify_spus_active()
190 if (spu->alloc_state != SPU_FREE) { in do_notify_spus_active()
191 struct spu_context *ctx = spu->ctx; in do_notify_spus_active()
207 static void spu_bind_context(struct spu *spu, struct spu_context *ctx) in spu_bind_context() argument
209 spu_context_trace(spu_bind_context__enter, ctx, spu); in spu_bind_context()
214 atomic_inc(&cbe_spu_info[spu->node].reserved_spus); in spu_bind_context()
216 ctx->stats.slb_flt_base = spu->stats.slb_flt; in spu_bind_context()
217 ctx->stats.class2_intr_base = spu->stats.class2_intr; in spu_bind_context()
219 spu_associate_mm(spu, ctx->owner); in spu_bind_context()
221 spin_lock_irq(&spu->register_lock); in spu_bind_context()
222 spu->ctx = ctx; in spu_bind_context()
223 spu->flags = 0; in spu_bind_context()
224 ctx->spu = spu; in spu_bind_context()
226 spu->pid = current->pid; in spu_bind_context()
227 spu->tgid = current->tgid; in spu_bind_context()
228 spu->ibox_callback = spufs_ibox_callback; in spu_bind_context()
229 spu->wbox_callback = spufs_wbox_callback; in spu_bind_context()
230 spu->stop_callback = spufs_stop_callback; in spu_bind_context()
231 spu->mfc_callback = spufs_mfc_callback; in spu_bind_context()
232 spin_unlock_irq(&spu->register_lock); in spu_bind_context()
236 spu_switch_log_notify(spu, ctx, SWITCH_LOG_START, 0); in spu_bind_context()
237 spu_restore(&ctx->csa, spu); in spu_bind_context()
238 spu->timestamp = jiffies; in spu_bind_context()
247 static inline int sched_spu(struct spu *spu) in sched_spu() argument
249 BUG_ON(!mutex_is_locked(&cbe_spu_info[spu->node].list_mutex)); in sched_spu()
251 return (!spu->ctx || !(spu->ctx->flags & SPU_CREATE_NOSCHED)); in sched_spu()
288 static struct spu *aff_ref_location(struct spu_context *ctx, int mem_aff, in aff_ref_location()
291 struct spu *spu; in aff_ref_location() local
317 list_for_each_entry(spu, &cbe_spu_info[node].spus, cbe_list) { in aff_ref_location()
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()
328 list_for_each_entry(spu, &cbe_spu_info[node].spus, cbe_list) { in aff_ref_location()
329 if ((!mem_aff || spu->has_mem_affinity) && in aff_ref_location()
330 sched_spu(spu)) { in aff_ref_location()
332 return spu; in aff_ref_location()
344 struct spu *tmp; in aff_set_ref_point_location()
364 static struct spu *ctx_location(struct spu *ref, int offset, int node) in ctx_location()
366 struct spu *spu; in ctx_location() local
368 spu = NULL; in ctx_location()
370 list_for_each_entry(spu, ref->aff_list.prev, aff_list) { in ctx_location()
371 BUG_ON(spu->node != node); in ctx_location()
374 if (sched_spu(spu)) in ctx_location()
378 list_for_each_entry_reverse(spu, ref->aff_list.next, aff_list) { in ctx_location()
379 BUG_ON(spu->node != node); in ctx_location()
382 if (sched_spu(spu)) in ctx_location()
387 return spu; in ctx_location()
420 static void spu_unbind_context(struct spu *spu, struct spu_context *ctx) in spu_unbind_context() argument
424 spu_context_trace(spu_unbind_context__enter, ctx, spu); in spu_unbind_context()
428 if (spu->ctx->flags & SPU_CREATE_NOSCHED) in spu_unbind_context()
429 atomic_dec(&cbe_spu_info[spu->node].reserved_spus); in spu_unbind_context()
440 spu_save(&ctx->csa, spu); in spu_unbind_context()
441 spu_switch_log_notify(spu, ctx, SWITCH_LOG_STOP, 0); in spu_unbind_context()
443 spin_lock_irq(&spu->register_lock); in spu_unbind_context()
444 spu->timestamp = jiffies; in spu_unbind_context()
446 spu->ibox_callback = NULL; in spu_unbind_context()
447 spu->wbox_callback = NULL; in spu_unbind_context()
448 spu->stop_callback = NULL; in spu_unbind_context()
449 spu->mfc_callback = NULL; in spu_unbind_context()
450 spu->pid = 0; in spu_unbind_context()
451 spu->tgid = 0; in spu_unbind_context()
453 spu->flags = 0; in spu_unbind_context()
454 spu->ctx = NULL; in spu_unbind_context()
455 spin_unlock_irq(&spu->register_lock); in spu_unbind_context()
457 spu_associate_mm(spu, NULL); in spu_unbind_context()
460 (spu->stats.slb_flt - ctx->stats.slb_flt_base); in spu_unbind_context()
462 (spu->stats.class2_intr - ctx->stats.class2_intr_base); in spu_unbind_context()
466 ctx->spu = NULL; in spu_unbind_context()
554 static struct spu *spu_get_idle(struct spu_context *ctx) in spu_get_idle()
556 struct spu *spu, *aff_ref_spu; in spu_get_idle() local
570 spu = ctx_location(aff_ref_spu, ctx->aff_offset, node); in spu_get_idle()
571 if (spu && spu->alloc_state == SPU_FREE) in spu_get_idle()
587 list_for_each_entry(spu, &cbe_spu_info[node].spus, cbe_list) { in spu_get_idle()
588 if (spu->alloc_state == SPU_FREE) in spu_get_idle()
599 spu->alloc_state = SPU_USED; in spu_get_idle()
601 spu_context_trace(spu_get_idle__found, ctx, spu); in spu_get_idle()
602 spu_init_channels(spu); in spu_get_idle()
603 return spu; in spu_get_idle()
612 static struct spu *find_victim(struct spu_context *ctx) in find_victim()
615 struct spu *spu; in find_victim() local
635 list_for_each_entry(spu, &cbe_spu_info[node].spus, cbe_list) { in find_victim()
636 struct spu_context *tmp = spu->ctx; in find_victim()
641 victim = spu->ctx; in find_victim()
665 spu = victim->spu; in find_victim()
666 if (!spu || victim->prio <= ctx->prio) { in find_victim()
678 spu_context_trace(__spu_deactivate__unload, ctx, spu); in find_victim()
682 spu_unbind_context(spu, victim); in find_victim()
686 spu->stats.invol_ctx_switch++; in find_victim()
693 return spu; in find_victim()
700 static void __spu_schedule(struct spu *spu, struct spu_context *ctx) in __spu_schedule() argument
702 int node = spu->node; in __spu_schedule()
708 if (spu->ctx == NULL) { in __spu_schedule()
709 spu_bind_context(spu, ctx); in __spu_schedule()
711 spu->alloc_state = SPU_USED; in __spu_schedule()
722 static void spu_schedule(struct spu *spu, struct spu_context *ctx) in spu_schedule() argument
728 __spu_schedule(spu, ctx); in spu_schedule()
745 static void spu_unschedule(struct spu *spu, struct spu_context *ctx, in spu_unschedule() argument
748 int node = spu->node; in spu_unschedule()
753 spu->alloc_state = SPU_FREE; in spu_unschedule()
754 spu_unbind_context(spu, ctx); in spu_unschedule()
756 spu->stats.invol_ctx_switch++; in spu_unschedule()
771 struct spu *spu; in spu_activate() local
779 if (ctx->spu) in spu_activate()
786 spu = spu_get_idle(ctx); in spu_activate()
791 if (!spu && rt_prio(ctx->prio)) in spu_activate()
792 spu = find_victim(ctx); in spu_activate()
793 if (spu) { in spu_activate()
797 __spu_schedule(spu, ctx); in spu_activate()
847 struct spu *spu = ctx->spu; in __spu_deactivate() local
850 if (spu) { in __spu_deactivate()
851 new = grab_runnable_context(max_prio, spu->node); in __spu_deactivate()
853 spu_unschedule(spu, ctx, new == NULL); in __spu_deactivate()
859 spu_schedule(spu, new); in __spu_deactivate()
905 struct spu *spu = NULL; in spusched_tick() local
920 spu = ctx->spu; in spusched_tick()
922 spu_context_trace(spusched_tick__preempt, ctx, spu); in spusched_tick()
924 new = grab_runnable_context(ctx->prio + 1, spu->node); in spusched_tick()
926 spu_unschedule(spu, ctx, 0); in spusched_tick()
938 spu_schedule(spu, new); in spusched_tick()
991 struct spu *spu; in spusched_thread() local
1001 list_for_each_entry(spu, &cbe_spu_info[node].spus, in spusched_thread()
1003 struct spu_context *ctx = spu->ctx; in spusched_thread()
1025 struct spu *spu; in spuctx_switch_state() local
1035 spu = ctx->spu; in spuctx_switch_state()
1043 if (spu) { in spuctx_switch_state()
1045 spu->stats.times[old_state] += delta; in spuctx_switch_state()
1046 spu->stats.util_state = new_state; in spuctx_switch_state()
1047 spu->stats.tstamp = curtime; in spuctx_switch_state()
1048 node = spu->node; in spuctx_switch_state()
1123 struct spu *spu; in spu_sched_exit() local
1134 list_for_each_entry(spu, &cbe_spu_info[node].spus, cbe_list) in spu_sched_exit()
1135 if (spu->alloc_state != SPU_FREE) in spu_sched_exit()
1136 spu->alloc_state = SPU_FREE; in spu_sched_exit()