Skip to contentSkip to conversation

(CI) drm/xe: Fix initial framebuffer handover.

PATCH Superseded Maarten Lankhorst 1 participant 9 messages Oct 29, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v3 cover (CI) drm/xe: Fix initial framebuffer handover.

Another CI run, hopefully works now.
May also be called: rework and cleanup init sequence.

Maarten Lankhorst (8):
drm/xe: Remove double pageflip
drm/i915/display: Use async flip when available for initial plane
config
drm/xe: Move suballocator init to after display init drm/xe: Defer irq init until after xe_display_init_noaccel drm/xe/display: Use a single early init call for display drm/xe/sriov: Move VF bootstrap and query_config to vf_guc_init drm/xe: Simplify GuC early initialisation
drm/xe: Split init of xe_gt_init_hwconfig to xe_gt_init and *_early

 .../drm/i915/display/skl_universal_plane.c    | 13 +++-
 drivers/gpu/drm/xe/display/xe_display.c       | 72 +++++-------------
 drivers/gpu/drm/xe/display/xe_display.h       |  4 +-
 drivers/gpu/drm/xe/display/xe_plane_initial.c | 10 ---
 drivers/gpu/drm/xe/xe_device.c                | 50 +++----------
 drivers/gpu/drm/xe/xe_gt.c                    | 73 ++++++++++---------
 drivers/gpu/drm/xe/xe_gt.h                    |  1 -
 drivers/gpu/drm/xe/xe_gt_sriov_vf.c           |  1 -
 drivers/gpu/drm/xe/xe_guc.c                   | 56 ++++++++------
 drivers/gpu/drm/xe/xe_guc.h                   |  1 +
 drivers/gpu/drm/xe/xe_guc_ct.c                | 28 ++++---
 drivers/gpu/drm/xe/xe_guc_ct.h                |  1 +
 drivers/gpu/drm/xe/xe_guc_relay.c             |  6 +-
 drivers/gpu/drm/xe/xe_guc_relay.h             |  2 +-
 drivers/gpu/drm/xe/xe_huc.h                   |  1 +
 drivers/gpu/drm/xe/xe_tile.c                  | 19 ++++-
 drivers/gpu/drm/xe/xe_tile.h                  |  1 +
 drivers/gpu/drm/xe/xe_uc.c                    | 21 ++++++
 drivers/gpu/drm/xe/xe_uc.h                    |  1 +
 19 files changed, 180 insertions(+), 181 deletions(-)
Signature · 1 line
2.45.2
#1 lore raw

PATCH v3 1/8 drm/xe: Remove double pageflip

This is already handled below by fixup_initial_plane_config.

Fixes a8153627520a ("drm/i915: Try to relocate the BIOS fb to the start of ggtt")
Cc Ville Syrjälä <[email protected]>
---
 drivers/gpu/drm/xe/display/xe_plane_initial.c | 10 ----------
 1 file changed, 10 deletions(-)
