diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/broadcom/clif/clif_dump.c | 45 | ||||
-rw-r--r-- | src/broadcom/clif/clif_dump.h | 8 | ||||
-rw-r--r-- | src/broadcom/clif/clif_private.h | 14 | ||||
-rw-r--r-- | src/gallium/drivers/v3d/v3d_job.c | 37 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/vc4_cl_dump.c | 2 |
5 files changed, 68 insertions, 38 deletions
diff --git a/src/broadcom/clif/clif_dump.c b/src/broadcom/clif/clif_dump.c index ca8d6d3e6fd..fe68b5102eb 100644 --- a/src/broadcom/clif/clif_dump.c +++ b/src/broadcom/clif/clif_dump.c @@ -51,16 +51,12 @@ clif_dump_add_address_to_worklist(struct clif_dump *clif, 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); @@ -74,6 +70,22 @@ clif_dump_destroy(struct clif_dump *clif) 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); @@ -91,7 +103,7 @@ static void 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; @@ -101,7 +113,7 @@ clif_dump_cl(struct clif_dump *clif, uint32_t start, uint32_t end) * 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; @@ -151,7 +163,7 @@ clif_process_worklist(struct clif_dump *clif) 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; @@ -180,3 +192,20 @@ clif_dump_add_cl(struct clif_dump *clif, uint32_t start, uint32_t end) 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++; +} diff --git a/src/broadcom/clif/clif_dump.h b/src/broadcom/clif/clif_dump.h index d46cc84710e..f89447b9bd9 100644 --- a/src/broadcom/clif/clif_dump.h +++ b/src/broadcom/clif/clif_dump.h @@ -31,12 +31,12 @@ struct v3d_device_info; 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 diff --git a/src/broadcom/clif/clif_private.h b/src/broadcom/clif/clif_private.h index 376daef80d9..0d762c4b747 100644 --- a/src/broadcom/clif/clif_private.h +++ b/src/broadcom/clif/clif_private.h @@ -28,17 +28,25 @@ #include <stdarg.h> #include "util/list.h" +struct clif_bo { + const char *name; + uint32_t offset; + uint32_t size; + void *vaddr; +}; + struct clif_dump { const struct v3d_device_info *devinfo; - bool (*lookup_vaddr)(void *data, uint32_t addr, void **vaddr); FILE *out; - /* Opaque data from the caller that is passed to the callbacks. */ - void *data; struct v3d_spec *spec; /* List of struct reloc_worklist_entry */ struct list_head worklist; + + struct clif_bo *bo; + int bo_count; + int bo_array_size; }; enum reloc_worklist_type { diff --git a/src/gallium/drivers/v3d/v3d_job.c b/src/gallium/drivers/v3d/v3d_job.c index 9ab8e5107a7..20f8bcc3f32 100644 --- a/src/gallium/drivers/v3d/v3d_job.c +++ b/src/gallium/drivers/v3d/v3d_job.c @@ -341,26 +341,6 @@ v3d_get_job_for_fbo(struct v3d_context *v3d) 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) { @@ -368,8 +348,19 @@ 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); @@ -379,6 +370,8 @@ v3d_clif_dump(struct v3d_context *v3d, struct v3d_job *job) 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); } /** diff --git a/src/gallium/drivers/vc4/vc4_cl_dump.c b/src/gallium/drivers/vc4/vc4_cl_dump.c index c5be426d132..bd2d7137c58 100644 --- a/src/gallium/drivers/vc4/vc4_cl_dump.c +++ b/src/gallium/drivers/vc4/vc4_cl_dump.c @@ -42,7 +42,7 @@ vc4_dump_cl(void *cl, uint32_t size, bool is_render) }; struct v3d_spec *spec = v3d_spec_load(&devinfo); - struct clif_dump *clif = clif_dump_init(&devinfo, stderr, NULL, NULL); + struct clif_dump *clif = clif_dump_init(&devinfo, stderr); uint32_t offset = 0, hw_offset = 0; uint8_t *p = cl; |