]> git.hungrycats.org Git - linux/commitdiff
drm/xe: Add framework for info probing
authorGustavo Sousa <gustavo.sousa@intel.com>
Tue, 9 Jun 2026 20:17:33 +0000 (17:17 -0300)
committerGustavo Sousa <gustavo.sousa@intel.com>
Thu, 2 Jul 2026 21:41:49 +0000 (18:41 -0300)
Functions xe_info_init_early() and xe_info_init() currently probe some
information from the hardware while doing initialization of info
fields.  Besides mixing responsibilities, another issue from this
approach is that kunit tests need to implement static stubs for the
probing part.

Let's prepare the ground to ensuring that those functions stop probing
the information from the hardware by creating the necessary framework
for extracting the probing bits out of them.  Do that by creating a
new struct type called xe_probed_info and the functions responsible
for populating it.

In upcoming changes, we will gradually refactor the code so that all
info needed by xe_info_init_early() and xe_info_init() that is probed
from the hardware is passed to them via struct xe_probed_info.

Reviewed-by: Dnyaneshwar Bhadane <dnyaneshwar.bhadane@intel.com>
Reviewed-by: Violet Monti <violet.monti@intel.com>
Link: https://patch.msgid.link/20260609-xe-probe-info-v1-1-21e83e188e60@intel.com
Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
drivers/gpu/drm/xe/tests/xe_pci.c
drivers/gpu/drm/xe/xe_pci.c

index 9240aff779da3d16313cdd9640e1c3e7b272c74c..51d032a9e01a225113465c60572e66d6d6bed712 100644 (file)
@@ -338,13 +338,21 @@ static void fake_xe_info_probe_tile_count(struct xe_device *xe)
        /* Nothing to do, just use the statically defined value. */
 }
 
+static int fake_probe_info(struct xe_device *xe,
+                          struct xe_probed_info *probed_info)
+{
+       return 0;
+}
+
 int xe_pci_fake_device_init(struct xe_device *xe)
 {
        struct kunit *test = kunit_get_current_test();
        struct xe_pci_fake_data *data = test->priv;
+       struct xe_probed_info probed_info = {};
        const struct pci_device_id *ent = pciidlist;
        const struct xe_device_desc *desc;
        const struct xe_subplatform_desc *subplatform_desc;
+       int err;
 
        if (!data) {
                desc = (const void *)ent->driver_data;
@@ -379,8 +387,12 @@ done:
        kunit_activate_static_stub(test, xe_info_probe_tile_count,
                                   fake_xe_info_probe_tile_count);
 
-       xe_info_init_early(xe, desc, subplatform_desc);
-       xe_info_init(xe, desc);
+       err = fake_probe_info(xe, &probed_info);
+       if (err)
+               return err;
+
+       xe_info_init_early(xe, desc, subplatform_desc, &probed_info);
+       xe_info_init(xe, desc, &probed_info);
 
        return 0;
 }
index 096c99b865b4370466aa1d0cef369639e10a7de1..6156d8689430e1df41b54a2654ac96784e02d78f 100644 (file)
@@ -739,13 +739,27 @@ static void init_devid(struct xe_device *xe)
        xe->info.revid = pdev->revision;
 }
 
+struct xe_probed_info {
+       /* Nothing for now. */
+};
+
+/*
+ * Probe from the hardware the info required by xe_info_init_early().
+ */
+static int xe_probe_info_early(struct xe_device *xe,
+                              struct xe_probed_info *probed_info)
+{
+       return 0;
+}
+
 /*
  * Initialize device info content that only depends on static driver_data
  * passed to the driver at probe time from PCI ID table.
  */
 static int xe_info_init_early(struct xe_device *xe,
                              const struct xe_device_desc *desc,
-                             const struct xe_subplatform_desc *subplatform_desc)
+                             const struct xe_subplatform_desc *subplatform_desc,
+                             struct xe_probed_info *probed_info)
 {
        int err;
 
@@ -912,6 +926,15 @@ static struct xe_gt *alloc_media_gt(struct xe_tile *tile,
        return gt;
 }
 
+/*
+ * Probe from the hardware the info required by xe_info_init().
+ */
+static int xe_probe_info(struct xe_device *xe,
+                        struct xe_probed_info *probed_info)
+{
+       return 0;
+}
+
 /*
  * Initialize device info content that does require knowledge about
  * graphics / media IP version.
@@ -919,7 +942,8 @@ static struct xe_gt *alloc_media_gt(struct xe_tile *tile,
  * present in device info.
  */
 static int xe_info_init(struct xe_device *xe,
-                       const struct xe_device_desc *desc)
+                       const struct xe_device_desc *desc,
+                       struct xe_probed_info *probed_info)
 {
        u32 graphics_gmdid_revid = 0, media_gmdid_revid = 0;
        const struct xe_ip *graphics_ip;
@@ -1075,6 +1099,7 @@ static void xe_pci_remove(struct pci_dev *pdev)
  */
 static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
+       struct xe_probed_info probed_info = {};
        const struct xe_device_desc *desc = (const void *)ent->driver_data;
        const struct xe_subplatform_desc *subplatform_desc;
        struct xe_device *xe;
@@ -1127,7 +1152,11 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        pci_set_master(pdev);
 
-       err = xe_info_init_early(xe, desc, subplatform_desc);
+       err = xe_probe_info_early(xe, &probed_info);
+       if (err)
+               return err;
+
+       err = xe_info_init_early(xe, desc, subplatform_desc, &probed_info);
        if (err)
                return err;
 
@@ -1146,7 +1175,11 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        if (err)
                return err;
 
-       err = xe_info_init(xe, desc);
+       err = xe_probe_info(xe, &probed_info);
+       if (err)
+               return err;
+
+       err = xe_info_init(xe, desc, &probed_info);
        if (err)
                return err;