fd/pps: Allocate performance counters from high-to-low

The UMD will be switching to allocating counters from low-to-high,
so to avoid the chances of conflict with this new policy the PPS
driver now allocates the other way around. Additionally, this will
future proof it for the MSM-DRM uAPI for performance counters which
will similarly allocate from high-to-low.

Cc: mesa-stable
Signed-off-by: Dhruv Mark Collins <mark@igalia.com>
Assisted-by: OpenAI Codex (GPT-5.4)
(cherry picked from commit 24849eef9f)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41104>
This commit is contained in:
Dhruv Mark Collins 2026-04-16 19:10:53 +00:00 committed by Eric Engestrom
parent 920a848027
commit 3d6fab0404
2 changed files with 9 additions and 6 deletions

View file

@ -2124,7 +2124,7 @@
"description": "fd/pps: Allocate performance counters from high-to-low",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -1710,7 +1710,7 @@ FreedrenoDriver::Countable::collect() const
d->state[id].value = *reg;
}
/* Resolve the countable and assign next counter from it's group: */
/* Resolve the countable and assign the next counter from its group. */
void
FreedrenoDriver::Countable::resolve() const
{
@ -1726,12 +1726,15 @@ FreedrenoDriver::Countable::resolve() const
d->state[id].countable = c;
/* Assign a counter from the same group: */
/* Assign counters from high to low to reduce conflicts with UMD-owned
* slots. */
assert(d->assigned_counters[i] < g->num_counters);
d->state[id].counter = &g->counters[d->assigned_counters[i]++];
unsigned counter_index =
(g->num_counters - 1) - d->assigned_counters[i]++;
d->state[id].counter = &g->counters[counter_index];
std::cout << "Countable: " << name << ", group=" << g->name <<
", counter=" << d->assigned_counters[i] - 1 << "\n";
std::cout << "Countable: " << name << ", group=" << g->name
<< ", counter=" << counter_index << "\n";
return;
}