All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matt Roper <matthew.d.roper@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: matthew.d.roper@intel.com
Subject: [PATCH i-g-t] tests/intel/xe_pmu: Ensure stash_gt_freq allocates sufficient storage
Date: Mon, 31 Aug 2026 13:44:56 -0700	[thread overview]
Message-ID: <20260831204455.1242947-2-matthew.d.roper@intel.com> (raw)

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


             reply	other threads:[~2026-08-31 20:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31 20:44 Matt Roper [this message]
2026-09-01 21:18 ` ✓ i915.CI.BAT: success for tests/intel/xe_pmu: Ensure stash_gt_freq allocates sufficient storage 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260831204455.1242947-2-matthew.d.roper@intel.com \
    --to=matthew.d.roper@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.