intel/aub_write: write header in init
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Rafael Antognolli <rafael.antognolli@intel.com>
This commit is contained in:
+87
-83
@@ -114,32 +114,6 @@ aub_ppgtt_table_finish(struct aub_ppgtt_table *table, int level)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
aub_file_init(struct aub_file *aub, FILE *file, uint16_t pci_id)
|
||||
{
|
||||
memset(aub, 0, sizeof(*aub));
|
||||
|
||||
aub->file = file;
|
||||
aub->pci_id = pci_id;
|
||||
fail_if(!gen_get_device_info(pci_id, &aub->devinfo),
|
||||
"failed to identify chipset=0x%x\n", pci_id);
|
||||
aub->addr_bits = aub->devinfo.gen >= 8 ? 48 : 32;
|
||||
|
||||
aub->pml4.phys_addr = PML4_PHYS_ADDR;
|
||||
}
|
||||
|
||||
void
|
||||
aub_file_finish(struct aub_file *aub)
|
||||
{
|
||||
aub_ppgtt_table_finish(&aub->pml4, 4);
|
||||
fclose(aub->file);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
aub_gtt_size(struct aub_file *aub)
|
||||
{
|
||||
return NUM_PT_ENTRIES * (aub->addr_bits > 32 ? GEN8_PTE_SIZE : PTE_SIZE);
|
||||
}
|
||||
|
||||
static void
|
||||
data_out(struct aub_file *aub, const void *data, size_t size)
|
||||
@@ -157,6 +131,93 @@ dword_out(struct aub_file *aub, uint32_t data)
|
||||
data_out(aub, &data, sizeof(data));
|
||||
}
|
||||
|
||||
static void
|
||||
write_execlists_header(struct aub_file *aub, const char *name)
|
||||
{
|
||||
char app_name[8 * 4];
|
||||
int app_name_len, dwords;
|
||||
|
||||
app_name_len =
|
||||
snprintf(app_name, sizeof(app_name), "PCI-ID=0x%X %s",
|
||||
aub->pci_id, name);
|
||||
app_name_len = ALIGN(app_name_len, sizeof(uint32_t));
|
||||
|
||||
dwords = 5 + app_name_len / sizeof(uint32_t);
|
||||
dword_out(aub, CMD_MEM_TRACE_VERSION | (dwords - 1));
|
||||
dword_out(aub, AUB_MEM_TRACE_VERSION_FILE_VERSION);
|
||||
dword_out(aub, aub->devinfo.simulator_id << AUB_MEM_TRACE_VERSION_DEVICE_SHIFT);
|
||||
dword_out(aub, 0); /* version */
|
||||
dword_out(aub, 0); /* version */
|
||||
data_out(aub, app_name, app_name_len);
|
||||
}
|
||||
|
||||
static void
|
||||
write_legacy_header(struct aub_file *aub, const char *name)
|
||||
{
|
||||
char app_name[8 * 4];
|
||||
char comment[16];
|
||||
int comment_len, comment_dwords, dwords;
|
||||
|
||||
comment_len = snprintf(comment, sizeof(comment), "PCI-ID=0x%x", aub->pci_id);
|
||||
comment_dwords = ((comment_len + 3) / 4);
|
||||
|
||||
/* Start with a (required) version packet. */
|
||||
dwords = 13 + comment_dwords;
|
||||
dword_out(aub, CMD_AUB_HEADER | (dwords - 2));
|
||||
dword_out(aub, (4 << AUB_HEADER_MAJOR_SHIFT) |
|
||||
(0 << AUB_HEADER_MINOR_SHIFT));
|
||||
|
||||
/* Next comes a 32-byte application name. */
|
||||
strncpy(app_name, name, sizeof(app_name));
|
||||
app_name[sizeof(app_name) - 1] = 0;
|
||||
data_out(aub, app_name, sizeof(app_name));
|
||||
|
||||
dword_out(aub, 0); /* timestamp */
|
||||
dword_out(aub, 0); /* timestamp */
|
||||
dword_out(aub, comment_len);
|
||||
data_out(aub, comment, comment_dwords * 4);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
aub_write_header(struct aub_file *aub, const char *app_name)
|
||||
{
|
||||
if (aub_use_execlists(aub))
|
||||
write_execlists_header(aub, app_name);
|
||||
else
|
||||
write_legacy_header(aub, app_name);
|
||||
}
|
||||
|
||||
void
|
||||
aub_file_init(struct aub_file *aub, FILE *file, FILE *debug, uint16_t pci_id, const char *app_name)
|
||||
{
|
||||
memset(aub, 0, sizeof(*aub));
|
||||
|
||||
aub->verbose_log_file = debug;
|
||||
aub->file = file;
|
||||
aub->pci_id = pci_id;
|
||||
fail_if(!gen_get_device_info(pci_id, &aub->devinfo),
|
||||
"failed to identify chipset=0x%x\n", pci_id);
|
||||
aub->addr_bits = aub->devinfo.gen >= 8 ? 48 : 32;
|
||||
|
||||
aub->pml4.phys_addr = PML4_PHYS_ADDR;
|
||||
|
||||
aub_write_header(aub, app_name);
|
||||
}
|
||||
|
||||
void
|
||||
aub_file_finish(struct aub_file *aub)
|
||||
{
|
||||
aub_ppgtt_table_finish(&aub->pml4, 4);
|
||||
fclose(aub->file);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
aub_gtt_size(struct aub_file *aub)
|
||||
{
|
||||
return NUM_PT_ENTRIES * (aub->addr_bits > 32 ? GEN8_PTE_SIZE : PTE_SIZE);
|
||||
}
|
||||
|
||||
static void
|
||||
mem_trace_memory_write_header_out(struct aub_file *aub, uint64_t addr,
|
||||
uint32_t len, uint32_t addr_space,
|
||||
@@ -306,63 +367,6 @@ ppgtt_lookup(struct aub_file *aub, uint64_t ppgtt_addr)
|
||||
return (uint64_t)L1_table(ppgtt_addr)->subtables[L1_index(ppgtt_addr)];
|
||||
}
|
||||
|
||||
static void
|
||||
write_execlists_header(struct aub_file *aub, const char *name)
|
||||
{
|
||||
char app_name[8 * 4];
|
||||
int app_name_len, dwords;
|
||||
|
||||
app_name_len =
|
||||
snprintf(app_name, sizeof(app_name), "PCI-ID=0x%X %s",
|
||||
aub->pci_id, name);
|
||||
app_name_len = ALIGN(app_name_len, sizeof(uint32_t));
|
||||
|
||||
dwords = 5 + app_name_len / sizeof(uint32_t);
|
||||
dword_out(aub, CMD_MEM_TRACE_VERSION | (dwords - 1));
|
||||
dword_out(aub, AUB_MEM_TRACE_VERSION_FILE_VERSION);
|
||||
dword_out(aub, aub->devinfo.simulator_id << AUB_MEM_TRACE_VERSION_DEVICE_SHIFT);
|
||||
dword_out(aub, 0); /* version */
|
||||
dword_out(aub, 0); /* version */
|
||||
data_out(aub, app_name, app_name_len);
|
||||
}
|
||||
|
||||
static void
|
||||
write_legacy_header(struct aub_file *aub, const char *name)
|
||||
{
|
||||
char app_name[8 * 4];
|
||||
char comment[16];
|
||||
int comment_len, comment_dwords, dwords;
|
||||
|
||||
comment_len = snprintf(comment, sizeof(comment), "PCI-ID=0x%x", aub->pci_id);
|
||||
comment_dwords = ((comment_len + 3) / 4);
|
||||
|
||||
/* Start with a (required) version packet. */
|
||||
dwords = 13 + comment_dwords;
|
||||
dword_out(aub, CMD_AUB_HEADER | (dwords - 2));
|
||||
dword_out(aub, (4 << AUB_HEADER_MAJOR_SHIFT) |
|
||||
(0 << AUB_HEADER_MINOR_SHIFT));
|
||||
|
||||
/* Next comes a 32-byte application name. */
|
||||
strncpy(app_name, name, sizeof(app_name));
|
||||
app_name[sizeof(app_name) - 1] = 0;
|
||||
data_out(aub, app_name, sizeof(app_name));
|
||||
|
||||
dword_out(aub, 0); /* timestamp */
|
||||
dword_out(aub, 0); /* timestamp */
|
||||
dword_out(aub, comment_len);
|
||||
data_out(aub, comment, comment_dwords * 4);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
aub_write_header(struct aub_file *aub, const char *app_name)
|
||||
{
|
||||
if (aub_use_execlists(aub))
|
||||
write_execlists_header(aub, app_name);
|
||||
else
|
||||
write_legacy_header(aub, app_name);
|
||||
}
|
||||
|
||||
static void
|
||||
write_execlists_default_setup(struct aub_file *aub)
|
||||
{
|
||||
|
||||
@@ -54,7 +54,7 @@ struct aub_file {
|
||||
struct aub_ppgtt_table pml4;
|
||||
};
|
||||
|
||||
void aub_file_init(struct aub_file *aub, FILE *file, uint16_t pci_id);
|
||||
void aub_file_init(struct aub_file *aub, FILE *file, FILE *debug, uint16_t pci_id, const char *app_name);
|
||||
void aub_file_finish(struct aub_file *aub);
|
||||
|
||||
static inline bool aub_use_execlists(const struct aub_file *aub)
|
||||
@@ -74,7 +74,6 @@ aub_write_reloc(const struct gen_device_info *devinfo, void *p, uint64_t v)
|
||||
}
|
||||
}
|
||||
|
||||
void aub_write_header(struct aub_file *aub, const char *app_name);
|
||||
void aub_write_default_setup(struct aub_file *aub);
|
||||
void aub_map_ppgtt(struct aub_file *aub, uint64_t start, uint64_t size);
|
||||
void aub_write_trace_block(struct aub_file *aub,
|
||||
|
||||
@@ -218,11 +218,11 @@ main(int argc, char *argv[])
|
||||
int matched = sscanf(line, "PCI ID: 0x%04x\n", &pci_id);
|
||||
fail_if(!matched, "Invalid error state file!\n");
|
||||
|
||||
aub_file_init(&aub, aub_file, pci_id);
|
||||
aub_file_init(&aub, aub_file,
|
||||
NULL, pci_id, "error_state");
|
||||
fail_if(!aub_use_execlists(&aub),
|
||||
"%s currently only works on gen8+\n", argv[0]);
|
||||
|
||||
aub_write_header(&aub, "error state");
|
||||
aub_write_default_setup(&aub);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -208,10 +208,9 @@ dump_execbuffer2(int fd, struct drm_i915_gem_execbuffer2 *execbuffer2)
|
||||
fail_if(!gen_get_device_info(device, &devinfo),
|
||||
"failed to identify chipset=0x%x\n", device);
|
||||
|
||||
aub_file_init(&aub_file, output_file, device);
|
||||
if (verbose == 2)
|
||||
aub_file.verbose_log_file = stdout;
|
||||
aub_write_header(&aub_file, program_invocation_short_name);
|
||||
aub_file_init(&aub_file, output_file,
|
||||
verbose == 2 ? stdout : NULL,
|
||||
device, program_invocation_short_name);
|
||||
aub_write_default_setup(&aub_file);
|
||||
|
||||
if (verbose)
|
||||
|
||||
Reference in New Issue
Block a user