drm/xe: Allow to stub lookup for graphics and media IP

In upcoming patch we will want to replace lookup code during the
test to relax the strict match that we use in production.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://lore.kernel.org/r/20250829171922.572-2-michal.wajdeczko@intel.com
This commit is contained in:
Michal Wajdeczko
2025-08-29 19:19:16 +02:00
parent edb1745fc6
commit 981daf1046

View File

@@ -510,6 +510,26 @@ static void read_gmdid(struct xe_device *xe, enum xe_gmdid_type type, u32 *ver,
*revid = REG_FIELD_GET(GMD_ID_REVID, val);
}
static const struct xe_ip *find_graphics_ip(unsigned int verx100)
{
KUNIT_STATIC_STUB_REDIRECT(find_graphics_ip, verx100);
for (int i = 0; i < ARRAY_SIZE(graphics_ips); i++)
if (graphics_ips[i].verx100 == verx100)
return &graphics_ips[i];
return NULL;
}
static const struct xe_ip *find_media_ip(unsigned int verx100)
{
KUNIT_STATIC_STUB_REDIRECT(find_media_ip, verx100);
for (int i = 0; i < ARRAY_SIZE(media_ips); i++)
if (media_ips[i].verx100 == verx100)
return &media_ips[i];
return NULL;
}
/*
* Read IP version from hardware and select graphics/media IP descriptors
* based on the result.
@@ -527,14 +547,7 @@ static void handle_gmdid(struct xe_device *xe,
read_gmdid(xe, GMDID_GRAPHICS, &ver, graphics_revid);
for (int i = 0; i < ARRAY_SIZE(graphics_ips); i++) {
if (ver == graphics_ips[i].verx100) {
*graphics_ip = &graphics_ips[i];
break;
}
}
*graphics_ip = find_graphics_ip(ver);
if (!*graphics_ip) {
drm_err(&xe->drm, "Hardware reports unknown graphics version %u.%02u\n",
ver / 100, ver % 100);
@@ -545,14 +558,7 @@ static void handle_gmdid(struct xe_device *xe,
if (ver == 0)
return;
for (int i = 0; i < ARRAY_SIZE(media_ips); i++) {
if (ver == media_ips[i].verx100) {
*media_ip = &media_ips[i];
break;
}
}
*media_ip = find_media_ip(ver);
if (!*media_ip) {
drm_err(&xe->drm, "Hardware reports unknown media version %u.%02u\n",
ver / 100, ver % 100);