<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 30-06-2025 15:07, Riana Tauro wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:20250630093741.2435281-1-riana.tauro@intel.com">
      <pre wrap="" class="moz-quote-pre">Validate gt instead of checking gt_id is lesser
than max gts per tile

Signed-off-by: Riana Tauro <a class="moz-txt-link-rfc2396E" href="mailto:riana.tauro@intel.com"><riana.tauro@intel.com></a>
---
 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);</pre>
    </blockquote>
    <pre wrap="" class="moz-quote-pre">Looks like xe_device_get_gt<span style="white-space: normal">() would return primary_gt handle, instead of NULL, if gt_id > </span><span style="white-space: pre-wrap">XE_MAX_GT_PER_TILE.
gt would be always valid then !</span></pre>
    <blockquote type="cite" cite="mid:20250630093741.2435281-1-riana.tauro@intel.com">
      <pre wrap="" class="moz-quote-pre">
+
+       if (!gt)
                return false;
 
        return id < sizeof(pmu->supported_events) * BITS_PER_BYTE &&
</pre>
    </blockquote>
  </body>
</html>