static void whitelist_reg(struct whitelist *w, i915_reg_t reg) { if (GEM_WARN_ON(w->count >= RING_MAX_NONPRIV_SLOTS)) return; w->reg[w->count++] = reg; }
int intel_uc_init_hw(struct drm_i915_private *i915) { struct intel_guc *guc = &i915->guc; struct intel_huc *huc = &i915->huc; int ret, attempts; if (!USES_GUC(i915)) return 0; GEM_BUG_ON(!HAS_GUC(i915)); guc_reset_interrupts(guc); /* WaEnableuKernelHeaderValidFix:skl */ /* WaEnableGuCBootHashCheckNotSet:skl,bxt,kbl */ if (IS_GEN(i915, 9)) attempts = 3; else attempts = 1; while (attempts--) { /* * Always reset the GuC just before (re)loading, so * that the state and timing are fairly predictable */ ret = __intel_uc_reset_hw(i915); if (ret) goto err_out; if (USES_HUC(i915)) { ret = intel_huc_fw_upload(huc); if (ret) goto err_out; } intel_guc_ads_reset(guc); intel_guc_init_params(guc); ret = intel_guc_fw_upload(guc); if (ret == 0) break; DRM_DEBUG_DRIVER("GuC fw load failed: %d; will reset and " "retry %d more time(s)\n", ret, attempts); } /* Did we succeded or run out of retries? */ if (ret) goto err_log_capture; ret = guc_enable_communication(guc); if (ret) goto err_log_capture; if (USES_HUC(i915)) { ret = intel_huc_auth(huc); if (ret) goto err_communication; } ret = intel_guc_sample_forcewake(guc); if (ret) goto err_communication; if (USES_GUC_SUBMISSION(i915)) { ret = intel_guc_submission_enable(guc); if (ret) goto err_communication; } dev_info(i915->drm.dev, "GuC firmware version %u.%u\n", guc->fw.major_ver_found, guc->fw.minor_ver_found); dev_info(i915->drm.dev, "GuC submission %s\n", enableddisabled(USES_GUC_SUBMISSION(i915))); dev_info(i915->drm.dev, "HuC %s\n", enableddisabled(USES_HUC(i915))); return 0; /* * We've failed to load the firmware :( */ err_communication: guc_disable_communication(guc); err_log_capture: guc_capture_load_err_log(guc); err_out: __uc_sanitize(i915); /* * Note that there is no fallback as either user explicitly asked for * the GuC or driver default option was to run with the GuC enabled. */ if (GEM_WARN_ON(ret == -EIO)) ret = -EINVAL; dev_err(i915->drm.dev, "GuC initialization failed %d\n", ret); return ret; }