From 1b63a25d5dc851c20a676020e0956ee027aee410 Mon Sep 17 00:00:00 2001 From: Gustavo Sousa Date: Tue, 9 Jun 2026 17:17:33 -0300 Subject: [PATCH] drm/xe: Add framework for info probing 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 Reviewed-by: Violet Monti Link: https://patch.msgid.link/20260609-xe-probe-info-v1-1-21e83e188e60@intel.com Signed-off-by: Gustavo Sousa --- drivers/gpu/drm/xe/tests/xe_pci.c | 16 ++++++++++-- drivers/gpu/drm/xe/xe_pci.c | 41 ++++++++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/xe/tests/xe_pci.c b/drivers/gpu/drm/xe/tests/xe_pci.c index 9240aff779da..51d032a9e01a 100644 --- a/drivers/gpu/drm/xe/tests/xe_pci.c +++ b/drivers/gpu/drm/xe/tests/xe_pci.c @@ -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 @@ int xe_pci_fake_device_init(struct xe_device *xe) 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; } diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c index 096c99b865b4..6156d8689430 100644 --- a/drivers/gpu/drm/xe/xe_pci.c +++ b/drivers/gpu/drm/xe/xe_pci.c @@ -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;