drivers/gpu/drm/i915/gt/intel_context.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/gt/intel_context.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/gt/intel_context.c- Extension
.c- Size
- 14868 bytes
- Lines
- 651
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
gem/i915_gem_context.hgem/i915_gem_pm.hi915_drm_client.hi915_drv.hi915_trace.hintel_context.hintel_engine.hintel_engine_pm.hintel_ring.hselftest_context.c
Detected Declarations
function rcu_context_freefunction intel_context_freefunction intel_context_createfunction intel_context_alloc_statefunction intel_context_active_acquirefunction intel_context_active_releasefunction __context_pin_statefunction __context_unpin_statefunction __ring_activefunction __ring_retirefunction intel_context_pre_pinfunction intel_context_post_unpinfunction __intel_context_do_pin_wwfunction __intel_context_do_pinfunction __intel_context_do_unpinfunction __intel_context_retirefunction __intel_context_activefunction sw_fence_dummy_notifyfunction intel_context_initfunction intel_context_finifunction i915_context_module_exitfunction i915_context_module_initfunction intel_context_enter_enginefunction intel_context_exit_enginefunction intel_context_prepare_remote_requestfunction intel_context_bind_parent_childfunction intel_context_get_total_runtime_nsfunction intel_context_get_avg_runtime_nsfunction intel_context_banfunction intel_context_revoke
Annotated Snippet
if (intel_context_is_banned(ce)) {
err = -EIO;
goto unlock;
}
err = ce->ops->alloc(ce);
if (unlikely(err))
goto unlock;
set_bit(CONTEXT_ALLOC_BIT, &ce->flags);
rcu_read_lock();
ctx = rcu_dereference(ce->gem_context);
if (ctx && !kref_get_unless_zero(&ctx->ref))
ctx = NULL;
rcu_read_unlock();
if (ctx) {
if (ctx->client)
i915_drm_client_add_context_objects(ctx->client,
ce);
i915_gem_context_put(ctx);
}
}
unlock:
mutex_unlock(&ce->pin_mutex);
return err;
}
static int intel_context_active_acquire(struct intel_context *ce)
{
int err;
__i915_active_acquire(&ce->active);
if (intel_context_is_barrier(ce) || intel_engine_uses_guc(ce->engine) ||
intel_context_is_parallel(ce))
return 0;
/* Preallocate tracking nodes */
err = i915_active_acquire_preallocate_barrier(&ce->active,
ce->engine);
if (err)
i915_active_release(&ce->active);
return err;
}
static void intel_context_active_release(struct intel_context *ce)
{
/* Nodes preallocated in intel_context_active() */
i915_active_acquire_barrier(&ce->active);
i915_active_release(&ce->active);
}
static int __context_pin_state(struct i915_vma *vma, struct i915_gem_ww_ctx *ww)
{
unsigned int bias = i915_ggtt_pin_bias(vma) | PIN_OFFSET_BIAS;
int err;
err = i915_ggtt_pin(vma, ww, 0, bias | PIN_HIGH);
if (err)
return err;
err = i915_active_acquire(&vma->active);
if (err)
goto err_unpin;
/*
* And mark it as a globally pinned object to let the shrinker know
* it cannot reclaim the object until we release it.
*/
i915_vma_make_unshrinkable(vma);
vma->obj->mm.dirty = true;
return 0;
err_unpin:
i915_vma_unpin(vma);
return err;
}
static void __context_unpin_state(struct i915_vma *vma)
{
i915_vma_make_shrinkable(vma);
i915_active_release(&vma->active);
__i915_vma_unpin(vma);
}
static int __ring_active(struct intel_ring *ring,
Annotation
- Immediate include surface: `gem/i915_gem_context.h`, `gem/i915_gem_pm.h`, `i915_drm_client.h`, `i915_drv.h`, `i915_trace.h`, `intel_context.h`, `intel_engine.h`, `intel_engine_pm.h`.
- Detected declarations: `function rcu_context_free`, `function intel_context_free`, `function intel_context_create`, `function intel_context_alloc_state`, `function intel_context_active_acquire`, `function intel_context_active_release`, `function __context_pin_state`, `function __context_unpin_state`, `function __ring_active`, `function __ring_retire`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.