WIP: freedreno/perfcntrs: Add tool to dump perfctr tables

Just so we have a sane way to check for errors while migrating.
This commit is contained in:
Rob Clark 2026-03-17 12:53:40 -07:00
parent f694b2ac6f
commit f52f68d548
2 changed files with 102 additions and 0 deletions

View file

@ -0,0 +1,82 @@
/*
* Copyright © 2016 Rob Clark <robclark@freedesktop.org>
* All Rights Reserved.
* SPDX-License-Identifier: MIT
*/
#include <assert.h>
#include <ctype.h>
#include <curses.h>
#include <err.h>
#include <inttypes.h>
#include <libconfig.h>
#include <locale.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <xf86drm.h>
#include "drm/freedreno_drmif.h"
#include "drm/freedreno_ringbuffer.h"
#include "util/os_file.h"
#include "freedreno_dt.h"
#include "freedreno_perfcntr.h"
/*
* Simple tool to dump perfctr tables (so we can make sure nothing gets
* missed while converting to generated tables)
*/
int
main(int argc, char **argv)
{
struct fd_dev_id dev_id = {};
unsigned ngroups = 0;
const struct fd_perfcntr_group *groups;
if (argc != 2)
return -1;
if (!strcmp(argv[1], "a2xx")) {
dev_id.gpu_id = 200;
} else if (!strcmp(argv[1], "a5xx")) {
dev_id.gpu_id = 530;
} else if (!strcmp(argv[1], "a6xx")) {
dev_id.gpu_id = 630;
} else if (!strcmp(argv[1], "a7xx")) {
dev_id.chip_id = 0xffff07030001;
}
groups = fd_perfcntrs(&dev_id, &ngroups);
if (!groups) {
errx(1, "no perfcntr support");
}
for (int i = 0; i < ngroups; i++) {
const struct fd_perfcntr_group *g = &groups[i];
printf("GROUP[%s]: num_counters=%u, num_countables=%u\n",
g->name, g->num_counters, g->num_countables);
for (int j = 0; j < g->num_counters; j++) {
const struct fd_perfcntr_counter *counter = &g->counters[j];
printf("COUNTER: %04x, %04x, %04x, %04x, %04x\n",
counter->select_reg, counter->counter_reg_lo, counter->counter_reg_hi,
counter->enable, counter->clear);
}
for (int j = 0; j < g->num_countables; j++) {
const struct fd_perfcntr_countable *countable = &g->countables[j];
printf("COUNTABLE[%s]: %04x\n", countable->name, countable->selector);
}
printf("\n");
}
return 0;
}

View file

@ -51,3 +51,23 @@ if dep_libconfig.found() and dep_curses.found()
install : with_tools.contains('freedreno'),
)
endif
dumpctrs = executable(
'dumpctrs',
['dumpctrs.c', freedreno_xml_header_files],
include_directories : [
inc_freedreno,
inc_include,
inc_src,
],
link_with : [
libfreedreno_common,
libfreedreno_drm,
libfreedreno_perfcntrs,
],
dependencies : [
dep_libdrm,
idep_mesautil,
],
build_by_default : with_tools.contains('freedreno'),
)