Re: [Intel-gfx] [PATCH v2] drm/i915/mtl: Add initial gt workarounds

2023-01-05 Thread Matt Atwood
On Tue, Jan 03, 2023 at 04:18:27PM -0800, Matt Roper wrote:
> On Thu, Dec 15, 2022 at 03:30:55PM -0800, Matt Atwood wrote:
> > From: Matt Roper 
> > 
> > This patch introduces initial gt workarounds for the MTL platform.
> > 
> > v2: drop redundant/stale comments specifying wa platforms affected
> 
> This is being discussed on the other thread, but it also doesn't look
> like this actually happened completely in v2 here.  You removed a few
> but most of the workarounds still have them?
Ack.
> 
> > (Lucas). Drop Wa_22011802037 for MTL.
> 
> This statement doesn't seem right...Wa_22011802037 is still (correctly)
> present for the affected variant/steppings of MTL.
You're right.
> 
> 
> Matt
> 
> > 
> > Bspec: 66622
> > 
> > Signed-off-by: Matt Atwood 
> > Signed-off-by: Matt Roper 
> > ---
> >  drivers/gpu/drm/i915/gt/intel_engine_cs.c |   6 +-
> >  .../drm/i915/gt/intel_execlists_submission.c  |   6 +-
> >  drivers/gpu/drm/i915/gt/intel_gt_mcr.c|  11 +-
> >  drivers/gpu/drm/i915/gt/intel_gt_regs.h   |   5 +
> >  drivers/gpu/drm/i915/gt/intel_workarounds.c   | 115 +-
> >  drivers/gpu/drm/i915/gt/uc/intel_guc.c|   9 +-
> >  .../gpu/drm/i915/gt/uc/intel_guc_submission.c |   8 +-
> >  drivers/gpu/drm/i915/i915_drv.h   |   4 +
> >  drivers/gpu/drm/i915/intel_device_info.c  |   6 +
> >  9 files changed, 128 insertions(+), 42 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c 
> > b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> > index 99c4b866addd..e3f30bdf7e61 100644
> > --- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> > +++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> > @@ -1494,10 +1494,12 @@ static int __intel_engine_stop_cs(struct 
> > intel_engine_cs *engine,
> > intel_uncore_write_fw(uncore, mode, _MASKED_BIT_ENABLE(STOP_RING));
> >  
> > /*
> > -* Wa_22011802037 : gen11, gen12, Prior to doing a reset, ensure CS is
> > +* Wa_22011802037 : Prior to doing a reset, ensure CS is
> >  * stopped, set ring stop bit and prefetch disable bit to halt CS
> >  */
> > -   if (IS_GRAPHICS_VER(engine->i915, 11, 12))
> > +   if (IS_MTL_GRAPHICS_STEP(engine->i915, M, STEP_A0, STEP_B0) ||
> > +   (GRAPHICS_VER(engine->i915) >= 11 &&
> > +   GRAPHICS_VER_FULL(engine->i915) < IP_VER(12, 70)))
> > intel_uncore_write_fw(uncore, RING_MODE_GEN7(engine->mmio_base),
> >   
> > _MASKED_BIT_ENABLE(GEN12_GFX_PREFETCH_DISABLE));
> >  
> > diff --git a/drivers/gpu/drm/i915/gt/intel_execlists_submission.c 
> > b/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
> > index 49a8f10d76c7..c14476c777cc 100644
> > --- a/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
> > +++ b/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
> > @@ -2989,10 +2989,12 @@ static void execlists_reset_prepare(struct 
> > intel_engine_cs *engine)
> > intel_engine_stop_cs(engine);
> >  
> > /*
> > -* Wa_22011802037:gen11/gen12: In addition to stopping the cs, we need
> > +* Wa_22011802037: In addition to stopping the cs, we need
> >  * to wait for any pending mi force wakeups
> >  */
> > -   if (IS_GRAPHICS_VER(engine->i915, 11, 12))
> > +   if (IS_MTL_GRAPHICS_STEP(engine->i915, M, STEP_A0, STEP_B0) ||
> > +   (GRAPHICS_VER(engine->i915) >= 11 &&
> > +   GRAPHICS_VER_FULL(engine->i915) < IP_VER(12, 70)))
> > intel_engine_wait_for_pending_mi_fw(engine);
> >  
> > engine->execlists.reset_ccid = active_ccid(engine);
> > diff --git a/drivers/gpu/drm/i915/gt/intel_gt_mcr.c 
> > b/drivers/gpu/drm/i915/gt/intel_gt_mcr.c
> > index 41a237509dcf..4127830c33ca 100644
> > --- a/drivers/gpu/drm/i915/gt/intel_gt_mcr.c
> > +++ b/drivers/gpu/drm/i915/gt/intel_gt_mcr.c
> > @@ -164,8 +164,15 @@ void intel_gt_mcr_init(struct intel_gt *gt)
> > if (MEDIA_VER(i915) >= 13 && gt->type == GT_MEDIA) {
> > gt->steering_table[OADDRM] = xelpmp_oaddrm_steering_table;
> > } else if (GRAPHICS_VER_FULL(i915) >= IP_VER(12, 70)) {
> > -   fuse = REG_FIELD_GET(GT_L3_EXC_MASK,
> > -intel_uncore_read(gt->uncore, XEHP_FUSE4));
> > +   /* Wa_14016747170 */
> > +   if (IS_MTL_GRAPHICS_STEP(i915, M, STEP_A0, STEP_B0) ||
> > +   IS_MTL_GRAPHICS_STEP(i915, P, STEP_A0, STEP_B0))
> > +   fuse = REG_FIELD_GET(MTL_GT_L3_EXC_MASK,
> > +intel_uncore_read(gt->uncore,
> > +  
> > MTL_GT_ACTIVITY_FACTOR));
> > +   else
> > +   fuse = REG_FIELD_GET(GT_L3_EXC_MASK,
> > +intel_uncore_read(gt->uncore, 
> > XEHP_FUSE4));
> >  
> > /*
> >  * Despite the register field being named "exclude mask" the
> > diff --git a/drivers/gpu/drm/i915/gt/intel_gt_regs.h 
> > b/drivers/gpu/drm/i915/gt/intel_gt_regs.h
> > index f8eb807b56f9..470

Re: [Intel-gfx] [PATCH v2] drm/i915/mtl: Add initial gt workarounds

2023-01-03 Thread Matt Roper
On Thu, Dec 15, 2022 at 03:30:55PM -0800, Matt Atwood wrote:
> From: Matt Roper 
> 
> This patch introduces initial gt workarounds for the MTL platform.
> 
> v2: drop redundant/stale comments specifying wa platforms affected

This is being discussed on the other thread, but it also doesn't look
like this actually happened completely in v2 here.  You removed a few
but most of the workarounds still have them?

> (Lucas). Drop Wa_22011802037 for MTL.

This statement doesn't seem right...Wa_22011802037 is still (correctly)
present for the affected variant/steppings of MTL.


Matt

> 
> Bspec: 66622
> 
> Signed-off-by: Matt Atwood 
> Signed-off-by: Matt Roper 
> ---
>  drivers/gpu/drm/i915/gt/intel_engine_cs.c |   6 +-
>  .../drm/i915/gt/intel_execlists_submission.c  |   6 +-
>  drivers/gpu/drm/i915/gt/intel_gt_mcr.c|  11 +-
>  drivers/gpu/drm/i915/gt/intel_gt_regs.h   |   5 +
>  drivers/gpu/drm/i915/gt/intel_workarounds.c   | 115 +-
>  drivers/gpu/drm/i915/gt/uc/intel_guc.c|   9 +-
>  .../gpu/drm/i915/gt/uc/intel_guc_submission.c |   8 +-
>  drivers/gpu/drm/i915/i915_drv.h   |   4 +
>  drivers/gpu/drm/i915/intel_device_info.c  |   6 +
>  9 files changed, 128 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c 
> b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> index 99c4b866addd..e3f30bdf7e61 100644
> --- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> +++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> @@ -1494,10 +1494,12 @@ static int __intel_engine_stop_cs(struct 
> intel_engine_cs *engine,
>   intel_uncore_write_fw(uncore, mode, _MASKED_BIT_ENABLE(STOP_RING));
>  
>   /*
> -  * Wa_22011802037 : gen11, gen12, Prior to doing a reset, ensure CS is
> +  * Wa_22011802037 : Prior to doing a reset, ensure CS is
>* stopped, set ring stop bit and prefetch disable bit to halt CS
>*/
> - if (IS_GRAPHICS_VER(engine->i915, 11, 12))
> + if (IS_MTL_GRAPHICS_STEP(engine->i915, M, STEP_A0, STEP_B0) ||
> + (GRAPHICS_VER(engine->i915) >= 11 &&
> + GRAPHICS_VER_FULL(engine->i915) < IP_VER(12, 70)))
>   intel_uncore_write_fw(uncore, RING_MODE_GEN7(engine->mmio_base),
> 
> _MASKED_BIT_ENABLE(GEN12_GFX_PREFETCH_DISABLE));
>  
> diff --git a/drivers/gpu/drm/i915/gt/intel_execlists_submission.c 
> b/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
> index 49a8f10d76c7..c14476c777cc 100644
> --- a/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
> +++ b/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
> @@ -2989,10 +2989,12 @@ static void execlists_reset_prepare(struct 
> intel_engine_cs *engine)
>   intel_engine_stop_cs(engine);
>  
>   /*
> -  * Wa_22011802037:gen11/gen12: In addition to stopping the cs, we need
> +  * Wa_22011802037: In addition to stopping the cs, we need
>* to wait for any pending mi force wakeups
>*/
> - if (IS_GRAPHICS_VER(engine->i915, 11, 12))
> + if (IS_MTL_GRAPHICS_STEP(engine->i915, M, STEP_A0, STEP_B0) ||
> + (GRAPHICS_VER(engine->i915) >= 11 &&
> + GRAPHICS_VER_FULL(engine->i915) < IP_VER(12, 70)))
>   intel_engine_wait_for_pending_mi_fw(engine);
>  
>   engine->execlists.reset_ccid = active_ccid(engine);
> diff --git a/drivers/gpu/drm/i915/gt/intel_gt_mcr.c 
> b/drivers/gpu/drm/i915/gt/intel_gt_mcr.c
> index 41a237509dcf..4127830c33ca 100644
> --- a/drivers/gpu/drm/i915/gt/intel_gt_mcr.c
> +++ b/drivers/gpu/drm/i915/gt/intel_gt_mcr.c
> @@ -164,8 +164,15 @@ void intel_gt_mcr_init(struct intel_gt *gt)
>   if (MEDIA_VER(i915) >= 13 && gt->type == GT_MEDIA) {
>   gt->steering_table[OADDRM] = xelpmp_oaddrm_steering_table;
>   } else if (GRAPHICS_VER_FULL(i915) >= IP_VER(12, 70)) {
> - fuse = REG_FIELD_GET(GT_L3_EXC_MASK,
> -  intel_uncore_read(gt->uncore, XEHP_FUSE4));
> + /* Wa_14016747170 */
> + if (IS_MTL_GRAPHICS_STEP(i915, M, STEP_A0, STEP_B0) ||
> + IS_MTL_GRAPHICS_STEP(i915, P, STEP_A0, STEP_B0))
> + fuse = REG_FIELD_GET(MTL_GT_L3_EXC_MASK,
> +  intel_uncore_read(gt->uncore,
> +
> MTL_GT_ACTIVITY_FACTOR));
> + else
> + fuse = REG_FIELD_GET(GT_L3_EXC_MASK,
> +  intel_uncore_read(gt->uncore, 
> XEHP_FUSE4));
>  
>   /*
>* Despite the register field being named "exclude mask" the
> diff --git a/drivers/gpu/drm/i915/gt/intel_gt_regs.h 
> b/drivers/gpu/drm/i915/gt/intel_gt_regs.h
> index f8eb807b56f9..470d6feb456a 100644
> --- a/drivers/gpu/drm/i915/gt/intel_gt_regs.h
> +++ b/drivers/gpu/drm/i915/gt/intel_gt_regs.h
> @@ -414,6 +414,7 @@
>  #define   TBIMR_FAST_CLIPREG_BIT(5)
>  
>  #define VFLS

[Intel-gfx] [PATCH v2] drm/i915/mtl: Add initial gt workarounds

2022-12-15 Thread Matt Atwood
From: Matt Roper 

This patch introduces initial gt workarounds for the MTL platform.

v2: drop redundant/stale comments specifying wa platforms affected
(Lucas). Drop Wa_22011802037 for MTL.

Bspec: 66622

Signed-off-by: Matt Atwood 
Signed-off-by: Matt Roper 
---
 drivers/gpu/drm/i915/gt/intel_engine_cs.c |   6 +-
 .../drm/i915/gt/intel_execlists_submission.c  |   6 +-
 drivers/gpu/drm/i915/gt/intel_gt_mcr.c|  11 +-
 drivers/gpu/drm/i915/gt/intel_gt_regs.h   |   5 +
 drivers/gpu/drm/i915/gt/intel_workarounds.c   | 115 +-
 drivers/gpu/drm/i915/gt/uc/intel_guc.c|   9 +-
 .../gpu/drm/i915/gt/uc/intel_guc_submission.c |   8 +-
 drivers/gpu/drm/i915/i915_drv.h   |   4 +
 drivers/gpu/drm/i915/intel_device_info.c  |   6 +
 9 files changed, 128 insertions(+), 42 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c 
b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
index 99c4b866addd..e3f30bdf7e61 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
@@ -1494,10 +1494,12 @@ static int __intel_engine_stop_cs(struct 
intel_engine_cs *engine,
intel_uncore_write_fw(uncore, mode, _MASKED_BIT_ENABLE(STOP_RING));
 
/*
-* Wa_22011802037 : gen11, gen12, Prior to doing a reset, ensure CS is
+* Wa_22011802037 : Prior to doing a reset, ensure CS is
 * stopped, set ring stop bit and prefetch disable bit to halt CS
 */
-   if (IS_GRAPHICS_VER(engine->i915, 11, 12))
+   if (IS_MTL_GRAPHICS_STEP(engine->i915, M, STEP_A0, STEP_B0) ||
+   (GRAPHICS_VER(engine->i915) >= 11 &&
+   GRAPHICS_VER_FULL(engine->i915) < IP_VER(12, 70)))
intel_uncore_write_fw(uncore, RING_MODE_GEN7(engine->mmio_base),
  
_MASKED_BIT_ENABLE(GEN12_GFX_PREFETCH_DISABLE));
 
diff --git a/drivers/gpu/drm/i915/gt/intel_execlists_submission.c 
b/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
index 49a8f10d76c7..c14476c777cc 100644
--- a/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
+++ b/drivers/gpu/drm/i915/gt/intel_execlists_submission.c
@@ -2989,10 +2989,12 @@ static void execlists_reset_prepare(struct 
intel_engine_cs *engine)
intel_engine_stop_cs(engine);
 
/*
-* Wa_22011802037:gen11/gen12: In addition to stopping the cs, we need
+* Wa_22011802037: In addition to stopping the cs, we need
 * to wait for any pending mi force wakeups
 */
-   if (IS_GRAPHICS_VER(engine->i915, 11, 12))
+   if (IS_MTL_GRAPHICS_STEP(engine->i915, M, STEP_A0, STEP_B0) ||
+   (GRAPHICS_VER(engine->i915) >= 11 &&
+   GRAPHICS_VER_FULL(engine->i915) < IP_VER(12, 70)))
intel_engine_wait_for_pending_mi_fw(engine);
 
engine->execlists.reset_ccid = active_ccid(engine);
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_mcr.c 
b/drivers/gpu/drm/i915/gt/intel_gt_mcr.c
index 41a237509dcf..4127830c33ca 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_mcr.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt_mcr.c
@@ -164,8 +164,15 @@ void intel_gt_mcr_init(struct intel_gt *gt)
if (MEDIA_VER(i915) >= 13 && gt->type == GT_MEDIA) {
gt->steering_table[OADDRM] = xelpmp_oaddrm_steering_table;
} else if (GRAPHICS_VER_FULL(i915) >= IP_VER(12, 70)) {
-   fuse = REG_FIELD_GET(GT_L3_EXC_MASK,
-intel_uncore_read(gt->uncore, XEHP_FUSE4));
+   /* Wa_14016747170 */
+   if (IS_MTL_GRAPHICS_STEP(i915, M, STEP_A0, STEP_B0) ||
+   IS_MTL_GRAPHICS_STEP(i915, P, STEP_A0, STEP_B0))
+   fuse = REG_FIELD_GET(MTL_GT_L3_EXC_MASK,
+intel_uncore_read(gt->uncore,
+  
MTL_GT_ACTIVITY_FACTOR));
+   else
+   fuse = REG_FIELD_GET(GT_L3_EXC_MASK,
+intel_uncore_read(gt->uncore, 
XEHP_FUSE4));
 
/*
 * Despite the register field being named "exclude mask" the
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_regs.h 
b/drivers/gpu/drm/i915/gt/intel_gt_regs.h
index f8eb807b56f9..470d6feb456a 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_regs.h
+++ b/drivers/gpu/drm/i915/gt/intel_gt_regs.h
@@ -414,6 +414,7 @@
 #define   TBIMR_FAST_CLIP  REG_BIT(5)
 
 #define VFLSKPDMCR_REG(0x62a8)
+#define   VF_PREFETCH_TLB_DIS  REG_BIT(5)
 #define   DIS_OVER_FETCH_CACHE REG_BIT(1)
 #define   DIS_MULT_MISS_RD_SQUASH  REG_BIT(0)
 
@@ -1535,6 +1536,10 @@
 
 #define MTL_MEDIA_MC6  _MMIO(0x138048)
 
+/* Wa_14016747170:mtl-p[a0], mtl-m[a0] */
+#define MTL_GT_ACTIVITY_FACTOR _MMIO(0x138010)
+#define   MTL_GT_L3_EXC_MASK   REG_GENMASK(5,