iris: Set MOCS in all STATE_BASE_ADDRESS commands
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 22 Aug 2019 23:52:52 +0000 (16:52 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Fri, 23 Aug 2019 17:21:48 +0000 (10:21 -0700)
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 <jason@jlekstrand.net>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/gallium/drivers/iris/iris_state.c

index 02b8683..592718d 100644 (file)
@@ -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;