intel/perf: add a helper to read timestamp from reports

On newer HW it will require more work than just reading a dword. It
could also vary depending on the report format.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Antonio Caggiano <antonio.caggiano@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13831>
This commit is contained in:
Lionel Landwerlin 2021-11-08 00:10:06 +02:00 committed by Marge Bot
parent 8657fa6b86
commit 120f24cb36
2 changed files with 20 additions and 4 deletions

View file

@ -1027,6 +1027,13 @@ can_use_mi_rpc_bc_counters(const struct intel_device_info *devinfo)
return devinfo->ver <= 11;
}
uint64_t
intel_perf_report_timestamp(const struct intel_perf_query_info *query,
const uint32_t *report)
{
return report[1];
}
void
intel_perf_query_result_accumulate(struct intel_perf_query_result *result,
const struct intel_perf_query_info *query,
@ -1040,13 +1047,15 @@ intel_perf_query_result_accumulate(struct intel_perf_query_result *result,
start[2] != INTEL_PERF_INVALID_CTX_ID)
result->hw_id = start[2];
if (result->reports_accumulated == 0)
result->begin_timestamp = start[1];
result->begin_timestamp = intel_perf_report_timestamp(query, start);
result->reports_accumulated++;
switch (query->oa_format) {
case I915_OA_FORMAT_A32u40_A4u32_B8_C8:
accumulate_uint32(start + 1, end + 1,
result->accumulator + query->gpu_time_offset); /* timestamp */
result->accumulator[query->gpu_time_offset] =
intel_perf_report_timestamp(query, end) -
intel_perf_report_timestamp(query, start);
accumulate_uint32(start + 3, end + 3,
result->accumulator + query->gpu_clock_offset); /* clock */
@ -1078,7 +1087,9 @@ intel_perf_query_result_accumulate(struct intel_perf_query_result *result,
break;
case I915_OA_FORMAT_A45_B8_C8:
accumulate_uint32(start + 1, end + 1, result->accumulator); /* timestamp */
result->accumulator[query->gpu_time_offset] =
intel_perf_report_timestamp(query, end) -
intel_perf_report_timestamp(query, start);
for (i = 0; i < 61; i++) {
accumulate_uint32(start + 3 + i, end + 3 + i,

View file

@ -454,6 +454,11 @@ void intel_perf_query_result_accumulate(struct intel_perf_query_result *result,
const uint32_t *start,
const uint32_t *end);
/** Read the timestamp value in a report.
*/
uint64_t intel_perf_report_timestamp(const struct intel_perf_query_info *query,
const uint32_t *report);
/** Accumulate the delta between 2 snapshots of OA perf registers (layout
* should match description specified through intel_perf_query_register_layout).
*/