[PATCH i-g-t] tests/xe: Fix usage of xe_dev_max_gt() for array allocation
Gustavo Sousa
gustavo.sousa at intel.com
Thu Jul 10 20:53:10 UTC 2025
The function xe_dev_max_gt() returns the maximum GT ID. Because the ID
is zero-based, if we want to allocate an array that can hold positions
for all possible GTs, we need to take xe_dev_max_gt() + 1.
Fix the current allocations to conform to that.
Cc: Matt Roper <matthew.d.roper at intel.com>
Cc: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
Fixes: edd059dcd652 ("tests/xe: Don't assume max GT ID is num_gt - 1")
Signed-off-by: Gustavo Sousa <gustavo.sousa at intel.com>
---
tests/intel/xe_gt_freq.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/intel/xe_gt_freq.c b/tests/intel/xe_gt_freq.c
index 2c90804282c9f9f2ca5cfd0ddc1c7b9f01410225..d0f35b10a5fe4b09779ca8120120b22c98477b44 100644
--- a/tests/intel/xe_gt_freq.c
+++ b/tests/intel/xe_gt_freq.c
@@ -408,8 +408,8 @@ igt_main
max_gt = xe_dev_max_gt(fd);
/* The defaults are the same. Stashing the gt0 is enough */
- stash_min = (uint32_t *) malloc(sizeof(uint32_t) * max_gt);
- stash_max = (uint32_t *) malloc(sizeof(uint32_t) * max_gt);
+ stash_min = (uint32_t *) malloc(sizeof(uint32_t) * (max_gt + 1));
+ stash_max = (uint32_t *) malloc(sizeof(uint32_t) * (max_gt + 1));
xe_for_each_gt(fd, gt) {
stash_min[gt] = xe_gt_get_freq(fd, gt, "min");
---
base-commit: eacde5c2acc37c1570e27b68b8b6c39d8b61fb32
change-id: 20250710-fix-use-of-xe_dev_max_gt-for-array-allocation-e8400cce536c
Best regards,
--
Gustavo Sousa <gustavo.sousa at intel.com>
More information about the igt-dev
mailing list