From 24849eef9f55a072eca342a48ff46471e3b89422 Mon Sep 17 00:00:00 2001 From: Dhruv Mark Collins Date: Thu, 16 Apr 2026 19:10:53 +0000 Subject: [PATCH] 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 Assisted-by: OpenAI Codex (GPT-5.4) Part-of: --- src/freedreno/ds/fd_pps_driver.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/freedreno/ds/fd_pps_driver.cc b/src/freedreno/ds/fd_pps_driver.cc index 945d559eefd..0917835f536 100644 --- a/src/freedreno/ds/fd_pps_driver.cc +++ b/src/freedreno/ds/fd_pps_driver.cc @@ -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; }