aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2018-06-25 15:37:51 -0700
committerEric Anholt <[email protected]>2018-07-27 17:56:36 -0700
commit95bafeeabfeb1d8348191fa66ed2e5c3b730c54b (patch)
treea8e9cf8e2dd4c0b4b4cd9ef74831c641328fc603
parent3c02838d2956692101ae205f1aff362fa3a93c76 (diff)
v3d: Print addresses in CLIFs as references to buffers.
With CLIFs, the parser will choose an address for the buffer being created, so we need to use effectively relocations to buffers instead of the addresses that the driver uses. This is also a whole lot more intelligible for console output than raw addresses!
-rw-r--r--src/broadcom/cle/v3d_decoder.c25
-rw-r--r--src/broadcom/cle/v3d_decoder.h3
-rw-r--r--src/broadcom/clif/clif_dump.c20
-rw-r--r--src/broadcom/clif/clif_private.h3
4 files changed, 42 insertions, 9 deletions
diff --git a/src/broadcom/cle/v3d_decoder.c b/src/broadcom/cle/v3d_decoder.c
index f97aa6604cb..725561cef85 100644
--- a/src/broadcom/cle/v3d_decoder.c
+++ b/src/broadcom/cle/v3d_decoder.c
@@ -827,7 +827,7 @@ iter_advance_field(struct v3d_field_iterator *iter)
}
bool
-v3d_field_iterator_next(struct v3d_field_iterator *iter)
+v3d_field_iterator_next(struct clif_dump *clif, struct v3d_field_iterator *iter)
{
if (!iter_advance_field(iter))
return false;
@@ -872,7 +872,26 @@ v3d_field_iterator_next(struct v3d_field_iterator *iter)
snprintf(iter->value, sizeof(iter->value), "%f",
__gen_unpack_float(iter->p, s, e));
break;
- case V3D_TYPE_ADDRESS:
+
+ case V3D_TYPE_ADDRESS: {
+ uint32_t addr =
+ __gen_unpack_uint(iter->p, s, e) << (31 - (e - s));
+ struct clif_bo *bo = clif_lookup_bo(clif, addr);
+ if (bo) {
+ snprintf(iter->value, sizeof(iter->value),
+ "[%s+0x%08x] /* 0x%08x */",
+ bo->name, addr - bo->offset, addr);
+ } else if (addr) {
+ snprintf(iter->value, sizeof(iter->value),
+ "/* XXX: BO unknown */ 0x%08x", addr);
+ } else {
+ snprintf(iter->value, sizeof(iter->value),
+ "[null]");
+ }
+
+ break;
+ }
+
case V3D_TYPE_OFFSET:
snprintf(iter->value, sizeof(iter->value), "0x%08"PRIx64,
__gen_unpack_uint(iter->p, s, e) << (31 - (e - s)));
@@ -926,7 +945,7 @@ v3d_print_group(struct clif_dump *clif, struct v3d_group *group,
struct v3d_field_iterator iter;
v3d_field_iterator_init(&iter, group, p);
- while (v3d_field_iterator_next(&iter)) {
+ while (v3d_field_iterator_next(clif, &iter)) {
fprintf(clif->out, " %s: %s\n", iter.name, iter.value);
if (iter.struct_desc) {
uint64_t struct_offset = offset + iter.offset;
diff --git a/src/broadcom/cle/v3d_decoder.h b/src/broadcom/cle/v3d_decoder.h
index e147b1ea703..10a7e50b87f 100644
--- a/src/broadcom/cle/v3d_decoder.h
+++ b/src/broadcom/cle/v3d_decoder.h
@@ -136,7 +136,8 @@ void v3d_field_iterator_init(struct v3d_field_iterator *iter,
struct v3d_group *group,
const uint8_t *p);
-bool v3d_field_iterator_next(struct v3d_field_iterator *iter);
+bool v3d_field_iterator_next(struct clif_dump *clif,
+ struct v3d_field_iterator *iter);
void v3d_print_group(struct clif_dump *clif,
struct v3d_group *group,
diff --git a/src/broadcom/clif/clif_dump.c b/src/broadcom/clif/clif_dump.c
index f297c774b5a..3b693284e49 100644
--- a/src/broadcom/clif/clif_dump.c
+++ b/src/broadcom/clif/clif_dump.c
@@ -70,20 +70,30 @@ clif_dump_destroy(struct clif_dump *clif)
ralloc_free(clif);
}
-static bool
-clif_lookup_vaddr(struct clif_dump *clif, uint32_t addr, void **vaddr)
+struct clif_bo *
+clif_lookup_bo(struct clif_dump *clif, uint32_t addr)
{
for (int i = 0; i < clif->bo_count; i++) {
struct clif_bo *bo = &clif->bo[i];
if (addr >= bo->offset &&
addr < bo->offset + bo->size) {
- *vaddr = bo->vaddr + addr - bo->offset;
- return true;
+ return bo;
}
}
- return false;
+ return NULL;
+}
+
+static bool
+clif_lookup_vaddr(struct clif_dump *clif, uint32_t addr, void **vaddr)
+{
+ struct clif_bo *bo = clif_lookup_bo(clif, addr);
+ if (!bo)
+ return false;
+
+ *vaddr = bo->vaddr + addr - bo->offset;
+ return true;
}
#define out_uint(_clif, field) out(_clif, " /* %s = */ %u\n", \
diff --git a/src/broadcom/clif/clif_private.h b/src/broadcom/clif/clif_private.h
index da5f2a3cc29..ea96784289a 100644
--- a/src/broadcom/clif/clif_private.h
+++ b/src/broadcom/clif/clif_private.h
@@ -74,6 +74,9 @@ struct reloc_worklist_entry {
};
};
+struct clif_bo *
+clif_lookup_bo(struct clif_dump *clif, uint32_t addr);
+
struct reloc_worklist_entry *
clif_dump_add_address_to_worklist(struct clif_dump *clif,
enum reloc_worklist_type type,