Skip to content

Commit fb72cd2

Browse files
committed
drm/xe/tests/pci: Ensure all platforms have a valid GT/tile count
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. v2: - Rebase on latest xe_pci test rework from Michal and convert to a parameterized test that runs on each PCI ID supported by the driver. Cc: Michal Wajdeczko <michal.wajdeczko@intel.com> Reviewed-by: Ravi Kumar Vodapalli <ravi.kumar.vodapalli@intel.com> Link: https://lore.kernel.org/r/20250701201320.2514369-13-matthew.d.roper@intel.com Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
1 parent f8e0f4c commit fb72cd2

5 files changed

Lines changed: 85 additions & 39 deletions

File tree

drivers/gpu/drm/xe/tests/xe_pci.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ static void xe_ip_kunit_desc(const struct xe_ip *param, char *desc)
2121
KUNIT_ARRAY_PARAM(graphics_ip, graphics_ips, xe_ip_kunit_desc);
2222
KUNIT_ARRAY_PARAM(media_ip, media_ips, xe_ip_kunit_desc);
2323

24+
static void xe_pci_id_kunit_desc(const struct pci_device_id *param, char *desc)
25+
{
26+
const struct xe_device_desc *dev_desc =
27+
(const struct xe_device_desc *)param->driver_data;
28+
29+
if (dev_desc)
30+
snprintf(desc, KUNIT_PARAM_DESC_SIZE, "0x%X (%s)",
31+
param->device, dev_desc->platform_name);
32+
}
33+
34+
KUNIT_ARRAY_PARAM(pci_id, pciidlist, xe_pci_id_kunit_desc);
35+
2436
/**
2537
* xe_pci_graphics_ip_gen_param - Generate graphics struct xe_ip parameters
2638
* @prev: the pointer to the previous parameter to iterate from or NULL
@@ -55,6 +67,25 @@ const void *xe_pci_media_ip_gen_param(const void *prev, char *desc)
5567
}
5668
EXPORT_SYMBOL_IF_KUNIT(xe_pci_media_ip_gen_param);
5769

70+
/**
71+
* xe_pci_id_gen_param - Generate struct pci_device_id parameters
72+
* @prev: the pointer to the previous parameter to iterate from or NULL
73+
* @desc: output buffer with minimum size of KUNIT_PARAM_DESC_SIZE
74+
*
75+
* This function prepares struct pci_device_id parameter.
76+
*
77+
* To be used only as a parameter generator function in &KUNIT_CASE_PARAM.
78+
*
79+
* Return: pointer to the next parameter or NULL if no more parameters
80+
*/
81+
const void *xe_pci_id_gen_param(const void *prev, char *desc)
82+
{
83+
const struct pci_device_id *pci = pci_id_gen_params(prev, desc);
84+
85+
return pci->driver_data ? pci : NULL;
86+
}
87+
EXPORT_SYMBOL_IF_KUNIT(xe_pci_id_gen_param);
88+
5889
static void fake_read_gmdid(struct xe_device *xe, enum xe_gmdid_type type,
5990
u32 *ver, u32 *revid)
6091
{

drivers/gpu/drm/xe/tests/xe_pci_test.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,21 @@ static void check_media_ip(struct kunit *test)
4444
KUNIT_ASSERT_EQ(test, mask, 0);
4545
}
4646

47+
static void check_platform_gt_count(struct kunit *test)
48+
{
49+
const struct pci_device_id *pci = test->param_value;
50+
const struct xe_device_desc *desc =
51+
(const struct xe_device_desc *)pci->driver_data;
52+
int max_gt = desc->max_gt_per_tile;
53+
54+
KUNIT_ASSERT_GT(test, max_gt, 0);
55+
KUNIT_ASSERT_LE(test, max_gt, XE_MAX_GT_PER_TILE);
56+
}
57+
4758
static struct kunit_case xe_pci_tests[] = {
4859
KUNIT_CASE_PARAM(check_graphics_ip, xe_pci_graphics_ip_gen_param),
4960
KUNIT_CASE_PARAM(check_media_ip, xe_pci_media_ip_gen_param),
61+
KUNIT_CASE_PARAM(check_platform_gt_count, xe_pci_id_gen_param),
5062
{}
5163
};
5264

