Skip to content

Commit dffa8fe

Browse files
committed
drm/i915/perf: Assert locking for i915_init_oa_perf_state()
We use the context->pin_mutex to serialise updates to the OA config and the registers values written into each new context. Document this relationship and assert we do hold the context->pin_mutex as used by gen8_configure_all_contexts() to serialise updates to the OA config itself. v2: Add a white-lie for when we call intel_gt_resume() from init. v3: Lie while we have the context pinned inside atomic reset. Signed-off-by: Chris Wilson <[email protected]> Cc: Lionel Landwerlin <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]> #v1 Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 3d1da92 commit dffa8fe

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

drivers/gpu/drm/i915/gt/intel_gt_pm.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "i915_drv.h"
88
#include "i915_params.h"
9+
#include "intel_context.h"
910
#include "intel_engine_pm.h"
1011
#include "intel_gt.h"
1112
#include "intel_gt_pm.h"
@@ -142,8 +143,12 @@ int intel_gt_resume(struct intel_gt *gt)
142143
intel_engine_pm_get(engine);
143144

144145
ce = engine->kernel_context;
145-
if (ce)
146+
if (ce) {
147+
GEM_BUG_ON(!intel_context_is_pinned(ce));
148+
mutex_acquire(&ce->pin_mutex.dep_map, 0, 0, _THIS_IP_);
146149
ce->ops->reset(ce);
150+
mutex_release(&ce->pin_mutex.dep_map, 0, _THIS_IP_);
151+
}
147152

148153
engine->serial++; /* kernel context lost */
149154
err = engine->resume(engine);

drivers/gpu/drm/i915/gt/intel_lrc.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2383,6 +2383,11 @@ static void __execlists_reset(struct intel_engine_cs *engine, bool stalled)
23832383
ce = rq->hw_context;
23842384
GEM_BUG_ON(i915_active_is_idle(&ce->active));
23852385
GEM_BUG_ON(!i915_vma_is_pinned(ce->state));
2386+
2387+
/* Proclaim we have exclusive access to the context image! */
2388+
GEM_BUG_ON(!intel_context_is_pinned(ce));
2389+
mutex_acquire(&ce->pin_mutex.dep_map, 2, 0, _THIS_IP_);
2390+
23862391
rq = active_request(rq);
23872392
if (!rq) {
23882393
ce->ring->head = ce->ring->tail;
@@ -2442,6 +2447,7 @@ static void __execlists_reset(struct intel_engine_cs *engine, bool stalled)
24422447
engine->name, ce->ring->head, ce->ring->tail);
24432448
intel_ring_update_space(ce->ring);
24442449
__execlists_update_reg_state(ce, engine);
2450+
mutex_release(&ce->pin_mutex.dep_map, 0, _THIS_IP_);
24452451

24462452
unwind:
24472453
/* Push back any incomplete requests for replay after the reset. */
@@ -3920,6 +3926,9 @@ void intel_lr_context_reset(struct intel_engine_cs *engine,
39203926
u32 head,
39213927
bool scrub)
39223928
{
3929+
GEM_BUG_ON(!intel_context_is_pinned(ce));
3930+
mutex_acquire(&ce->pin_mutex.dep_map, 2, 0, _THIS_IP_);
3931+
39233932
/*
39243933
* We want a simple context + ring to execute the breadcrumb update.
39253934
* We cannot rely on the context being intact across the GPU hang,
@@ -3944,6 +3953,7 @@ void intel_lr_context_reset(struct intel_engine_cs *engine,
39443953
intel_ring_update_space(ce->ring);
39453954

39463955
__execlists_update_reg_state(ce, engine);
3956+
mutex_release(&ce->pin_mutex.dep_map, 0, _THIS_IP_);
39473957
}
39483958

39493959
#if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)

drivers/gpu/drm/i915/i915_perf.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2305,6 +2305,9 @@ void i915_oa_init_reg_state(struct intel_engine_cs *engine,
23052305
{
23062306
struct i915_perf_stream *stream;
23072307

2308+
/* perf.exclusive_stream serialised by gen8_configure_all_contexts() */
2309+
lockdep_assert_held(&ce->pin_mutex);
2310+
23082311
if (engine->class != RENDER_CLASS)
23092312
return;
23102313

0 commit comments

Comments
 (0)