]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/xe: Allow to stub lookup for graphics and media IP
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Fri, 29 Aug 2025 17:19:16 +0000 (19:19 +0200)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Fri, 5 Sep 2025 10:57:22 +0000 (12:57 +0200)
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
drivers/gpu/drm/xe/xe_pci.c

index 046d330bad34286f9859dabfe3c3c99f36aa1700..dea027e175b6c56e751f4be02dcaba9bcd726780 100644 (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);