• Home
  • Raw
  • Download

Lines Matching refs:aub

54 static struct aub_context *aub_context_new(struct aub_file *aub, uint32_t new_id);
55 static void mem_trace_memory_write_header_out(struct aub_file *aub, uint64_t addr,
82 data_out(struct aub_file *aub, const void *data, size_t size) in data_out() argument
87 fail_if(fwrite(data, 1, size, aub->file) == 0, in data_out()
92 dword_out(struct aub_file *aub, uint32_t data) in dword_out() argument
94 data_out(aub, &data, sizeof(data)); in dword_out()
98 write_execlists_header(struct aub_file *aub, const char *name) in write_execlists_header() argument
105 aub->pci_id, name); in write_execlists_header()
109 dword_out(aub, CMD_MEM_TRACE_VERSION | (dwords - 1)); in write_execlists_header()
110 dword_out(aub, AUB_MEM_TRACE_VERSION_FILE_VERSION); in write_execlists_header()
111 dword_out(aub, aub->devinfo.simulator_id << AUB_MEM_TRACE_VERSION_DEVICE_SHIFT); in write_execlists_header()
112 dword_out(aub, 0); /* version */ in write_execlists_header()
113 dword_out(aub, 0); /* version */ in write_execlists_header()
114 data_out(aub, app_name, app_name_len); in write_execlists_header()
118 write_legacy_header(struct aub_file *aub, const char *name) in write_legacy_header() argument
124 comment_len = snprintf(comment, sizeof(comment), "PCI-ID=0x%x", aub->pci_id); in write_legacy_header()
129 dword_out(aub, CMD_AUB_HEADER | (dwords - 2)); in write_legacy_header()
130 dword_out(aub, (4 << AUB_HEADER_MAJOR_SHIFT) | in write_legacy_header()
136 data_out(aub, app_name, sizeof(app_name)); in write_legacy_header()
138 dword_out(aub, 0); /* timestamp */ in write_legacy_header()
139 dword_out(aub, 0); /* timestamp */ in write_legacy_header()
140 dword_out(aub, comment_len); in write_legacy_header()
141 data_out(aub, comment, comment_dwords * 4); in write_legacy_header()
146 aub_write_header(struct aub_file *aub, const char *app_name) in aub_write_header() argument
148 if (aub_use_execlists(aub)) in aub_write_header()
149 write_execlists_header(aub, app_name); in aub_write_header()
151 write_legacy_header(aub, app_name); in aub_write_header()
155 aub_file_init(struct aub_file *aub, FILE *file, FILE *debug, uint16_t pci_id, const char *app_name) in aub_file_init() argument
157 memset(aub, 0, sizeof(*aub)); in aub_file_init()
159 aub->verbose_log_file = debug; in aub_file_init()
160 aub->file = file; in aub_file_init()
161 aub->pci_id = pci_id; in aub_file_init()
162 fail_if(!gen_get_device_info_from_pci_id(pci_id, &aub->devinfo), in aub_file_init()
164 aub->addr_bits = aub->devinfo.gen >= 8 ? 48 : 32; in aub_file_init()
166 aub_write_header(aub, app_name); in aub_file_init()
168 aub->phys_addrs_allocator = 0; in aub_file_init()
169 aub->ggtt_addrs_allocator = 0; in aub_file_init()
170 aub->pml4.phys_addr = aub->phys_addrs_allocator++ << 12; in aub_file_init()
172 mem_trace_memory_write_header_out(aub, aub->ggtt_addrs_allocator++, in aub_file_init()
176 dword_out(aub, 1); in aub_file_init()
177 dword_out(aub, 0); in aub_file_init()
179 aub->next_context_handle = 1; in aub_file_init()
180 aub_context_new(aub, 0); /* Default context */ in aub_file_init()
184 aub_file_finish(struct aub_file *aub) in aub_file_finish() argument
186 aub_ppgtt_table_finish(&aub->pml4, 4); in aub_file_finish()
187 fclose(aub->file); in aub_file_finish()
191 aub_gtt_size(struct aub_file *aub) in aub_gtt_size() argument
193 return NUM_PT_ENTRIES * (aub->addr_bits > 32 ? GEN8_PTE_SIZE : PTE_SIZE); in aub_gtt_size()
197 mem_trace_memory_write_header_out(struct aub_file *aub, uint64_t addr, in mem_trace_memory_write_header_out() argument
203 if (aub->verbose_log_file) { in mem_trace_memory_write_header_out()
204 fprintf(aub->verbose_log_file, in mem_trace_memory_write_header_out()
209 dword_out(aub, CMD_MEM_TRACE_MEMORY_WRITE | (5 + dwords - 1)); in mem_trace_memory_write_header_out()
210 dword_out(aub, addr & 0xFFFFFFFF); /* addr lo */ in mem_trace_memory_write_header_out()
211 dword_out(aub, addr >> 32); /* addr hi */ in mem_trace_memory_write_header_out()
212 dword_out(aub, addr_space); /* gtt */ in mem_trace_memory_write_header_out()
213 dword_out(aub, len); in mem_trace_memory_write_header_out()
217 register_write_out(struct aub_file *aub, uint32_t addr, uint32_t value) in register_write_out() argument
221 if (aub->verbose_log_file) { in register_write_out()
222 fprintf(aub->verbose_log_file, in register_write_out()
226 dword_out(aub, CMD_MEM_TRACE_REGISTER_WRITE | (5 + dwords - 1)); in register_write_out()
227 dword_out(aub, addr); in register_write_out()
228 dword_out(aub, AUB_MEM_TRACE_REGISTER_SIZE_DWORD | in register_write_out()
230 dword_out(aub, 0xFFFFFFFF); /* mask lo */ in register_write_out()
231 dword_out(aub, 0x00000000); /* mask hi */ in register_write_out()
232 dword_out(aub, value); in register_write_out()
236 populate_ppgtt_table(struct aub_file *aub, struct aub_ppgtt_table *table, in populate_ppgtt_table() argument
242 if (aub->verbose_log_file) { in populate_ppgtt_table()
243 fprintf(aub->verbose_log_file, in populate_ppgtt_table()
254 (void *)(aub->phys_addrs_allocator++ << 12); in populate_ppgtt_table()
255 if (aub->verbose_log_file) { in populate_ppgtt_table()
256 fprintf(aub->verbose_log_file, in populate_ppgtt_table()
264 aub->phys_addrs_allocator++ << 12; in populate_ppgtt_table()
265 if (aub->verbose_log_file) { in populate_ppgtt_table()
266 fprintf(aub->verbose_log_file, in populate_ppgtt_table()
282 mem_trace_memory_write_header_out(aub, write_addr, write_size, in populate_ppgtt_table()
285 data_out(aub, entries + dirty_start, write_size); in populate_ppgtt_table()
290 aub_map_ppgtt(struct aub_file *aub, uint64_t start, uint64_t size) in aub_map_ppgtt() argument
300 #define L3_table(addr) (aub->pml4.subtables[L4_index(addr)]) in aub_map_ppgtt()
304 if (aub->verbose_log_file) { in aub_map_ppgtt()
305 fprintf(aub->verbose_log_file, in aub_map_ppgtt()
310 populate_ppgtt_table(aub, &aub->pml4, L4_index(l4_start), L4_index(l4_end), 4); in aub_map_ppgtt()
319 populate_ppgtt_table(aub, L3_table(l4), l3_start_idx, l3_end_idx, 3); in aub_map_ppgtt()
328 populate_ppgtt_table(aub, L2_table(l3), l2_start_idx, l2_end_idx, 2); in aub_map_ppgtt()
337 populate_ppgtt_table(aub, L1_table(l2), l1_start_idx, l1_end_idx, 1); in aub_map_ppgtt()
344 ppgtt_lookup(struct aub_file *aub, uint64_t ppgtt_addr) in ppgtt_lookup() argument
388 aub_map_ggtt(struct aub_file *aub, uint64_t virt_addr, uint64_t size) in aub_map_ggtt() argument
394 assert((aub->phys_addrs_allocator + size) < (1UL << 32)); in aub_map_ggtt()
398 uint64_t phys_addr = aub->phys_addrs_allocator << 12; in aub_map_ggtt()
399 aub->phys_addrs_allocator += ggtt_ptes; in aub_map_ggtt()
401 if (aub->verbose_log_file) { in aub_map_ggtt()
402 fprintf(aub->verbose_log_file, in aub_map_ggtt()
407 mem_trace_memory_write_header_out(aub, in aub_map_ggtt()
413 dword_out(aub, 1 + phys_addr + i * 4096); in aub_map_ggtt()
414 dword_out(aub, 0); in aub_map_ggtt()
419 aub_write_ggtt(struct aub_file *aub, uint64_t virt_addr, uint64_t size, const void *data) in aub_write_ggtt() argument
427 assert(!aub->has_default_setup); in aub_write_ggtt()
429 aub_map_ggtt(aub, virt_addr, size); in aub_write_ggtt()
440 mem_trace_memory_write_header_out(aub, virt_addr + offset, block_size, in aub_write_ggtt()
443 data_out(aub, (char *) data + offset, block_size); in aub_write_ggtt()
446 data_out(aub, null_block, -block_size & 3); in aub_write_ggtt()
490 alloc_ggtt_address(struct aub_file *aub, uint64_t size) in alloc_ggtt_address() argument
493 uint64_t addr = aub->ggtt_addrs_allocator << 12; in alloc_ggtt_address()
495 aub->ggtt_addrs_allocator += ggtt_ptes; in alloc_ggtt_address()
496 aub_map_ggtt(aub, addr, size); in alloc_ggtt_address()
502 write_hwsp(struct aub_file *aub, in write_hwsp() argument
514 register_write_out(aub, reg, aub->engine_setup[engine_class].hwsp_addr); in write_hwsp()
518 write_engine_execlist_setup(struct aub_file *aub, in write_engine_execlist_setup() argument
526 get_context_init(&aub->devinfo, NULL, engine_class, NULL, &context_size); in write_engine_execlist_setup()
531 uint64_t ggtt_addr = alloc_ggtt_address(aub, total_size); in write_engine_execlist_setup()
538 mem_trace_memory_write_header_out(aub, ggtt_addr, RING_SIZE, in write_engine_execlist_setup()
542 dword_out(aub, 0); in write_engine_execlist_setup()
548 mem_trace_memory_write_header_out(aub, ggtt_addr, in write_engine_execlist_setup()
553 dword_out(aub, 0); in write_engine_execlist_setup()
559 .pml4_addr = aub->pml4.phys_addr, in write_engine_execlist_setup()
562 get_context_init(&aub->devinfo, &params, engine_class, context_data, &context_size); in write_engine_execlist_setup()
563 data_out(aub, context_data, context_size); in write_engine_execlist_setup()
572 write_execlists_default_setup(struct aub_file *aub) in write_execlists_default_setup() argument
574 register_write_out(aub, GFX_MODE_RCSUNIT, 0x80008000 /* execlist enable */); in write_execlists_default_setup()
575 register_write_out(aub, GFX_MODE_VCSUNIT0, 0x80008000 /* execlist enable */); in write_execlists_default_setup()
576 register_write_out(aub, GFX_MODE_BCSUNIT, 0x80008000 /* execlist enable */); in write_execlists_default_setup()
579 static void write_legacy_default_setup(struct aub_file *aub) in write_legacy_default_setup() argument
584 dword_out(aub, CMD_AUB_TRACE_HEADER_BLOCK | in write_legacy_default_setup()
585 ((aub->addr_bits > 32 ? 6 : 5) - 2)); in write_legacy_default_setup()
586 dword_out(aub, AUB_TRACE_MEMTYPE_GTT_ENTRY | in write_legacy_default_setup()
588 dword_out(aub, 0); /* subtype */ in write_legacy_default_setup()
589 dword_out(aub, 0); /* offset */ in write_legacy_default_setup()
590 dword_out(aub, aub_gtt_size(aub)); /* size */ in write_legacy_default_setup()
591 if (aub->addr_bits > 32) in write_legacy_default_setup()
592 dword_out(aub, 0); in write_legacy_default_setup()
594 dword_out(aub, entry + 0x1000 * i); in write_legacy_default_setup()
595 if (aub->addr_bits > 32) in write_legacy_default_setup()
596 dword_out(aub, 0); in write_legacy_default_setup()
605 aub_write_default_setup(struct aub_file *aub) in aub_write_default_setup() argument
607 if (aub_use_execlists(aub)) in aub_write_default_setup()
608 write_execlists_default_setup(aub); in aub_write_default_setup()
610 write_legacy_default_setup(aub); in aub_write_default_setup()
612 aub->has_default_setup = true; in aub_write_default_setup()
616 aub_context_new(struct aub_file *aub, uint32_t new_id) in aub_context_new() argument
618 assert(aub->num_contexts < MAX_CONTEXT_COUNT); in aub_context_new()
620 struct aub_context *ctx = &aub->contexts[aub->num_contexts++]; in aub_context_new()
628 aub_write_context_create(struct aub_file *aub, uint32_t *ctx_id) in aub_write_context_create() argument
630 uint32_t new_id = ctx_id ? *ctx_id : aub->next_context_handle; in aub_write_context_create()
632 aub_context_new(aub, new_id); in aub_write_context_create()
635 aub->next_context_handle++; in aub_write_context_create()
641 aub_context_find(struct aub_file *aub, uint32_t id) in aub_context_find() argument
643 for (int i = 0; i < aub->num_contexts; i++) { in aub_context_find()
644 if (aub->contexts[i].id == id) in aub_context_find()
645 return &aub->contexts[i]; in aub_context_find()
652 aub_write_ensure_context(struct aub_file *aub, uint32_t ctx_id, in aub_write_ensure_context() argument
655 struct aub_context *ctx = aub_context_find(aub, ctx_id); in aub_write_ensure_context()
660 write_engine_execlist_setup(aub, ctx->id, hw_ctx, engine_class); in aub_write_ensure_context()
666 get_context_descriptor(struct aub_file *aub, in get_context_descriptor() argument
679 aub_write_trace_block(struct aub_file *aub, in aub_write_trace_block() argument
690 if (aub_use_execlists(aub)) { in aub_write_trace_block()
692 mem_trace_memory_write_header_out(aub, in aub_write_trace_block()
693 ppgtt_lookup(aub, gtt_offset + offset), in aub_write_trace_block()
698 dword_out(aub, CMD_AUB_TRACE_HEADER_BLOCK | in aub_write_trace_block()
699 ((aub->addr_bits > 32 ? 6 : 5) - 2)); in aub_write_trace_block()
700 dword_out(aub, AUB_TRACE_MEMTYPE_GTT | in aub_write_trace_block()
702 dword_out(aub, subtype); in aub_write_trace_block()
703 dword_out(aub, gtt_offset + offset); in aub_write_trace_block()
704 dword_out(aub, align_u32(block_size, 4)); in aub_write_trace_block()
705 if (aub->addr_bits > 32) in aub_write_trace_block()
706 dword_out(aub, (gtt_offset + offset) >> 32); in aub_write_trace_block()
710 data_out(aub, ((char *) virtual) + offset, block_size); in aub_write_trace_block()
712 data_out(aub, null_block, block_size); in aub_write_trace_block()
715 data_out(aub, null_block, -block_size & 3); in aub_write_trace_block()
720 aub_dump_ring_buffer_execlist(struct aub_file *aub, in aub_dump_ring_buffer_execlist() argument
725 mem_trace_memory_write_header_out(aub, hw_ctx->ring_addr, 16, in aub_dump_ring_buffer_execlist()
728 dword_out(aub, AUB_MI_BATCH_BUFFER_START | MI_BATCH_NON_SECURE_I965 | (3 - 2)); in aub_dump_ring_buffer_execlist()
729 dword_out(aub, batch_offset & 0xFFFFFFFF); in aub_dump_ring_buffer_execlist()
730 dword_out(aub, batch_offset >> 32); in aub_dump_ring_buffer_execlist()
731 dword_out(aub, 0 /* MI_NOOP */); in aub_dump_ring_buffer_execlist()
733 mem_trace_memory_write_header_out(aub, hw_ctx->ring_addr + 8192 + 20, 4, in aub_dump_ring_buffer_execlist()
736 dword_out(aub, 0); /* RING_BUFFER_HEAD */ in aub_dump_ring_buffer_execlist()
737 mem_trace_memory_write_header_out(aub, hw_ctx->ring_addr + 8192 + 28, 4, in aub_dump_ring_buffer_execlist()
740 dword_out(aub, 16); /* RING_BUFFER_TAIL */ in aub_dump_ring_buffer_execlist()
744 aub_dump_execlist(struct aub_file *aub, const struct engine *cs, uint64_t descriptor) in aub_dump_execlist() argument
746 if (aub->devinfo.gen >= 11) { in aub_dump_execlist()
747 register_write_out(aub, cs->elsq_reg, descriptor & 0xFFFFFFFF); in aub_dump_execlist()
748 register_write_out(aub, cs->elsq_reg + sizeof(uint32_t), descriptor >> 32); in aub_dump_execlist()
749 register_write_out(aub, cs->control_reg, 1); in aub_dump_execlist()
751 register_write_out(aub, cs->elsp_reg, 0); in aub_dump_execlist()
752 register_write_out(aub, cs->elsp_reg, 0); in aub_dump_execlist()
753 register_write_out(aub, cs->elsp_reg, descriptor >> 32); in aub_dump_execlist()
754 register_write_out(aub, cs->elsp_reg, descriptor & 0xFFFFFFFF); in aub_dump_execlist()
757 dword_out(aub, CMD_MEM_TRACE_REGISTER_POLL | (5 + 1 - 1)); in aub_dump_execlist()
758 dword_out(aub, cs->status_reg); in aub_dump_execlist()
759 dword_out(aub, AUB_MEM_TRACE_REGISTER_SIZE_DWORD | in aub_dump_execlist()
761 if (aub->devinfo.gen >= 11) { in aub_dump_execlist()
762 dword_out(aub, 0x00000001); /* mask lo */ in aub_dump_execlist()
763 dword_out(aub, 0x00000000); /* mask hi */ in aub_dump_execlist()
764 dword_out(aub, 0x00000001); in aub_dump_execlist()
766 dword_out(aub, 0x00000010); /* mask lo */ in aub_dump_execlist()
767 dword_out(aub, 0x00000000); /* mask hi */ in aub_dump_execlist()
768 dword_out(aub, 0x00000000); in aub_dump_execlist()
773 aub_dump_ring_buffer_legacy(struct aub_file *aub, in aub_dump_ring_buffer_legacy() argument
791 aub_mi_bbs_len = aub->addr_bits > 32 ? 3 : 2; in aub_dump_ring_buffer_legacy()
793 aub_write_reloc(&aub->devinfo, &ringbuffer[ring_count + 1], batch_offset); in aub_dump_ring_buffer_legacy()
799 dword_out(aub, CMD_AUB_TRACE_HEADER_BLOCK | in aub_dump_ring_buffer_legacy()
800 ((aub->addr_bits > 32 ? 6 : 5) - 2)); in aub_dump_ring_buffer_legacy()
801 dword_out(aub, AUB_TRACE_MEMTYPE_GTT | ring | AUB_TRACE_OP_COMMAND_WRITE); in aub_dump_ring_buffer_legacy()
802 dword_out(aub, 0); /* general/surface subtype */ in aub_dump_ring_buffer_legacy()
803 dword_out(aub, offset); in aub_dump_ring_buffer_legacy()
804 dword_out(aub, ring_count * 4); in aub_dump_ring_buffer_legacy()
805 if (aub->addr_bits > 32) in aub_dump_ring_buffer_legacy()
806 dword_out(aub, offset >> 32); in aub_dump_ring_buffer_legacy()
808 data_out(aub, ringbuffer, ring_count * 4); in aub_dump_ring_buffer_legacy()
812 aub_write_ensure_hwsp(struct aub_file *aub, in aub_write_ensure_hwsp() argument
815 uint64_t *hwsp_addr = &aub->engine_setup[engine_class].hwsp_addr; in aub_write_ensure_hwsp()
820 *hwsp_addr = alloc_ggtt_address(aub, 4096); in aub_write_ensure_hwsp()
821 write_hwsp(aub, engine_class); in aub_write_ensure_hwsp()
825 aub_write_exec(struct aub_file *aub, uint32_t ctx_id, uint64_t batch_addr, in aub_write_exec() argument
830 if (aub_use_execlists(aub)) { in aub_write_exec()
832 aub_write_ensure_context(aub, ctx_id, engine_class); in aub_write_exec()
833 uint64_t descriptor = get_context_descriptor(aub, cs, hw_ctx); in aub_write_exec()
834 aub_write_ensure_hwsp(aub, engine_class); in aub_write_exec()
835 aub_dump_ring_buffer_execlist(aub, hw_ctx, cs, batch_addr); in aub_write_exec()
836 aub_dump_execlist(aub, cs, descriptor); in aub_write_exec()
839 aub_dump_ring_buffer_legacy(aub, batch_addr, offset, engine_class); in aub_write_exec()
841 fflush(aub->file); in aub_write_exec()
845 aub_write_context_execlists(struct aub_file *aub, uint64_t context_addr, in aub_write_context_execlists() argument
850 aub_dump_execlist(aub, cs, descriptor); in aub_write_context_execlists()