drivers/gpu/drm/i915/gt/selftest_lrc.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/gt/selftest_lrc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/gt/selftest_lrc.c- Extension
.c- Size
- 41892 bytes
- Lines
- 1995
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/prime_numbers.hgem/i915_gem_internal.hi915_drv.hi915_selftest.hintel_engine_heartbeat.hintel_engine_pm.hintel_reset.hintel_ring.hselftest_engine_heartbeat.hselftests/i915_random.hselftests/igt_flush_test.hselftests/igt_live_test.hselftests/igt_spinner.hselftests/lib_sw_fence.hshmem_utils.hgem/selftests/igt_gem_utils.hgem/selftests/mock_context.h
Detected Declarations
struct lrc_timestampfunction is_activefunction wait_for_submitfunction emit_semaphore_signalfunction context_flushfunction get_lri_maskfunction live_lrc_layoutfunction find_offsetfunction live_lrc_fixedfunction for_each_enginefunction __live_lrc_statefunction live_lrc_statefunction for_each_enginefunction gpr_make_dirtyfunction __gpr_readfunction __live_lrc_gprfunction live_lrc_gprfunction for_each_enginefunction create_timestampfunction timestamp_advancedfunction __lrc_timestampfunction live_lrc_timestampfunction requestfunction create_user_vmafunction safe_poisonfunction store_contextfunction record_registersfunction poison_registersfunction is_movingfunction compare_isolationfunction create_result_vmafunction __lrc_isolationfunction skip_isolationfunction live_lrc_isolationfunction for_each_enginefunction wabb_ctx_submit_reqfunction emit_wabb_ctx_canaryfunction emit_indirect_ctx_bb_canaryfunction emit_per_ctx_bb_canaryfunction wabb_ctx_setupfunction check_ring_startfunction wabb_ctx_checkfunction __lrc_wabb_ctxfunction lrc_wabb_ctxfunction for_each_enginefunction live_lrc_indirect_ctx_bbfunction live_lrc_per_ctx_bbfunction garbage_reset
Annotated Snippet
struct lrc_timestamp {
struct intel_engine_cs *engine;
struct intel_context *ce[2];
u32 poison;
};
static bool timestamp_advanced(u32 start, u32 end)
{
return (s32)(end - start) > 0;
}
static int __lrc_timestamp(const struct lrc_timestamp *arg, bool preempt)
{
u32 *slot = memset32(arg->engine->status_page.addr + 1000, 0, 4);
struct i915_request *rq;
u32 timestamp;
int err = 0;
arg->ce[0]->lrc_reg_state[CTX_TIMESTAMP] = arg->poison;
rq = create_timestamp(arg->ce[0], slot, 1);
if (IS_ERR(rq))
return PTR_ERR(rq);
err = wait_for_submit(rq->engine, rq, HZ / 2);
if (err)
goto err;
if (preempt) {
arg->ce[1]->lrc_reg_state[CTX_TIMESTAMP] = 0xdeadbeef;
err = emit_semaphore_signal(arg->ce[1], slot);
if (err)
goto err;
} else {
slot[0] = 1;
wmb();
}
/* And wait for switch to kernel (to save our context to memory) */
err = context_flush(arg->ce[0], HZ / 2);
if (err)
goto err;
if (!timestamp_advanced(arg->poison, slot[1])) {
pr_err("%s(%s): invalid timestamp on restore, context:%x, request:%x\n",
arg->engine->name, preempt ? "preempt" : "simple",
arg->poison, slot[1]);
err = -EINVAL;
}
timestamp = READ_ONCE(arg->ce[0]->lrc_reg_state[CTX_TIMESTAMP]);
if (!timestamp_advanced(slot[1], timestamp)) {
pr_err("%s(%s): invalid timestamp on save, request:%x, context:%x\n",
arg->engine->name, preempt ? "preempt" : "simple",
slot[1], timestamp);
err = -EINVAL;
}
err:
memset32(slot, -1, 4);
i915_request_put(rq);
return err;
}
static int live_lrc_timestamp(void *arg)
{
struct lrc_timestamp data = {};
struct intel_gt *gt = arg;
enum intel_engine_id id;
const u32 poison[] = {
0,
S32_MAX,
(u32)S32_MAX + 1,
U32_MAX,
};
/*
* This test was designed to isolate a hardware bug.
* The bug was found and fixed in future generations but
* now the test pollutes our CI on previous generation.
*/
if (GRAPHICS_VER(gt->i915) == 12)
return 0;
/*
* We want to verify that the timestamp is saved and restore across
* context switches and is monotonic.
*
* So we do this with a little bit of LRC poisoning to check various
* boundary conditions, and see what happens if we preempt the context
* with a second request (carrying more poison into the timestamp).
Annotation
- Immediate include surface: `linux/prime_numbers.h`, `gem/i915_gem_internal.h`, `i915_drv.h`, `i915_selftest.h`, `intel_engine_heartbeat.h`, `intel_engine_pm.h`, `intel_reset.h`, `intel_ring.h`.
- Detected declarations: `struct lrc_timestamp`, `function is_active`, `function wait_for_submit`, `function emit_semaphore_signal`, `function context_flush`, `function get_lri_mask`, `function live_lrc_layout`, `function find_offset`, `function live_lrc_fixed`, `function for_each_engine`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
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.