From 9310ae6f689da1d2872accdcbb73498394e38798 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 22 Aug 2019 16:52:52 -0700 Subject: [PATCH] iris: Set MOCS in all STATE_BASE_ADDRESS commands Rafael Antognolli tracked down a performance gap between i965 and iris in Synmark2's OglCSDof microbenchmark, noting that iris was performing substantially more memory reads and writes, with substantially fewer L3 hits. He suggested that something might be wrong with MOCS, or L3 configs, at which point I came up with a theory... It would appear that the STATE_BASE_ADDRESS command updates the MOCS settings for various base addresses even if you don't specify the "Modify Enable" bit for that address. Until now, we had been setting only the MOCS for bases we intended to change, leaving the others "blank" which is MOCS table entry 0, which is uncached. Most data access has a more specific MOCS (e.g. in SURFACE_STATE), but scratch access uses the Stateless Data Port Access MOCS from STATE_BASE_ADDRESS. So this meant all scratch access was uncached. Improves performance in Synmark2's OglCSDof by 2x, bringing iris on par with the existing i965 driver. Reviewed-by: Jason Ekstrand Reviewed-by: Lionel Landwerlin --- src/gallium/drivers/iris/iris_state.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c index 02b8683..592718d 100644 --- a/src/gallium/drivers/iris/iris_state.c +++ b/src/gallium/drivers/iris/iris_state.c @@ -528,6 +528,7 @@ init_state_base_address(struct iris_batch *batch) sba.DynamicStateMOCS = MOCS_WB; sba.IndirectObjectMOCS = MOCS_WB; sba.InstructionMOCS = MOCS_WB; + sba.SurfaceStateMOCS = MOCS_WB; sba.GeneralStateBaseAddressModifyEnable = true; sba.DynamicStateBaseAddressModifyEnable = true; @@ -4568,9 +4569,21 @@ iris_update_surface_base_address(struct iris_batch *batch, flush_for_state_base_change(batch); iris_emit_cmd(batch, GENX(STATE_BASE_ADDRESS), sba) { - sba.SurfaceStateMOCS = MOCS_WB; sba.SurfaceStateBaseAddressModifyEnable = true; sba.SurfaceStateBaseAddress = ro_bo(binder->bo, 0); + + /* The hardware appears to pay attention to the MOCS fields even + * if you don't set the "Address Modify Enable" bit for the base. + */ + sba.GeneralStateMOCS = MOCS_WB; + sba.StatelessDataPortAccessMOCS = MOCS_WB; + sba.DynamicStateMOCS = MOCS_WB; + sba.IndirectObjectMOCS = MOCS_WB; + sba.InstructionMOCS = MOCS_WB; + sba.SurfaceStateMOCS = MOCS_WB; +#if GEN_GEN >= 9 + sba.BindlessSurfaceStateMOCS = MOCS_WB; +#endif } batch->last_surface_base_address = binder->bo->gtt_offset; -- 2.7.4