1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © 2018 Intel Corporation 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13bf215546Sopenharmony_ci * Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21bf215546Sopenharmony_ci * IN THE SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ci#include "intel_perf.h" 25bf215546Sopenharmony_ci#include "intel_perf_mdapi.h" 26bf215546Sopenharmony_ci#include "intel_perf_private.h" 27bf215546Sopenharmony_ci#include "intel_perf_regs.h" 28bf215546Sopenharmony_ci 29bf215546Sopenharmony_ci#include "dev/intel_device_info.h" 30bf215546Sopenharmony_ci 31bf215546Sopenharmony_ci#include <drm-uapi/i915_drm.h> 32bf215546Sopenharmony_ci 33bf215546Sopenharmony_ci 34bf215546Sopenharmony_ciint 35bf215546Sopenharmony_ciintel_perf_query_result_write_mdapi(void *data, uint32_t data_size, 36bf215546Sopenharmony_ci const struct intel_device_info *devinfo, 37bf215546Sopenharmony_ci const struct intel_perf_query_info *query, 38bf215546Sopenharmony_ci const struct intel_perf_query_result *result) 39bf215546Sopenharmony_ci{ 40bf215546Sopenharmony_ci switch (devinfo->ver) { 41bf215546Sopenharmony_ci case 7: { 42bf215546Sopenharmony_ci struct gfx7_mdapi_metrics *mdapi_data = (struct gfx7_mdapi_metrics *) data; 43bf215546Sopenharmony_ci 44bf215546Sopenharmony_ci if (data_size < sizeof(*mdapi_data)) 45bf215546Sopenharmony_ci return 0; 46bf215546Sopenharmony_ci 47bf215546Sopenharmony_ci assert(devinfo->platform == INTEL_PLATFORM_HSW); 48bf215546Sopenharmony_ci 49bf215546Sopenharmony_ci for (int i = 0; i < ARRAY_SIZE(mdapi_data->ACounters); i++) 50bf215546Sopenharmony_ci mdapi_data->ACounters[i] = result->accumulator[1 + i]; 51bf215546Sopenharmony_ci 52bf215546Sopenharmony_ci for (int i = 0; i < ARRAY_SIZE(mdapi_data->NOACounters); i++) { 53bf215546Sopenharmony_ci mdapi_data->NOACounters[i] = 54bf215546Sopenharmony_ci result->accumulator[1 + ARRAY_SIZE(mdapi_data->ACounters) + i]; 55bf215546Sopenharmony_ci } 56bf215546Sopenharmony_ci 57bf215546Sopenharmony_ci mdapi_data->PerfCounter1 = result->accumulator[query->perfcnt_offset + 0]; 58bf215546Sopenharmony_ci mdapi_data->PerfCounter2 = result->accumulator[query->perfcnt_offset + 1]; 59bf215546Sopenharmony_ci 60bf215546Sopenharmony_ci mdapi_data->ReportsCount = result->reports_accumulated; 61bf215546Sopenharmony_ci mdapi_data->TotalTime = 62bf215546Sopenharmony_ci intel_device_info_timebase_scale(devinfo, result->accumulator[0]); 63bf215546Sopenharmony_ci mdapi_data->CoreFrequency = result->gt_frequency[1]; 64bf215546Sopenharmony_ci mdapi_data->CoreFrequencyChanged = result->gt_frequency[1] != result->gt_frequency[0]; 65bf215546Sopenharmony_ci mdapi_data->SplitOccured = result->query_disjoint; 66bf215546Sopenharmony_ci return sizeof(*mdapi_data); 67bf215546Sopenharmony_ci } 68bf215546Sopenharmony_ci case 8: { 69bf215546Sopenharmony_ci struct gfx8_mdapi_metrics *mdapi_data = (struct gfx8_mdapi_metrics *) data; 70bf215546Sopenharmony_ci 71bf215546Sopenharmony_ci if (data_size < sizeof(*mdapi_data)) 72bf215546Sopenharmony_ci return 0; 73bf215546Sopenharmony_ci 74bf215546Sopenharmony_ci for (int i = 0; i < ARRAY_SIZE(mdapi_data->OaCntr); i++) 75bf215546Sopenharmony_ci mdapi_data->OaCntr[i] = result->accumulator[2 + i]; 76bf215546Sopenharmony_ci for (int i = 0; i < ARRAY_SIZE(mdapi_data->NoaCntr); i++) { 77bf215546Sopenharmony_ci mdapi_data->NoaCntr[i] = 78bf215546Sopenharmony_ci result->accumulator[2 + ARRAY_SIZE(mdapi_data->OaCntr) + i]; 79bf215546Sopenharmony_ci } 80bf215546Sopenharmony_ci 81bf215546Sopenharmony_ci mdapi_data->PerfCounter1 = result->accumulator[query->perfcnt_offset + 0]; 82bf215546Sopenharmony_ci mdapi_data->PerfCounter2 = result->accumulator[query->perfcnt_offset + 1]; 83bf215546Sopenharmony_ci 84bf215546Sopenharmony_ci mdapi_data->ReportId = result->hw_id; 85bf215546Sopenharmony_ci mdapi_data->ReportsCount = result->reports_accumulated; 86bf215546Sopenharmony_ci mdapi_data->TotalTime = 87bf215546Sopenharmony_ci intel_device_info_timebase_scale(devinfo, result->accumulator[0]); 88bf215546Sopenharmony_ci mdapi_data->BeginTimestamp = 89bf215546Sopenharmony_ci intel_device_info_timebase_scale(devinfo, result->begin_timestamp); 90bf215546Sopenharmony_ci mdapi_data->GPUTicks = result->accumulator[1]; 91bf215546Sopenharmony_ci mdapi_data->CoreFrequency = result->gt_frequency[1]; 92bf215546Sopenharmony_ci mdapi_data->CoreFrequencyChanged = result->gt_frequency[1] != result->gt_frequency[0]; 93bf215546Sopenharmony_ci mdapi_data->SliceFrequency = 94bf215546Sopenharmony_ci (result->slice_frequency[0] + result->slice_frequency[1]) / 2ULL; 95bf215546Sopenharmony_ci mdapi_data->UnsliceFrequency = 96bf215546Sopenharmony_ci (result->unslice_frequency[0] + result->unslice_frequency[1]) / 2ULL; 97bf215546Sopenharmony_ci mdapi_data->SplitOccured = result->query_disjoint; 98bf215546Sopenharmony_ci return sizeof(*mdapi_data); 99bf215546Sopenharmony_ci } 100bf215546Sopenharmony_ci case 9: 101bf215546Sopenharmony_ci case 11: 102bf215546Sopenharmony_ci case 12:{ 103bf215546Sopenharmony_ci struct gfx9_mdapi_metrics *mdapi_data = (struct gfx9_mdapi_metrics *) data; 104bf215546Sopenharmony_ci 105bf215546Sopenharmony_ci if (data_size < sizeof(*mdapi_data)) 106bf215546Sopenharmony_ci return 0; 107bf215546Sopenharmony_ci 108bf215546Sopenharmony_ci for (int i = 0; i < ARRAY_SIZE(mdapi_data->OaCntr); i++) 109bf215546Sopenharmony_ci mdapi_data->OaCntr[i] = result->accumulator[2 + i]; 110bf215546Sopenharmony_ci for (int i = 0; i < ARRAY_SIZE(mdapi_data->NoaCntr); i++) { 111bf215546Sopenharmony_ci mdapi_data->NoaCntr[i] = 112bf215546Sopenharmony_ci result->accumulator[2 + ARRAY_SIZE(mdapi_data->OaCntr) + i]; 113bf215546Sopenharmony_ci } 114bf215546Sopenharmony_ci 115bf215546Sopenharmony_ci mdapi_data->PerfCounter1 = result->accumulator[query->perfcnt_offset + 0]; 116bf215546Sopenharmony_ci mdapi_data->PerfCounter2 = result->accumulator[query->perfcnt_offset + 1]; 117bf215546Sopenharmony_ci 118bf215546Sopenharmony_ci mdapi_data->ReportId = result->hw_id; 119bf215546Sopenharmony_ci mdapi_data->ReportsCount = result->reports_accumulated; 120bf215546Sopenharmony_ci mdapi_data->TotalTime = 121bf215546Sopenharmony_ci intel_device_info_timebase_scale(devinfo, result->accumulator[0]); 122bf215546Sopenharmony_ci mdapi_data->BeginTimestamp = 123bf215546Sopenharmony_ci intel_device_info_timebase_scale(devinfo, result->begin_timestamp); 124bf215546Sopenharmony_ci mdapi_data->GPUTicks = result->accumulator[1]; 125bf215546Sopenharmony_ci mdapi_data->CoreFrequency = result->gt_frequency[1]; 126bf215546Sopenharmony_ci mdapi_data->CoreFrequencyChanged = result->gt_frequency[1] != result->gt_frequency[0]; 127bf215546Sopenharmony_ci mdapi_data->SliceFrequency = 128bf215546Sopenharmony_ci (result->slice_frequency[0] + result->slice_frequency[1]) / 2ULL; 129bf215546Sopenharmony_ci mdapi_data->UnsliceFrequency = 130bf215546Sopenharmony_ci (result->unslice_frequency[0] + result->unslice_frequency[1]) / 2ULL; 131bf215546Sopenharmony_ci mdapi_data->SplitOccured = result->query_disjoint; 132bf215546Sopenharmony_ci return sizeof(*mdapi_data); 133bf215546Sopenharmony_ci } 134bf215546Sopenharmony_ci default: 135bf215546Sopenharmony_ci unreachable("unexpected gen"); 136bf215546Sopenharmony_ci } 137bf215546Sopenharmony_ci} 138bf215546Sopenharmony_ci 139bf215546Sopenharmony_civoid 140bf215546Sopenharmony_ciintel_perf_register_mdapi_statistic_query(struct intel_perf_config *perf_cfg, 141bf215546Sopenharmony_ci const struct intel_device_info *devinfo) 142bf215546Sopenharmony_ci{ 143bf215546Sopenharmony_ci if (!(devinfo->ver >= 7 && devinfo->ver <= 12)) 144bf215546Sopenharmony_ci return; 145bf215546Sopenharmony_ci 146bf215546Sopenharmony_ci struct intel_perf_query_info *query = 147bf215546Sopenharmony_ci intel_perf_append_query_info(perf_cfg, MAX_STAT_COUNTERS); 148bf215546Sopenharmony_ci 149bf215546Sopenharmony_ci query->kind = INTEL_PERF_QUERY_TYPE_PIPELINE; 150bf215546Sopenharmony_ci query->name = "Intel_Raw_Pipeline_Statistics_Query"; 151bf215546Sopenharmony_ci 152bf215546Sopenharmony_ci /* The order has to match mdapi_pipeline_metrics. */ 153bf215546Sopenharmony_ci intel_perf_query_add_basic_stat_reg(query, IA_VERTICES_COUNT, 154bf215546Sopenharmony_ci "N vertices submitted"); 155bf215546Sopenharmony_ci intel_perf_query_add_basic_stat_reg(query, IA_PRIMITIVES_COUNT, 156bf215546Sopenharmony_ci "N primitives submitted"); 157bf215546Sopenharmony_ci intel_perf_query_add_basic_stat_reg(query, VS_INVOCATION_COUNT, 158bf215546Sopenharmony_ci "N vertex shader invocations"); 159bf215546Sopenharmony_ci intel_perf_query_add_basic_stat_reg(query, GS_INVOCATION_COUNT, 160bf215546Sopenharmony_ci "N geometry shader invocations"); 161bf215546Sopenharmony_ci intel_perf_query_add_basic_stat_reg(query, GS_PRIMITIVES_COUNT, 162bf215546Sopenharmony_ci "N geometry shader primitives emitted"); 163bf215546Sopenharmony_ci intel_perf_query_add_basic_stat_reg(query, CL_INVOCATION_COUNT, 164bf215546Sopenharmony_ci "N primitives entering clipping"); 165bf215546Sopenharmony_ci intel_perf_query_add_basic_stat_reg(query, CL_PRIMITIVES_COUNT, 166bf215546Sopenharmony_ci "N primitives leaving clipping"); 167bf215546Sopenharmony_ci if (devinfo->verx10 == 75 || devinfo->ver == 8) { 168bf215546Sopenharmony_ci intel_perf_query_add_stat_reg(query, PS_INVOCATION_COUNT, 1, 4, 169bf215546Sopenharmony_ci "N fragment shader invocations", 170bf215546Sopenharmony_ci "N fragment shader invocations"); 171bf215546Sopenharmony_ci } else { 172bf215546Sopenharmony_ci intel_perf_query_add_basic_stat_reg(query, PS_INVOCATION_COUNT, 173bf215546Sopenharmony_ci "N fragment shader invocations"); 174bf215546Sopenharmony_ci } 175bf215546Sopenharmony_ci intel_perf_query_add_basic_stat_reg(query, HS_INVOCATION_COUNT, 176bf215546Sopenharmony_ci "N TCS shader invocations"); 177bf215546Sopenharmony_ci intel_perf_query_add_basic_stat_reg(query, DS_INVOCATION_COUNT, 178bf215546Sopenharmony_ci "N TES shader invocations"); 179bf215546Sopenharmony_ci if (devinfo->ver >= 7) { 180bf215546Sopenharmony_ci intel_perf_query_add_basic_stat_reg(query, CS_INVOCATION_COUNT, 181bf215546Sopenharmony_ci "N compute shader invocations"); 182bf215546Sopenharmony_ci } 183bf215546Sopenharmony_ci 184bf215546Sopenharmony_ci if (devinfo->ver >= 10) { 185bf215546Sopenharmony_ci /* Reuse existing CS invocation register until we can expose this new 186bf215546Sopenharmony_ci * one. 187bf215546Sopenharmony_ci */ 188bf215546Sopenharmony_ci intel_perf_query_add_basic_stat_reg(query, CS_INVOCATION_COUNT, 189bf215546Sopenharmony_ci "Reserved1"); 190bf215546Sopenharmony_ci } 191bf215546Sopenharmony_ci 192bf215546Sopenharmony_ci query->data_size = sizeof(uint64_t) * query->n_counters; 193bf215546Sopenharmony_ci} 194bf215546Sopenharmony_ci 195bf215546Sopenharmony_cistatic void 196bf215546Sopenharmony_cifill_mdapi_perf_query_counter(struct intel_perf_query_info *query, 197bf215546Sopenharmony_ci const char *name, 198bf215546Sopenharmony_ci uint32_t data_offset, 199bf215546Sopenharmony_ci uint32_t data_size, 200bf215546Sopenharmony_ci enum intel_perf_counter_data_type data_type) 201bf215546Sopenharmony_ci{ 202bf215546Sopenharmony_ci struct intel_perf_query_counter *counter = &query->counters[query->n_counters]; 203bf215546Sopenharmony_ci 204bf215546Sopenharmony_ci assert(query->n_counters <= query->max_counters); 205bf215546Sopenharmony_ci 206bf215546Sopenharmony_ci counter->name = name; 207bf215546Sopenharmony_ci counter->desc = "Raw counter value"; 208bf215546Sopenharmony_ci counter->type = INTEL_PERF_COUNTER_TYPE_RAW; 209bf215546Sopenharmony_ci counter->data_type = data_type; 210bf215546Sopenharmony_ci counter->offset = data_offset; 211bf215546Sopenharmony_ci 212bf215546Sopenharmony_ci query->n_counters++; 213bf215546Sopenharmony_ci 214bf215546Sopenharmony_ci assert(counter->offset + intel_perf_query_counter_get_size(counter) <= query->data_size); 215bf215546Sopenharmony_ci} 216bf215546Sopenharmony_ci 217bf215546Sopenharmony_ci#define MDAPI_QUERY_ADD_COUNTER(query, struct_name, field_name, type_name) \ 218bf215546Sopenharmony_ci fill_mdapi_perf_query_counter(query, #field_name, \ 219bf215546Sopenharmony_ci (uint8_t *) &struct_name.field_name - \ 220bf215546Sopenharmony_ci (uint8_t *) &struct_name, \ 221bf215546Sopenharmony_ci sizeof(struct_name.field_name), \ 222bf215546Sopenharmony_ci INTEL_PERF_COUNTER_DATA_TYPE_##type_name) 223bf215546Sopenharmony_ci#define MDAPI_QUERY_ADD_ARRAY_COUNTER(ctx, query, struct_name, field_name, idx, type_name) \ 224bf215546Sopenharmony_ci fill_mdapi_perf_query_counter(query, \ 225bf215546Sopenharmony_ci ralloc_asprintf(ctx, "%s%i", #field_name, idx), \ 226bf215546Sopenharmony_ci (uint8_t *) &struct_name.field_name[idx] - \ 227bf215546Sopenharmony_ci (uint8_t *) &struct_name, \ 228bf215546Sopenharmony_ci sizeof(struct_name.field_name[0]), \ 229bf215546Sopenharmony_ci INTEL_PERF_COUNTER_DATA_TYPE_##type_name) 230bf215546Sopenharmony_ci 231bf215546Sopenharmony_civoid 232bf215546Sopenharmony_ciintel_perf_register_mdapi_oa_query(struct intel_perf_config *perf, 233bf215546Sopenharmony_ci const struct intel_device_info *devinfo) 234bf215546Sopenharmony_ci{ 235bf215546Sopenharmony_ci struct intel_perf_query_info *query = NULL; 236bf215546Sopenharmony_ci 237bf215546Sopenharmony_ci /* MDAPI requires different structures for pretty much every generation 238bf215546Sopenharmony_ci * (right now we have definitions for gen 7 to 12). 239bf215546Sopenharmony_ci */ 240bf215546Sopenharmony_ci if (!(devinfo->ver >= 7 && devinfo->ver <= 12)) 241bf215546Sopenharmony_ci return; 242bf215546Sopenharmony_ci 243bf215546Sopenharmony_ci switch (devinfo->ver) { 244bf215546Sopenharmony_ci case 7: { 245bf215546Sopenharmony_ci query = intel_perf_append_query_info(perf, 1 + 45 + 16 + 7); 246bf215546Sopenharmony_ci query->oa_format = I915_OA_FORMAT_A45_B8_C8; 247bf215546Sopenharmony_ci 248bf215546Sopenharmony_ci struct gfx7_mdapi_metrics metric_data; 249bf215546Sopenharmony_ci query->data_size = sizeof(metric_data); 250bf215546Sopenharmony_ci 251bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, TotalTime, UINT64); 252bf215546Sopenharmony_ci for (int i = 0; i < ARRAY_SIZE(metric_data.ACounters); i++) { 253bf215546Sopenharmony_ci MDAPI_QUERY_ADD_ARRAY_COUNTER(perf->queries, query, 254bf215546Sopenharmony_ci metric_data, ACounters, i, UINT64); 255bf215546Sopenharmony_ci } 256bf215546Sopenharmony_ci for (int i = 0; i < ARRAY_SIZE(metric_data.NOACounters); i++) { 257bf215546Sopenharmony_ci MDAPI_QUERY_ADD_ARRAY_COUNTER(perf->queries, query, 258bf215546Sopenharmony_ci metric_data, NOACounters, i, UINT64); 259bf215546Sopenharmony_ci } 260bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, PerfCounter1, UINT64); 261bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, PerfCounter2, UINT64); 262bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, SplitOccured, BOOL32); 263bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, CoreFrequencyChanged, BOOL32); 264bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, CoreFrequency, UINT64); 265bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, ReportId, UINT32); 266bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, ReportsCount, UINT32); 267bf215546Sopenharmony_ci break; 268bf215546Sopenharmony_ci } 269bf215546Sopenharmony_ci case 8: { 270bf215546Sopenharmony_ci query = intel_perf_append_query_info(perf, 2 + 36 + 16 + 16); 271bf215546Sopenharmony_ci query->oa_format = I915_OA_FORMAT_A32u40_A4u32_B8_C8; 272bf215546Sopenharmony_ci 273bf215546Sopenharmony_ci struct gfx8_mdapi_metrics metric_data; 274bf215546Sopenharmony_ci query->data_size = sizeof(metric_data); 275bf215546Sopenharmony_ci 276bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, TotalTime, UINT64); 277bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, GPUTicks, UINT64); 278bf215546Sopenharmony_ci for (int i = 0; i < ARRAY_SIZE(metric_data.OaCntr); i++) { 279bf215546Sopenharmony_ci MDAPI_QUERY_ADD_ARRAY_COUNTER(perf->queries, query, 280bf215546Sopenharmony_ci metric_data, OaCntr, i, UINT64); 281bf215546Sopenharmony_ci } 282bf215546Sopenharmony_ci for (int i = 0; i < ARRAY_SIZE(metric_data.NoaCntr); i++) { 283bf215546Sopenharmony_ci MDAPI_QUERY_ADD_ARRAY_COUNTER(perf->queries, query, 284bf215546Sopenharmony_ci metric_data, NoaCntr, i, UINT64); 285bf215546Sopenharmony_ci } 286bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, BeginTimestamp, UINT64); 287bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, Reserved1, UINT64); 288bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, Reserved2, UINT64); 289bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, Reserved3, UINT32); 290bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, OverrunOccured, BOOL32); 291bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, MarkerUser, UINT64); 292bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, MarkerDriver, UINT64); 293bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, SliceFrequency, UINT64); 294bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, UnsliceFrequency, UINT64); 295bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, PerfCounter1, UINT64); 296bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, PerfCounter2, UINT64); 297bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, SplitOccured, BOOL32); 298bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, CoreFrequencyChanged, BOOL32); 299bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, CoreFrequency, UINT64); 300bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, ReportId, UINT32); 301bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, ReportsCount, UINT32); 302bf215546Sopenharmony_ci break; 303bf215546Sopenharmony_ci } 304bf215546Sopenharmony_ci case 9: 305bf215546Sopenharmony_ci case 11: 306bf215546Sopenharmony_ci case 12: { 307bf215546Sopenharmony_ci query = intel_perf_append_query_info(perf, 2 + 36 + 16 + 16 + 16 + 2); 308bf215546Sopenharmony_ci query->oa_format = I915_OA_FORMAT_A32u40_A4u32_B8_C8; 309bf215546Sopenharmony_ci 310bf215546Sopenharmony_ci struct gfx9_mdapi_metrics metric_data; 311bf215546Sopenharmony_ci query->data_size = sizeof(metric_data); 312bf215546Sopenharmony_ci 313bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, TotalTime, UINT64); 314bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, GPUTicks, UINT64); 315bf215546Sopenharmony_ci for (int i = 0; i < ARRAY_SIZE(metric_data.OaCntr); i++) { 316bf215546Sopenharmony_ci MDAPI_QUERY_ADD_ARRAY_COUNTER(perf->queries, query, 317bf215546Sopenharmony_ci metric_data, OaCntr, i, UINT64); 318bf215546Sopenharmony_ci } 319bf215546Sopenharmony_ci for (int i = 0; i < ARRAY_SIZE(metric_data.NoaCntr); i++) { 320bf215546Sopenharmony_ci MDAPI_QUERY_ADD_ARRAY_COUNTER(perf->queries, query, 321bf215546Sopenharmony_ci metric_data, NoaCntr, i, UINT64); 322bf215546Sopenharmony_ci } 323bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, BeginTimestamp, UINT64); 324bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, Reserved1, UINT64); 325bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, Reserved2, UINT64); 326bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, Reserved3, UINT32); 327bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, OverrunOccured, BOOL32); 328bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, MarkerUser, UINT64); 329bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, MarkerDriver, UINT64); 330bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, SliceFrequency, UINT64); 331bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, UnsliceFrequency, UINT64); 332bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, PerfCounter1, UINT64); 333bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, PerfCounter2, UINT64); 334bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, SplitOccured, BOOL32); 335bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, CoreFrequencyChanged, BOOL32); 336bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, CoreFrequency, UINT64); 337bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, ReportId, UINT32); 338bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, ReportsCount, UINT32); 339bf215546Sopenharmony_ci for (int i = 0; i < ARRAY_SIZE(metric_data.UserCntr); i++) { 340bf215546Sopenharmony_ci MDAPI_QUERY_ADD_ARRAY_COUNTER(perf->queries, query, 341bf215546Sopenharmony_ci metric_data, UserCntr, i, UINT64); 342bf215546Sopenharmony_ci } 343bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, UserCntrCfgId, UINT32); 344bf215546Sopenharmony_ci MDAPI_QUERY_ADD_COUNTER(query, metric_data, Reserved4, UINT32); 345bf215546Sopenharmony_ci break; 346bf215546Sopenharmony_ci } 347bf215546Sopenharmony_ci default: 348bf215546Sopenharmony_ci unreachable("Unsupported gen"); 349bf215546Sopenharmony_ci break; 350bf215546Sopenharmony_ci } 351bf215546Sopenharmony_ci 352bf215546Sopenharmony_ci query->kind = INTEL_PERF_QUERY_TYPE_RAW; 353bf215546Sopenharmony_ci query->name = "Intel_Raw_Hardware_Counters_Set_0_Query"; 354bf215546Sopenharmony_ci query->guid = INTEL_PERF_QUERY_GUID_MDAPI; 355bf215546Sopenharmony_ci 356bf215546Sopenharmony_ci { 357bf215546Sopenharmony_ci /* Accumulation buffer offsets copied from an actual query... */ 358bf215546Sopenharmony_ci const struct intel_perf_query_info *copy_query = 359bf215546Sopenharmony_ci &perf->queries[0]; 360bf215546Sopenharmony_ci 361bf215546Sopenharmony_ci query->gpu_time_offset = copy_query->gpu_time_offset; 362bf215546Sopenharmony_ci query->gpu_clock_offset = copy_query->gpu_clock_offset; 363bf215546Sopenharmony_ci query->a_offset = copy_query->a_offset; 364bf215546Sopenharmony_ci query->b_offset = copy_query->b_offset; 365bf215546Sopenharmony_ci query->c_offset = copy_query->c_offset; 366bf215546Sopenharmony_ci query->perfcnt_offset = copy_query->perfcnt_offset; 367bf215546Sopenharmony_ci } 368bf215546Sopenharmony_ci} 369