[Intel-xe] [PATCH v3 06/20] drm/xe: Split xe_info_init

Lucas De Marchi lucas.demarchi at intel.com
Mon Nov 20 19:47:41 UTC 2023


On Tue, Nov 14, 2023 at 02:02:17PM +0100, Michał Winiarski wrote:
>Parts of xe_info_init are only dealing with processing driver_data.
>Extract it into xe_info_init_early to be able to use it earlier duing
>probe.
>
>Signed-off-by: Michał Winiarski <michal.winiarski at intel.com>
>Reviewed-by: Matthew Brost <matthew.brost at intel.com>


Reviewed-by: Lucas De Marchi <lucas.demarchi at intel.com>

Lucas De Marchi

>---
>v1 -> v2:
>- Add comment to "early" variant (Lucas)
>- Move xe_info_init_early usage in kunit to correct patch (Matt Brost)
>
> drivers/gpu/drm/xe/tests/xe_pci.c |  1 +
> drivers/gpu/drm/xe/xe_pci.c       | 41 ++++++++++++++++++++++---------
> 2 files changed, 30 insertions(+), 12 deletions(-)
>
>diff --git a/drivers/gpu/drm/xe/tests/xe_pci.c b/drivers/gpu/drm/xe/tests/xe_pci.c
>index a40879da2fbe1..733df9a270db2 100644
>--- a/drivers/gpu/drm/xe/tests/xe_pci.c
>+++ b/drivers/gpu/drm/xe/tests/xe_pci.c
>@@ -143,6 +143,7 @@ int xe_pci_fake_device_init(struct xe_device *xe, enum xe_platform platform,
> 		return -ENODEV;
>
> done:
>+	xe_info_init_early(xe, desc, subplatform_desc);
> 	xe_info_init(xe, desc, subplatform_desc);
>
> 	return 0;
>diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c
>index e6b59c4b02bdc..d603093f32274 100644
>--- a/drivers/gpu/drm/xe/xe_pci.c
>+++ b/drivers/gpu/drm/xe/xe_pci.c
>@@ -532,7 +532,34 @@ static void handle_gmdid(struct xe_device *xe,
> 	}
> }
>
>+/*
>+ * Initialize device info content that only depends on static driver_data passed to the driver at
>+ * probe time from PCI ID table.
>+ */
>+static void xe_info_init_early(struct xe_device *xe,
>+			       const struct xe_device_desc *desc,
>+			       const struct xe_subplatform_desc *subplatform_desc)
>+{
>+	xe->info.platform = desc->platform;
>+	xe->info.subplatform = subplatform_desc ?
>+		subplatform_desc->subplatform : XE_SUBPLATFORM_NONE;
>+
>+	xe->info.is_dgfx = desc->is_dgfx;
>+	xe->info.has_heci_gscfi = desc->has_heci_gscfi;
>+	xe->info.has_llc = desc->has_llc;
>+	xe->info.bypass_mtcfg = desc->bypass_mtcfg;
>+	xe->info.supports_mmio_ext = desc->supports_mmio_ext;
>+
>+	xe->info.enable_display = IS_ENABLED(CONFIG_DRM_XE_DISPLAY) &&
>+				  enable_display &&
>+				  desc->has_display;
>+}
>
>+/*
>+ * Initialize device info content that does require knowledge about graphics / media IP version.
>+ * Make sure that GT / tile structures allocated by the driver match the data present in device
>+ * info.
>+ */
> static int xe_info_init(struct xe_device *xe,
> 			const struct xe_device_desc *desc,
> 			const struct xe_subplatform_desc *subplatform_desc)
>@@ -544,10 +571,6 @@ static int xe_info_init(struct xe_device *xe,
> 	struct xe_gt *gt;
> 	u8 id;
>
>-	xe->info.platform = desc->platform;
>-	xe->info.subplatform = subplatform_desc ?
>-		subplatform_desc->subplatform : XE_SUBPLATFORM_NONE;
>-
> 	/*
> 	 * If this platform supports GMD_ID, we'll detect the proper IP
> 	 * descriptor to use from hardware registers. desc->graphics will only
>@@ -573,13 +596,8 @@ static int xe_info_init(struct xe_device *xe,
> 	if (!graphics_desc)
> 		return -ENODEV;
>
>-	xe->info.is_dgfx = desc->is_dgfx;
>-	xe->info.has_heci_gscfi = desc->has_heci_gscfi;
> 	xe->info.graphics_name = graphics_desc->name;
> 	xe->info.media_name = media_desc ? media_desc->name : "none";
>-	xe->info.has_llc = desc->has_llc;
>-	xe->info.bypass_mtcfg = desc->bypass_mtcfg;
>-	xe->info.supports_mmio_ext = desc->supports_mmio_ext;
> 	xe->info.tile_mmio_ext_size = graphics_desc->tile_mmio_ext_size;
>
> 	xe->info.dma_mask_size = graphics_desc->dma_mask_size;
>@@ -591,9 +609,6 @@ static int xe_info_init(struct xe_device *xe,
> 	xe->info.has_flat_ccs = graphics_desc->has_flat_ccs;
> 	xe->info.has_range_tlb_invalidation = graphics_desc->has_range_tlb_invalidation;
>
>-	xe->info.enable_display = IS_ENABLED(CONFIG_DRM_XE_DISPLAY) &&
>-				  enable_display &&
>-				  desc->has_display;
> 	/*
> 	 * All platforms have at least one primary GT.  Any platform with media
> 	 * version 13 or higher has an additional dedicated media GT.  And
>@@ -712,6 +727,8 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> 	pci_set_master(pdev);
> 	devm_add_action(&pdev->dev, xe_pci_clear_master, pdev);
>
>+	xe_info_init_early(xe, desc, subplatform_desc);
>+
> 	err = xe_info_init(xe, desc, subplatform_desc);
> 	if (err)
> 		return err;
>-- 
>2.42.1
>


More information about the Intel-xe mailing list