drivers/gpu/drm/xe/tests/xe_pci_test.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ int xe_pci_fake_device_init(struct xe_device *xe);
2727

2828
const void *xe_pci_graphics_ip_gen_param(const void *prev, char *desc);
2929
const void *xe_pci_media_ip_gen_param(const void *prev, char *desc);
30+
const void *xe_pci_id_gen_param(const void *prev, char *desc);
3031
const void *xe_pci_live_device_gen_param(const void *prev, char *desc);
3132

3233
#endif

drivers/gpu/drm/xe/xe_pci.c

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -38,45 +38,6 @@ enum toggle_d3cold {
3838
D3COLD_ENABLE,
3939
};
4040

41-
struct xe_subplatform_desc {
42-
enum xe_subplatform subplatform;
43-
const char *name;
44-
const u16 *pciidlist;
45-
};
46-
47-
struct xe_device_desc {
48-
/* Should only ever be set for platforms without GMD_ID */
49-
const struct xe_ip *pre_gmdid_graphics_ip;
50-
/* Should only ever be set for platforms without GMD_ID */
51-
const struct xe_ip *pre_gmdid_media_ip;
52-
53-
const char *platform_name;
54-
const struct xe_subplatform_desc *subplatforms;
55-
56-
enum xe_platform platform;
57-
58-
u8 dma_mask_size;
59-
u8 max_remote_tiles:2;
60-
u8 max_gt_per_tile:2;
61-
62-
u8 require_force_probe:1;
63-
u8 is_dgfx:1;
64-
65-
u8 has_display:1;
66-
u8 has_fan_control:1;
67-
u8 has_gsc_nvm:1;
68-
u8 has_heci_gscfi:1;
69-
u8 has_heci_cscfi:1;
70-
u8 has_llc:1;
71-
u8 has_mbx_power_limits:1;
72-
u8 has_pxp:1;
73-
u8 has_sriov:1;
74-
u8 needs_scratch:1;
75-
u8 skip_guc_pc:1;
76-
u8 skip_mtcfg:1;
77-
u8 skip_pcode:1;
78-
};
79-
8041
__diag_push();
8142
__diag_ignore_all("-Woverride-init", "Allow field overrides in table");
8243

drivers/gpu/drm/xe/xe_pci_types.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,47 @@
88

99
#include <linux/types.h>
1010

11+
#include "xe_platform_types.h"
12+
13+
struct xe_subplatform_desc {
14+
enum xe_subplatform subplatform;
15+
const char *name;
16+
const u16 *pciidlist;
17+
};
18+
19+
struct xe_device_desc {
20+
/* Should only ever be set for platforms without GMD_ID */
21+
const struct xe_ip *pre_gmdid_graphics_ip;
22+
/* Should only ever be set for platforms without GMD_ID */
23+
const struct xe_ip *pre_gmdid_media_ip;
24+
25+
const char *platform_name;
26+
const struct xe_subplatform_desc *subplatforms;
27+
28+
enum xe_platform platform;
29+
30+
u8 dma_mask_size;
31+
u8 max_remote_tiles:2;
32+
u8 max_gt_per_tile:2;
33+
34+
u8 require_force_probe:1;
35+
u8 is_dgfx:1;
36+
37+
u8 has_display:1;
38+
u8 has_fan_control:1;
39+
u8 has_gsc_nvm:1;
40+
u8 has_heci_gscfi:1;
41+
u8 has_heci_cscfi:1;
42+
u8 has_llc:1;
43+
u8 has_mbx_power_limits:1;
44+
u8 has_pxp:1;
45+
u8 has_sriov:1;
46+
u8 needs_scratch:1;
47+
u8 skip_guc_pc:1;
48+
u8 skip_mtcfg:1;
49+
u8 skip_pcode:1;
50+
};
51+
1152
struct xe_graphics_desc {
1253
u8 va_bits;
1354
u8 vm_max_level;

0 commit comments

Comments
 (0)