Skip to content

Commit 5152def

Browse files
mwiniarsickle
authored andcommitted
drm/i915/preempt: Default to disabled mid-command preemption levels
Supporting fine-granularity preemption levels may require changes in userspace batch buffer programming. Therefore, we need to fallback to safe default values, rather that use hardware defaults. Userspace is still able to enable fine-granularity, since we're whitelisting the register controlling it in WaEnablePreemptionGranularityControlByUMD. v2: Extend w/a to cover Cannonlake v3: Fix commentary to include both fake w/a names. Signed-off-by: Michał Winiarski <michal.winiarski@intel.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20171003203453.15692-2-chris@chris-wilson.co.uk
1 parent 1e99834 commit 5152def

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

drivers/gpu/drm/i915/i915_reg.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7003,6 +7003,12 @@ enum {
70037003
#define GEN9_CS_DEBUG_MODE1 _MMIO(0x20ec)
70047004
#define GEN9_CTX_PREEMPT_REG _MMIO(0x2248)
70057005
#define GEN8_CS_CHICKEN1 _MMIO(0x2580)
7006+
#define GEN9_PREEMPT_3D_OBJECT_LEVEL (1<<0)
7007+
#define GEN9_PREEMPT_GPGPU_LEVEL(hi, lo) (((hi) << 2) | ((lo) << 1))
7008+
#define GEN9_PREEMPT_GPGPU_MID_THREAD_LEVEL GEN9_PREEMPT_GPGPU_LEVEL(0, 0)
7009+
#define GEN9_PREEMPT_GPGPU_THREAD_GROUP_LEVEL GEN9_PREEMPT_GPGPU_LEVEL(0, 1)
7010+
#define GEN9_PREEMPT_GPGPU_COMMAND_LEVEL GEN9_PREEMPT_GPGPU_LEVEL(1, 0)
7011+
#define GEN9_PREEMPT_GPGPU_LEVEL_MASK GEN9_PREEMPT_GPGPU_LEVEL(1, 1)
70067012

70077013
/* GEN7 chicken */
70087014
#define GEN7_COMMON_SLICE_CHICKEN1 _MMIO(0x7010)

drivers/gpu/drm/i915/intel_engine_cs.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,24 @@ static int gen9_init_workarounds(struct intel_engine_cs *engine)
10701070
I915_WRITE(GEN8_L3SQCREG4, (I915_READ(GEN8_L3SQCREG4) |
10711071
GEN8_LQSC_FLUSH_COHERENT_LINES));
10721072

1073+
/*
1074+
* Supporting preemption with fine-granularity requires changes in the
1075+
* batch buffer programming. Since we can't break old userspace, we
1076+
* need to set our default preemption level to safe value. Userspace is
1077+
* still able to use more fine-grained preemption levels, since in
1078+
* WaEnablePreemptionGranularityControlByUMD we're whitelisting the
1079+
* per-ctx register. As such, WaDisable{3D,GPGPU}MidCmdPreemption are
1080+
* not real HW workarounds, but merely a way to start using preemption
1081+
* while maintaining old contract with userspace.
1082+
*/
1083+
1084+
/* WaDisable3DMidCmdPreemption:skl,bxt,glk,cfl,[cnl] */
1085+
WA_CLR_BIT_MASKED(GEN8_CS_CHICKEN1, GEN9_PREEMPT_3D_OBJECT_LEVEL);
1086+
1087+
/* WaDisableGPGPUMidCmdPreemption:skl,bxt,blk,cfl,[cnl] */
1088+
WA_SET_FIELD_MASKED(GEN8_CS_CHICKEN1, GEN9_PREEMPT_GPGPU_LEVEL_MASK,
1089+
GEN9_PREEMPT_GPGPU_COMMAND_LEVEL);
1090+
10731091
/* WaVFEStateAfterPipeControlwithMediaStateClear:skl,bxt,glk,cfl */
10741092
ret = wa_ring_whitelist_reg(engine, GEN9_CTX_PREEMPT_REG);
10751093
if (ret)
@@ -1271,6 +1289,13 @@ static int cnl_init_workarounds(struct intel_engine_cs *engine)
12711289
/* FtrEnableFastAnisoL1BankingFix: cnl */
12721290
WA_SET_BIT_MASKED(HALF_SLICE_CHICKEN3, CNL_FAST_ANISO_L1_BANKING_FIX);
12731291

1292+
/* WaDisable3DMidCmdPreemption:cnl */
1293+
WA_CLR_BIT_MASKED(GEN8_CS_CHICKEN1, GEN9_PREEMPT_3D_OBJECT_LEVEL);
1294+
1295+
/* WaDisableGPGPUMidCmdPreemption:cnl */
1296+
WA_SET_FIELD_MASKED(GEN8_CS_CHICKEN1, GEN9_PREEMPT_GPGPU_LEVEL_MASK,
1297+
GEN9_PREEMPT_GPGPU_COMMAND_LEVEL);
1298+
12741299
/* WaEnablePreemptionGranularityControlByUMD:cnl */
12751300
I915_WRITE(GEN7_FF_SLICE_CS_CHICKEN1,
12761301
_MASKED_BIT_ENABLE(GEN9_FFSC_PERCTX_PREEMPT_CTRL));

0 commit comments

Comments
 (0)