drm/xe/device: Introduce xe_device_probe_early
authorMichał Winiarski <michal.winiarski@intel.com>
Tue, 5 Dec 2023 01:32:59 +0000 (02:32 +0100)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Thu, 21 Dec 2023 16:45:11 +0000 (11:45 -0500)
SR-IOV VF doesn't have access to MMIO registers used to determine
graphics/media ID. It can however communicate with GuC.
Introduce xe_device_probe_early, which initializes enough HW to use
MMIO GuC communication.
This will allow both VF and PF/native driver to have unified probe
ordering.

Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/xe_device.c
drivers/gpu/drm/xe/xe_device.h
drivers/gpu/drm/xe/xe_mmio.c
drivers/gpu/drm/xe/xe_mmio.h
drivers/gpu/drm/xe/xe_pci.c

index 5e1f73c8c77adab29883139ecf6b97e1c765dcb6..f4be4b13a506e572a4cc1bbc961435e7b42519da 100644 (file)
@@ -375,6 +375,24 @@ mask_err:
        return err;
 }
 
+/*
+ * Initialize MMIO resources that don't require any knowledge about tile count.
+ */
+int xe_device_probe_early(struct xe_device *xe)
+{
+       int err;
+
+       err = xe_mmio_init(xe);
+       if (err)
+               return err;
+
+       err = xe_mmio_root_tile_init(xe);
+       if (err)
+               return err;
+
+       return 0;
+}
+
 int xe_device_probe(struct xe_device *xe)
 {
        struct xe_tile *tile;
@@ -393,10 +411,6 @@ int xe_device_probe(struct xe_device *xe)
        if (err)
                return err;
 
-       err = xe_mmio_init(xe);
-       if (err)
-               return err;
-
        xe_mmio_probe_tiles(xe);
 
        err = drmm_add_action_or_reset(&xe->drm, xe_driver_flr_fini, xe);
index 54694f98c91a23e14473d79552a1ce3c8d7a1e12..3da83b2332063882afcaffb3f204410fa848de9d 100644 (file)
@@ -37,6 +37,7 @@ static inline struct xe_device *ttm_to_xe_device(struct ttm_device *ttm)
 
 struct xe_device *xe_device_create(struct pci_dev *pdev,
                                   const struct pci_device_id *ent);
+int xe_device_probe_early(struct xe_device *xe);
 int xe_device_probe(struct xe_device *xe);
 void xe_device_remove(struct xe_device *xe);
 void xe_device_shutdown(struct xe_device *xe);
@@ -123,6 +124,10 @@ static inline bool xe_device_uc_enabled(struct xe_device *xe)
        for ((id__) = 0; (id__) < (xe__)->info.tile_count; (id__)++) \
                for_each_if((tile__) = &(xe__)->tiles[(id__)])
 
+#define for_each_remote_tile(tile__, xe__, id__) \
+       for ((id__) = 1; (id__) < (xe__)->info.tile_count; (id__)++) \
+               for_each_if((tile__) = &(xe__)->tiles[(id__)])
+
 /*
  * FIXME: This only works for now since multi-tile and standalone media
  * happen to be mutually exclusive.  Future platforms may change this...
index 2e6c94731a5a0973e1779fe83646dd76d6baede3..35aeb50b71589c49ba7f8aaef4600ce80e7fe314 100644 (file)
 #include "regs/xe_regs.h"
 #include "xe_bo.h"
 #include "xe_device.h"
+#include "xe_ggtt.h"
 #include "xe_gt.h"
 #include "xe_gt_mcr.h"
 #include "xe_macros.h"
 #include "xe_module.h"
+#include "xe_tile.h"
 
 #define XEHP_MTCFG_ADDR                XE_REG(0x101800)
 #define TILE_COUNT             REG_GENMASK(15, 8)
@@ -376,10 +378,8 @@ static int xe_verify_lmem_ready(struct xe_device *xe)
 
 int xe_mmio_init(struct xe_device *xe)
 {
-       struct xe_tile *root_tile = xe_device_get_root_tile(xe);
        struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
        const int mmio_bar = 0;
-       int err;
 
        /*
         * Map the entire BAR.
@@ -393,12 +393,16 @@ int xe_mmio_init(struct xe_device *xe)
                return -EIO;
        }
 
-       err = drmm_add_action_or_reset(&xe->drm, mmio_fini, xe);
-       if (err)
-               return err;
+       return drmm_add_action_or_reset(&xe->drm, mmio_fini, xe);
+}
+
+int xe_mmio_root_tile_init(struct xe_device *xe)
+{
+       struct xe_tile *root_tile = xe_device_get_root_tile(xe);
+       int err;
 
        /* Setup first tile; other tiles (if present) will be setup later. */
-       root_tile->mmio.size = xe->mmio.size;
+       root_tile->mmio.size = SZ_16M;
        root_tile->mmio.regs = xe->mmio.regs;
 
        err = xe_verify_lmem_ready(xe);
index c054c27f6925ded06b751d7f72267e8f38b00096..98de5c13c89ba1d0b59ae6d60743f67971a07416 100644 (file)
@@ -21,6 +21,7 @@ struct xe_device;
 #define LMEM_BAR               2
 
 int xe_mmio_init(struct xe_device *xe);
+int xe_mmio_root_tile_init(struct xe_device *xe);
 void xe_mmio_probe_tiles(struct xe_device *xe);
 
 static inline u8 xe_mmio_read8(struct xe_gt *gt, struct xe_reg reg)
index 87257716b93eb2feb828c4dd983300e9d37cb492..d1b8f268ce09036dd545f0e2d895940ffc48e963 100644 (file)
@@ -536,10 +536,12 @@ 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)
+static int xe_info_init_early(struct xe_device *xe,
+                             const struct xe_device_desc *desc,
+                             const struct xe_subplatform_desc *subplatform_desc)
 {
+       int err;
+
        xe->info.platform = desc->platform;
        xe->info.subplatform = subplatform_desc ?
                subplatform_desc->subplatform : XE_SUBPLATFORM_NONE;
@@ -556,6 +558,12 @@ static void xe_info_init_early(struct xe_device *xe,
        xe->info.enable_display = IS_ENABLED(CONFIG_DRM_XE_DISPLAY) &&
                                  xe_modparam.enable_display &&
                                  desc->has_display;
+
+       err = xe_tile_init_early(xe_device_get_root_tile(xe), xe, 0);
+       if (err)
+               return err;
+
+       return 0;
 }
 
 /*
@@ -623,13 +631,15 @@ static int xe_info_init(struct xe_device *xe,
         */
        xe->info.tile_count = 1 + graphics_desc->max_remote_tiles;
 
-       for_each_tile(tile, xe, id) {
+       for_each_remote_tile(tile, xe, id) {
                int err;
 
                err = xe_tile_init_early(tile, xe, id);
                if (err)
                        return err;
+       }
 
+       for_each_tile(tile, xe, id) {
                gt = tile->primary_gt;
                gt->info.id = xe->info.gt_count++;
                gt->info.type = XE_GT_TYPE_MAIN;
@@ -723,10 +733,16 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        pci_set_master(pdev);
 
-       xe_info_init_early(xe, desc, subplatform_desc);
+       err = xe_info_init_early(xe, desc, subplatform_desc);
+       if (err)
+               return err;
 
        xe_sriov_probe_early(xe, desc->has_sriov);
 
+       err = xe_device_probe_early(xe);
+       if (err)
+               return err;
+
        err = xe_info_init(xe, desc->graphics, desc->media);
        if (err)
                return err;