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 <michal.wajdeczko@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Link: https://lore.kernel.org/r/20250614182446.2024-1-michal.wajdeczko@intel.com
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
This commit is contained in:
Michal Wajdeczko
2025-06-14 20:24:46 +02:00
committed by Matt Roper
parent 48f2f7a9fe
commit 33c77e00f2
3 changed files with 44 additions and 59 deletions

View File

@@ -12,49 +12,48 @@
#include <kunit/test-bug.h>
#include <kunit/visibility.h>
/**
* xe_call_for_each_graphics_ip - Iterate over all recognized graphics IPs
* @xe_fn: Function to call for each device.
*
* This function iterates over the descriptors for all graphics IPs recognized
* by the driver and calls @xe_fn: for each one of them.
*/
void xe_call_for_each_graphics_ip(xe_graphics_fn xe_fn)
static void xe_ip_kunit_desc(const struct xe_ip *param, char *desc)
{
const struct xe_graphics_desc *desc, *last = NULL;
for (int i = 0; i < ARRAY_SIZE(graphics_ips); i++) {
desc = graphics_ips[i].desc;
if (desc == last)
continue;
xe_fn(desc);
last = desc;
}
snprintf(desc, KUNIT_PARAM_DESC_SIZE, "%u.%02u %s",
param->verx100 / 100, param->verx100 % 100, param->name);
}
EXPORT_SYMBOL_IF_KUNIT(xe_call_for_each_graphics_ip);
KUNIT_ARRAY_PARAM(graphics_ip, graphics_ips, xe_ip_kunit_desc);
KUNIT_ARRAY_PARAM(media_ip, media_ips, xe_ip_kunit_desc);
/**
* xe_call_for_each_media_ip - Iterate over all recognized media IPs
* @xe_fn: Function to call for each device.
* xe_pci_graphics_ip_gen_param - Generate graphics struct xe_ip parameters
* @prev: the pointer to the previous parameter to iterate from or NULL
* @desc: output buffer with minimum size of KUNIT_PARAM_DESC_SIZE
*
* This function iterates over the descriptors for all media IPs recognized
* by the driver and calls @xe_fn: for each one of them.
* This function prepares struct xe_ip parameter.
*
* To be used only as a parameter generator function in &KUNIT_CASE_PARAM.
*
* Return: pointer to the next parameter or NULL if no more parameters
*/
void xe_call_for_each_media_ip(xe_media_fn xe_fn)
const void *xe_pci_graphics_ip_gen_param(const void *prev, char *desc)
{
const struct xe_media_desc *desc, *last = NULL;
for (int i = 0; i < ARRAY_SIZE(media_ips); i++) {
desc = media_ips[i].desc;
if (desc == last)
continue;
xe_fn(desc);
last = desc;
}
return graphics_ip_gen_params(prev, desc);
}
EXPORT_SYMBOL_IF_KUNIT(xe_call_for_each_media_ip);
EXPORT_SYMBOL_IF_KUNIT(xe_pci_graphics_ip_gen_param);
/**
* xe_pci_media_ip_gen_param - Generate media struct xe_ip parameters
* @prev: the pointer to the previous parameter to iterate from or NULL
* @desc: output buffer with minimum size of KUNIT_PARAM_DESC_SIZE
*
* This function prepares struct xe_ip parameter.
*
* To be used only as a parameter generator function in &KUNIT_CASE_PARAM.
*
* Return: pointer to the next parameter or NULL if no more parameters
*/
const void *xe_pci_media_ip_gen_param(const void *prev, char *desc)
{
return media_ip_gen_params(prev, desc);
}
EXPORT_SYMBOL_IF_KUNIT(xe_pci_media_ip_gen_param);
static void fake_read_gmdid(struct xe_device *xe, enum xe_gmdid_type type,
u32 *ver, u32 *revid)

View File

@@ -14,9 +14,10 @@
#include "xe_pci_test.h"
#include "xe_pci_types.h"
static void check_graphics_ip(const struct xe_graphics_desc *graphics)
static void check_graphics_ip(struct kunit *test)
{
struct kunit *test = kunit_get_current_test();
const struct xe_ip *param = test->param_value;
const struct xe_graphics_desc *graphics = param->desc;
u64 mask = graphics->hw_engine_mask;
/* 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)
KUNIT_ASSERT_EQ(test, mask, 0);
}
static void check_media_ip(const struct xe_media_desc *media)
static void check_media_ip(struct kunit *test)
{
struct kunit *test = kunit_get_current_test();
const struct xe_ip *param = test->param_value;
const struct xe_media_desc *media = param->desc;
u64 mask = media->hw_engine_mask;
/* 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)
KUNIT_ASSERT_EQ(test, mask, 0);
}
static void xe_gmdid_graphics_ip(struct kunit *test)
{
xe_call_for_each_graphics_ip(check_graphics_ip);
}
static void xe_gmdid_media_ip(struct kunit *test)
{
xe_call_for_each_media_ip(check_media_ip);
}
static struct kunit_case xe_pci_tests[] = {
KUNIT_CASE(xe_gmdid_graphics_ip),
KUNIT_CASE(xe_gmdid_media_ip),
KUNIT_CASE_PARAM(check_graphics_ip, xe_pci_graphics_ip_gen_param),
KUNIT_CASE_PARAM(check_media_ip, xe_pci_media_ip_gen_param),
{}
};

View File

@@ -12,14 +12,6 @@
#include "xe_sriov_types.h"
struct xe_device;
struct xe_graphics_desc;
struct xe_media_desc;
typedef void (*xe_graphics_fn)(const struct xe_graphics_desc *);
typedef void (*xe_media_fn)(const struct xe_media_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);
struct xe_pci_fake_data {
enum xe_sriov_mode sriov_mode;
@@ -33,6 +25,8 @@ struct xe_pci_fake_data {
int xe_pci_fake_device_init(struct xe_device *xe);
const void *xe_pci_graphics_ip_gen_param(const void *prev, char *desc);
const void *xe_pci_media_ip_gen_param(const void *prev, char *desc);
const void *xe_pci_live_device_gen_param(const void *prev, char *desc);
#endif