All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t] tests/intel/xe_pmu: Ensure stash_gt_freq allocates sufficient storage
@ 2026-08-31 20:44 Matt Roper
  2026-09-01 21:18 ` ✓ i915.CI.BAT: success for " Patchwork
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Matt Roper @ 2026-08-31 20:44 UTC (permalink / raw)
  To: igt-dev; +Cc: matthew.d.roper

stash_gt_freq() malloc's arrays based on the number of GTs returned by
the kernel's query ioctl and then indexes into the arrays by uapi GT ID.
This works fine if all GT IDs are consecutive (which is always the case
on platforms today), but will be insufficient if future platforms allow
the list to contain non-consecutive IDs (e.g., 0, 2, ...).  Allocate
storage based on the maximum GT ID returned, not the number of GTs
returned.  Some of the array indices will remain unused, but the
xe_for_each_gt() loops will already skip over those unused entries
properly.

Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
---
 tests/intel/xe_pmu.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/intel/xe_pmu.c b/tests/intel/xe_pmu.c
index a8ceac46c..ea8950ee5 100644
--- a/tests/intel/xe_pmu.c
+++ b/tests/intel/xe_pmu.c
@@ -1039,12 +1039,12 @@ static void unprovision_and_disable_vfs(int fd)
 
 static void stash_gt_freq(int fd, uint32_t **stash_min, uint32_t **stash_max)
 {
-	int num_gts, gt;
+	int max_gt, gt;
 
-	num_gts = xe_number_gt(fd);
+	max_gt = xe_dev_max_gt(fd);
 
-	*stash_min = (uint32_t *) malloc(sizeof(uint32_t) * num_gts);
-	*stash_max = (uint32_t *) malloc(sizeof(uint32_t) * num_gts);
+	*stash_min = (uint32_t *)calloc(max_gt + 1, sizeof(uint32_t));
+	*stash_max = (uint32_t *)calloc(max_gt + 1, sizeof(uint32_t));
 
 	igt_skip_on(*stash_min == NULL || *stash_max == NULL);
 
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-09-02 10:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-31 20:44 [PATCH i-g-t] tests/intel/xe_pmu: Ensure stash_gt_freq allocates sufficient storage Matt Roper
2026-09-01 21:18 ` ✓ i915.CI.BAT: success for " Patchwork
2026-09-01 21:20 ` ✓ Xe.CI.BAT: " Patchwork
2026-09-02  9:49 ` ✗ i915.CI.Full: failure " Patchwork
2026-09-02 10:06 ` ✗ Xe.CI.FULL: " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.