drivers/gpu/drm/xe/display/xe_plane_initial.c +0 -10
index 8c113463a3d55..668f544a7ac80 100644
@@ -194,8 +194,6 @@ intel_find_initial_plane_obj(struct intel_crtc *crtc,
 		to_intel_plane(crtc->base.primary);
 	struct intel_plane_state *plane_state =
 		to_intel_plane_state(plane->base.state);
-	struct intel_crtc_state *crtc_state =
-		to_intel_crtc_state(crtc->base.state);
 	struct drm_framebuffer *fb;
 	struct i915_vma *vma;
 
@@ -241,14 +239,6 @@ intel_find_initial_plane_obj(struct intel_crtc *crtc,
 	atomic_or(plane->frontbuffer_bit, &to_intel_frontbuffer(fb)->bits);
 
 	plane_config->vma = vma;
-
-	/*
-	 * Flip to the newly created mapping ASAP, so we can re-use the
-	 * first part of GGTT for WOPCM, prevent flickering, and prevent
-	 * the lookup of sysmem scratch pages.
-	 */
-	plane->check_plane(crtc_state, plane_state);
-	plane->async_flip(NULL, plane, crtc_state, plane_state, true);
 	return;
 
 nofb:
Signature · 1 line
2.45.2
#2 lore raw

PATCH v3 2/8 drm/i915/display: Use async flip when available for initial plane config

In reply to Maarten Lankhorst

I'm planning to reorder readout in the Xe sequence in such a way that interrupts will not be available, so just use an async flip.

Since the new FB points to the same pages, it will not tear. It also has the benefit of perhaps being slightly faster.

---
 drivers/gpu/drm/i915/display/skl_universal_plane.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/display/skl_universal_plane.c +11 -2
index a0a7ed01415a5..6740c193920ff 100644
@@ -2902,7 +2902,7 @@ bool skl_fixup_initial_plane_config(struct intel_crtc *crtc,
 		to_intel_plane_state(plane->base.state);
 	enum plane_id plane_id = plane->id;
 	enum pipe pipe = crtc->pipe;
-	u32 base;
+	u32 base, plane_ctl;
 
 	if (!plane_state->uapi.visible)
 		return false;
@@ -2916,7 +2916,16 @@ bool skl_fixup_initial_plane_config(struct intel_crtc *crtc,
 	if (plane_config->base == base)
 		return false;
 
+	/* Perform an async flip to the new surface. */
+	plane_ctl = intel_de_read(i915, PLANE_CTL(pipe, plane_id));
+	plane_ctl |= PLANE_CTL_ASYNC_FLIP;
+
+	intel_de_write(i915, PLANE_CTL(pipe, plane_id), plane_ctl);
 	intel_de_write(i915, PLANE_SURF(pipe, plane_id), base);
 
-	return true;
+	if (intel_de_wait(i915, PLANE_SURFLIVE(pipe, plane_id), ~0U, base, 40) < 0)
+		drm_warn(&i915->drm, "async flip timed out\n");
+
+	/* No need to vblank wait either */
+	return false;
 }
Signature · 1 line
2.45.2
#3 lore raw

PATCH v3 3/8 drm/xe: Move suballocator init to after display init

No allocations should be done before we have had a chance to preserve the display fb.

---
 drivers/gpu/drm/xe/xe_device.c |  6 ++++++
 drivers/gpu/drm/xe/xe_tile.c   | 12 ++++++++----
 drivers/gpu/drm/xe/xe_tile.h   |  1 +
 3 files changed, 15 insertions(+), 4 deletions(-)
drivers/gpu/drm/xe/xe_device.c +6 -0
index cb4b2013eb808..d145f1376069e 100644
@@ -740,6 +740,12 @@ int xe_device_probe(struct xe_device *xe)
 	if (err)
 		goto err;
 
+	for_each_tile(tile, xe, id) {
+		err = xe_tile_init(tile);
+		if (err)
+			goto err;
+	}
+
 	for_each_gt(gt, xe, id) {
 		last_gt = id;
 
drivers/gpu/drm/xe/xe_tile.c +8 -4
index 07cf7cfe4abd5..2825553b568f7 100644
@@ -170,10 +170,6 @@ int xe_tile_init_noalloc(struct xe_tile *tile)
 	if (err)
 		return err;
 
-	tile->mem.kernel_bb_pool = xe_sa_bo_manager_init(tile, SZ_1M, 16);
-	if (IS_ERR(tile->mem.kernel_bb_pool))
-		return PTR_ERR(tile->mem.kernel_bb_pool);
-
 	xe_wa_apply_tile_workarounds(tile);
 
 	err = xe_tile_sysfs_init(tile);
@@ -181,6 +177,14 @@ int xe_tile_init_noalloc(struct xe_tile *tile)
 	return 0;
 }
 
+int xe_tile_init(struct xe_tile *tile)
+{
+	tile->mem.kernel_bb_pool = xe_sa_bo_manager_init(tile, SZ_1M, 16);
+	if (IS_ERR(tile->mem.kernel_bb_pool))
+		return PTR_ERR(tile->mem.kernel_bb_pool);
+
+	return 0;
+}
 void xe_tile_migrate_wait(struct xe_tile *tile)
 {
 	xe_migrate_wait(tile->migrate);
drivers/gpu/drm/xe/xe_tile.h +1 -0
index 1c9e42ade6b05..eb939316d55b0 100644
@@ -12,6 +12,7 @@ struct xe_tile;
 
 int xe_tile_init_early(struct xe_tile *tile, struct xe_device *xe, u8 id);
 int xe_tile_init_noalloc(struct xe_tile *tile);
+int xe_tile_init(struct xe_tile *tile);
 
 void xe_tile_migrate_wait(struct xe_tile *tile);
 
Signature · 1 line
2.45.2
#4 lore raw

PATCH v3 4/8 drm/xe: Defer irq init until after xe_display_init_noaccel

In reply to Maarten Lankhorst

Technically, I believe this means that xe_display_init_noirq and xe_display_init_noaccel can be merged together now.

---
 drivers/gpu/drm/xe/xe_device.c | 12 ++++--------
 drivers/gpu/drm/xe/xe_tile.c   |  7 +++++++
 2 files changed, 11 insertions(+), 8 deletions(-)
drivers/gpu/drm/xe/xe_device.c +4 -8
index d145f1376069e..c8bce9858b511 100644
@@ -41,7 +41,6 @@
 #include "xe_hw_engine_group.h"
 #include "xe_hwmon.h"
 #include "xe_irq.h"
-#include "xe_memirq.h"
 #include "xe_mmio.h"
 #include "xe_module.h"
 #include "xe_observation.h"
@@ -683,9 +682,6 @@ int xe_device_probe(struct xe_device *xe)
 		err = xe_ggtt_init_early(tile->mem.ggtt);
 		if (err)
 			return err;
-		err = xe_memirq_init(&tile->memirq);
-		if (err)
-			return err;
 	}
 
 	for_each_gt(gt, xe, id) {
@@ -705,10 +701,6 @@ int xe_device_probe(struct xe_device *xe)
 	if (err)
 		return err;
 
-	err = xe_irq_install(xe);
-	if (err)
-		goto err;
-
 	err = probe_has_flat_ccs(xe);
 	if (err)
 		goto err;
@@ -746,6 +738,10 @@ int xe_device_probe(struct xe_device *xe)
 			goto err;
 	}
 
+	err = xe_irq_install(xe);
+	if (err)
+		goto err;
+
 	for_each_gt(gt, xe, id) {
 		last_gt = id;
 
drivers/gpu/drm/xe/xe_tile.c +7 -0
index 2825553b568f7..d07c1fba793ca 100644
@@ -10,6 +10,7 @@
 #include "xe_device.h"
 #include "xe_ggtt.h"
 #include "xe_gt.h"
+#include "xe_memirq.h"
 #include "xe_migrate.h"
 #include "xe_pcode.h"
 #include "xe_sa.h"
@@ -179,6 +180,12 @@ int xe_tile_init_noalloc(struct xe_tile *tile)
 
 int xe_tile_init(struct xe_tile *tile)
 {
+	int err;
+
+	err = xe_memirq_init(&tile->memirq);
+	if (err)
+		return err;
+
 	tile->mem.kernel_bb_pool = xe_sa_bo_manager_init(tile, SZ_1M, 16);
 	if (IS_ERR(tile->mem.kernel_bb_pool))
 		return PTR_ERR(tile->mem.kernel_bb_pool);
Signature · 1 line
2.45.2
#5 lore raw

PATCH v3 5/8 drm/xe/display: Use a single early init call for display

In reply to Maarten Lankhorst

Instead of 3 different calls, it should be safe to unify to a single call now. This makes the init sequence cleaner, and display less tangled.

---
 drivers/gpu/drm/xe/display/xe_display.c | 72 +++++++------------------
 drivers/gpu/drm/xe/display/xe_display.h |  4 +-
 drivers/gpu/drm/xe/xe_device.c          | 10 +---
 3 files changed, 22 insertions(+), 64 deletions(-)
drivers/gpu/drm/xe/display/xe_display.c +20 -52
index 695c27ac6b0f8..88dcec57620dd 100644
@@ -100,31 +100,7 @@ int xe_display_create(struct xe_device *xe)
 	return drmm_add_action_or_reset(&xe->drm, display_destroy, NULL);
 }
 
-static void xe_display_fini_nommio(struct drm_device *dev, void *dummy)
-{
-	struct xe_device *xe = to_xe_device(dev);
-
-	if (!xe->info.probe_display)
-		return;
-
-	intel_power_domains_cleanup(xe);
-}
-
-int xe_display_init_nommio(struct xe_device *xe)
-{
-	if (!xe->info.probe_display)
-		return 0;
-
-	/* Fake uncore lock */
-	spin_lock_init(&xe->uncore.lock);
-
-	/* This must be called before any calls to HAS_PCH_* */
-	intel_detect_pch(xe);
-
-	return drmm_add_action_or_reset(&xe->drm, xe_display_fini_nommio, xe);
-}
-
-static void xe_display_fini_noirq(void *arg)
+static void xe_display_fini_early(void *arg)
 {
 	struct xe_device *xe = arg;
 	struct intel_display *display = &xe->display;
@@ -132,11 +108,13 @@ static void xe_display_fini_noirq(void *arg)
 	if (!xe->info.probe_display)
 		return;
 
+	intel_display_driver_remove_nogem(xe);
 	intel_display_driver_remove_noirq(xe);
 	intel_opregion_cleanup(display);
+	intel_power_domains_cleanup(xe);
 }
 
-int xe_display_init_noirq(struct xe_device *xe)
+int xe_display_init_early(struct xe_device *xe)
 {
 	struct intel_display *display = &xe->display;
 	int err;
@@ -144,6 +122,12 @@ int xe_display_init_noirq(struct xe_device *xe)
 	if (!xe->info.probe_display)
 		return 0;
 
+	/* Fake uncore lock */
+	spin_lock_init(&xe->uncore.lock);
+
+	/* This must be called before any calls to HAS_PCH_* */
+	intel_detect_pch(xe);
+
 	intel_display_driver_early_probe(xe);
 
 	/* Early display init.. */
@@ -160,36 +144,20 @@ int xe_display_init_noirq(struct xe_device *xe)
 	intel_display_device_info_runtime_init(xe);
 
 	err = intel_display_driver_probe_noirq(xe);
-	if (err) {
-		intel_opregion_cleanup(display);
-		return err;
-	}
-
-	return devm_add_action_or_reset(xe->drm.dev, xe_display_fini_noirq, xe);
-}
-
-static void xe_display_fini_noaccel(void *arg)
-{
-	struct xe_device *xe = arg;
-
-	if (!xe->info.probe_display)
-		return;
-
-	intel_display_driver_remove_nogem(xe);
-}
-
-int xe_display_init_noaccel(struct xe_device *xe)
-{
-	int err;
-
-	if (!xe->info.probe_display)
-		return 0;
+	if (err)
+		goto err_opregion;
 
 	err = intel_display_driver_probe_nogem(xe);
 	if (err)
-		return err;
+		goto err_noirq;
 
-	return devm_add_action_or_reset(xe->drm.dev, xe_display_fini_noaccel, xe);
+	return devm_add_action_or_reset(xe->drm.dev, xe_display_fini_early, xe);
+err_noirq:
+	intel_display_driver_remove_noirq(xe);
+	intel_power_domains_cleanup(xe);
+err_opregion:
+	intel_opregion_cleanup(display);
+	return err;
 }
 
 int xe_display_init(struct xe_device *xe)
drivers/gpu/drm/xe/display/xe_display.h +1 -3
index 17afa537aee50..aec4fab7faf31 100644
@@ -20,9 +20,7 @@ int xe_display_create(struct xe_device *xe);
 
 int xe_display_probe(struct xe_device *xe);
 
-int xe_display_init_nommio(struct xe_device *xe);
-int xe_display_init_noirq(struct xe_device *xe);
-int xe_display_init_noaccel(struct xe_device *xe);
+int xe_display_init_early(struct xe_device *xe);
 int xe_display_init(struct xe_device *xe);
 void xe_display_fini(struct xe_device *xe);
 
drivers/gpu/drm/xe/xe_device.c +1 -9
index c8bce9858b511..845a8d46c8076 100644
@@ -642,10 +642,6 @@ int xe_device_probe(struct xe_device *xe)
 		return err;
 
 	xe->info.mem_region_mask = 1;
-	err = xe_display_init_nommio(xe);
-	if (err)
-		return err;
-
 	err = xe_set_dma_info(xe);
 	if (err)
 		return err;
@@ -697,10 +693,6 @@ int xe_device_probe(struct xe_device *xe)
 	if (err)
 		return err;
 
-	err = xe_display_init_noirq(xe);
-	if (err)
-		return err;
-
 	err = probe_has_flat_ccs(xe);
 	if (err)
 		goto err;
@@ -728,7 +720,7 @@ int xe_device_probe(struct xe_device *xe)
 	 * This is the reason the first allocation needs to be done
 	 * inside display.
 	 */
-	err = xe_display_init_noaccel(xe);
+	err = xe_display_init_early(xe);
 	if (err)
 		goto err;
 
Signature · 1 line
2.45.2
#6 lore raw

PATCH v3 6/8 drm/xe/sriov: Move VF bootstrap and query_config to vf_guc_init

In reply to Maarten Lankhorst

We want to split up GUC init to an alloc and noalloc part to keep the init path the same for VF and !VF as much as possible.

Everything in vf_guc_init should be done as early as possible, otherwise VRAM probing becomes impossible.

---
 drivers/gpu/drm/xe/xe_gt_sriov_vf.c |  1 -
 drivers/gpu/drm/xe/xe_guc.c         | 17 +++++++++--------
 2 files changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/xe/xe_gt_sriov_vf.c +0 -1
index d3baba50f0851..521aaa3631f06 100644
@@ -885,7 +885,6 @@ u32 xe_gt_sriov_vf_read32(struct xe_gt *gt, struct xe_reg reg)
 	struct vf_runtime_reg *rr;
 
 	xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt)));
-	xe_gt_assert(gt, gt->sriov.vf.pf_version.major);
 	xe_gt_assert(gt, !reg.vf);
 
 	if (reg.addr == GMD_ID.addr) {
drivers/gpu/drm/xe/xe_guc.c +9 -8
index 76437d42b8a1e..2a368509d36c7 100644
@@ -301,6 +301,7 @@ static int xe_guc_realloc_post_hwconfig(struct xe_guc *guc)
 
 static int vf_guc_init(struct xe_guc *guc)
 {
+	struct xe_gt *gt = guc_to_gt(guc);
 	int err;
 
 	xe_guc_comm_init_early(guc);
@@ -313,6 +314,14 @@ static int vf_guc_init(struct xe_guc *guc)
 	if (err)
 		return err;
 
+	err = xe_gt_sriov_vf_bootstrap(gt);
+	if (err)
+		return err;
+
+	err = xe_gt_sriov_vf_query_config(gt);
+	if (err)
+		return err;
+
 	return 0;
 }
 
@@ -753,14 +762,6 @@ static int vf_guc_min_load_for_hwconfig(struct xe_guc *guc)
 	struct xe_gt *gt = guc_to_gt(guc);
 	int ret;
 
-	ret = xe_gt_sriov_vf_bootstrap(gt);
-	if (ret)
-		return ret;
-
-	ret = xe_gt_sriov_vf_query_config(gt);
-	if (ret)
-		return ret;
-
 	ret = xe_guc_hwconfig_init(guc);
 	if (ret)
 		return ret;
Signature · 1 line
2.45.2
#7 lore raw

PATCH v3 7/8 drm/xe: Simplify GuC early initialisation

In reply to Maarten Lankhorst

Add a 2-stage GuC init. An early one for everything that is needed for VF, and a full one that loads GuC and is allowed to do allocations.

---
 drivers/gpu/drm/xe/xe_device.c    | 16 ----------
 drivers/gpu/drm/xe/xe_gt.c        |  9 +++++-
 drivers/gpu/drm/xe/xe_guc.c       | 51 +++++++++++++++++++------------
 drivers/gpu/drm/xe/xe_guc.h       |  1 +
 drivers/gpu/drm/xe/xe_guc_ct.c    | 28 +++++++++++------
 drivers/gpu/drm/xe/xe_guc_ct.h    |  1 +
 drivers/gpu/drm/xe/xe_guc_relay.c |  6 ++--
 drivers/gpu/drm/xe/xe_guc_relay.h |  2 +-
 drivers/gpu/drm/xe/xe_huc.h       |  1 +
 drivers/gpu/drm/xe/xe_uc.c        | 21 +++++++++++++
 drivers/gpu/drm/xe/xe_uc.h        |  1 +
 11 files changed, 87 insertions(+), 50 deletions(-)
drivers/gpu/drm/xe/xe_device.c +0 -16
index 845a8d46c8076..0d662158fc83a 100644
@@ -656,25 +656,9 @@ int xe_device_probe(struct xe_device *xe)
 		err = xe_gt_init_early(gt);
 		if (err)
 			return err;
-
-		/*
-		 * Only after this point can GT-specific MMIO operations
-		 * (including things like communication with the GuC)
-		 * be performed.
-		 */
-		xe_gt_mmio_init(gt);
 	}
 
 	for_each_tile(tile, xe, id) {
-		if (IS_SRIOV_VF(xe)) {
-			xe_guc_comm_init_early(&tile->primary_gt->uc.guc);
-			err = xe_gt_sriov_vf_bootstrap(tile->primary_gt);
-			if (err)
-				return err;
-			err = xe_gt_sriov_vf_query_config(tile->primary_gt);
-			if (err)
-				return err;
-		}
 		err = xe_ggtt_init_early(tile->mem.ggtt);
 		if (err)
 			return err;
drivers/gpu/drm/xe/xe_gt.c +8 -1
index 89e9d9d4db060..59f26ef6e68bc 100644
@@ -386,7 +386,14 @@ int xe_gt_init_early(struct xe_gt *gt)
 	xe_force_wake_init_gt(gt, gt_to_fw(gt));
 	spin_lock_init(&gt->global_invl_lock);
 
-	return 0;
+	/*
+	 * Only after this point can GT-specific MMIO operations
+	 * (including things like communication with the GuC)
+	 * be performed.
+	 */
+	xe_gt_mmio_init(gt);
+
+	return xe_uc_init_noalloc(&gt->uc);
 }
 
 static void dump_pat_on_error(struct xe_gt *gt)
drivers/gpu/drm/xe/xe_guc.c +32 -19

90 lines not on this page · raw message

drivers/gpu/drm/xe/xe_guc.h +1 -0
index 58338be445585..965bf72912009 100644
@@ -26,6 +26,7 @@
 struct drm_printer;
 
 void xe_guc_comm_init_early(struct xe_guc *guc);
+int xe_guc_init_noalloc(struct xe_guc *guc);
 int xe_guc_init(struct xe_guc *guc);
 int xe_guc_init_post_hwconfig(struct xe_guc *guc);
 int xe_guc_post_load_init(struct xe_guc *guc);
drivers/gpu/drm/xe/xe_guc_ct.c +18 -10
index c260d88409907..0c302d248e8d5 100644
@@ -203,12 +203,10 @@ static void primelockdep(struct xe_guc_ct *ct)
 	fs_reclaim_release(GFP_KERNEL);
 }
 
-int xe_guc_ct_init(struct xe_guc_ct *ct)
+int xe_guc_ct_init_noalloc(struct xe_guc_ct *ct)
 {
 	struct xe_device *xe = ct_to_xe(ct);
 	struct xe_gt *gt = ct_to_gt(ct);
-	struct xe_tile *tile = gt_to_tile(gt);
-	struct xe_bo *bo;
 	int err;
 
 	xe_gt_assert(gt, !(guc_ct_size() % PAGE_SIZE));
@@ -234,6 +232,23 @@ int xe_guc_ct_init(struct xe_guc_ct *ct)
 
 	primelockdep(ct);
 
+	err = drmm_add_action_or_reset(&xe->drm, guc_ct_fini, ct);
+	if (err)
+		return err;
+
+	xe_gt_assert(gt, ct->state == XE_GUC_CT_STATE_NOT_INITIALIZED);
+	ct->state = XE_GUC_CT_STATE_DISABLED;
+	return 0;
+}
+ALLOW_ERROR_INJECTION(xe_guc_ct_init_noalloc, ERRNO); /* See xe_pci_probe() */
+
+int xe_guc_ct_init(struct xe_guc_ct *ct)
+{
+	struct xe_device *xe = ct_to_xe(ct);
+	struct xe_gt *gt = ct_to_gt(ct);
+	struct xe_tile *tile = gt_to_tile(gt);
+	struct xe_bo *bo;
+
 	bo = xe_managed_bo_create_pin_map(xe, tile, guc_ct_size(),
 					  XE_BO_FLAG_SYSTEM |
 					  XE_BO_FLAG_GGTT |
@@ -242,13 +257,6 @@ int xe_guc_ct_init(struct xe_guc_ct *ct)
 		return PTR_ERR(bo);
 
 	ct->bo = bo;
-
-	err = drmm_add_action_or_reset(&xe->drm, guc_ct_fini, ct);
-	if (err)
-		return err;
-
-	xe_gt_assert(gt, ct->state == XE_GUC_CT_STATE_NOT_INITIALIZED);
-	ct->state = XE_GUC_CT_STATE_DISABLED;
 	return 0;
 }
 ALLOW_ERROR_INJECTION(xe_guc_ct_init, ERRNO); /* See xe_pci_probe() */
drivers/gpu/drm/xe/xe_guc_ct.h +1 -0
index 338f0b75d29f9..b48a5d056e923 100644
@@ -11,6 +11,7 @@
 struct drm_printer;
 struct xe_device;
 
+int xe_guc_ct_init_noalloc(struct xe_guc_ct *ct);
 int xe_guc_ct_init(struct xe_guc_ct *ct);
 int xe_guc_ct_enable(struct xe_guc_ct *ct);
 void xe_guc_ct_disable(struct xe_guc_ct *ct);
drivers/gpu/drm/xe/xe_guc_relay.c +3 -3
index 8f62de026724c..b778d0e0253de 100644
@@ -322,7 +322,7 @@ static void __fini_relay(struct drm_device *drm, void *arg)
 }
 
 /**
- * xe_guc_relay_init - Initialize a &xe_guc_relay
+ * xe_guc_relay_init_noalloc - Initialize a &xe_guc_relay
  * @relay: the &xe_guc_relay to initialize
  *
  * Initialize remaining members of &xe_guc_relay that may depend
@@ -330,7 +330,7 @@ static void __fini_relay(struct drm_device *drm, void *arg)
  *
  * Return: 0 on success or a negative error code on failure.
  */
-int xe_guc_relay_init(struct xe_guc_relay *relay)
+int xe_guc_relay_init_noalloc(struct xe_guc_relay *relay)
 {
 	const int XE_RELAY_MEMPOOL_MIN_NUM = 1;
 	struct xe_device *xe = relay_to_xe(relay);
@@ -356,7 +356,7 @@ int xe_guc_relay_init(struct xe_guc_relay *relay)
 
 	return drmm_add_action_or_reset(&xe->drm, __fini_relay, relay);
 }
-ALLOW_ERROR_INJECTION(xe_guc_relay_init, ERRNO); /* See xe_pci_probe() */
+ALLOW_ERROR_INJECTION(xe_guc_relay_init_noalloc, ERRNO); /* See xe_pci_probe() */
 
 static u32 to_relay_error(int err)
 {
drivers/gpu/drm/xe/xe_guc_relay.h +1 -1
index 385429aa188ab..e0afff4542cfc 100644
@@ -11,7 +11,7 @@
 
 struct xe_guc_relay;
 
-int xe_guc_relay_init(struct xe_guc_relay *relay);
+int xe_guc_relay_init_noalloc(struct xe_guc_relay *relay);
 
 int xe_guc_relay_send_to_pf(struct xe_guc_relay *relay,
 			    const u32 *msg, u32 len, u32 *buf, u32 buf_size);
drivers/gpu/drm/xe/xe_huc.h +1 -0
index fa1c45e704432..bc6f93028c2b6 100644
@@ -17,6 +17,7 @@ enum xe_huc_auth_types {
 	XE_HUC_AUTH_TYPES_COUNT
 };
 
+int xe_huc_init_noalloc(struct xe_huc *huc);
 int xe_huc_init(struct xe_huc *huc);
 int xe_huc_init_post_hwconfig(struct xe_huc *huc);
 int xe_huc_upload(struct xe_huc *huc);
drivers/gpu/drm/xe/xe_uc.c +21 -0
index 0d073a9987c2e..45d0c2f26754c 100644
@@ -32,6 +32,27 @@ uc_to_xe(struct xe_uc *uc)
 }
 
 /* Should be called once at driver load only */
+int xe_uc_init_noalloc(struct xe_uc *uc)
+{
+	int ret;
+
+	/*
+	 * We call the GuC/HuC/GSC init functions even if GuC submission is off
+	 * to correctly move our tracking of the FW state to "disabled".
+	 */
+	ret = xe_guc_init_noalloc(&uc->guc);
+	if (ret)
+		goto err;
+
+	/* HuC and GSC have no early dependencies and can be completely initialised during full xe_uc_init(). */
+
+	return 0;
+
+err:
+	xe_gt_err(uc_to_gt(uc), "Failed to early initialize uC (%pe)\n", ERR_PTR(ret));
+	return ret;
+}
+
 int xe_uc_init(struct xe_uc *uc)
 {
 	int ret;
drivers/gpu/drm/xe/xe_uc.h +1 -0
index 506517c113339..650e95585b4ba 100644
@@ -8,6 +8,7 @@
 
 struct xe_uc;
 
+int xe_uc_init_noalloc(struct xe_uc *uc);
 int xe_uc_init(struct xe_uc *uc);
 int xe_uc_init_hwconfig(struct xe_uc *uc);
 int xe_uc_init_post_hwconfig(struct xe_uc *uc);
Signature · 1 line
2.45.2
#8 lore raw

PATCH v3 8/8 drm/xe: Split init of xe_gt_init_hwconfig to xe_gt_init and *_early

In reply to Maarten Lankhorst

Now that we added the separate step of initialising GUC in xe_gt_init_early, it should be ok to initialise the minimum during early init, and the rest after allocations are allowed.

---
 drivers/gpu/drm/xe/xe_device.c |  6 ----
 drivers/gpu/drm/xe/xe_gt.c     | 66 +++++++++++++++++-----------------
 drivers/gpu/drm/xe/xe_gt.h     |  1 -
 3 files changed, 32 insertions(+), 41 deletions(-)
drivers/gpu/drm/xe/xe_device.c +0 -6
index 0d662158fc83a..9116e513dc4bc 100644
@@ -664,12 +664,6 @@ int xe_device_probe(struct xe_device *xe)
 			return err;
 	}
 
-	for_each_gt(gt, xe, id) {
-		err = xe_gt_init_hwconfig(gt);
-		if (err)
-			return err;
-	}
-
 	err = xe_devcoredump_init(xe);
 	if (err)
 		return err;
drivers/gpu/drm/xe/xe_gt.c +32 -34

90 lines not on this page · raw message

drivers/gpu/drm/xe/xe_gt.h +0 -1
index 82b9b7f82fcab..0c026cc91ffe9 100644
@@ -28,7 +28,6 @@ static inline bool xe_fault_inject_gt_reset(void)
 }
 
 struct xe_gt *xe_gt_alloc(struct xe_tile *tile);
-int xe_gt_init_hwconfig(struct xe_gt *gt);
 int xe_gt_init_early(struct xe_gt *gt);
 int xe_gt_init(struct xe_gt *gt);
 void xe_gt_mmio_init(struct xe_gt *gt);
Signature · 1 line
2.45.2