From 791d0362a9e2d47352ee6b35cc8999cb3404e27c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Micha=C5=82=20Winiarski?= Date: Tue, 5 Dec 2023 02:33:03 +0100 Subject: [PATCH] drm/xe: Reorder GGTT init to earlier point in probe MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Matt Roper Signed-off-by: Rodrigo Vivi --- drivers/gpu/drm/xe/xe_device.c | 7 +++++++ drivers/gpu/drm/xe/xe_ggtt.c | 22 ++++++++++++++++++---- drivers/gpu/drm/xe/xe_ggtt.h | 2 +- drivers/gpu/drm/xe/xe_tile.c | 4 ---- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c index bcc10b7f23ab7..65e9aa5e6c31e 100644 --- a/drivers/gpu/drm/xe/xe_device.c +++ b/drivers/gpu/drm/xe/xe_device.c @@ -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; diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c index 0e2a41837f169..f8bdbd6010f7f 100644 --- a/drivers/gpu/drm/xe/xe_ggtt.c +++ b/drivers/gpu/drm/xe/xe_ggtt.c @@ -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; diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h index 3faa3c6d0375f..a09c166dff701 100644 --- a/drivers/gpu/drm/xe/xe_ggtt.h +++ b/drivers/gpu/drm/xe/xe_ggtt.h @@ -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); diff --git a/drivers/gpu/drm/xe/xe_tile.c b/drivers/gpu/drm/xe/xe_tile.c index c74a4f840d846..044c20881de7e 100644 --- a/drivers/gpu/drm/xe/xe_tile.c +++ b/drivers/gpu/drm/xe/xe_tile.c @@ -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); -- 2.30.2