Skip to content

Commit 33c77e0

Browse files
mwajdeczmattrope
authored andcommitted
drm/xe/tests: Convert xe_pci tests to parametrized tests
Instead of looping over known IP descriptors within single test case, without any diagnostics which IP descriptor is eventually broken, define kunit parameter generators with IP descriptors, and make existing xe_pci tests fully parametrized: [ ] =================== xe_pci (2 subtests) ==================== [ ] ==================== check_graphics_ip ==================== [ ] [PASSED] 12.70 Xe_LPG [ ] [PASSED] 12.71 Xe_LPG [ ] [PASSED] 12.74 Xe_LPG+ [ ] [PASSED] 20.01 Xe2_HPG [ ] [PASSED] 20.04 Xe2_LPG [ ] [PASSED] 30.00 Xe3_LPG [ ] [PASSED] 30.01 Xe3_LPG [ ] ================ [PASSED] check_graphics_ip ================ [ ] ===================== check_media_ip ====================== [ ] [PASSED] 13.00 Xe_LPM+ [ ] [PASSED] 13.01 Xe2_HPM [ ] [PASSED] 20.00 Xe2_LPM [ ] [PASSED] 30.00 Xe3_LPM [ ] ================= [PASSED] check_media_ip ================== [ ] ===================== [PASSED] xe_pci ====================== Signed-off-by: Michal Wajdeczko <[email protected]> Cc: Lucas De Marchi <[email protected]> Cc: Matt Roper <[email protected]> Reviewed-by: Lucas De Marchi <[email protected]> Reviewed-by: Matt Roper <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Matt Roper <[email protected]>
1 parent 48f2f7a commit 33c77e0

File tree

3 files changed

+41
-56
lines changed

3 files changed

+41
-56
lines changed

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

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,49 +12,48 @@
1212
#include <kunit/test-bug.h>
1313
#include <kunit/visibility.h>
1414

15+
static void xe_ip_kunit_desc(const struct xe_ip *param, char *desc)
16+
{
17+
snprintf(desc, KUNIT_PARAM_DESC_SIZE, "%u.%02u %s",
18+
param->verx100 / 100, param->verx100 % 100, param->name);
19+
}
20+
21+
KUNIT_ARRAY_PARAM(graphics_ip, graphics_ips, xe_ip_kunit_desc);
22+
KUNIT_ARRAY_PARAM(media_ip, media_ips, xe_ip_kunit_desc);
23+
1524
/**
16-
* xe_call_for_each_graphics_ip - Iterate over all recognized graphics IPs
17-
* @xe_fn: Function to call for each device.
25+
* xe_pci_graphics_ip_gen_param - Generate graphics struct xe_ip parameters
26+
* @prev: the pointer to the previous parameter to iterate from or NULL
27+
* @desc: output buffer with minimum size of KUNIT_PARAM_DESC_SIZE
1828
*
19-
* This function iterates over the descriptors for all graphics IPs recognized
20-
* by the driver and calls @xe_fn: for each one of them.
29+
* This function prepares struct xe_ip parameter.
30+
*
31+
* To be used only as a parameter generator function in &KUNIT_CASE_PARAM.
32+
*
33+
* Return: pointer to the next parameter or NULL if no more parameters
2134
*/
22-
void xe_call_for_each_graphics_ip(xe_graphics_fn xe_fn)
35+
const void *xe_pci_graphics_ip_gen_param(const void *prev, char *desc)
2336
{
24-
const struct xe_graphics_desc *desc, *last = NULL;
25-
26-
for (int i = 0; i < ARRAY_SIZE(graphics_ips); i++) {
27-
desc = graphics_ips[i].desc;
28-
if (desc == last)
29-
continue;
30-
31-
xe_fn(desc);
32-
last = desc;
33-
}
37+
return graphics_ip_gen_params(prev, desc);
3438
}
35-
EXPORT_SYMBOL_IF_KUNIT(xe_call_for_each_graphics_ip);
39+
EXPORT_SYMBOL_IF_KUNIT(xe_pci_graphics_ip_gen_param);
3640

3741
/**
38-
* xe_call_for_each_media_ip - Iterate over all recognized media IPs
39-
* @xe_fn: Function to call for each device.
42+
* xe_pci_media_ip_gen_param - Generate media struct xe_ip parameters
43+
* @prev: the pointer to the previous parameter to iterate from or NULL
44+
* @desc: output buffer with minimum size of KUNIT_PARAM_DESC_SIZE
45+
*
46+
* This function prepares struct xe_ip parameter.
47+
*
48+
* To be used only as a parameter generator function in &KUNIT_CASE_PARAM.
4049
*
41-
* This function iterates over the descriptors for all media IPs recognized
42-
* by the driver and calls @xe_fn: for each one of them.
50+
* Return: pointer to the next parameter or NULL if no more parameters
4351
*/
44-
void xe_call_for_each_media_ip(xe_media_fn xe_fn)
52+
const void *xe_pci_media_ip_gen_param(const void *prev, char *desc)
4553
{
46-
const struct xe_media_desc *desc, *last = NULL;
47-
48-
for (int i = 0; i < ARRAY_SIZE(media_ips); i++) {
49-
desc = media_ips[i].desc;
50-
if (desc == last)
51-
continue;
52-
53-
xe_fn(desc);
54-
last = desc;
55-
}
54+
return media_ip_gen_params(prev, desc);
5655
}
57-
EXPORT_SYMBOL_IF_KUNIT(xe_call_for_each_media_ip);
56+
EXPORT_SYMBOL_IF_KUNIT(xe_pci_media_ip_gen_param);
5857

5958
static void fake_read_gmdid(struct xe_device *xe, enum xe_gmdid_type type,
6059
u32 *ver, u32 *revid)

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

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
#include "xe_pci_test.h"
1515
#include "xe_pci_types.h"
1616

17-
static void check_graphics_ip(const struct xe_graphics_desc *graphics)
17+
static void check_graphics_ip(struct kunit *test)
1818
{
19-
struct kunit *test = kunit_get_current_test();
19+
const struct xe_ip *param = test->param_value;
20+
const struct xe_graphics_desc *graphics = param->desc;
2021
u64 mask = graphics->hw_engine_mask;
2122

2223
/* RCS, CCS, and BCS engines are allowed on the graphics IP */
@@ -28,9 +29,10 @@ static void check_graphics_ip(const struct xe_graphics_desc *graphics)
2829
KUNIT_ASSERT_EQ(test, mask, 0);
2930
}
3031

31-
static void check_media_ip(const struct xe_media_desc *media)
32+
static void check_media_ip(struct kunit *test)
3233
{
33-
struct kunit *test = kunit_get_current_test();
34+
const struct xe_ip *param = test->param_value;
35+
const struct xe_media_desc *media = param->desc;
3436
u64 mask = media->hw_engine_mask;
3537

3638
/* VCS, VECS and GSCCS engines are allowed on the media IP */
@@ -42,19 +44,9 @@ static void check_media_ip(const struct xe_media_desc *media)
4244
KUNIT_ASSERT_EQ(test, mask, 0);
4345
}
4446

45-
static void xe_gmdid_graphics_ip(struct kunit *test)
46-
{
47-
xe_call_for_each_graphics_ip(check_graphics_ip);
48-
}
49-
50-
static void xe_gmdid_media_ip(struct kunit *test)
51-
{
52-
xe_call_for_each_media_ip(check_media_ip);
53-
}
54-
5547
static struct kunit_case xe_pci_tests[] = {
56-
KUNIT_CASE(xe_gmdid_graphics_ip),
57-
KUNIT_CASE(xe_gmdid_media_ip),
48+
KUNIT_CASE_PARAM(check_graphics_ip, xe_pci_graphics_ip_gen_param),
49+
KUNIT_CASE_PARAM(check_media_ip, xe_pci_media_ip_gen_param),
5850
{}
5951
};
6052

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@
1212
#include "xe_sriov_types.h"
1313

1414
struct xe_device;
15-
struct xe_graphics_desc;
16-
struct xe_media_desc;
17-
18-
typedef void (*xe_graphics_fn)(const struct xe_graphics_desc *);
19-
typedef void (*xe_media_fn)(const struct xe_media_desc *);
20-
21-
void xe_call_for_each_graphics_ip(xe_graphics_fn xe_fn);
22-
void xe_call_for_each_media_ip(xe_media_fn xe_fn);
2315

2416
struct xe_pci_fake_data {
2517
enum xe_sriov_mode sriov_mode;
@@ -33,6 +25,8 @@ struct xe_pci_fake_data {
3325

3426
int xe_pci_fake_device_init(struct xe_device *xe);
3527

28+
const void *xe_pci_graphics_ip_gen_param(const void *prev, char *desc);
29+
const void *xe_pci_media_ip_gen_param(const void *prev, char *desc);
3630
const void *xe_pci_live_device_gen_param(const void *prev, char *desc);
3731

3832
#endif

0 commit comments

Comments
 (0)