Lines Matching refs:spu

65 void spu_invalidate_slbs(struct spu *spu)  in spu_invalidate_slbs()  argument
67 struct spu_priv2 __iomem *priv2 = spu->priv2; in spu_invalidate_slbs()
70 spin_lock_irqsave(&spu->register_lock, flags); in spu_invalidate_slbs()
71 if (spu_mfc_sr1_get(spu) & MFC_STATE1_RELOCATE_MASK) in spu_invalidate_slbs()
73 spin_unlock_irqrestore(&spu->register_lock, flags); in spu_invalidate_slbs()
82 struct spu *spu; in spu_flush_all_slbs() local
86 list_for_each_entry(spu, &spu_full_list, full_list) { in spu_flush_all_slbs()
87 if (spu->mm == mm) in spu_flush_all_slbs()
88 spu_invalidate_slbs(spu); in spu_flush_all_slbs()
104 void spu_associate_mm(struct spu *spu, struct mm_struct *mm) in spu_associate_mm() argument
109 spu->mm = mm; in spu_associate_mm()
122 static void spu_restart_dma(struct spu *spu) in spu_restart_dma() argument
124 struct spu_priv2 __iomem *priv2 = spu->priv2; in spu_restart_dma()
126 if (!test_bit(SPU_CONTEXT_SWITCH_PENDING, &spu->flags)) in spu_restart_dma()
129 set_bit(SPU_CONTEXT_FAULT_PENDING, &spu->flags); in spu_restart_dma()
134 static inline void spu_load_slb(struct spu *spu, int slbe, struct copro_slb *slb) in spu_load_slb() argument
136 struct spu_priv2 __iomem *priv2 = spu->priv2; in spu_load_slb()
150 static int __spu_trap_data_seg(struct spu *spu, unsigned long ea) in __spu_trap_data_seg() argument
155 ret = copro_calculate_slb(spu->mm, ea, &slb); in __spu_trap_data_seg()
159 spu_load_slb(spu, spu->slb_replace, &slb); in __spu_trap_data_seg()
161 spu->slb_replace++; in __spu_trap_data_seg()
162 if (spu->slb_replace >= 8) in __spu_trap_data_seg()
163 spu->slb_replace = 0; in __spu_trap_data_seg()
165 spu_restart_dma(spu); in __spu_trap_data_seg()
166 spu->stats.slb_flt++; in __spu_trap_data_seg()
172 static int __spu_trap_data_map(struct spu *spu, unsigned long ea, u64 dsisr) in __spu_trap_data_map() argument
185 spin_unlock(&spu->register_lock); in __spu_trap_data_map()
189 spin_lock(&spu->register_lock); in __spu_trap_data_map()
192 spu_restart_dma(spu); in __spu_trap_data_map()
197 spu->class_1_dar = ea; in __spu_trap_data_map()
198 spu->class_1_dsisr = dsisr; in __spu_trap_data_map()
200 spu->stop_callback(spu, 1); in __spu_trap_data_map()
202 spu->class_1_dar = 0; in __spu_trap_data_map()
203 spu->class_1_dsisr = 0; in __spu_trap_data_map()
249 void spu_setup_kernel_slbs(struct spu *spu, struct spu_lscsa *lscsa, in spu_setup_kernel_slbs() argument
270 spin_lock_irq(&spu->register_lock); in spu_setup_kernel_slbs()
273 spu_load_slb(spu, i, &slbs[i]); in spu_setup_kernel_slbs()
274 spin_unlock_irq(&spu->register_lock); in spu_setup_kernel_slbs()
281 struct spu *spu; in spu_irq_class_0() local
284 spu = data; in spu_irq_class_0()
286 spin_lock(&spu->register_lock); in spu_irq_class_0()
287 mask = spu_int_mask_get(spu, 0); in spu_irq_class_0()
288 stat = spu_int_stat_get(spu, 0) & mask; in spu_irq_class_0()
290 spu->class_0_pending |= stat; in spu_irq_class_0()
291 spu->class_0_dar = spu_mfc_dar_get(spu); in spu_irq_class_0()
292 spu->stop_callback(spu, 0); in spu_irq_class_0()
293 spu->class_0_pending = 0; in spu_irq_class_0()
294 spu->class_0_dar = 0; in spu_irq_class_0()
296 spu_int_stat_clear(spu, 0, stat); in spu_irq_class_0()
297 spin_unlock(&spu->register_lock); in spu_irq_class_0()
305 struct spu *spu; in spu_irq_class_1() local
308 spu = data; in spu_irq_class_1()
311 spin_lock(&spu->register_lock); in spu_irq_class_1()
312 mask = spu_int_mask_get(spu, 1); in spu_irq_class_1()
313 stat = spu_int_stat_get(spu, 1) & mask; in spu_irq_class_1()
314 dar = spu_mfc_dar_get(spu); in spu_irq_class_1()
315 dsisr = spu_mfc_dsisr_get(spu); in spu_irq_class_1()
317 spu_mfc_dsisr_set(spu, 0ul); in spu_irq_class_1()
318 spu_int_stat_clear(spu, 1, stat); in spu_irq_class_1()
324 __spu_trap_data_seg(spu, dar); in spu_irq_class_1()
327 __spu_trap_data_map(spu, dar, dsisr); in spu_irq_class_1()
335 spu->class_1_dsisr = 0; in spu_irq_class_1()
336 spu->class_1_dar = 0; in spu_irq_class_1()
338 spin_unlock(&spu->register_lock); in spu_irq_class_1()
346 struct spu *spu; in spu_irq_class_2() local
352 spu = data; in spu_irq_class_2()
353 spin_lock(&spu->register_lock); in spu_irq_class_2()
354 stat = spu_int_stat_get(spu, 2); in spu_irq_class_2()
355 mask = spu_int_mask_get(spu, 2); in spu_irq_class_2()
361 spu_int_mask_and(spu, 2, ~(stat & mailbox_intrs)); in spu_irq_class_2()
363 spu_int_stat_clear(spu, 2, stat); in spu_irq_class_2()
368 spu->ibox_callback(spu); in spu_irq_class_2()
371 spu->stop_callback(spu, 2); in spu_irq_class_2()
374 spu->stop_callback(spu, 2); in spu_irq_class_2()
377 spu->mfc_callback(spu); in spu_irq_class_2()
380 spu->wbox_callback(spu); in spu_irq_class_2()
382 spu->stats.class2_intr++; in spu_irq_class_2()
384 spin_unlock(&spu->register_lock); in spu_irq_class_2()
389 static int __init spu_request_irqs(struct spu *spu) in spu_request_irqs() argument
393 if (spu->irqs[0]) { in spu_request_irqs()
394 snprintf(spu->irq_c0, sizeof (spu->irq_c0), "spe%02d.0", in spu_request_irqs()
395 spu->number); in spu_request_irqs()
396 ret = request_irq(spu->irqs[0], spu_irq_class_0, in spu_request_irqs()
397 0, spu->irq_c0, spu); in spu_request_irqs()
401 if (spu->irqs[1]) { in spu_request_irqs()
402 snprintf(spu->irq_c1, sizeof (spu->irq_c1), "spe%02d.1", in spu_request_irqs()
403 spu->number); in spu_request_irqs()
404 ret = request_irq(spu->irqs[1], spu_irq_class_1, in spu_request_irqs()
405 0, spu->irq_c1, spu); in spu_request_irqs()
409 if (spu->irqs[2]) { in spu_request_irqs()
410 snprintf(spu->irq_c2, sizeof (spu->irq_c2), "spe%02d.2", in spu_request_irqs()
411 spu->number); in spu_request_irqs()
412 ret = request_irq(spu->irqs[2], spu_irq_class_2, in spu_request_irqs()
413 0, spu->irq_c2, spu); in spu_request_irqs()
420 if (spu->irqs[1]) in spu_request_irqs()
421 free_irq(spu->irqs[1], spu); in spu_request_irqs()
423 if (spu->irqs[0]) in spu_request_irqs()
424 free_irq(spu->irqs[0], spu); in spu_request_irqs()
429 static void spu_free_irqs(struct spu *spu) in spu_free_irqs() argument
431 if (spu->irqs[0]) in spu_free_irqs()
432 free_irq(spu->irqs[0], spu); in spu_free_irqs()
433 if (spu->irqs[1]) in spu_free_irqs()
434 free_irq(spu->irqs[1], spu); in spu_free_irqs()
435 if (spu->irqs[2]) in spu_free_irqs()
436 free_irq(spu->irqs[2], spu); in spu_free_irqs()
439 void spu_init_channels(struct spu *spu) in spu_init_channels() argument
455 priv2 = spu->priv2; in spu_init_channels()
481 struct spu *spu; in spu_add_dev_attr() local
484 list_for_each_entry(spu, &spu_full_list, full_list) in spu_add_dev_attr()
485 device_create_file(&spu->dev, attr); in spu_add_dev_attr()
494 struct spu *spu; in spu_add_dev_attr_group() local
498 list_for_each_entry(spu, &spu_full_list, full_list) { in spu_add_dev_attr_group()
499 rc = sysfs_create_group(&spu->dev.kobj, attrs); in spu_add_dev_attr_group()
506 list_for_each_entry_continue_reverse(spu, in spu_add_dev_attr_group()
508 sysfs_remove_group(&spu->dev.kobj, attrs); in spu_add_dev_attr_group()
522 struct spu *spu; in spu_remove_dev_attr() local
525 list_for_each_entry(spu, &spu_full_list, full_list) in spu_remove_dev_attr()
526 device_remove_file(&spu->dev, attr); in spu_remove_dev_attr()
533 struct spu *spu; in spu_remove_dev_attr_group() local
536 list_for_each_entry(spu, &spu_full_list, full_list) in spu_remove_dev_attr_group()
537 sysfs_remove_group(&spu->dev.kobj, attrs); in spu_remove_dev_attr_group()
542 static int __init spu_create_dev(struct spu *spu) in spu_create_dev() argument
546 spu->dev.id = spu->number; in spu_create_dev()
547 spu->dev.bus = &spu_subsys; in spu_create_dev()
548 ret = device_register(&spu->dev); in spu_create_dev()
551 spu->number); in spu_create_dev()
555 sysfs_add_device_to_node(&spu->dev, spu->node); in spu_create_dev()
562 struct spu *spu; in create_spu() local
568 spu = kzalloc(sizeof (*spu), GFP_KERNEL); in create_spu()
569 if (!spu) in create_spu()
572 spu->alloc_state = SPU_FREE; in create_spu()
574 spin_lock_init(&spu->register_lock); in create_spu()
576 spu->number = number++; in create_spu()
579 ret = spu_create_spu(spu, data); in create_spu()
584 spu_mfc_sdr_setup(spu); in create_spu()
585 spu_mfc_sr1_set(spu, 0x33); in create_spu()
586 ret = spu_request_irqs(spu); in create_spu()
590 ret = spu_create_dev(spu); in create_spu()
594 mutex_lock(&cbe_spu_info[spu->node].list_mutex); in create_spu()
595 list_add(&spu->cbe_list, &cbe_spu_info[spu->node].spus); in create_spu()
596 cbe_spu_info[spu->node].n_spus++; in create_spu()
597 mutex_unlock(&cbe_spu_info[spu->node].list_mutex); in create_spu()
601 list_add(&spu->full_list, &spu_full_list); in create_spu()
605 spu->stats.util_state = SPU_UTIL_IDLE_LOADED; in create_spu()
606 spu->stats.tstamp = ktime_get_ns(); in create_spu()
608 INIT_LIST_HEAD(&spu->aff_list); in create_spu()
613 spu_free_irqs(spu); in create_spu()
615 spu_destroy_spu(spu); in create_spu()
617 kfree(spu); in create_spu()
626 static unsigned long long spu_acct_time(struct spu *spu, in spu_acct_time() argument
629 unsigned long long time = spu->stats.times[state]; in spu_acct_time()
636 if (spu->stats.util_state == state) in spu_acct_time()
637 time += ktime_get_ns() - spu->stats.tstamp; in spu_acct_time()
646 struct spu *spu = container_of(dev, struct spu, dev); in spu_stat_show() local
650 spu_state_names[spu->stats.util_state], in spu_stat_show()
651 spu_acct_time(spu, SPU_UTIL_USER), in spu_stat_show()
652 spu_acct_time(spu, SPU_UTIL_SYSTEM), in spu_stat_show()
653 spu_acct_time(spu, SPU_UTIL_IOWAIT), in spu_stat_show()
654 spu_acct_time(spu, SPU_UTIL_IDLE_LOADED), in spu_stat_show()
655 spu->stats.vol_ctx_switch, in spu_stat_show()
656 spu->stats.invol_ctx_switch, in spu_stat_show()
657 spu->stats.slb_flt, in spu_stat_show()
658 spu->stats.hash_flt, in spu_stat_show()
659 spu->stats.min_flt, in spu_stat_show()
660 spu->stats.maj_flt, in spu_stat_show()
661 spu->stats.class2_intr, in spu_stat_show()
662 spu->stats.libassist); in spu_stat_show()
670 struct spu *spu; member
684 struct spu *spu; in crash_kexec_stop_spus() local
689 if (!crash_spu_info[i].spu) in crash_kexec_stop_spus()
692 spu = crash_spu_info[i].spu; in crash_kexec_stop_spus()
695 in_be32(&spu->problem->spu_runcntl_RW); in crash_kexec_stop_spus()
697 in_be32(&spu->problem->spu_status_R); in crash_kexec_stop_spus()
699 in_be32(&spu->problem->spu_npc_RW); in crash_kexec_stop_spus()
701 crash_spu_info[i].saved_mfc_dar = spu_mfc_dar_get(spu); in crash_kexec_stop_spus()
702 crash_spu_info[i].saved_mfc_dsisr = spu_mfc_dsisr_get(spu); in crash_kexec_stop_spus()
703 tmp = spu_mfc_sr1_get(spu); in crash_kexec_stop_spus()
707 spu_mfc_sr1_set(spu, tmp); in crash_kexec_stop_spus()
715 struct spu *spu; in crash_register_spus() local
718 list_for_each_entry(spu, list, full_list) { in crash_register_spus()
719 if (WARN_ON(spu->number >= CRASH_NUM_SPUS)) in crash_register_spus()
722 crash_spu_info[spu->number].spu = spu; in crash_register_spus()
738 struct spu *spu; in spu_shutdown() local
741 list_for_each_entry(spu, &spu_full_list, full_list) { in spu_shutdown()
742 spu_free_irqs(spu); in spu_shutdown()
743 spu_destroy_spu(spu); in spu_shutdown()