]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/xe: Move xe->info.devid|revid initialization
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Tue, 26 May 2026 19:54:49 +0000 (21:54 +0200)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Wed, 27 May 2026 10:51:25 +0000 (12:51 +0200)
The xe_info_init_early() is a place where we initialize those of
the xe->info fields that do not require any additional hardware
probes. Move the initialization of the devid/revid also there, but
to avoid breaking the kunit helper, which also calls this function,
keep their initialization separate in sub-function so we can easily
stub it when running the kunit test.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Gustavo Sousa <gustavo.sousa@intel.com>
Reviewed-by: Gustavo Sousa <gustavo.sousa@intel.com>
Link: https://patch.msgid.link/20260526195452.20545-5-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/tests/xe_pci.c
drivers/gpu/drm/xe/xe_device.c
drivers/gpu/drm/xe/xe_pci.c

index 860409c579f8c169187692b04823155b8bb6f7d5..9240aff779da3d16313cdd9640e1c3e7b272c74c 100644 (file)
@@ -311,6 +311,11 @@ const void *xe_pci_id_gen_param(struct kunit *test, const void *prev, char *desc
 }
 EXPORT_SYMBOL_IF_KUNIT(xe_pci_id_gen_param);
 
+static void fake_init_devid(struct xe_device *xe)
+{
+       /* Nothing to do, just keep zero. */
+}
+
 static int fake_read_gmdid(struct xe_device *xe, enum xe_gmdid_type type,
                           u32 *ver, u32 *revid)
 {
@@ -369,6 +374,7 @@ done:
        xe->sriov.__mode = data && data->sriov_mode ?
                           data->sriov_mode : XE_SRIOV_MODE_NONE;
 
+       kunit_activate_static_stub(test, init_devid, fake_init_devid);
        kunit_activate_static_stub(test, read_gmdid, fake_read_gmdid);
        kunit_activate_static_stub(test, xe_info_probe_tile_count,
                                   fake_xe_info_probe_tile_count);
index cdc7e0935c13a01f630148c83d0d6940341b3ac9..b498147dcf61edc86ac7040624ce6a437a95ed4e 100644 (file)
@@ -521,8 +521,6 @@ struct xe_device *xe_device_create(struct pci_dev *pdev)
        if (err)
                return ERR_PTR(err);
 
-       xe->info.devid = pdev->device;
-       xe->info.revid = pdev->revision;
        xe->atomic_svm_timeslice_ms = 5;
        xe->min_run_period_lr_ms = 5;
 
index ed932254f16f42bb54217f256cb6c83261d0490e..c05cd2ba35098d1cd2bb491b30b91d77448fb8b5 100644 (file)
@@ -726,6 +726,16 @@ static int handle_gmdid(struct xe_device *xe,
        return 0;
 }
 
+static void init_devid(struct xe_device *xe)
+{
+       struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
+
+       KUNIT_STATIC_STUB_REDIRECT(init_devid, xe);
+
+       xe->info.devid = pdev->device;
+       xe->info.revid = pdev->revision;
+}
+
 /*
  * Initialize device info content that only depends on static driver_data
  * passed to the driver at probe time from PCI ID table.
@@ -741,6 +751,8 @@ static int xe_info_init_early(struct xe_device *xe,
        xe->info.subplatform = subplatform_desc ?
                subplatform_desc->subplatform : XE_SUBPLATFORM_NONE;
 
+       init_devid(xe);
+
        xe->info.dma_mask_size = desc->dma_mask_size;
        xe->info.va_bits = desc->va_bits;
        xe->info.vm_max_level = desc->vm_max_level;