drm/i915/guc: Split GuC firmware xfer function into clear steps
Subsystems (2)
PATCH v2 1/4 drm/i915/guc: Split GuC firmware xfer function into clear steps
Transfer of GuC firmware requires few steps that currently are implemented in two large functions. Split this code into smaller functions to make these steps small and clear. Also be prepared for potential DMA xfer step failure.
v2: rename function steps (Sagar)
--- drivers/gpu/drm/i915/intel_guc_fw.c | 172 +++++++++++++++++++++--------------- 1 file changed, 103 insertions(+), 69 deletions(-)
drivers/gpu/drm/i915/intel_guc_fw.c +103 -69
@@ -97,23 +97,55 @@ int intel_guc_fw_select(struct intel_guc *guc)return 0 ; } -/* -* Read the GuC status register (GUC_STATUS) and store it in the -* specified location; then return a boolean indicating whether -* the value matches either of two values representing completion -* of the GuC boot process. -* -* This is used for polling the GuC status in a wait_for() -* loop below. -*/ -static inline bool guc_ucode_response (struct drm_i915_private *dev_priv, -u32 *status) +static void guc_prepare_xfer (struct intel_guc *guc) { -u32 val =I915_READ (GUC_STATUS ); -u32 uk_val = val &GS_UKERNEL_MASK ; - *status = val; -return (uk_val ==GS_UKERNEL_READY || - ((val &GS_MIA_CORE_STATE ) && uk_val ==GS_UKERNEL_LAPIC_DONE )); +struct drm_i915_private *dev_priv =guc_to_i915 (guc); + +/* Enable MIA caching. GuC clock gating is disabled. */ +I915_WRITE (GUC_SHIM_CONTROL ,GUC_SHIM_CONTROL_VALUE ); + +/* WaDisableMinuteIaClockGating:bxt */ +if (IS_BXT_REVID (dev_priv,0 ,BXT_REVID_A1 )) { +I915_WRITE (GUC_SHIM_CONTROL , (I915_READ (GUC_SHIM_CONTROL ) & + ~GUC_ENABLE_MIA_CLOCK_GATING )); + } + +/* WaC6DisallowByGfxPause:bxt */ +if (IS_BXT_REVID (dev_priv,0 ,BXT_REVID_B0 )) +I915_WRITE (GEN6_GFXPAUSE ,0x30FFF ); + +if (IS_GEN9_LP (dev_priv)) +I915_WRITE (GEN9LP_GT_PM_CONFIG ,GT_DOORBELL_ENABLE ); +else +I915_WRITE (GEN9_GT_PM_CONFIG ,GT_DOORBELL_ENABLE ); + +if (IS_GEN9 (dev_priv)) { +/* DOP Clock Gating Enable for GuC clocks */ +I915_WRITE (GEN7_MISCCPCTL , (GEN8_DOP_CLOCK_GATE_GUC_ENABLE | +I915_READ (GEN7_MISCCPCTL ))); + +/* allows for 5us (in 10ns units) before GT can go to RC6 */ +I915_WRITE (GUC_ARAT_C6DIS ,0x1FF ); + } +} + +/* Copy RSA signature from the fw image to HW for verification */ +static int guc_xfer_rsa (struct intel_guc *guc,struct i915_vma *vma) +{ +struct drm_i915_private *dev_priv =guc_to_i915 (guc); +struct intel_uc_fw *guc_fw = &guc->fw; +struct sg_table *sg = vma->pages; +u32 rsa[UOS_RSA_SCRATCH_MAX_COUNT ]; +int i; + +if (sg_pcopy_to_buffer (sg->sgl, sg->nents, rsa,sizeof (rsa), + guc_fw->rsa_offset) !=sizeof (rsa)) +return -EINVAL ; + +for (i =0 ; i <UOS_RSA_SCRATCH_MAX_COUNT ; i++) +I915_WRITE (UOS_RSA_SCRATCH (i), rsa[i]); + +return 0 ; }/*
@@ -122,29 +154,17 @@ static inline bool guc_ucode_response(struct drm_i915_private *dev_priv,* Architecturally, the DMA engine is bidirectional, and can potentially even * transfer between GTT locations. This functionality is left out of the API * for now as there is no need for it. -* -* Note that GuC needs the CSS header plus uKernel code to be copied by the -* DMA engine in one operation, whereas the RSA signature is loaded via MMIO. */ -static int guc_ucode_xfer_dma (struct drm_i915_private *dev_priv, -struct i915_vma *vma) +static int guc_xfer_ucode (struct intel_guc *guc,struct i915_vma *vma) { -struct intel_uc_fw *guc_fw = &dev_priv->guc.fw; +struct drm_i915_private *dev_priv =guc_to_i915 (guc); +struct intel_uc_fw *guc_fw = &guc->fw;unsigned long offset; -struct sg_table *sg = vma->pages; -u32 status, rsa[UOS_RSA_SCRATCH_MAX_COUNT ]; -int i, ret =0 ; - -/* where RSA signature starts */ - offset = guc_fw->rsa_offset; -/* Copy RSA signature from the fw image to HW for verification */ -sg_pcopy_to_buffer (sg->sgl, sg->nents, rsa,sizeof (rsa), offset); -for (i =0 ; i <UOS_RSA_SCRATCH_MAX_COUNT ; i++) -I915_WRITE (UOS_RSA_SCRATCH (i), rsa[i]); - -/* The header plus uCode will be copied to WOPCM via DMA, excluding any -* other components */ +/* +* The header plus uCode will be copied to WOPCM via DMA, excluding any +* other components +*/ I915_WRITE (DMA_COPY_SIZE , guc_fw->header_size + guc_fw->ucode_size);/* Set the source address for the new blob */
@@ -162,33 +182,57 @@ static int guc_ucode_xfer_dma(struct drm_i915_private *dev_priv,/* Finally start the DMA */ I915_WRITE (DMA_CTRL ,_MASKED_BIT_ENABLE (UOS_MOVE |START_DMA )); +return 0 ; +} + +/* +* Read the GuC status register (GUC_STATUS) and store it in the +* specified location; then return a boolean indicating whether +* the value matches either of two values representing completion +* of the GuC boot process. +* +* This is used for polling the GuC status in a wait_for() +* loop below. +*/ +static inline bool guc_ready (struct intel_guc *guc,u32 *status) +{ +struct drm_i915_private *dev_priv =guc_to_i915 (guc); +u32 val =I915_READ (GUC_STATUS ); +u32 uk_val = val &GS_UKERNEL_MASK ; + + *status = val; +return (uk_val ==GS_UKERNEL_READY ) || + ((val &GS_MIA_CORE_STATE ) && (uk_val ==GS_UKERNEL_LAPIC_DONE )); +} + +static int guc_wait_ucode (struct intel_guc *guc) +{ +u32 status; +int ret; +/* -* Wait for the DMA to complete & the GuC to start up. +* Wait for the GuC to start up. * NB: Docs recommend not using the interrupt for completion. * Measurements indicate this should take no more than 20ms, so a * timeout here indicates that the GuC has failed and is unusable. * (Higher levels of the driver will attempt to fall back to * execlist mode if this happens.) */ - ret =wait_for (guc_ucode_response (dev_priv, &status),100 ); - -DRM_DEBUG_DRIVER ("DMA status 0x%x, GuC status 0x%x\n" , -I915_READ (DMA_CTRL ), status); + ret =wait_for (guc_ready (guc, &status),100 ); +DRM_DEBUG_DRIVER ("GuC status %#x\n" , status);if ((status &GS_BOOTROM_MASK ) ==GS_BOOTROM_RSA_FAILED ) {DRM_ERROR ("GuC firmware signature verification failed\n" ); ret = -ENOEXEC ; } -DRM_DEBUG_DRIVER ("returning %d\n" , ret); -return ret; }/* * Load the GuC firmware blob into the MinuteIA. */ -static int guc_ucode_xfer (struct intel_uc_fw *guc_fw,struct i915_vma *vma) +static int guc_fw_xfer (struct intel_uc_fw *guc_fw,struct i915_vma *vma) { struct intel_guc *guc = container_of(guc_fw, struct intel_guc, fw);struct drm_i915_private *dev_priv =guc_to_i915 (guc);
@@ -198,34 +242,24 @@ static int guc_ucode_xfer(struct intel_uc_fw *guc_fw, struct i915_vma *vma)intel_uncore_forcewake_get (dev_priv,FORCEWAKE_ALL ); -/* Enable MIA caching. GuC clock gating is disabled. */ -I915_WRITE (GUC_SHIM_CONTROL ,GUC_SHIM_CONTROL_VALUE ); - -/* WaDisableMinuteIaClockGating:bxt */ -if (IS_BXT_REVID (dev_priv,0 ,BXT_REVID_A1 )) { -I915_WRITE (GUC_SHIM_CONTROL , (I915_READ (GUC_SHIM_CONTROL ) & - ~GUC_ENABLE_MIA_CLOCK_GATING )); - } - -/* WaC6DisallowByGfxPause:bxt */ -if (IS_BXT_REVID (dev_priv,0 ,BXT_REVID_B0 )) -I915_WRITE (GEN6_GFXPAUSE ,0x30FFF ); +guc_prepare_xfer (guc); -if (IS_GEN9_LP (dev_priv)) -I915_WRITE (GEN9LP_GT_PM_CONFIG ,GT_DOORBELL_ENABLE ); -else -I915_WRITE (GEN9_GT_PM_CONFIG ,GT_DOORBELL_ENABLE ); - -if (IS_GEN9 (dev_priv)) { -/* DOP Clock Gating Enable for GuC clocks */ -I915_WRITE (GEN7_MISCCPCTL , (GEN8_DOP_CLOCK_GATE_GUC_ENABLE | -I915_READ (GEN7_MISCCPCTL ))); +/* +* Note that GuC needs the CSS header plus uKernel code to be copied +* by the DMA engine in one operation, whereas the RSA signature is +* loaded via MMIO. +*/ + ret =guc_xfer_rsa (guc, vma); +if (ret) +DRM_WARN ("GuC firmware signature xfer error %d\n" , ret); -/* allows for 5us (in 10ns units) before GT can go to RC6 */ -I915_WRITE (GUC_ARAT_C6DIS ,0x1FF ); - } + ret =guc_xfer_ucode (guc, vma); +if (ret) +DRM_WARN ("GuC firmware code xfer error %d\n" , ret); - ret =guc_ucode_xfer_dma (dev_priv, vma); + ret =guc_wait_ucode (guc); +if (ret) +DRM_ERROR ("GuC firmware xfer error %d\n" , ret);intel_uncore_forcewake_put (dev_priv,FORCEWAKE_ALL );
@@ -247,5 +281,5 @@ static int guc_ucode_xfer(struct intel_uc_fw *guc_fw, struct i915_vma *vma)*/ int intel_guc_fw_upload (struct intel_guc *guc) { -return intel_uc_fw_upload (&guc->fw, guc_ucode_xfer); +return intel_uc_fw_upload (&guc->fw, guc_fw_xfer); }
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 2/4 drm/i915/guc: Wait for ucode DMA transfer completion
We silently assumed that DMA transfer will be completed within assumed timeout and thus we were waiting only at last step for GuC to become ready. Add intermediate wait to catch unexpected delays in DMA transfer.
--- drivers/gpu/drm/i915/intel_guc_fw.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_guc_fw.c +8 -1
@@ -160,6 +160,8 @@ static int guc_xfer_ucode(struct intel_guc *guc, struct i915_vma *vma)struct drm_i915_private *dev_priv =guc_to_i915 (guc);struct intel_uc_fw *guc_fw = &guc->fw;unsigned long offset; +u32 status; +int ret;/* * The header plus uCode will be copied to WOPCM via DMA, excluding any
@@ -182,7 +184,12 @@ static int guc_xfer_ucode(struct intel_guc *guc, struct i915_vma *vma)/* Finally start the DMA */ I915_WRITE (DMA_CTRL ,_MASKED_BIT_ENABLE (UOS_MOVE |START_DMA )); -return 0 ; +/* Wait for DMA to finish */ + ret =__intel_wait_for_register_fw (dev_priv,DMA_CTRL ,START_DMA ,0 , +2 ,100 , &status); +DRM_DEBUG_DRIVER ("GuC DMA status %#x\n" , status); + +return ret; }/*
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 2/4] drm/i915/guc: Wait for ucode DMA transfer completion
Quoted 9 lines · Michal Wajdeczko
We silently assumed that DMA transfer will be completed within assumed timeout and thus we were waiting only at last step for GuC to become ready. Add intermediate wait to catch unexpected delays in DMA transfer.
Signed-off-by Michal Wajdeczko <[email protected]>Cc Chris Wilson <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Sagar Arun Kamble <[email protected]>
Quoted 21 lines
--- drivers/gpu/drm/i915/intel_guc_fw.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_guc_fw.c +2
-0@@ -160,6 +160,8 @@ static int guc_xfer_ucode(struct intel_guc *guc, struct i915_vma *vma)struct drm_i915_private *dev_priv =guc_to_i915 (guc);struct intel_uc_fw *guc_fw = &guc->fw;unsigned long offset; +u32 status; +int ret;/* * The header plus uCode will be copied to WOPCM via DMA, excluding any @@ -182,7 +184,12 @@ static int guc_xfer_ucode(struct intel_guc *guc, struct i915_vma *vma)/* Finally start the DMA */ I915_WRITE (DMA_CTRL ,_MASKED_BIT_ENABLE (UOS_MOVE |START_DMA ));
drivers/gpu/drm/i915/intel_guc_fw.c static int guc_xfer_ucode(struct intel_guc *guc, struct i915_vma *vma) · line 195
Quoted 10 lines
drivers/gpu/drm/i915/intel_guc_fw.c +6
-1-return 0 ; +/* Wait for DMA to finish */ + ret =__intel_wait_for_register_fw (dev_priv,DMA_CTRL ,START_DMA ,0 , +2 ,100 , &status); +DRM_DEBUG_DRIVER ("GuC DMA status %#x\n" , status); + +return ret; }/*
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 3/4 drm/i915/guc: Simplify programming of GUC_SHIM_CONTROL
In reply to Michal WajdeczkoWe unconditionally program GUC_SHIM_CONTROL register with all expected bits, but in case of required workaround we modify those bits by using additional READ/WRITE calls. Lets prepare correct value for this register prior to first register programming.
--- drivers/gpu/drm/i915/i915_guc_reg.h | 7 ------- drivers/gpu/drm/i915/intel_guc_fw.c | 19 +++++++++++++------ 2 files changed, 13 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/i915_guc_reg.h +0 -7
@@ -102,13 +102,6 @@#define GUC_ENABLE_MIA_CLOCK_GATING (1<<15)#define GUC_GEN10_SHIM_WC_ENABLE (1<<21) -#define GUC_SHIM_CONTROL_VALUE (GUC_DISABLE_SRAM_INIT_TO_ZEROES | \ - GUC_ENABLE_READ_CACHE_LOGIC | \ - GUC_ENABLE_MIA_CACHING | \ - GUC_ENABLE_READ_CACHE_FOR_SRAM_DATA | \ - GUC_ENABLE_READ_CACHE_FOR_WOPCM_DATA | \ - GUC_ENABLE_MIA_CLOCK_GATING) -#define GUC_SEND_INTERRUPT _MMIO(0xc4c8)#define GUC_SEND_TRIGGER (1<<0)
drivers/gpu/drm/i915/intel_guc_fw.c +13 -6
@@ -100,15 +100,22 @@ int intel_guc_fw_select(struct intel_guc *guc)static void guc_prepare_xfer (struct intel_guc *guc) {struct drm_i915_private *dev_priv =guc_to_i915 (guc); +u32 shim_control_value; -/* Enable MIA caching. GuC clock gating is disabled. */ -I915_WRITE (GUC_SHIM_CONTROL ,GUC_SHIM_CONTROL_VALUE ); +/* Expected bits for normal operation */ + shim_control_value =GUC_DISABLE_SRAM_INIT_TO_ZEROES | +GUC_ENABLE_READ_CACHE_LOGIC | +GUC_ENABLE_MIA_CACHING | +GUC_ENABLE_READ_CACHE_FOR_SRAM_DATA | +GUC_ENABLE_READ_CACHE_FOR_WOPCM_DATA | +GUC_ENABLE_MIA_CLOCK_GATING ;/* WaDisableMinuteIaClockGating:bxt */ -if (IS_BXT_REVID (dev_priv,0 ,BXT_REVID_A1 )) { -I915_WRITE (GUC_SHIM_CONTROL , (I915_READ (GUC_SHIM_CONTROL ) & - ~GUC_ENABLE_MIA_CLOCK_GATING )); - } +if (IS_BXT_REVID (dev_priv,0 ,BXT_REVID_A1 )) + shim_control_value &= ~GUC_ENABLE_MIA_CLOCK_GATING ; + +/* Must program this register before loading the ucode with DMA */ +I915_WRITE (GUC_SHIM_CONTROL , shim_control_value);/* WaC6DisallowByGfxPause:bxt */ if (IS_BXT_REVID (dev_priv,0 ,BXT_REVID_B0 ))
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 3/4] drm/i915/guc: Simplify programming of GUC_SHIM_CONTROL
Quoted 10 lines · Michal Wajdeczko
We unconditionally program
GUC_SHIM_CONTROLregister with all expected bits, but in case of required workaround we modify those bits by using additional READ/WRITE calls. Lets prepare correct value for this register prior to first register programming.Signed-off-by Michal Wajdeczko <[email protected]>Cc Chris Wilson <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Sagar Arun Kamble <[email protected]>
As per bspec, WaDisableMinuteIaClockGating is applicable to SKL A0/B0 as well. Should fix for those platforms unless we dont want to carry early pre-production workarounds.
Quoted 46 lines
--- drivers/gpu/drm/i915/i915_guc_reg.h | 7 ------- drivers/gpu/drm/i915/intel_guc_fw.c | 19 +++++++++++++------ 2 files changed, 13 insertions(+), 13 deletions(-)drivers/gpu/drm/i915/i915_guc_reg.h +0
-7@@ -102,13 +102,6 @@#define GUC_ENABLE_MIA_CLOCK_GATING (1<<15)#define GUC_GEN10_SHIM_WC_ENABLE (1<<21) -#define GUC_SHIM_CONTROL_VALUE (GUC_DISABLE_SRAM_INIT_TO_ZEROES | \ - GUC_ENABLE_READ_CACHE_LOGIC | \ - GUC_ENABLE_MIA_CACHING | \ - GUC_ENABLE_READ_CACHE_FOR_SRAM_DATA | \ - GUC_ENABLE_READ_CACHE_FOR_WOPCM_DATA | \ - GUC_ENABLE_MIA_CLOCK_GATING) -#define GUC_SEND_INTERRUPT _MMIO(0xc4c8)#define GUC_SEND_TRIGGER (1<<0)drivers/gpu/drm/i915/intel_guc_fw.c +8
-4@@ -100,15 +100,22 @@ int intel_guc_fw_select(struct intel_guc *guc)static void guc_prepare_xfer (struct intel_guc *guc) {struct drm_i915_private *dev_priv =guc_to_i915 (guc); +u32 shim_control_value; -/* Enable MIA caching. GuC clock gating is disabled. */ -I915_WRITE (GUC_SHIM_CONTROL ,GUC_SHIM_CONTROL_VALUE ); +/* Expected bits for normal operation */ + shim_control_value =GUC_DISABLE_SRAM_INIT_TO_ZEROES | +GUC_ENABLE_READ_CACHE_LOGIC | +GUC_ENABLE_MIA_CACHING | +GUC_ENABLE_READ_CACHE_FOR_SRAM_DATA | +GUC_ENABLE_READ_CACHE_FOR_WOPCM_DATA | +GUC_ENABLE_MIA_CLOCK_GATING ;/* WaDisableMinuteIaClockGating:bxt */ -if (IS_BXT_REVID (dev_priv,0 ,BXT_REVID_A1 )) { - I915_WRITE(GUC_SHIM_CONTROL, (I915_READ(GUC_SHIM_CONTROL) &
drivers/gpu/drm/i915/intel_guc_fw.c int intel_guc_fw_select(struct intel_guc *guc) · line 121
Quoted 10 lines
drivers/gpu/drm/i915/intel_guc_fw.c +5
-2- ~GUC_ENABLE_MIA_CLOCK_GATING)); - } +if (IS_BXT_REVID (dev_priv,0 ,BXT_REVID_A1 )) + shim_control_value &= ~GUC_ENABLE_MIA_CLOCK_GATING ; + +/* Must program this register before loading the ucode with DMA */ +I915_WRITE (GUC_SHIM_CONTROL , shim_control_value);/* WaC6DisallowByGfxPause:bxt */ if (IS_BXT_REVID (dev_priv,0 ,BXT_REVID_B0 ))
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 3/4] drm/i915/guc: Simplify programming of GUC_SHIM_CONTROL
Quoted 22 lines · Michal Wajdeczko
Quoted 21 lines
We unconditionally program
GUC_SHIM_CONTROLregister withdrivers/gpu/drm/i915/intel_guc_fw.c +8
-2@@ -100,15 +100,22 @@ int intel_guc_fw_select(struct intel_guc *guc)static void guc_prepare_xfer (struct intel_guc *guc) {struct drm_i915_private *dev_priv =guc_to_i915 (guc); +u32 shim_control_value; -/* Enable MIA caching. GuC clock gating is disabled. */ -I915_WRITE (GUC_SHIM_CONTROL ,GUC_SHIM_CONTROL_VALUE ); +/* Expected bits for normal operation */ + shim_control_value =GUC_DISABLE_SRAM_INIT_TO_ZEROES | +GUC_ENABLE_READ_CACHE_LOGIC | +GUC_ENABLE_MIA_CACHING | +GUC_ENABLE_READ_CACHE_FOR_SRAM_DATA | +GUC_ENABLE_READ_CACHE_FOR_WOPCM_DATA | +GUC_ENABLE_MIA_CLOCK_GATING ;
Quoted 8 lines
drivers/gpu/drm/i915/intel_guc_fw.c int intel_guc_fw_select(struct intel_guc *guc) · line 116
Quoted 8 lines
drivers/gpu/drm/i915/intel_guc_fw.c +3
-4/* WaDisableMinuteIaClockGating:bxt */ -if (IS_BXT_REVID (dev_priv,0 ,BXT_REVID_A1 )) { -I915_WRITE (GUC_SHIM_CONTROL , (I915_READ (GUC_SHIM_CONTROL ) & - ~GUC_ENABLE_MIA_CLOCK_GATING )); - } +if (IS_BXT_REVID (dev_priv,0 ,BXT_REVID_A1 )) + shim_control_value &= ~GUC_ENABLE_MIA_CLOCK_GATING ; +
Do you want to before changing this process, rip out the preproduction steps?
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 4/4 HAX enable GuC submission for CI
In reply to Michal WajdeczkoAlso revert ("drm/i915/guc: Assert that we switch between known ggtt->invalidate functions"
--- drivers/gpu/drm/i915/i915_gem_gtt.c | 8 ++------ drivers/gpu/drm/i915/i915_params.h | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +2 -6
@@ -3562,17 +3562,13 @@ int i915_ggtt_enable_hw(struct drm_i915_private *dev_priv)void i915_ggtt_enable_guc (struct drm_i915_private *i915) { -GEM_BUG_ON (i915->ggtt.invalidate != gen6_ggtt_invalidate); - i915->ggtt.invalidate = guc_ggtt_invalidate; }void i915_ggtt_disable_guc (struct drm_i915_private *i915) { -/* We should only be called after i915_ggtt_enable_guc() */ -GEM_BUG_ON (i915->ggtt.invalidate != guc_ggtt_invalidate); - - i915->ggtt.invalidate = gen6_ggtt_invalidate; +if (i915->ggtt.invalidate == guc_ggtt_invalidate) + i915->ggtt.invalidate = gen6_ggtt_invalidate; }void i915_gem_restore_gtt_mappings (struct drm_i915_private *dev_priv)
drivers/gpu/drm/i915/i915_params.h +2 -2
@@ -44,8 +44,8 @@ param(int, disable_power_well, -1) \ param(int, enable_ips, 1) \ param(int, invert_brightness, 0) \ - param(int, enable_guc_loading, 0) \ - param(int, enable_guc_submission, 0) \ + param(int, enable_guc_loading, 1) \ + param(int, enable_guc_submission, 1) \ param(int, guc_log_level, -1) \ param(char *, guc_firmware_path, NULL) \param (char *, huc_firmware_path, NULL) \
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 11 lines · Michal Wajdeczko
Transfer of GuC firmware requires few steps that currently are implemented in two large functions. Split this code into smaller functions to make these steps small and clear. Also be prepared for potential DMA xfer step failure.
v2: rename function steps (Sagar)
Signed-off-by Michal Wajdeczko <[email protected]>Cc Chris Wilson <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Sagar Arun Kamble <[email protected]>
Quoted 234 lines
--- drivers/gpu/drm/i915/intel_guc_fw.c | 172 +++++++++++++++++++++--------------- 1 file changed, 103 insertions(+), 69 deletions(-)drivers/gpu/drm/i915/intel_guc_fw.c +102
-68@@ -97,23 +97,55 @@ int intel_guc_fw_select(struct intel_guc *guc)return 0 ; } -/* -* Read the GuC status register (GUC_STATUS) and store it in the -* specified location; then return a boolean indicating whether -* the value matches either of two values representing completion -* of the GuC boot process. -* -* This is used for polling the GuC status in a wait_for() -* loop below. -*/ -static inline bool guc_ucode_response (struct drm_i915_private *dev_priv, -u32 *status) +static void guc_prepare_xfer (struct intel_guc *guc) { -u32 val =I915_READ (GUC_STATUS ); -u32 uk_val = val &GS_UKERNEL_MASK ; - *status = val; -return (uk_val ==GS_UKERNEL_READY || - ((val &GS_MIA_CORE_STATE ) && uk_val ==GS_UKERNEL_LAPIC_DONE )); +struct drm_i915_private *dev_priv =guc_to_i915 (guc); + +/* Enable MIA caching. GuC clock gating is disabled. */ +I915_WRITE (GUC_SHIM_CONTROL ,GUC_SHIM_CONTROL_VALUE ); + +/* WaDisableMinuteIaClockGating:bxt */ +if (IS_BXT_REVID (dev_priv,0 ,BXT_REVID_A1 )) { +I915_WRITE (GUC_SHIM_CONTROL , (I915_READ (GUC_SHIM_CONTROL ) & + ~GUC_ENABLE_MIA_CLOCK_GATING )); + } + +/* WaC6DisallowByGfxPause:bxt */ +if (IS_BXT_REVID (dev_priv,0 ,BXT_REVID_B0 )) +I915_WRITE (GEN6_GFXPAUSE ,0x30FFF ); + +if (IS_GEN9_LP (dev_priv)) +I915_WRITE (GEN9LP_GT_PM_CONFIG ,GT_DOORBELL_ENABLE ); +else +I915_WRITE (GEN9_GT_PM_CONFIG ,GT_DOORBELL_ENABLE ); + +if (IS_GEN9 (dev_priv)) { +/* DOP Clock Gating Enable for GuC clocks */ +I915_WRITE (GEN7_MISCCPCTL , (GEN8_DOP_CLOCK_GATE_GUC_ENABLE | +I915_READ (GEN7_MISCCPCTL ))); + +/* allows for 5us (in 10ns units) before GT can go to RC6 */ +I915_WRITE (GUC_ARAT_C6DIS ,0x1FF ); + } +} + +/* Copy RSA signature from the fw image to HW for verification */ +static int guc_xfer_rsa (struct intel_guc *guc,struct i915_vma *vma) +{ +struct drm_i915_private *dev_priv =guc_to_i915 (guc); +struct intel_uc_fw *guc_fw = &guc->fw; +struct sg_table *sg = vma->pages; +u32 rsa[UOS_RSA_SCRATCH_MAX_COUNT ]; +int i; + +if (sg_pcopy_to_buffer (sg->sgl, sg->nents, rsa,sizeof (rsa), + guc_fw->rsa_offset) !=sizeof (rsa)) +return -EINVAL ; + +for (i =0 ; i <UOS_RSA_SCRATCH_MAX_COUNT ; i++) +I915_WRITE (UOS_RSA_SCRATCH (i), rsa[i]); + +return 0 ; }/* @@ -122,29 +154,17 @@ static inline bool guc_ucode_response(struct drm_i915_private *dev_priv,* Architecturally, the DMA engine is bidirectional, and can potentially even * transfer between GTT locations. This functionality is left out of the API * for now as there is no need for it. -* -* Note that GuC needs the CSS header plus uKernel code to be copied by the -* DMA engine in one operation, whereas the RSA signature is loaded via MMIO. */ -static int guc_ucode_xfer_dma (struct drm_i915_private *dev_priv, -struct i915_vma *vma) +static int guc_xfer_ucode (struct intel_guc *guc,struct i915_vma *vma) { -struct intel_uc_fw *guc_fw = &dev_priv->guc.fw; +struct drm_i915_private *dev_priv =guc_to_i915 (guc); +struct intel_uc_fw *guc_fw = &guc->fw;unsigned long offset; -struct sg_table *sg = vma->pages; -u32 status, rsa[UOS_RSA_SCRATCH_MAX_COUNT ]; -int i, ret =0 ; - -/* where RSA signature starts */ - offset = guc_fw->rsa_offset; -/* Copy RSA signature from the fw image to HW for verification */ -sg_pcopy_to_buffer (sg->sgl, sg->nents, rsa,sizeof (rsa), offset); -for (i =0 ; i <UOS_RSA_SCRATCH_MAX_COUNT ; i++) -I915_WRITE (UOS_RSA_SCRATCH (i), rsa[i]); - -/* The header plus uCode will be copied to WOPCM via DMA, excluding any -* other components */ +/* +* The header plus uCode will be copied to WOPCM via DMA, excluding any +* other components +*/ I915_WRITE (DMA_COPY_SIZE , guc_fw->header_size + guc_fw->ucode_size);/* Set the source address for the new blob */ @@ -162,33 +182,57 @@ static int guc_ucode_xfer_dma(struct drm_i915_private *dev_priv,/* Finally start the DMA */ I915_WRITE (DMA_CTRL ,_MASKED_BIT_ENABLE (UOS_MOVE |START_DMA )); +return 0 ; +} + +/* +* Read the GuC status register (GUC_STATUS) and store it in the +* specified location; then return a boolean indicating whether +* the value matches either of two values representing completion +* of the GuC boot process. +* +* This is used for polling the GuC status in a wait_for() +* loop below. +*/ +static inline bool guc_ready (struct intel_guc *guc,u32 *status) +{ +struct drm_i915_private *dev_priv =guc_to_i915 (guc); +u32 val =I915_READ (GUC_STATUS ); +u32 uk_val = val &GS_UKERNEL_MASK ; + + *status = val; +return (uk_val ==GS_UKERNEL_READY ) || + ((val &GS_MIA_CORE_STATE ) && (uk_val ==GS_UKERNEL_LAPIC_DONE )); +} + +static int guc_wait_ucode (struct intel_guc *guc) +{ +u32 status; +int ret; +/* -* Wait for the DMA to complete & the GuC to start up. +* Wait for the GuC to start up. * NB: Docs recommend not using the interrupt for completion. * Measurements indicate this should take no more than 20ms, so a * timeout here indicates that the GuC has failed and is unusable. * (Higher levels of the driver will attempt to fall back to * execlist mode if this happens.) */ - ret =wait_for (guc_ucode_response (dev_priv, &status),100 ); - -DRM_DEBUG_DRIVER ("DMA status 0x%x, GuC status 0x%x\n" , -I915_READ (DMA_CTRL ), status); + ret =wait_for (guc_ready (guc, &status),100 ); +DRM_DEBUG_DRIVER ("GuC status %#x\n" , status);if ((status &GS_BOOTROM_MASK ) ==GS_BOOTROM_RSA_FAILED ) {DRM_ERROR ("GuC firmware signature verification failed\n" ); ret = -ENOEXEC ; } -DRM_DEBUG_DRIVER ("returning %d\n" , ret); -return ret; }/* * Load the GuC firmware blob into the MinuteIA. */ -static int guc_ucode_xfer (struct intel_uc_fw *guc_fw,struct i915_vma *vma) +static int guc_fw_xfer (struct intel_uc_fw *guc_fw,struct i915_vma *vma) { struct intel_guc *guc = container_of(guc_fw, struct intel_guc, fw);struct drm_i915_private *dev_priv =guc_to_i915 (guc);@@ -198,34 +242,24 @@ static int guc_ucode_xfer(struct intel_uc_fw *guc_fw, struct i915_vma *vma)intel_uncore_forcewake_get (dev_priv,FORCEWAKE_ALL ); -/* Enable MIA caching. GuC clock gating is disabled. */ -I915_WRITE (GUC_SHIM_CONTROL ,GUC_SHIM_CONTROL_VALUE ); - -/* WaDisableMinuteIaClockGating:bxt */ -if (IS_BXT_REVID (dev_priv,0 ,BXT_REVID_A1 )) { -I915_WRITE (GUC_SHIM_CONTROL , (I915_READ (GUC_SHIM_CONTROL ) & - ~GUC_ENABLE_MIA_CLOCK_GATING )); - } - -/* WaC6DisallowByGfxPause:bxt */ -if (IS_BXT_REVID (dev_priv,0 ,BXT_REVID_B0 )) -I915_WRITE (GEN6_GFXPAUSE ,0x30FFF ); +guc_prepare_xfer (guc); -if (IS_GEN9_LP (dev_priv)) -I915_WRITE (GEN9LP_GT_PM_CONFIG ,GT_DOORBELL_ENABLE ); -else -I915_WRITE (GEN9_GT_PM_CONFIG ,GT_DOORBELL_ENABLE ); - -if (IS_GEN9 (dev_priv)) { -/* DOP Clock Gating Enable for GuC clocks */ -I915_WRITE (GEN7_MISCCPCTL , (GEN8_DOP_CLOCK_GATE_GUC_ENABLE | -I915_READ (GEN7_MISCCPCTL ))); +/* +* Note that GuC needs the CSS header plus uKernel code to be copied +* by the DMA engine in one operation, whereas the RSA signature is +* loaded via MMIO. +*/ + ret =guc_xfer_rsa (guc, vma); +if (ret) +DRM_WARN ("GuC firmware signature xfer error %d\n" , ret); -/* allows for 5us (in 10ns units) before GT can go to RC6 */ -I915_WRITE (GUC_ARAT_C6DIS ,0x1FF ); - } + ret =guc_xfer_ucode (guc, vma); +if (ret) +DRM_WARN ("GuC firmware code xfer error %d\n" , ret); - ret =guc_ucode_xfer_dma (dev_priv, vma); + ret =guc_wait_ucode (guc); +if (ret) +DRM_ERROR ("GuC firmware xfer error %d\n" , ret);intel_uncore_forcewake_put (dev_priv,FORCEWAKE_ALL );
drivers/gpu/drm/i915/intel_guc_fw.c static int guc_ucode_xfer(struct intel_uc_fw *guc_fw, struct i915_vma *vma) · line 285
Quoted 6 lines
drivers/gpu/drm/i915/intel_guc_fw.c +1
-1@@ -247,5 +281,5 @@ static int guc_ucode_xfer(struct intel_uc_fw *guc_fw, struct i915_vma *vma)*/ int intel_guc_fw_upload (struct intel_guc *guc) { -return intel_uc_fw_upload (&guc->fw, guc_ucode_xfer); +return intel_uc_fw_upload (&guc->fw, guc_fw_xfer); }
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for series starting with [v2,1/4] drm/i915/guc: Split GuC firmware xfer function into clear steps
In reply to Michal Wajdeczko== Series Details ==
== Series Details ==
Series: series starting with [v2,1/4] drm/i915/guc: Split GuC firmware xfer function into clear steps
URL : https://patchwork.freedesktop.org/series/33112/
State : success
== Summary ==
Series 33112v1 series starting with [v2,1/4] drm/i915/guc: Split GuC firmware xfer function into clear steps
https://patchwork.freedesktop.org/api/1.0/series/33112/revisions/1/mbox/
Test chamelium:
Subgroup dp-crc-fast:
incomplete -> PASS (fi-kbl-7500u) fdo#102514
Test gem_exec_reloc:
Subgroup basic-cpu-gtt-active:
pass -> FAIL (fi-gdg-551) fdo#102582 +1fdo#102514 https://bugs.freedesktop.org/show_bug.cgi?id=102514
fdo#102582 https://bugs.freedesktop.org/show_bug.cgi?id=102582
fi-bdw-5557u total:289 pass:268 dwarn:0 dfail:0 fail:0 skip:21 time:450s fi-blb-e6850 total:289 pass:223 dwarn:1 dfail:0 fail:0 skip:65 time:380s fi-bsw-n3050 total:289 pass:243 dwarn:0 dfail:0 fail:0 skip:46 time:533s fi-bwr-2160 total:289 pass:183 dwarn:0 dfail:0 fail:0 skip:106 time:275s fi-bxt-dsi total:289 pass:259 dwarn:0 dfail:0 fail:0 skip:30 time:512s fi-bxt-j4205 total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:511s fi-byt-j1900 total:289 pass:253 dwarn:1 dfail:0 fail:0 skip:35 time:504s fi-byt-n2820 total:289 pass:249 dwarn:1 dfail:0 fail:0 skip:39 time:498s fi-cfl-s total:289 pass:254 dwarn:3 dfail:0 fail:0 skip:32 time:565s fi-elk-e7500 total:289 pass:229 dwarn:0 dfail:0 fail:0 skip:60 time:419s fi-gdg-551 total:289 pass:176 dwarn:1 dfail:0 fail:3 skip:109 time:261s fi-glk-1 total:289 pass:261 dwarn:0 dfail:0 fail:0 skip:28 time:590s fi-glk-dsi total:289 pass:258 dwarn:0 dfail:0 fail:1 skip:30 time:489s fi-hsw-4770 total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:436s fi-hsw-4770r total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:430s fi-ilk-650 total:289 pass:228 dwarn:0 dfail:0 fail:0 skip:61 time:425s fi-ivb-3770 total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:461s fi-kbl-7500u total:289 pass:264 dwarn:1 dfail:0 fail:0 skip:24 time:491s fi-kbl-7560u total:289 pass:270 dwarn:0 dfail:0 fail:0 skip:19 time:574s fi-kbl-7567u total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:481s fi-kbl-r total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:581s fi-pnv-d510 total:289 pass:222 dwarn:1 dfail:0 fail:0 skip:66 time:572s fi-skl-6260u total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:451s fi-skl-6600u total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:591s fi-skl-6700hq total:289 pass:263 dwarn:0 dfail:0 fail:0 skip:26 time:648s fi-skl-6700k total:289 pass:265 dwarn:0 dfail:0 fail:0 skip:24 time:525s fi-skl-6770hq total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:506s fi-skl-gvtdvm total:289 pass:266 dwarn:0 dfail:0 fail:0 skip:23 time:462s fi-snb-2520m total:289 pass:250 dwarn:0 dfail:0 fail:0 skip:39 time:570s fi-snb-2600 total:289 pass:249 dwarn:0 dfail:0 fail:0 skip:40 time:426s
fi-bdw-gvtdvm failed to connect after reboot
2f945d948d05de1dd4bd1ca14eac40ff563d9d77 drm-tip: 2017y-11m-03d-09h-28m-20s UTC integration manifest f13cf7f4d241 HAX enable GuC submission for CI5d7b95ce7782 drm/i915/guc: Simplify programming of GUC_SHIM_CONTROL997bafa93e44 drm/i915/guc: Wait for ucode DMA transfer completion959ce04b0ab9 drm/i915/guc: Split GuC firmware xfer function into clear steps
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_6936/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.IGT: warning for series starting with [v2,1/4] drm/i915/guc: Split GuC firmware xfer function into clear steps
In reply to Michal Wajdeczko== Series Details ==
== Series Details ==
Series: series starting with [v2,1/4] drm/i915/guc: Split GuC firmware xfer function into clear steps
URL : https://patchwork.freedesktop.org/series/33112/
State : warning
== Summary ==
Test kms_setmode:
Subgroup basic:
fail -> PASS (shard-hsw) fdo#99912
Test kms_plane_lowres:
Subgroup pipe-C-tiling-none:
pass -> DMESG-WARN (shard-hsw)fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
shard-hsw total:2539 pass:1433 dwarn:1 dfail:1 fail:7 skip:1097 time:9490s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_6936/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx