mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 09:08:10 +02:00
freedreno/perfcntrs: Add helpers to resolve group and countable
We were duplicating this in a few places. Add helpers instead. Signed-off-by: Rob Clark <rob.clark@oss.qualcomm.com>
This commit is contained in:
parent
8fbc34bdc5
commit
cc743feb52
4 changed files with 36 additions and 31 deletions
|
|
@ -134,13 +134,10 @@ setup_counter(const char *name, struct perfcntr *c)
|
|||
{
|
||||
for (int i = 0; i < num_groups; i++) {
|
||||
const struct fd_perfcntr_group *group = &groups[i];
|
||||
const struct fd_perfcntr_countable *countable =
|
||||
fd_perfcntrs_countable(group, name);
|
||||
|
||||
for (int j = 0; j < group->num_countables; j++) {
|
||||
const struct fd_perfcntr_countable *countable = &group->countables[j];
|
||||
|
||||
if (strcmp(name, countable->name) != 0)
|
||||
continue;
|
||||
|
||||
if (countable) {
|
||||
/*
|
||||
* Allocate a counter to use to monitor the requested countable:
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -539,11 +539,10 @@ FreedrenoDriver::Countable::resolve() const
|
|||
if (group != g->name)
|
||||
continue;
|
||||
|
||||
for (unsigned j = 0; j < g->num_countables; j++) {
|
||||
const struct fd_perfcntr_countable *c = &g->countables[j];
|
||||
if (name != c->name)
|
||||
continue;
|
||||
const struct fd_perfcntr_countable *c =
|
||||
fd_perfcntrs_countable(g, name.c_str());
|
||||
|
||||
if (c) {
|
||||
d->state[id].countable = c;
|
||||
|
||||
/* Assign counters from high to low to reduce conflicts with UMD-owned
|
||||
|
|
|
|||
|
|
@ -89,6 +89,33 @@ const struct fd_perfcntr_group *fd_perfcntrs(const struct fd_dev_id *id, unsigne
|
|||
.countables = _countables, \
|
||||
}
|
||||
|
||||
static inline const struct fd_perfcntr_group *
|
||||
fd_perfcntrs_group(const struct fd_dev_id *id, const char *name)
|
||||
{
|
||||
const struct fd_perfcntr_group *groups;
|
||||
unsigned count;
|
||||
|
||||
groups = fd_perfcntrs(id, &count);
|
||||
if (!groups)
|
||||
return NULL;
|
||||
|
||||
for (unsigned i = 0; i < count; i++)
|
||||
if (!strcmp(groups[i].name, name))
|
||||
return &groups[i];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline const struct fd_perfcntr_countable *
|
||||
fd_perfcntrs_countable(const struct fd_perfcntr_group *group, const char *name)
|
||||
{
|
||||
for (unsigned i = 0; i < group->num_countables; i++)
|
||||
if (!strcmp(group->countables[i].name, name))
|
||||
return &group->countables[i];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#define FD_DERIVED_COUNTER_MAX_PERFCNTRS 8
|
||||
|
||||
struct fd_derivation_context {
|
||||
|
|
|
|||
|
|
@ -1633,31 +1633,13 @@ tu_autotune::tu_autotune(struct tu_device *device, VkResult &result)
|
|||
tu_bo_suballocator_init(&suballoc, device, 128 * 1024, TU_BO_ALLOC_INTERNAL_RESOURCE, "autotune_suballoc");
|
||||
|
||||
if (supports_preempt_latency_tracking()) {
|
||||
uint32_t group_count;
|
||||
const struct fd_perfcntr_group *groups = fd_perfcntrs(&device->physical_device->dev_id, &group_count);
|
||||
const char *fail_reason = nullptr;
|
||||
|
||||
const fd_perfcntr_group *cp_group = nullptr;
|
||||
for (uint32_t i = 0; i < group_count; i++) {
|
||||
if (strcmp(groups[i].name, "CP") == 0) {
|
||||
cp_group = &groups[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
const fd_perfcntr_group *cp_group = fd_perfcntrs_group(&device->physical_device->dev_id, "CP");
|
||||
|
||||
if (cp_group) {
|
||||
auto get_perfcntr_countable = [](const struct fd_perfcntr_group *group,
|
||||
const char *name) -> const struct fd_perfcntr_countable * {
|
||||
for (uint32_t i = 0; i < group->num_countables; i++) {
|
||||
if (strcmp(group->countables[i].name, name) == 0)
|
||||
return &group->countables[i];
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
auto preemption_latency_countable = get_perfcntr_countable(cp_group, "PERF_CP_PREEMPTION_REACTION_DELAY");
|
||||
auto always_count_countable = get_perfcntr_countable(cp_group, "PERF_CP_ALWAYS_COUNT");
|
||||
auto preemption_latency_countable = fd_perfcntrs_countable(cp_group, "PERF_CP_PREEMPTION_REACTION_DELAY");
|
||||
auto always_count_countable = fd_perfcntrs_countable(cp_group, "PERF_CP_ALWAYS_COUNT");
|
||||
if (preemption_latency_countable && always_count_countable) {
|
||||
if (cp_group->num_counters >= 2) {
|
||||
preemption_latency_selector_reg = cp_group->counters[0].select_reg;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue