freedreno/fdperf: Use common device info helpers
Manually constructing the chip-id will stop working with future devices.
And now that we get the generation from the device table, we can't be
sloppy about using a bogus dev_id.
Fixes: 00900b76e0 ("freedreno: Decouple GPU gen from gpu_id/chip_id")
Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23953>
This commit is contained in:
@@ -86,7 +86,6 @@ struct counter_group {
|
||||
|
||||
static struct {
|
||||
void *io;
|
||||
uint32_t chipid;
|
||||
uint32_t min_freq;
|
||||
uint32_t max_freq;
|
||||
/* per-generation table of counters: */
|
||||
@@ -95,6 +94,7 @@ static struct {
|
||||
/* drm device (for writing select regs via ring): */
|
||||
struct fd_device *dev;
|
||||
struct fd_pipe *pipe;
|
||||
const struct fd_dev_id *dev_id;
|
||||
struct fd_submit *submit;
|
||||
struct fd_ringbuffer *ring;
|
||||
} dev;
|
||||
@@ -146,22 +146,16 @@ find_device(void)
|
||||
|
||||
dev.pipe = fd_pipe_new(dev.dev, FD_PIPE_3D);
|
||||
|
||||
uint64_t val;
|
||||
ret = fd_pipe_get_param(dev.pipe, FD_CHIP_ID, &val);
|
||||
if (ret) {
|
||||
err(1, "could not get gpu-id");
|
||||
}
|
||||
dev.chipid = val;
|
||||
dev.dev_id = fd_pipe_dev_id(dev.pipe);
|
||||
if (!fd_dev_info(dev.dev_id))
|
||||
err(1, "unknown device");
|
||||
|
||||
#define CHIP_FMT "d%d%d.%d"
|
||||
#define CHIP_ARGS(chipid) \
|
||||
((chipid) >> 24) & 0xff, ((chipid) >> 16) & 0xff, ((chipid) >> 8) & 0xff, \
|
||||
((chipid) >> 0) & 0xff
|
||||
printf("device: a%" CHIP_FMT "\n", CHIP_ARGS(dev.chipid));
|
||||
printf("device: %s\n", fd_dev_name(dev.dev_id));
|
||||
|
||||
/* try MAX_FREQ first as that will work regardless of old dt
|
||||
* dt bindings vs upstream bindings:
|
||||
*/
|
||||
uint64_t val;
|
||||
ret = fd_pipe_get_param(dev.pipe, FD_MAX_FREQ, &val);
|
||||
if (ret) {
|
||||
printf("falling back to parsing DT bindings for freq\n");
|
||||
@@ -229,7 +223,7 @@ select_counter(struct counter_group *group, int ctr, int n)
|
||||
* makes things more complicated for capturing inital sample value
|
||||
*/
|
||||
struct fd_ringbuffer *ring = dev.ring;
|
||||
switch (dev.chipid >> 24) {
|
||||
switch (fd_dev_gen(dev.dev_id)) {
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
@@ -340,8 +334,8 @@ redraw_footer(WINDOW *win)
|
||||
char *footer;
|
||||
int n;
|
||||
|
||||
n = asprintf(&footer, " fdperf: a%" CHIP_FMT " (%.2fMHz..%.2fMHz)",
|
||||
CHIP_ARGS(dev.chipid), ((float)dev.min_freq) / 1000000.0,
|
||||
n = asprintf(&footer, " fdperf: %s (%.2fMHz..%.2fMHz)",
|
||||
fd_dev_name(dev.dev_id), ((float)dev.min_freq) / 1000000.0,
|
||||
((float)dev.max_freq) / 1000000.0);
|
||||
|
||||
wmove(win, h - 1, 0);
|
||||
@@ -846,11 +840,13 @@ config_restore(void)
|
||||
config_setting_t *root = config_root_setting(&cfg);
|
||||
|
||||
/* per device settings: */
|
||||
(void)asprintf(&str, "a%dxx", dev.chipid >> 24);
|
||||
(void)asprintf(&str, "%s", fd_dev_name(dev.dev_id));
|
||||
setting = config_setting_get_member(root, str);
|
||||
if (!setting)
|
||||
setting = config_setting_add(root, str, CONFIG_TYPE_GROUP);
|
||||
free(str);
|
||||
if (!setting)
|
||||
return;
|
||||
|
||||
for (unsigned i = 0; i < dev.ngroups; i++) {
|
||||
struct counter_group *group = &dev.groups[i];
|
||||
@@ -926,10 +922,7 @@ main(int argc, char **argv)
|
||||
find_device();
|
||||
|
||||
const struct fd_perfcntr_group *groups;
|
||||
struct fd_dev_id dev_id = {
|
||||
.gpu_id = (dev.chipid >> 24) * 100,
|
||||
};
|
||||
groups = fd_perfcntrs(&dev_id, &dev.ngroups);
|
||||
groups = fd_perfcntrs(dev.dev_id, &dev.ngroups);
|
||||
if (!groups) {
|
||||
errx(1, "no perfcntr support");
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ if dep_libconfig.found() and dep_curses.found()
|
||||
inc_gallium_aux,
|
||||
],
|
||||
link_with : [
|
||||
libfreedreno_common,
|
||||
libfreedreno_drm,
|
||||
libfreedreno_perfcntrs,
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user