[PATCH v4 1/7] drm/xe/pmu: Fix GT sanity check in event_supported()
Matt Roper
matthew.d.roper at intel.com
Tue Jul 1 20:13:22 UTC 2025
event_supported() tries to ensure that the GT ID passed is valid by
comparing against XE_MAX_GT_PER_TILE. However this does not account
for cases where a GT ID is within the proper range, but still references
a non-existent / fused-off GT (e.g., GT ID = 1 on a PVC platform with
only a single tile). Switch the check to an actual GT lookup
so that EINVAL will be returned properly for all non-existent GTs.
Cc: Riana Tauro <riana.tauro at intel.com>
Signed-off-by: Matt Roper <matthew.d.roper at intel.com>
---
drivers/gpu/drm/xe/xe_pmu.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_pmu.c b/drivers/gpu/drm/xe/xe_pmu.c
index 69df0e3520a5..cab51d826345 100644
--- a/drivers/gpu/drm/xe/xe_pmu.c
+++ b/drivers/gpu/drm/xe/xe_pmu.c
@@ -157,10 +157,13 @@ static bool event_gt_forcewake(struct perf_event *event)
return true;
}
-static bool event_supported(struct xe_pmu *pmu, unsigned int gt,
+static bool event_supported(struct xe_pmu *pmu, unsigned int gt_id,
unsigned int id)
{
- if (gt >= XE_MAX_GT_PER_TILE)
+ struct xe_device *xe = container_of(pmu, typeof(*xe), pmu);
+ struct xe_gt *gt = xe_device_get_gt(xe, gt_id);
+
+ if (!gt)
return false;
return id < sizeof(pmu->supported_events) * BITS_PER_BYTE &&
--
2.49.0
More information about the Intel-xe
mailing list