struct clif_dump *
clif_dump_init(const struct v3d_device_info *devinfo,
- FILE *out,
- bool (*lookup_vaddr)(void *data, uint32_t addr, void **vaddr),
- void *data)
+ FILE *out)
{
struct clif_dump *clif = rzalloc(NULL, struct clif_dump);
clif->devinfo = devinfo;
- clif->lookup_vaddr = lookup_vaddr;
clif->out = out;
- clif->data = data;
clif->spec = v3d_spec_load(devinfo);
list_inithead(&clif->worklist);
ralloc_free(clif);
}
+static bool
+clif_lookup_vaddr(struct clif_dump *clif, uint32_t addr, void **vaddr)
+{
+ 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 false;
+}
+
#define out_uint(_clif, field) out(_clif, " /* %s = */ %u\n", \
#field, values-> field);
clif_dump_cl(struct clif_dump *clif, uint32_t start, uint32_t end)
{
void *start_vaddr;
- if (!clif->lookup_vaddr(clif->data, start, &start_vaddr)) {
+ if (!clif_lookup_vaddr(clif, start, &start_vaddr)) {
out(clif, "Failed to look up address 0x%08x\n",
start);
return;
* won't set an end), but is used for BCL/RCL termination.
*/
void *end_vaddr = NULL;
- if (end && !clif->lookup_vaddr(clif->data, end, &end_vaddr)) {
+ if (end && !clif_lookup_vaddr(clif, end, &end_vaddr)) {
out(clif, "Failed to look up address 0x%08x\n",
end);
return;
list_del(&reloc->link);
void *vaddr;
- if (!clif->lookup_vaddr(clif->data, reloc->addr, &vaddr)) {
+ if (!clif_lookup_vaddr(clif, reloc->addr, &vaddr)) {
out(clif, "Failed to look up address 0x%08x\n",
reloc->addr);
continue;
clif_process_worklist(clif);
}
+
+void
+clif_dump_add_bo(struct clif_dump *clif, const char *name,
+ uint32_t offset, uint32_t size, void *vaddr)
+{
+ if (clif->bo_count >= clif->bo_array_size) {
+ clif->bo_array_size = MAX2(4, clif->bo_array_size * 2);
+ clif->bo = reralloc(clif, clif->bo, struct clif_bo,
+ clif->bo_array_size);
+ }
+
+ clif->bo[clif->bo_count].name = ralloc_strdup(clif, name);
+ clif->bo[clif->bo_count].offset = offset;
+ clif->bo[clif->bo_count].size = size;
+ clif->bo[clif->bo_count].vaddr = vaddr;
+ clif->bo_count++;
+}
struct clif_dump;
struct clif_dump *clif_dump_init(const struct v3d_device_info *devinfo,
- FILE *output,
- bool (*lookup_vaddr)(void *data, uint32_t addr,
- void **vaddr),
- void *data);
+ FILE *output);
+void clif_dump(struct clif_dump *clif);
void clif_dump_destroy(struct clif_dump *clif);
+void clif_dump_add_bo(struct clif_dump *clif, const char *name,
+ uint32_t offset, uint32_t size, void *vaddr);
void clif_dump_add_cl(struct clif_dump *clif, uint32_t start, uint32_t end);
#endif
return job;
}
-static bool
-v3d_clif_dump_lookup(void *data, uint32_t addr, void **vaddr)
-{
- struct v3d_job *job = data;
- struct set_entry *entry;
-
- set_foreach(job->bos, entry) {
- struct v3d_bo *bo = (void *)entry->key;
-
- if (addr >= bo->offset &&
- addr < bo->offset + bo->size) {
- v3d_bo_map(bo);
- *vaddr = bo->map + addr - bo->offset;
- return true;
- }
- }
-
- return false;
-}
-
static void
v3d_clif_dump(struct v3d_context *v3d, struct v3d_job *job)
{
return;
struct clif_dump *clif = clif_dump_init(&v3d->screen->devinfo,
- stderr, v3d_clif_dump_lookup,
- job);
+ stderr);
+
+ struct set_entry *entry;
+ set_foreach(job->bos, entry) {
+ struct v3d_bo *bo = (void *)entry->key;
+ char *name = ralloc_asprintf(NULL, "%s_0x%x",
+ bo->name, bo->offset);
+
+ v3d_bo_map(bo);
+ clif_dump_add_bo(clif, name, bo->offset, bo->size, bo->map);
+
+ ralloc_free(name);
+ }
fprintf(stderr, "BCL: 0x%08x..0x%08x\n",
job->submit.bcl_start, job->submit.bcl_end);
fprintf(stderr, "RCL: 0x%08x..0x%08x\n",
job->submit.rcl_start, job->submit.rcl_end);
clif_dump_add_cl(clif, job->submit.rcl_start, job->submit.rcl_end);
+
+ clif_dump_destroy(clif);
}
/**