drivers/gpu/drm/i915/gt/mock_engine.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/gt/mock_engine.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/gt/mock_engine.c- Extension
.c- Size
- 10607 bytes
- Lines
- 446
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
gem/i915_gem_context.hgt/intel_ring.hi915_drv.hintel_context.hintel_engine_pm.hmock_engine.hselftests/mock_request.h
Detected Declarations
function mock_timeline_pinfunction mock_timeline_unpinfunction mock_ring_freefunction advancefunction hw_delay_completefunction mock_context_unpinfunction mock_context_destroyfunction mock_context_allocfunction mock_context_pre_pinfunction mock_context_pinfunction mock_context_resetfunction mock_request_allocfunction mock_emit_flushfunction mock_submit_requestfunction mock_add_to_enginefunction mock_remove_from_enginefunction mock_reset_preparefunction mock_reset_cancelfunction mock_reset_finishfunction mock_engine_initfunction mock_engine_flushfunction mock_engine_reset
Annotated Snippet
if (request->mock.delay) {
mod_timer(&engine->hw_delay,
jiffies + request->mock.delay);
break;
}
advance(request);
}
spin_unlock_irqrestore(&engine->hw_lock, flags);
}
static void mock_context_unpin(struct intel_context *ce)
{
}
static void mock_context_post_unpin(struct intel_context *ce)
{
i915_vma_unpin(ce->ring->vma);
}
static void mock_context_destroy(struct kref *ref)
{
struct intel_context *ce = container_of(ref, typeof(*ce), ref);
GEM_BUG_ON(intel_context_is_pinned(ce));
if (test_bit(CONTEXT_ALLOC_BIT, &ce->flags)) {
mock_ring_free(ce->ring);
mock_timeline_unpin(ce->timeline);
}
intel_context_fini(ce);
intel_context_free(ce);
}
static int mock_context_alloc(struct intel_context *ce)
{
int err;
ce->ring = mock_ring(ce->engine);
if (!ce->ring)
return -ENOMEM;
ce->timeline = intel_timeline_create(ce->engine->gt);
if (IS_ERR(ce->timeline)) {
kfree(ce->engine);
return PTR_ERR(ce->timeline);
}
err = mock_timeline_pin(ce->timeline);
if (err) {
intel_timeline_put(ce->timeline);
ce->timeline = NULL;
return err;
}
return 0;
}
static int mock_context_pre_pin(struct intel_context *ce,
struct i915_gem_ww_ctx *ww, void **unused)
{
return i915_vma_pin_ww(ce->ring->vma, ww, 0, 0, PIN_GLOBAL | PIN_HIGH);
}
static int mock_context_pin(struct intel_context *ce, void *unused)
{
return 0;
}
static void mock_context_reset(struct intel_context *ce)
{
}
static const struct intel_context_ops mock_context_ops = {
.alloc = mock_context_alloc,
.pre_pin = mock_context_pre_pin,
.pin = mock_context_pin,
.unpin = mock_context_unpin,
.post_unpin = mock_context_post_unpin,
.enter = intel_context_enter_engine,
.exit = intel_context_exit_engine,
.reset = mock_context_reset,
.destroy = mock_context_destroy,
};
Annotation
- Immediate include surface: `gem/i915_gem_context.h`, `gt/intel_ring.h`, `i915_drv.h`, `intel_context.h`, `intel_engine_pm.h`, `mock_engine.h`, `selftests/mock_request.h`.
- Detected declarations: `function mock_timeline_pin`, `function mock_timeline_unpin`, `function mock_ring_free`, `function advance`, `function hw_delay_complete`, `function mock_context_unpin`, `function mock_context_destroy`, `function mock_context_alloc`, `function mock_context_pre_pin`, `function mock_context_pin`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source 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.