// SPDX-License-Identifier: MIT /* * Copyright © 2017-2019 Intel Corporation */ #include "intel_wopcm.h" #include "i915_drv.h" /** * DOC: WOPCM Layout * * The layout of the WOPCM will be fixed after writing to GuC WOPCM size and * offset registers whose values are calculated and determined by HuC/GuC * firmware size and set of hardware requirements/restrictions as shown below: * * :: * * +=========> +====================+ <== WOPCM Top * ^ | HW contexts RSVD | * | +===> +====================+ <== GuC WOPCM Top * | ^ | | * | | | | * | | | | * | GuC | | * | WOPCM | | * | Size +--------------------+ * WOPCM | | GuC FW RSVD | * | | +--------------------+ * | | | GuC Stack RSVD | * | | +------------------- + * | v | GuC WOPCM RSVD | * | +===> +====================+ <== GuC WOPCM base * | | WOPCM RSVD | * | +------------------- + <== HuC Firmware Top * v | HuC FW | * +=========> +====================+ <== WOPCM Base * * GuC accessible WOPCM starts at GuC WOPCM base and ends at GuC WOPCM top. * The top part of the WOPCM is reserved for hardware contexts (e.g. RC6 * context). */ /* Default WOPCM size is 2MB from Gen11, 1MB on previous platforms */ #define GEN11_WOPCM_SIZE … #define GEN9_WOPCM_SIZE … #define MAX_WOPCM_SIZE … /* 16KB WOPCM (RSVD WOPCM) is reserved from HuC firmware top. */ #define WOPCM_RESERVED_SIZE … /* 16KB reserved at the beginning of GuC WOPCM. */ #define GUC_WOPCM_RESERVED … /* 8KB from GUC_WOPCM_RESERVED is reserved for GuC stack. */ #define GUC_WOPCM_STACK_RESERVED … /* GuC WOPCM Offset value needs to be aligned to 16KB. */ #define GUC_WOPCM_OFFSET_ALIGNMENT … /* 24KB at the end of WOPCM is reserved for RC6 CTX on BXT. */ #define BXT_WOPCM_RC6_CTX_RESERVED … /* 36KB WOPCM reserved at the end of WOPCM on ICL. */ #define ICL_WOPCM_HW_CTX_RESERVED … /* 128KB from GUC_WOPCM_RESERVED is reserved for FW on Gen9. */ #define GEN9_GUC_FW_RESERVED … #define GEN9_GUC_WOPCM_OFFSET … static inline struct intel_gt *wopcm_to_gt(struct intel_wopcm *wopcm) { … } /** * intel_wopcm_init_early() - Early initialization of the WOPCM. * @wopcm: pointer to intel_wopcm. * * Setup the size of WOPCM which will be used by later on WOPCM partitioning. */ void intel_wopcm_init_early(struct intel_wopcm *wopcm) { … } static u32 context_reserved_size(struct drm_i915_private *i915) { … } static bool gen9_check_dword_gap(struct drm_i915_private *i915, u32 guc_wopcm_base, u32 guc_wopcm_size) { … } static bool gen9_check_huc_fw_fits(struct drm_i915_private *i915, u32 guc_wopcm_size, u32 huc_fw_size) { … } static bool check_hw_restrictions(struct drm_i915_private *i915, u32 guc_wopcm_base, u32 guc_wopcm_size, u32 huc_fw_size) { … } static bool __check_layout(struct intel_gt *gt, u32 wopcm_size, u32 guc_wopcm_base, u32 guc_wopcm_size, u32 guc_fw_size, u32 huc_fw_size) { … } static bool __wopcm_regs_locked(struct intel_uncore *uncore, u32 *guc_wopcm_base, u32 *guc_wopcm_size) { … } static bool __wopcm_regs_writable(struct intel_uncore *uncore) { … } /** * intel_wopcm_init() - Initialize the WOPCM structure. * @wopcm: pointer to intel_wopcm. * * This function will partition WOPCM space based on GuC and HuC firmware sizes * and will allocate max remaining for use by GuC. This function will also * enforce platform dependent hardware restrictions on GuC WOPCM offset and * size. It will fail the WOPCM init if any of these checks fail, so that the * following WOPCM registers setup and GuC firmware uploading would be aborted. */ void intel_wopcm_init(struct intel_wopcm *wopcm) { … }