Skip to content

Commit 207e4a7

Browse files
committed
drm/i915: Use explicit flag to mark unreachable intel_context
I need to keep the GEM context around a bit longer so adding an explicit flag for syncing execbuf with closed/abandonded contexts. v2: * Use already available context flags. (Chris) Signed-off-by: Tvrtko Ursulin <[email protected]> Reviewed-by: Chris Wilson <[email protected]> Signed-off-by: Chris Wilson <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 2386b49 commit 207e4a7

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

drivers/gpu/drm/i915/gem/i915_gem_context.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ static void engines_idle_release(struct i915_gem_context *ctx,
574574
int err = 0;
575575

576576
/* serialises with execbuf */
577-
RCU_INIT_POINTER(ce->gem_context, NULL);
577+
set_bit(CONTEXT_CLOSED_BIT, &ce->flags);
578578
if (!intel_context_pin_if_active(ce))
579579
continue;
580580

drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2316,7 +2316,7 @@ static void eb_request_add(struct i915_execbuffer *eb)
23162316
prev = __i915_request_commit(rq);
23172317

23182318
/* Check that the context wasn't destroyed before submission */
2319-
if (likely(rcu_access_pointer(eb->context->gem_context))) {
2319+
if (likely(!intel_context_is_closed(eb->context))) {
23202320
attr = eb->gem_context->sched;
23212321

23222322
/*

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ int __intel_context_do_pin(struct intel_context *ce)
9797
{
9898
int err;
9999

100+
GEM_BUG_ON(intel_context_is_closed(ce));
101+
100102
if (unlikely(!test_bit(CONTEXT_ALLOC_BIT, &ce->flags))) {
101103
err = intel_context_alloc_state(ce);
102104
if (err)

drivers/gpu/drm/i915/gt/intel_context.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ static inline bool intel_context_is_barrier(const struct intel_context *ce)
173173
return test_bit(CONTEXT_BARRIER_BIT, &ce->flags);
174174
}
175175

176+
static inline bool intel_context_is_closed(const struct intel_context *ce)
177+
{
178+
return test_bit(CONTEXT_CLOSED_BIT, &ce->flags);
179+
}
180+
176181
static inline bool intel_context_use_semaphores(const struct intel_context *ce)
177182
{
178183
return test_bit(CONTEXT_USE_SEMAPHORES, &ce->flags);

drivers/gpu/drm/i915/gt/intel_context_types.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,11 @@ struct intel_context {
6262
#define CONTEXT_BARRIER_BIT 0
6363
#define CONTEXT_ALLOC_BIT 1
6464
#define CONTEXT_VALID_BIT 2
65-
#define CONTEXT_USE_SEMAPHORES 3
66-
#define CONTEXT_BANNED 4
67-
#define CONTEXT_FORCE_SINGLE_SUBMISSION 5
68-
#define CONTEXT_NOPREEMPT 6
65+
#define CONTEXT_CLOSED_BIT 3
66+
#define CONTEXT_USE_SEMAPHORES 4
67+
#define CONTEXT_BANNED 5
68+
#define CONTEXT_FORCE_SINGLE_SUBMISSION 6
69+
#define CONTEXT_NOPREEMPT 7
6970

7071
u32 *lrc_reg_state;
7172
u64 lrc_desc;

0 commit comments

Comments
 (0)