mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-20 18:40:39 +02:00
intel/tools: Replace error_decode_xe_read_hw_sp_or_ctx_line() by a more generic function
error_decode_xe_read_hw_sp_or_ctx_line() is too specific, replacing it by a more generic function that later will be used in other places too. Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Signed-off-by: José Roberto de Souza <jose.souza@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33249>
This commit is contained in:
parent
b89e0fa226
commit
52e9d25aa0
4 changed files with 61 additions and 63 deletions
|
|
@ -227,14 +227,13 @@ read_xe_data_file(FILE *file,
|
|||
case XE_TOPIC_CONTEXT: {
|
||||
enum xe_vm_topic_type type;
|
||||
const char *value_ptr;
|
||||
bool is_hw_ctx;
|
||||
char binary_name[64];
|
||||
|
||||
/* TODO: what to do with HWSP? */
|
||||
type = error_decode_xe_read_hw_sp_or_ctx_line(line, &value_ptr, &is_hw_ctx);
|
||||
if (type != XE_VM_TOPIC_TYPE_UNKNOWN) {
|
||||
if (error_decode_xe_binary_line(line, binary_name, sizeof(binary_name), &type, &value_ptr)) {
|
||||
print_line = false;
|
||||
|
||||
if (!is_hw_ctx)
|
||||
if (strncmp(binary_name, "HWCTX", strlen("HWCTX")) != 0)
|
||||
break;
|
||||
|
||||
switch (type) {
|
||||
|
|
@ -251,8 +250,7 @@ read_xe_data_file(FILE *file,
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
if (is_hw_ctx)
|
||||
error_decode_xe_vm_hw_ctx_set(&xe_vm, vm_entry_len, vm_entry_data);
|
||||
error_decode_xe_vm_hw_ctx_set(&xe_vm, vm_entry_len, vm_entry_data);
|
||||
break;
|
||||
}
|
||||
case XE_VM_TOPIC_TYPE_ERROR:
|
||||
|
|
|
|||
|
|
@ -56,34 +56,34 @@ read_xe_data_file(FILE *dump_file, FILE *hang_dump_file, bool verbose)
|
|||
case XE_TOPIC_CONTEXT: {
|
||||
enum xe_vm_topic_type type;
|
||||
const char *value_ptr;
|
||||
bool is_hw_ctx;
|
||||
char binary_name[64];
|
||||
|
||||
type = error_decode_xe_read_hw_sp_or_ctx_line(line, &value_ptr, &is_hw_ctx);
|
||||
if (type == XE_VM_TOPIC_TYPE_UNKNOWN || !is_hw_ctx) {
|
||||
break;
|
||||
}
|
||||
if (error_decode_xe_binary_line(line, binary_name, sizeof(binary_name), &type, &value_ptr)) {
|
||||
if (strncmp(binary_name, "HWCTX", strlen("HWCTX")) != 0)
|
||||
break;
|
||||
|
||||
switch (type) {
|
||||
case XE_VM_TOPIC_TYPE_DATA:
|
||||
if (!error_decode_xe_ascii85_decode_allocated(value_ptr, vm_entry_data, vm_entry_len))
|
||||
printf("Failed to parse HWCTX data\n");
|
||||
break;
|
||||
case XE_VM_TOPIC_TYPE_LENGTH: {
|
||||
vm_entry_len = strtoul(value_ptr, NULL, 0);
|
||||
vm_entry_data = calloc(1, vm_entry_len);
|
||||
if (!vm_entry_data) {
|
||||
printf("Out of memory to allocate a buffer to store content of HWCTX\n");
|
||||
switch (type) {
|
||||
case XE_VM_TOPIC_TYPE_DATA:
|
||||
if (!error_decode_xe_ascii85_decode_allocated(value_ptr, vm_entry_data, vm_entry_len))
|
||||
printf("Failed to parse HWCTX data\n");
|
||||
break;
|
||||
case XE_VM_TOPIC_TYPE_LENGTH: {
|
||||
vm_entry_len = strtoul(value_ptr, NULL, 0);
|
||||
vm_entry_data = calloc(1, vm_entry_len);
|
||||
if (!vm_entry_data) {
|
||||
printf("Out of memory to allocate a buffer to store content of HWCTX\n");
|
||||
break;
|
||||
}
|
||||
|
||||
error_decode_xe_vm_hw_ctx_set(&xe_vm, vm_entry_len, vm_entry_data);
|
||||
break;
|
||||
}
|
||||
|
||||
error_decode_xe_vm_hw_ctx_set(&xe_vm, vm_entry_len, vm_entry_data);
|
||||
break;
|
||||
}
|
||||
case XE_VM_TOPIC_TYPE_ERROR:
|
||||
printf("HWCTX not present in dump, content will be zeroed: %s\n", line);
|
||||
break;
|
||||
default:
|
||||
printf("Not expected line in HWCTX: %s", line);
|
||||
case XE_VM_TOPIC_TYPE_ERROR:
|
||||
printf("HWCTX not present in dump, content will be zeroed: %s\n", line);
|
||||
break;
|
||||
default:
|
||||
printf("Not expected line in HWCTX: %s", line);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -136,54 +136,54 @@ error_decode_xe_read_vm_line(const char *line, uint64_t *address, const char **v
|
|||
return type;
|
||||
}
|
||||
|
||||
/*
|
||||
* similar to read_xe_vm_line() but it parses '[HWCTX].data: ...'
|
||||
/* return true if line is a binary line.
|
||||
* name is set with binary name, type is set with line binary type and
|
||||
* value_ptr with line binary value(length, error or data).
|
||||
*/
|
||||
enum xe_vm_topic_type
|
||||
error_decode_xe_read_hw_sp_or_ctx_line(const char *line, const char **value_ptr, bool *is_hw_ctx)
|
||||
bool
|
||||
error_decode_xe_binary_line(const char *line, char *name, int name_len, enum xe_vm_topic_type *type, const char **value_ptr)
|
||||
{
|
||||
enum xe_vm_topic_type type;
|
||||
char text_addr[64];
|
||||
bool is_hw_sp;
|
||||
int i;
|
||||
const char *c = line;
|
||||
|
||||
if (*line != '\t')
|
||||
return XE_VM_TOPIC_TYPE_UNKNOWN;
|
||||
while (*c == '\t' || *c == 0)
|
||||
c++;
|
||||
|
||||
line++;
|
||||
if (*line != '[')
|
||||
return XE_VM_TOPIC_TYPE_UNKNOWN;
|
||||
if (*c != '[')
|
||||
return false;
|
||||
c++;
|
||||
|
||||
for (i = 0, line++; *line != ']'; i++, line++)
|
||||
text_addr[i] = *line;
|
||||
for (; *c != ']' && (name_len - 1) && *c != 0; c++, name++, name_len--)
|
||||
*name = *c;
|
||||
*name = 0;
|
||||
|
||||
text_addr[i] = 0;
|
||||
*is_hw_ctx = strncmp(text_addr, "HWCTX", strlen("HWCTX")) == 0;
|
||||
is_hw_sp = strncmp(text_addr, "HWSP", strlen("HWSP")) == 0;
|
||||
if (*is_hw_ctx == false && is_hw_sp == false)
|
||||
return XE_VM_TOPIC_TYPE_UNKNOWN;
|
||||
if (*c != ']' || c[1] != '.')
|
||||
return false;
|
||||
c += 2;
|
||||
|
||||
/* at this point line points to last address digit so +3 to point to type */
|
||||
line += 2;
|
||||
switch (*line) {
|
||||
switch (*c) {
|
||||
case 'd':
|
||||
type = XE_VM_TOPIC_TYPE_DATA;
|
||||
break;
|
||||
case 'l':
|
||||
type = XE_VM_TOPIC_TYPE_LENGTH;
|
||||
*type = XE_VM_TOPIC_TYPE_DATA;
|
||||
break;
|
||||
case 'e':
|
||||
type = XE_VM_TOPIC_TYPE_ERROR;
|
||||
*type = XE_VM_TOPIC_TYPE_ERROR;
|
||||
break;
|
||||
case 'l':
|
||||
*type = XE_VM_TOPIC_TYPE_LENGTH;
|
||||
break;
|
||||
default:
|
||||
printf("type char: %c\n", *line);
|
||||
return XE_VM_TOPIC_TYPE_UNKNOWN;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (; *line != ':'; line++);
|
||||
while (*c != ':' && *c != 0)
|
||||
c++;
|
||||
|
||||
*value_ptr = line + 2;
|
||||
return type;
|
||||
if (*c != ':' || c[1] != ' ')
|
||||
return false;
|
||||
c += 2;
|
||||
|
||||
*value_ptr = c;
|
||||
return true;
|
||||
}
|
||||
|
||||
void error_decode_xe_vm_init(struct xe_vm *xe_vm)
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ bool error_decode_xe_read_engine_name(const char *line, char *ring_name);
|
|||
bool error_decode_xe_decode_topic(const char *line, enum xe_topic *new_topic);
|
||||
|
||||
enum xe_vm_topic_type error_decode_xe_read_vm_line(const char *line, uint64_t *address, const char **value_ptr);
|
||||
enum xe_vm_topic_type error_decode_xe_read_hw_sp_or_ctx_line(const char *line, const char **value_ptr, bool *is_hw_ctx);
|
||||
bool error_decode_xe_binary_line(const char *line, char *name, int name_len, enum xe_vm_topic_type *type, const char **value_ptr);
|
||||
|
||||
void error_decode_xe_vm_init(struct xe_vm *xe_vm);
|
||||
void error_decode_xe_vm_fini(struct xe_vm *xe_vm);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue