drm/xe: Reorder GGTT init to earlier point in probe
authorMichał Winiarski <michal.winiarski@intel.com>
Tue, 5 Dec 2023 01:33:03 +0000 (02:33 +0100)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Thu, 21 Dec 2023 16:45:11 +0000 (11:45 -0500)
GuC will need to be loaded earlier during probe. Having functional GGTT
is one of the prerequisites.
Also rename xe_ggtt_init_noalloc to xe_ggtt_init_early to match the new
call site.

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

index bcc10b7f23ab716644b3f9b91c002a20e11eaae5..65e9aa5e6c31ecd70e330fabede83fc7ddd9024a 100644 (file)
@@ -24,6 +24,7 @@
 #include "xe_drv.h"
 #include "xe_exec_queue.h"
 #include "xe_exec.h"
+#include "xe_ggtt.h"
 #include "xe_gt.h"
 #include "xe_irq.h"
 #include "xe_mmio.h"
@@ -418,6 +419,12 @@ int xe_device_probe(struct xe_device *xe)
        for_each_gt(gt, xe, id)
                xe_force_wake_init_gt(gt, gt_to_fw(gt));
 
+       for_each_tile(tile, xe, id) {
+               err = xe_ggtt_init_early(tile->mem.ggtt);
+               if (err)
+                       return err;
+       }
+
        err = drmm_add_action_or_reset(&xe->drm, xe_driver_flr_fini, xe);
        if (err)
                return err;
index 0e2a41837f1697ed9d29c7ef4fb1ea2e09aaacaa..f8bdbd6010f7f4d3529763ca42490fe2c9ad217a 100644 (file)
@@ -96,14 +96,20 @@ static void xe_ggtt_clear(struct xe_ggtt *ggtt, u64 start, u64 size)
        }
 }
 
-static void ggtt_fini_noalloc(struct drm_device *drm, void *arg)
+static void ggtt_fini_early(struct drm_device *drm, void *arg)
 {
        struct xe_ggtt *ggtt = arg;
 
        mutex_destroy(&ggtt->lock);
        drm_mm_takedown(&ggtt->mm);
+}
+
+static void ggtt_fini(struct drm_device *drm, void *arg)
+{
+       struct xe_ggtt *ggtt = arg;
 
        xe_bo_unpin_map_no_vm(ggtt->scratch);
+       ggtt->scratch = NULL;
 }
 
 static void primelockdep(struct xe_ggtt *ggtt)
@@ -124,7 +130,14 @@ static const struct xe_ggtt_pt_ops xelpg_pt_ops = {
        .pte_encode_bo = xelpg_ggtt_pte_encode_bo,
 };
 
-int xe_ggtt_init_noalloc(struct xe_ggtt *ggtt)
+/*
+ * Early GGTT initialization, which allows to create new mappings usable by the
+ * GuC.
+ * Mappings are not usable by the HW engines, as it doesn't have scratch /
+ * initial clear done to it yet. That will happen in the regular, non-early
+ * GGTT init.
+ */
+int xe_ggtt_init_early(struct xe_ggtt *ggtt)
 {
        struct xe_device *xe = tile_to_xe(ggtt->tile);
        struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
@@ -178,7 +191,7 @@ int xe_ggtt_init_noalloc(struct xe_ggtt *ggtt)
        mutex_init(&ggtt->lock);
        primelockdep(ggtt);
 
-       return drmm_add_action_or_reset(&xe->drm, ggtt_fini_noalloc, ggtt);
+       return drmm_add_action_or_reset(&xe->drm, ggtt_fini_early, ggtt);
 }
 
 static void xe_ggtt_initial_clear(struct xe_ggtt *ggtt)
@@ -226,7 +239,8 @@ int xe_ggtt_init(struct xe_ggtt *ggtt)
        xe_map_memset(xe, &ggtt->scratch->vmap, 0, 0, ggtt->scratch->size);
 
        xe_ggtt_initial_clear(ggtt);
-       return 0;
+
+       return drmm_add_action_or_reset(&xe->drm, ggtt_fini, ggtt);
 err:
        ggtt->scratch = NULL;
        return err;
index 3faa3c6d0375f75d59c7e8acb7bf47110e7de618..a09c166dff7010d7730997c461230510b7155c13 100644 (file)
@@ -12,7 +12,7 @@ struct drm_printer;
 
 void xe_ggtt_set_pte(struct xe_ggtt *ggtt, u64 addr, u64 pte);
 void xe_ggtt_invalidate(struct xe_ggtt *ggtt);
-int xe_ggtt_init_noalloc(struct xe_ggtt *ggtt);
+int xe_ggtt_init_early(struct xe_ggtt *ggtt);
 int xe_ggtt_init(struct xe_ggtt *ggtt);
 void xe_ggtt_printk(struct xe_ggtt *ggtt, const char *prefix);
 
index c74a4f840d846983f8d88e6aa177e15011233fa6..044c20881de7ef0ede17f4dcfcdf34863817d8de 100644 (file)
@@ -166,10 +166,6 @@ int xe_tile_init_noalloc(struct xe_tile *tile)
        if (err)
                goto err_mem_access;
 
-       err = xe_ggtt_init_noalloc(tile->mem.ggtt);
-       if (err)
-               goto err_mem_access;
-
        tile->mem.kernel_bb_pool = xe_sa_bo_manager_init(tile, SZ_1M, 16);
        if (IS_ERR(tile->mem.kernel_bb_pool))
                err = PTR_ERR(tile->mem.kernel_bb_pool);