/* Reset GuC providing us with fresh state for both GuC and HuC.
*/ staticint __intel_uc_reset_hw(struct intel_uc *uc)
{ struct intel_gt *gt = uc_to_gt(uc); int ret;
u32 guc_status;
ret = i915_inject_probe_error(gt->i915, -ENXIO); if (ret) return ret;
ret = intel_reset_guc(gt); if (ret) {
gt_err(gt, "Failed to reset GuC, ret = %d\n", ret); return ret;
}
guc_status = intel_uncore_read(gt->uncore, GUC_STATUS);
gt_WARN(gt, !(guc_status & GS_MIA_IN_RESET), "GuC status: 0x%x, MIA core expected to be in reset\n",
guc_status);
/* * Events triggered while CT buffers are disabled are logged in the SCRATCH_15 * register using the same bits used in the CT message payload. Since our * communication channel with guc is turned off at this point, we can save the * message and handle it after we turn it back on.
*/ staticvoid guc_clear_mmio_msg(struct intel_guc *guc)
{
intel_uncore_write(guc_to_gt(guc)->uncore, SOFT_SCRATCH(15), 0);
}
val = intel_uncore_read(guc_to_gt(guc)->uncore, SOFT_SCRATCH(15));
guc->mmio_msg |= val & guc->msg_enabled_mask;
/* * clear all events, including the ones we're not currently servicing, * to make sure we don't try to process a stale message if we enable * handling of more events later.
*/
guc_clear_mmio_msg(guc);
spin_unlock_irq(&guc->irq_lock);
}
staticvoid guc_handle_mmio_msg(struct intel_guc *guc)
{ /* we need communication to be enabled to reply to GuC */
GEM_BUG_ON(!intel_guc_ct_enabled(&guc->ct));
ret = i915_inject_probe_error(i915, -ENXIO); if (ret) return ret;
ret = intel_guc_ct_enable(&guc->ct); if (ret) return ret;
/* check for mmio messages received before/during the CT enable */
guc_get_mmio_msg(guc);
guc_handle_mmio_msg(guc);
intel_guc_enable_interrupts(guc);
/* check for CT messages received before we enabled interrupts */
spin_lock_irq(gt->irq_lock);
intel_guc_ct_event_handler(&guc->ct);
spin_unlock_irq(gt->irq_lock);
guc_dbg(guc, "communication enabled\n");
return 0;
}
staticvoid guc_disable_communication(struct intel_guc *guc)
{ /* * Events generated during or after CT disable are logged by guc in * via mmio. Make sure the register is clear before disabling CT since * all events we cared about have already been processed via CT.
*/
guc_clear_mmio_msg(guc);
intel_guc_disable_interrupts(guc);
intel_guc_ct_disable(&guc->ct);
/* * Check for messages received during/after the CT disable. We do not * expect any messages to have arrived via CT between the interrupt * disable and the CT disable because GuC should've been idle until we * triggered the CT disable protocol.
*/
guc_get_mmio_msg(guc);
err = intel_uc_fw_fetch(&uc->guc.fw); if (err) { /* Make sure we transition out of transient "SELECTED" state */ if (intel_uc_wants_huc(uc)) {
gt_dbg(gt, "Failed to fetch GuC fw (%pe) disabling HuC\n", ERR_PTR(err));
intel_uc_fw_change_status(&uc->huc.fw,
INTEL_UC_FIRMWARE_ERROR);
}
if (intel_uc_wants_gsc_uc(uc)) {
gt_dbg(gt, "Failed to fetch GuC fw (%pe) disabling GSC\n", ERR_PTR(err));
intel_uc_fw_change_status(&uc->gsc.fw,
INTEL_UC_FIRMWARE_ERROR);
}
return;
}
if (intel_uc_wants_huc(uc))
intel_uc_fw_fetch(&uc->huc.fw);
if (intel_uc_wants_gsc_uc(uc))
intel_uc_fw_fetch(&uc->gsc.fw);
}
staticint __uc_check_hw(struct intel_uc *uc)
{ if (uc->fw_table_invalid) return -EIO;
if (!intel_uc_supports_guc(uc)) return 0;
/* * We can silently continue without GuC only if it was never enabled * before on this system after reboot, otherwise we risk GPU hangs. * To check if GuC was loaded before we look at WOPCM registers.
*/ if (uc_is_wopcm_locked(uc)) return -EIO;
/* Disable a potentially low PL1 power limit to allow freq to be raised */
i915_hwmon_power_max_disable(gt->i915, &pl1en);
intel_rps_raise_unslice(&uc_to_gt(uc)->rps);
while (attempts--) { /* * Always reset the GuC just before (re)loading, so * that the state and timing are fairly predictable
*/
ret = __uc_sanitize(uc); if (ret) goto err_rps;
intel_huc_fw_upload(huc);
intel_guc_ads_reset(guc);
intel_guc_write_params(guc);
ret = intel_guc_fw_upload(guc); if (ret == 0) break;
gt_dbg(gt, "GuC fw load failed (%pe) will reset and retry %d more time(s)\n",
ERR_PTR(ret), attempts);
}
/* Did we succeed or run out of retries? */ if (ret) goto err_log_capture;
ret = guc_enable_communication(guc); if (ret) goto err_log_capture;
/* * GSC-loaded HuC is authenticated by the GSC, so we don't need to * trigger the auth here. However, given that the HuC loaded this way * survive GT reset, we still need to update our SW bookkeeping to make * sure it reflects the correct HW status.
*/ if (intel_huc_is_loaded_by_gsc(huc))
intel_huc_update_auth_status(huc); else
intel_huc_auth(huc, INTEL_HUC_AUTH_BY_GUC);
if (intel_uc_uses_guc_submission(uc)) {
ret = intel_guc_submission_enable(guc); if (ret) goto err_log_capture;
}
if (intel_uc_uses_guc_slpc(uc)) {
ret = intel_guc_slpc_enable(&guc->slpc); if (ret) goto err_submission;
} else { /* Restore GT back to RPn for non-SLPC path */
intel_rps_lower_unslice(&uc_to_gt(uc)->rps);
}
/* * NB: The wedge code path results in prepare -> prepare -> finish -> finish. * So this function is sometimes called with the in-progress flag not set.
*/
uc->reset_in_progress = false;
/* Firmware expected to be running when this function is called */ if (intel_uc_uses_guc_submission(uc))
intel_guc_submission_reset_finish(guc);
}
if (!intel_guc_is_ready(guc)) {
guc->interrupts.enabled = false; return;
}
/* * Wait for any outstanding CTB before tearing down communication /w the * GuC.
*/ #define OUTSTANDING_CTB_TIMEOUT_PERIOD (HZ / 5)
intel_guc_wait_for_pending_msg(guc, &guc->outstanding_submission_g2h, false, OUTSTANDING_CTB_TIMEOUT_PERIOD);
GEM_WARN_ON(atomic_read(&guc->outstanding_submission_g2h));
/* Make sure we enable communication if and only if it's disabled */
GEM_BUG_ON(enable_communication == intel_guc_ct_enabled(&guc->ct));
if (enable_communication)
guc_enable_communication(guc);
/* If we are only resuming GuC communication but not reloading * GuC, we need to ensure the ARAT timer interrupt is enabled * again. In case of GuC reload, it is enabled during SLPC enable.
*/ if (enable_communication && intel_uc_uses_guc_slpc(uc))
intel_guc_pm_intrmsk_enable(gt);
err = intel_guc_resume(guc); if (err) {
guc_dbg(guc, "Failed to resume, %pe", ERR_PTR(err)); return err;
}
intel_gsc_uc_resume(&uc->gsc);
if (intel_guc_tlb_invalidation_is_available(guc)) {
intel_guc_invalidate_tlb_engines(guc);
intel_guc_invalidate_tlb_guc(guc);
}
return 0;
}
int intel_uc_resume(struct intel_uc *uc)
{ /* * When coming out of S3/S4 we sanitize and re-init the HW, so * communication is already re-enabled at this point.
*/ return __uc_resume(uc, false);
}
int intel_uc_runtime_resume(struct intel_uc *uc)
{ /* * During runtime resume we don't sanitize, so we need to re-init * communication as well.
*/ return __uc_resume(uc, true);
}
staticconststruct intel_uc_ops uc_ops_off = {
.init_hw = __uc_check_hw,
.fini = __uc_fini, /* to clean-up the init_early initialization */
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.