Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/xe/pmu: Initialize PMU event types based on first available GT

GT ID#0 (primary GT on tile 0) may not always be available if the
primary GT has been disabled via configfs. Instead use the first
available GT when determining which PMU events are supported. If there
are no GTs, then don't advertise any GT-related events.

Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://lore.kernel.org/r/20251013200944.2499947-36-matthew.d.roper@intel.com
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>

+10 -1
+10 -1
drivers/gpu/drm/xe/xe_pmu.c
··· 497 497 static void set_supported_events(struct xe_pmu *pmu) 498 498 { 499 499 struct xe_device *xe = container_of(pmu, typeof(*xe), pmu); 500 - struct xe_gt *gt = xe_device_get_gt(xe, 0); 500 + struct xe_gt *gt; 501 + int id; 502 + 503 + /* If there are no GTs, don't support any GT-related events */ 504 + if (xe->info.gt_count == 0) 505 + return; 501 506 502 507 if (!xe->info.skip_guc_pc) { 503 508 pmu->supported_events |= BIT_ULL(XE_PMU_EVENT_GT_C6_RESIDENCY); 504 509 pmu->supported_events |= BIT_ULL(XE_PMU_EVENT_GT_ACTUAL_FREQUENCY); 505 510 pmu->supported_events |= BIT_ULL(XE_PMU_EVENT_GT_REQUESTED_FREQUENCY); 506 511 } 512 + 513 + /* Find the first available GT to query engine event capabilities */ 514 + for_each_gt(gt, xe, id) 515 + break; 507 516 508 517 if (xe_guc_engine_activity_supported(&gt->uc.guc)) { 509 518 pmu->supported_events |= BIT_ULL(XE_PMU_EVENT_ENGINE_ACTIVE_TICKS);