Skip to content

Commit 53e8178

Browse files
committed
gen8+ fix initialization of per-ctx OA state for new contexts
1 parent 7287862 commit 53e8178

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

drivers/gpu/drm/i915/i915_drv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3587,6 +3587,9 @@ i915_gem_context_lookup_timeline(struct i915_gem_context *ctx,
35873587

35883588
int i915_perf_open_ioctl(struct drm_device *dev, void *data,
35893589
struct drm_file *file);
3590+
void i915_oa_init_reg_state(struct intel_engine_cs *engine,
3591+
struct i915_gem_context *ctx,
3592+
uint32_t *reg_state);
35903593
void i915_oa_update_reg_state(struct intel_engine_cs *engine,
35913594
struct i915_gem_context *ctx,
35923595
uint32_t *reg_state);

drivers/gpu/drm/i915/i915_perf.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

drivers/gpu/drm/i915/intel_lrc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1901,7 +1901,7 @@ static void execlists_init_reg_state(u32 *regs,
19011901
make_rpcs(dev_priv));
19021902
}
19031903

1904-
i915_oa_update_reg_state(engine, ctx, regs);
1904+
i915_oa_init_reg_state(engine, ctx, regs);
19051905
}
19061906

19071907
static int

0 commit comments

Comments
 (0)