@@ -2101,9 +2101,6 @@ static void gen8_update_reg_state_unlocked(struct intel_engine_cs *engine,
21012101 int ctx_flexeu0 = dev_priv -> perf .oa .ctx_flexeu0_off ;
21022102 int i ;
21032103
2104- if (!atomic_read (& ctx -> engine [engine -> id ].oa_state_dirty ))
2105- return ;
2106-
21072104 reg_state [ctx_oactxctrl ] = i915_mmio_reg_offset (GEN8_OACTXCONTROL );
21082105 reg_state [ctx_oactxctrl + 1 ] = (dev_priv -> perf .oa .period_exponent <<
21092106 GEN8_OA_TIMER_PERIOD_SHIFT ) |
@@ -2154,7 +2151,28 @@ void i915_oa_update_reg_state(struct intel_engine_cs *engine,
21542151 * update the state if the OA unit has been disabled since
21552152 * oa_state_dirty was last set.
21562153 */
2154+ if (atomic_read (& ctx -> engine [engine -> id ].oa_state_dirty ))
2155+ gen8_update_reg_state_unlocked (engine , ctx , reg_state );
2156+ }
2157+
2158+ void i915_oa_init_reg_state (struct intel_engine_cs * engine ,
2159+ struct i915_gem_context * ctx ,
2160+ uint32_t * reg_state )
2161+ {
2162+ struct drm_i915_private * dev_priv = engine -> i915 ;
2163+
2164+ if (!dev_priv -> perf .initialized )
2165+ return ;
21572166
2167+ /* XXX: We don't take a lock here and this may run async with
2168+ * respect to stream methods. Notably we don't want to block
2169+ * context switches by long i915 perf read() operations.
2170+ *
2171+ * It's expect to always be safe to read the dev_priv->perf
2172+ * state needed here, and expected to be benign to redundantly
2173+ * update the state if the OA unit has been disabled since
2174+ * oa_state_dirty was last set.
2175+ */
21582176 gen8_update_reg_state_unlocked (engine , ctx , reg_state );
21592177}
21602178
0 commit comments