drm/i915: Fix a bug in GuC status check
Subsystems (2)
PATCH 1/1 drm/i915: Fix a bug in GuC status check
From: Alex Dai <[email protected]>
Bit 16 of GuC status indicates resuming from RC6. The LAPIC_DONE status is a reliable readiness flag only when resuming from RC6. This fix a racing issue that allocation of doorbell fails whilst GuC init is not finished.
--- drivers/gpu/drm/i915/i915_guc_reg.h | 1 + drivers/gpu/drm/i915/intel_guc_loader.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_guc_reg.h +1 -0
@@ -37,6 +37,7 @@#define GS_UKERNEL_READY (0xF0 << GS_UKERNEL_SHIFT)#define GS_MIA_SHIFT 16#define GS_MIA_MASK (0x07 << GS_MIA_SHIFT) +#define GS_MIA_CORE_STATE (1 << GS_MIA_SHIFT)#define SOFT_SCRATCH (n) (0xc180 + ((n) * 4))
drivers/gpu/drm/i915/intel_guc_loader.c +3 -2
@@ -209,9 +209,10 @@ static inline bool guc_ucode_response(struct drm_i915_private *dev_priv, u32 *status) {u32 val =I915_READ (GUC_STATUS ); +u32 uk_val = val &GS_UKERNEL_MASK ; *status = val; -return ((val &GS_UKERNEL_MASK ) ==GS_UKERNEL_READY || - (val &GS_UKERNEL_MASK ) ==GS_UKERNEL_LAPIC_DONE ); +return (uk_val ==GS_UKERNEL_READY || + ((val &GS_MIA_CORE_STATE ) && uk_val ==GS_UKERNEL_LAPIC_DONE )); }/*
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 32 lines · On 02/09/15 23:52, [email protected] wrote:
From: Alex Dai <[email protected]>
Bit 16 of GuC status indicates resuming from RC6. The
LAPIC_DONEstatus is a reliable readiness flag only when resuming from RC6. This fix a racing issue that allocation of doorbell fails whilst GuC init is not finished.Signed-off-by Alex Dai <[email protected]>--- drivers/gpu/drm/i915/i915_guc_reg.h | 1 + drivers/gpu/drm/i915/intel_guc_loader.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/i915_guc_reg.h +1
-0@@ -37,6 +37,7 @@#define GS_UKERNEL_READY (0xF0 << GS_UKERNEL_SHIFT)#define GS_MIA_SHIFT 16#define GS_MIA_MASK (0x07 << GS_MIA_SHIFT) +#define GS_MIA_CORE_STATE (1 << GS_MIA_SHIFT)#define SOFT_SCRATCH (n) (0xc180 + ((n) * 4))drivers/gpu/drm/i915/intel_guc_loader.c +0
-0@@ -209,9 +209,10 @@ static inline bool guc_ucode_response(struct drm_i915_private *dev_priv, u32 *status) {
drivers/gpu/drm/i915/intel_guc_loader.c static inline bool guc_ucode_response(struct drm_i915_private *dev_priv, · line 218
Quoted 10 lines
drivers/gpu/drm/i915/intel_guc_loader.c +3
-2u32 val =I915_READ (GUC_STATUS ); +u32 uk_val = val &GS_UKERNEL_MASK ; *status = val; -return ((val &GS_UKERNEL_MASK ) ==GS_UKERNEL_READY || - (val &GS_UKERNEL_MASK ) ==GS_UKERNEL_LAPIC_DONE ); +return (uk_val ==GS_UKERNEL_READY || + ((val &GS_MIA_CORE_STATE ) && uk_val ==GS_UKERNEL_LAPIC_DONE )); }/*
This does indeed fix the problem of not being able to *re*initialise the GuC correctly after a hang/reset/reload cycle :) However I think the last line looks quite confusing, especially because of the mix of bitwise and logical operators (we have &, &&, and || all in one expression).
So I think it might be clearer if spelled out in two stages:
{
u32 val = I915_READ(GUC_STATUS);
+ u32 uk_val = val & GS_UKERNEL_MASK;
*status = val;- return ((val & GS_UKERNEL_MASK) == GS_UKERNEL_READY ||
- (val & GS_UKERNEL_MASK) == GS_UKERNEL_LAPIC_DONE);
+
+ /* Iff resuming from RC6, look for LAPIC_DONE */
+ if (val & GS_MIA_CORE_STATE)
+ if (uk_val == GS_UKERNEL_LAPIC_DONE)
+ return true;
+
+ /* Otherwise just check whether the uKernel is READY */
+ return uk_val == GS_UKERNEL_READY;
}
Other than that I'm quite happy with it, so either version gets a
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx