From: Matt Roper <matthew.d.roper@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: matthew.d.roper@intel.com
Subject: [PATCH 3/5] drm/xe/tests/pci: Ensure all platforms have a valid GT/tile count
Date: Thu, 12 Jun 2025 17:14:42 -0700 [thread overview]
Message-ID: <20250613001438.678728-10-matthew.d.roper@intel.com> (raw)
In-Reply-To: <20250613001438.678728-7-matthew.d.roper@intel.com>
Add a simple kunit test to ensure each platform's GT per tile count is
non-zero and does not exceed the global XE_MAX_GT_PER_TILE definition.
We need to move 'struct xe_subplatform_desc' from the .c file to the
types header to ensure it is accessible from the kunit test.
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
---
drivers/gpu/drm/xe/tests/xe_pci.c | 24 ++++++++++++++++
drivers/gpu/drm/xe/tests/xe_pci_test.c | 15 ++++++++++
drivers/gpu/drm/xe/tests/xe_pci_test.h | 3 ++
drivers/gpu/drm/xe/xe_pci.c | 38 ------------------------
drivers/gpu/drm/xe/xe_pci_types.h | 40 ++++++++++++++++++++++++++
5 files changed, 82 insertions(+), 38 deletions(-)
diff --git a/drivers/gpu/drm/xe/tests/xe_pci.c b/drivers/gpu/drm/xe/tests/xe_pci.c
index 1d3e2e50c355..f8858e193213 100644
--- a/drivers/gpu/drm/xe/tests/xe_pci.c
+++ b/drivers/gpu/drm/xe/tests/xe_pci.c
@@ -56,6 +56,30 @@ void xe_call_for_each_media_ip(xe_media_fn xe_fn)
}
EXPORT_SYMBOL_IF_KUNIT(xe_call_for_each_media_ip);
+/**
+ * xe_call_for_each_platform - Iterate over all recognized platforms
+ * @xe_fn: Function to call for each device.
+ *
+ * This function iterates over the descriptors for all platforms recognized
+ * by the driver and calls @xe_fn: for each one of them.
+ */
+void xe_call_for_each_platform(xe_platform_fn xe_fn)
+{
+ const struct xe_device_desc *desc, *last = NULL;
+
+ for (int i = 0; i < ARRAY_SIZE(pciidlist); i++) {
+ desc = (const struct xe_device_desc *)pciidlist[i].driver_data;
+ if (!desc)
+ break;
+ if (desc == last)
+ continue;
+
+ xe_fn(desc);
+ last = desc;
+ }
+}
+EXPORT_SYMBOL_IF_KUNIT(xe_call_for_each_platform);
+
static void fake_read_gmdid(struct xe_device *xe, enum xe_gmdid_type type,
u32 *ver, u32 *revid)
{
diff --git a/drivers/gpu/drm/xe/tests/xe_pci_test.c b/drivers/gpu/drm/xe/tests/xe_pci_test.c
index 744a37583d2d..a401a91af555 100644
--- a/drivers/gpu/drm/xe/tests/xe_pci_test.c
+++ b/drivers/gpu/drm/xe/tests/xe_pci_test.c
@@ -42,6 +42,15 @@ static void check_media_ip(const struct xe_media_desc *media)
KUNIT_ASSERT_EQ(test, mask, 0);
}
+static void check_platform_gt_count(const struct xe_device_desc *platform)
+{
+ struct kunit *test = kunit_get_current_test();
+ int max_gt = platform->max_gt_per_tile;
+
+ KUNIT_ASSERT_GT(test, max_gt, 0);
+ KUNIT_ASSERT_LE(test, max_gt, XE_MAX_GT_PER_TILE);
+}
+
static void xe_gmdid_graphics_ip(struct kunit *test)
{
xe_call_for_each_graphics_ip(check_graphics_ip);
@@ -52,9 +61,15 @@ static void xe_gmdid_media_ip(struct kunit *test)
xe_call_for_each_media_ip(check_media_ip);
}
+static void xe_platform_gt_count(struct kunit *test)
+{
+ xe_call_for_each_platform(check_platform_gt_count);
+}
+
static struct kunit_case xe_pci_tests[] = {
KUNIT_CASE(xe_gmdid_graphics_ip),
KUNIT_CASE(xe_gmdid_media_ip),
+ KUNIT_CASE(xe_platform_gt_count),
{}
};
diff --git a/drivers/gpu/drm/xe/tests/xe_pci_test.h b/drivers/gpu/drm/xe/tests/xe_pci_test.h
index ede46800aff1..5abbf522f7a8 100644
--- a/drivers/gpu/drm/xe/tests/xe_pci_test.h
+++ b/drivers/gpu/drm/xe/tests/xe_pci_test.h
@@ -14,13 +14,16 @@
struct xe_device;
struct xe_graphics_desc;
struct xe_media_desc;
+struct xe_device_desc;
typedef int (*xe_device_fn)(struct xe_device *);
typedef void (*xe_graphics_fn)(const struct xe_graphics_desc *);
typedef void (*xe_media_fn)(const struct xe_media_desc *);
+typedef void (*xe_platform_fn)(const struct xe_device_desc *);
void xe_call_for_each_graphics_ip(xe_graphics_fn xe_fn);
void xe_call_for_each_media_ip(xe_media_fn xe_fn);
+void xe_call_for_each_platform(xe_platform_fn xe_fn);
struct xe_pci_fake_data {
enum xe_sriov_mode sriov_mode;
diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c
index 3b997c941bbc..a4885f64c2c4 100644
--- a/drivers/gpu/drm/xe/xe_pci.c
+++ b/drivers/gpu/drm/xe/xe_pci.c
@@ -38,44 +38,6 @@ enum toggle_d3cold {
D3COLD_ENABLE,
};
-struct xe_subplatform_desc {
- enum xe_subplatform subplatform;
- const char *name;
- const u16 *pciidlist;
-};
-
-struct xe_device_desc {
- /* Should only ever be set for platforms without GMD_ID */
- const struct xe_ip *pre_gmdid_graphics_ip;
- /* Should only ever be set for platforms without GMD_ID */
- const struct xe_ip *pre_gmdid_media_ip;
-
- const char *platform_name;
- const struct xe_subplatform_desc *subplatforms;
-
- enum xe_platform platform;
-
- u8 dma_mask_size;
- u8 max_remote_tiles:2;
- u8 max_gt_per_tile:2;
-
- u8 require_force_probe:1;
- u8 is_dgfx:1;
-
- u8 has_display:1;
- u8 has_fan_control:1;
- u8 has_heci_gscfi:1;
- u8 has_heci_cscfi:1;
- u8 has_llc:1;
- u8 has_mbx_power_limits:1;
- u8 has_pxp:1;
- u8 has_sriov:1;
- u8 needs_scratch:1;
- u8 skip_guc_pc:1;
- u8 skip_mtcfg:1;
- u8 skip_pcode:1;
-};
-
__diag_push();
__diag_ignore_all("-Woverride-init", "Allow field overrides in table");
diff --git a/drivers/gpu/drm/xe/xe_pci_types.h b/drivers/gpu/drm/xe/xe_pci_types.h
index ca6b10d35573..e4bfbafa6809 100644
--- a/drivers/gpu/drm/xe/xe_pci_types.h
+++ b/drivers/gpu/drm/xe/xe_pci_types.h
@@ -8,6 +8,46 @@
#include <linux/types.h>
+#include "xe_platform_types.h"
+
+struct xe_subplatform_desc {
+ enum xe_subplatform subplatform;
+ const char *name;
+ const u16 *pciidlist;
+};
+
+struct xe_device_desc {
+ /* Should only ever be set for platforms without GMD_ID */
+ const struct xe_ip *pre_gmdid_graphics_ip;
+ /* Should only ever be set for platforms without GMD_ID */
+ const struct xe_ip *pre_gmdid_media_ip;
+
+ const char *platform_name;
+ const struct xe_subplatform_desc *subplatforms;
+
+ enum xe_platform platform;
+
+ u8 dma_mask_size;
+ u8 max_remote_tiles:2;
+ u8 max_gt_per_tile:2;
+
+ u8 require_force_probe:1;
+ u8 is_dgfx:1;
+
+ u8 has_display:1;
+ u8 has_fan_control:1;
+ u8 has_heci_gscfi:1;
+ u8 has_heci_cscfi:1;
+ u8 has_llc:1;
+ u8 has_mbx_power_limits:1;
+ u8 has_pxp:1;
+ u8 has_sriov:1;
+ u8 needs_scratch:1;
+ u8 skip_guc_pc:1;
+ u8 skip_mtcfg:1;
+ u8 skip_pcode:1;
+};
+
struct xe_graphics_desc {
u8 va_bits;
u8 vm_max_level;
--
2.49.0
next prev parent reply other threads:[~2025-06-13 0:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-13 0:14 [PATCH 0/5] Future-proof for multi-tile + multi-GT cases Matt Roper
2025-06-13 0:14 ` [PATCH 1/5] drm/xe: Export xe_step_name for kunit tests Matt Roper
2025-06-13 15:52 ` Michal Wajdeczko
2025-06-13 0:14 ` [PATCH 2/5] drm/xe: Track maximum GTs per tile on a per-platform basis Matt Roper
2025-06-13 20:32 ` Lucas De Marchi
2025-06-13 0:14 ` Matt Roper [this message]
2025-06-13 17:59 ` [PATCH 3/5] drm/xe/tests/pci: Ensure all platforms have a valid GT/tile count Michal Wajdeczko
2025-06-13 19:21 ` Michal Wajdeczko
2025-06-13 0:14 ` [PATCH 4/5] drm/xe: Assign GT IDs properly on multi-tile + multi-GT platforms Matt Roper
2025-06-13 0:14 ` [PATCH 5/5] drm/xe: Don't compare GT ID to GT count when determining valid GTs Matt Roper
2025-06-13 7:36 ` ✗ CI.checkpatch: warning for Future-proof for multi-tile + multi-GT cases Patchwork
2025-06-13 7:37 ` ✗ CI.KUnit: failure " 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=20250613001438.678728-10-matthew.d.roper@intel.com \
--to=matthew.d.roper@intel.com \
--cc=intel-xe@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox