Skip to content

Commit d758c8d

Browse files
baluvivekmattrope
authored andcommitted
drm/xe/device: Convert wait for lmem init into an assert
Prior to lmem init check, driver is waiting for the pcode uncore_init status. uncore_init status will be flagged after the complete boot and initialization of the SoC by the pcode. uncore_init confirms that lmem init and mmio unblock has been already completed. It makes no sense to check for lmem init after the pcode uncore_init check. So change the wait for lmem init check into an assert which confirms lmem init is set. Signed-off-by: Balasubramani Vivekanandan <balasubramani.vivekanandan@intel.com> Reviewed-by: Matt Roper <matthew.d.roper@intel.com> Link: https://patch.msgid.link/20251219145024.2955946-2-balasubramani.vivekanandan@intel.com Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
1 parent 987167b commit d758c8d

1 file changed

Lines changed: 16 additions & 57 deletions

File tree

drivers/gpu/drm/xe/xe_device.c

Lines changed: 16 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <linux/aperture.h>
99
#include <linux/delay.h>
1010
#include <linux/fault-inject.h>
11-
#include <linux/iopoll.h>
1211
#include <linux/units.h>
1312

1413
#include <drm/drm_atomic_helper.h>
@@ -654,62 +653,14 @@ static int xe_set_dma_info(struct xe_device *xe)
654653
return err;
655654
}
656655

657-
static int lmem_initializing(struct xe_device *xe)
656+
static void assert_lmem_ready(struct xe_device *xe)
658657
{
659-
if (xe_mmio_read32(xe_root_tile_mmio(xe), GU_CNTL) & LMEM_INIT)
660-
return 0;
661-
662-
if (signal_pending(current))
663-
return -EINTR;
664-
665-
return 1;
666-
}
667-
668-
static int wait_for_lmem_ready(struct xe_device *xe)
669-
{
670-
const unsigned long TIMEOUT_SEC = 60;
671-
unsigned long prev_jiffies;
672-
int initializing;
673-
674-
if (!IS_DGFX(xe))
675-
return 0;
676-
677-
if (IS_SRIOV_VF(xe))
678-
return 0;
679-
680-
if (!lmem_initializing(xe))
681-
return 0;
682-
683-
drm_dbg(&xe->drm, "Waiting for lmem initialization\n");
684-
prev_jiffies = jiffies;
685-
686-
/*
687-
* The boot firmware initializes local memory and
688-
* assesses its health. If memory training fails,
689-
* the punit will have been instructed to keep the GT powered
690-
* down.we won't be able to communicate with it
691-
*
692-
* If the status check is done before punit updates the register,
693-
* it can lead to the system being unusable.
694-
* use a timeout and defer the probe to prevent this.
695-
*/
696-
poll_timeout_us(initializing = lmem_initializing(xe),
697-
initializing <= 0,
698-
20 * USEC_PER_MSEC, TIMEOUT_SEC * USEC_PER_SEC, true);
699-
if (initializing < 0)
700-
return initializing;
701-
702-
if (initializing) {
703-
drm_dbg(&xe->drm, "lmem not initialized by firmware\n");
704-
return -EPROBE_DEFER;
705-
}
706-
707-
drm_dbg(&xe->drm, "lmem ready after %ums",
708-
jiffies_to_msecs(jiffies - prev_jiffies));
658+
if (!IS_DGFX(xe) || IS_SRIOV_VF(xe))
659+
return;
709660

710-
return 0;
661+
xe_assert(xe, xe_mmio_read32(xe_root_tile_mmio(xe), GU_CNTL) &
662+
LMEM_INIT);
711663
}
712-
ALLOW_ERROR_INJECTION(wait_for_lmem_ready, ERRNO); /* See xe_pci_probe() */
713664

714665
static void vf_update_device_info(struct xe_device *xe)
715666
{
@@ -764,6 +715,11 @@ int xe_device_probe_early(struct xe_device *xe)
764715
if (IS_SRIOV_VF(xe))
765716
vf_update_device_info(xe);
766717

718+
/*
719+
* Check for pcode uncore_init status to confirm if the SoC
720+
* initialization is complete. Until done, any MMIO or lmem access from
721+
* the driver will be blocked
722+
*/
767723
err = xe_pcode_probe_early(xe);
768724
if (err || xe_survivability_mode_is_requested(xe)) {
769725
int save_err = err;
@@ -780,9 +736,12 @@ int xe_device_probe_early(struct xe_device *xe)
780736
return save_err;
781737
}
782738

783-
err = wait_for_lmem_ready(xe);
784-
if (err)
785-
return err;
739+
/*
740+
* Make sure the lmem is initialized and ready to use. xe_pcode_ready()
741+
* is flagged after full initialization is complete. Assert if lmem is
742+
* not initialized.
743+
*/
744+
assert_lmem_ready(xe);
786745

787746
xe->wedged.mode = xe_device_validate_wedged_mode(xe, xe_modparam.wedged_mode) ?
788747
XE_WEDGED_MODE_DEFAULT : xe_modparam.wedged_mode;

0 commit comments

Comments
 (0)