diff --git a/src/panfrost/ds/pan_pps_perf.cpp b/src/panfrost/ds/pan_pps_perf.cpp index cb49e0b5f03..4211ff2beae 100644 --- a/src/panfrost/ds/pan_pps_perf.cpp +++ b/src/panfrost/ds/pan_pps_perf.cpp @@ -174,9 +174,7 @@ PanfrostPerf::create_available_counters() const auto &pan_driver = PanfrostDriver::into(d); struct pan_perf *perf = static_cast( pan_driver.perf->get_subinstance()); - return pan_perf_counter_read_raw( - perf, (enum pan_perf_counter_categories)cat_idx, block_idx, - cinfo->offset); + return pan_perf_counter_read_raw(perf, cinfo, block_idx); }); group.counters.push_back(counter.id); diff --git a/src/panfrost/perf/pan_perf.c b/src/panfrost/perf/pan_perf.c index ddf0f627623..aa53c0993cd 100644 --- a/src/panfrost/perf/pan_perf.c +++ b/src/panfrost/perf/pan_perf.c @@ -19,8 +19,7 @@ int64_t pan_perf_counter_read_raw(const struct pan_perf *perf, - enum pan_perf_counter_categories category, - uint8_t block_index, uint32_t counter_index) + const struct pan_perf_counter *counter, uint8_t block) { STATIC_ASSERT((int)PAN_KMOD_PERF_CAT_FRONTEND == (int)PAN_PERF_COUNTER_CAT_FRONTEND); STATIC_ASSERT((int)PAN_KMOD_PERF_CAT_TILER == (int)PAN_PERF_COUNTER_CAT_TILER); @@ -29,11 +28,12 @@ pan_perf_counter_read_raw(const struct pan_perf *perf, assert(perf->session->data != NULL); - const uint32_t val_offset = perf->mem_layout.category[category].offset + - perf->mem_layout.block_stride * block_index + - perf->mem_layout.counter_stride * counter_index; + const uint32_t category = counter->category_index; + const uint32_t offset = perf->mem_layout.category[category].offset + + perf->mem_layout.block_stride * block + + perf->mem_layout.counter_stride * counter->offset; - uint8_t *val_ptr = ((uint8_t *)perf->session->data) + val_offset; + uint8_t *val_ptr = ((uint8_t *)perf->session->data) + offset; return pan_kmod_perf_load_counter(perf->session, val_ptr); } @@ -41,16 +41,14 @@ int64_t pan_perf_counter_read(const struct pan_perf_counter *counter, const struct pan_perf *perf) { - int64_t ret = pan_perf_counter_read_raw(perf, counter->category_index, 0, - counter->offset); + int64_t ret = pan_perf_counter_read_raw(perf, counter, 0); /* If counter belongs to shader core, sum values for all cores. */ if (counter->category_index == PAN_PERF_COUNTER_CAT_SHADER) { uint32_t n_cores = perf->mem_layout.category[PAN_PERF_COUNTER_CAT_SHADER].n_blocks; for (uint32_t core = 1; core < n_cores; ++core) { - ret += pan_perf_counter_read_raw(perf, PAN_PERF_COUNTER_CAT_SHADER, - core, counter->offset); + ret += pan_perf_counter_read_raw(perf, counter, core); assert(ret >= 0 && "counter sum should not overflow"); } } diff --git a/src/panfrost/perf/pan_perf.h b/src/panfrost/perf/pan_perf.h index 752a0db1a1d..1e8446b62a4 100644 --- a/src/panfrost/perf/pan_perf.h +++ b/src/panfrost/perf/pan_perf.h @@ -79,8 +79,8 @@ struct pan_perf { }; int64_t pan_perf_counter_read_raw(const struct pan_perf *perf, - enum pan_perf_counter_categories category, - uint8_t block_index, uint32_t counter_index); + const struct pan_perf_counter *counter, + uint8_t block); int64_t pan_perf_counter_read(const struct pan_perf_counter *counter, const struct pan_perf *perf);