From 547f20773c043ddc966e8749666eadeb80428e56 Mon Sep 17 00:00:00 2001 From: Zan Dobersek Date: Fri, 22 Mar 2024 15:07:24 +0100 Subject: [PATCH] fdperf: select_counter() should work with a countable value Right now select_counter() is called with values of specific countables that should be tracked in the given counter, but it treats those values as indices into the array of all available countables for a given counter group. This works right now since all countable values for any counter group are sequential, but that won't be the case on a7xx. To address that, select_counter() is adjusted to find the index of the specified countable value, and use that to store the label pointer that should be displayed for the desired counter. Signed-off-by: Zan Dobersek Part-of: --- src/freedreno/perfcntrs/fdperf.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/freedreno/perfcntrs/fdperf.c b/src/freedreno/perfcntrs/fdperf.c index cf95805edf3..23861b2b542 100644 --- a/src/freedreno/perfcntrs/fdperf.c +++ b/src/freedreno/perfcntrs/fdperf.c @@ -201,13 +201,24 @@ flush_ring(void) } static void -select_counter(struct counter_group *group, int ctr, int n) +select_counter(struct counter_group *group, int ctr, int countable_val) { - assert(n < group->group->num_countables); assert(ctr < group->group->num_counters); - group->label[ctr] = group->group->countables[n].name; - group->counter[ctr].select_val = n; + unsigned countable_idx = UINT32_MAX; + for (unsigned i = 0; i < group->group->num_countables; i++) { + if (countable_val != group->group->countables[i].selector) + continue; + + countable_idx = i; + break; + } + + if (countable_idx >= group->group->num_countables) + return; + + group->label[ctr] = group->group->countables[countable_idx].name; + group->counter[ctr].select_val = countable_val; if (!dev.submit) { dev.submit = fd_submit_new(dev.pipe); @@ -244,7 +255,7 @@ select_counter(struct counter_group *group, int ctr, int n) } OUT_PKT0(ring, group->group->counters[ctr].select_reg, 1); - OUT_RING(ring, n); + OUT_RING(ring, countable_val); if (group->group->counters[ctr].enable) { OUT_PKT0(ring, group->group->counters[ctr].enable, 1); @@ -270,7 +281,7 @@ select_counter(struct counter_group *group, int ctr, int n) } OUT_PKT4(ring, group->group->counters[ctr].select_reg, 1); - OUT_RING(ring, n); + OUT_RING(ring, countable_val); if (group->group->counters[ctr].enable) { OUT_PKT4(ring, group->group->counters[ctr].enable, 1);