From: Ben Widawsky <benjamin.widawsky@xxxxxxxxx> Consolidate the instdone logic so we can get a bit fancier. This patch also removes the duplicated print of INSTDONE[0]. Signed-off-by: Ben Widawsky <ben@xxxxxxxxxxxx> --- Changes: (Imre) - keep capturing GEN4_INSTDONE1 too - don't save GEN7 registers on GEN4-6 --- drivers/gpu/drm/i915/i915_drv.h | 10 ++++++-- drivers/gpu/drm/i915/i915_gpu_error.c | 43 ++++++++++++++++++++++------------- drivers/gpu/drm/i915/i915_irq.c | 25 ++++++++++++++------ drivers/gpu/drm/i915/i915_reg.h | 1 - 4 files changed, 53 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 9c10270..621acf1 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -513,7 +513,12 @@ struct drm_i915_error_state { u32 gam_ecochk; u32 gab_ctl; u32 gfx_mode; - u32 extra_instdone[I915_NUM_INSTDONE_REG]; + struct extra_instdone { + u32 slice_common; + u32 sampler; + u32 row; + } extra_instdone; + u64 fence[I915_MAX_NUM_FENCES]; struct intel_overlay_error_state *overlay; struct intel_display_error_state *display; @@ -3259,7 +3264,8 @@ void i915_error_state_get(struct drm_device *dev, void i915_error_state_put(struct i915_error_state_file_priv *error_priv); void i915_destroy_error_state(struct drm_device *dev); -void i915_get_extra_instdone(struct drm_device *dev, uint32_t *instdone); +void i915_get_extra_instdone(struct drm_device *dev, + struct extra_instdone *extra); const char *i915_cache_level_str(struct drm_i915_private *i915, int type); /* i915_cmd_parser.c */ diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c index 2f04e4f..e78e512 100644 --- a/drivers/gpu/drm/i915/i915_gpu_error.c +++ b/drivers/gpu/drm/i915/i915_gpu_error.c @@ -383,9 +383,11 @@ int i915_error_state_to_str(struct drm_i915_error_state_buf *m, for (i = 0; i < dev_priv->num_fence_regs; i++) err_printf(m, " fence[%d] = %08llx\n", i, error->fence[i]); - for (i = 0; i < ARRAY_SIZE(error->extra_instdone); i++) - err_printf(m, " INSTDONE_%d: 0x%08x\n", i, - error->extra_instdone[i]); + err_printf(m, " SC_INSTDONE (slice common): 0x%08x\n", + error->extra_instdone.slice_common); + err_printf(m, " SAMPLER_INTSDONE: 0x%08x\n", + error->extra_instdone.sampler); + err_printf(m, " ROW_INSTDONE: 0x%08x\n", error->extra_instdone.row); if (INTEL_INFO(dev)->gen >= 6) { err_printf(m, "ERROR: 0x%08x\n", error->error); @@ -1233,7 +1235,7 @@ static void i915_capture_reg_state(struct drm_i915_private *dev_priv, error->eir = I915_READ(EIR); error->pgtbl_er = I915_READ(PGTBL_ER); - i915_get_extra_instdone(dev, error->extra_instdone); + i915_get_extra_instdone(dev, &error->extra_instdone); } static void i915_error_capture_msg(struct drm_device *dev, @@ -1382,20 +1384,29 @@ const char *i915_cache_level_str(struct drm_i915_private *i915, int type) } /* NB: please notice the memset */ -void i915_get_extra_instdone(struct drm_device *dev, uint32_t *instdone) +void i915_get_extra_instdone(struct drm_device *dev, + struct extra_instdone *extra) { struct drm_i915_private *dev_priv = dev->dev_private; - memset(instdone, 0, sizeof(*instdone) * I915_NUM_INSTDONE_REG); - if (IS_GEN2(dev) || IS_GEN3(dev)) - instdone[0] = I915_READ(GEN2_INSTDONE); - else if (IS_GEN4(dev) || IS_GEN5(dev) || IS_GEN6(dev)) { - instdone[0] = I915_READ(RING_INSTDONE(RENDER_RING_BASE)); - instdone[1] = I915_READ(GEN4_INSTDONE1); - } else if (INTEL_INFO(dev)->gen >= 7) { - instdone[0] = I915_READ(RING_INSTDONE(RENDER_RING_BASE)); - instdone[1] = I915_READ(GEN7_SC_INSTDONE); - instdone[2] = I915_READ(GEN7_SAMPLER_INSTDONE); - instdone[3] = I915_READ(GEN7_ROW_INSTDONE); + /* + * The render INSTDONE register (GEN2_INSTDONE, RING_INSTDONE) is read + * by the ring collection. + */ + switch (INTEL_INFO(dev)->gen) { + default: + extra->slice_common = I915_READ(GEN7_SC_INSTDONE); + extra->sampler = I915_READ(GEN7_SAMPLER_INSTDONE); + extra->row = I915_READ(GEN7_ROW_INSTDONE); + break; + case 6: + case 5: + case 4: + /* HACK: Using the wrong struct member */ + extra->slice_common = I915_READ(GEN4_INSTDONE1); + break; + case 3: + case 2: + break; } } diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c index 76bd40e..8a3dc73 100644 --- a/drivers/gpu/drm/i915/i915_irq.c +++ b/drivers/gpu/drm/i915/i915_irq.c @@ -2473,19 +2473,32 @@ static void i915_reset_and_wakeup(struct drm_device *dev) } } +static inline void +i915_err_print_instdone(uint32_t render, struct extra_instdone *extra) +{ + pr_err(" INSTDONE (render): 0x%08x\n", render); + pr_err(" INSTDONE (common): 0x%08x\n", extra->slice_common); + pr_err(" INSTDONE (sampler): 0x%08x\n", extra->sampler); + pr_err(" INSTDONE (row): 0x%08x\n", extra->row); +} + static void i915_report_and_clear_eir(struct drm_device *dev) { struct drm_i915_private *dev_priv = dev->dev_private; - uint32_t instdone[I915_NUM_INSTDONE_REG]; + u32 render_instdone; + struct extra_instdone extra = {0}; u32 eir = I915_READ(EIR); - int pipe, i; + int pipe; if (!eir) return; pr_err("render error detected, EIR: 0x%08x\n", eir); - i915_get_extra_instdone(dev, instdone); + render_instdone = I915_READ(INTEL_INFO(dev)->gen < 4 ? + GEN2_INSTDONE : + RING_INSTDONE(RENDER_RING_BASE)); + i915_get_extra_instdone(dev, &extra); if (IS_G4X(dev)) { if (eir & (GM45_ERROR_MEM_PRIV | GM45_ERROR_CP_PRIV)) { @@ -2493,8 +2506,7 @@ static void i915_report_and_clear_eir(struct drm_device *dev) pr_err(" IPEIR: 0x%08x\n", I915_READ(IPEIR_I965)); pr_err(" IPEHR: 0x%08x\n", I915_READ(IPEHR_I965)); - for (i = 0; i < ARRAY_SIZE(instdone); i++) - pr_err(" INSTDONE_%d: 0x%08x\n", i, instdone[i]); + i915_err_print_instdone(render_instdone, &extra); pr_err(" INSTPS: 0x%08x\n", I915_READ(INSTPS)); pr_err(" ACTHD: 0x%08x\n", I915_READ(ACTHD_I965)); I915_WRITE(IPEIR_I965, ipeir); @@ -2529,8 +2541,7 @@ static void i915_report_and_clear_eir(struct drm_device *dev) if (eir & I915_ERROR_INSTRUCTION) { pr_err("instruction error\n"); pr_err(" INSTPM: 0x%08x\n", I915_READ(INSTPM)); - for (i = 0; i < ARRAY_SIZE(instdone); i++) - pr_err(" INSTDONE_%d: 0x%08x\n", i, instdone[i]); + i915_err_print_instdone(render_instdone, &extra); if (INTEL_INFO(dev)->gen < 4) { u32 ipeir = I915_READ(IPEIR); diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index c12f3b8..ac5f49a 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h @@ -1596,7 +1596,6 @@ enum skl_disp_power_wells { #define GEN7_SC_INSTDONE 0x07100 #define GEN7_SAMPLER_INSTDONE 0x0e160 #define GEN7_ROW_INSTDONE 0x0e164 -#define I915_NUM_INSTDONE_REG 4 #define RING_IPEIR(base) ((base)+0x64) #define RING_IPEHR(base) ((base)+0x68) /* -- 2.1.4 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/intel-gfx