drivers/gpu/drm/i915/gt/selftest_timeline.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/gt/selftest_timeline.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/gt/selftest_timeline.c- Extension
.c- Size
- 31922 bytes
- Lines
- 1430
- 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
linux/prime_numbers.hlinux/string_helpers.hintel_context.hintel_engine_heartbeat.hintel_engine_pm.hintel_engine_regs.hintel_gpu_commands.hintel_gt.hintel_gt_requests.hintel_ring.hselftest_engine_heartbeat.h../selftests/i915_random.h../i915_selftest.hselftests/igt_flush_test.hselftests/lib_sw_fence.hselftests/mock_gem_device.hselftests/mock_timeline.h
Detected Declarations
struct mock_hwsp_freeliststruct __igt_syncstruct hwsp_watcherfunction hwsp_cachelinefunction selftest_tl_pinfunction __mock_hwsp_recordfunction __mock_hwsp_timelinefunction mock_hwsp_freelistfunction for_each_prime_number_fromfunction __igt_syncfunction igt_syncfunction random_enginefunction bench_syncfunction intel_timeline_mock_selftestsfunction emit_ggtt_store_dwfunction checked_tl_writefunction live_hwsp_enginefunction live_hwsp_alternatefunction for_each_enginefunction live_hwsp_wrapfunction for_each_enginefunction emit_read_hwspfunction cmp_ltfunction cmp_gtefunction setup_watcherfunction switch_tl_lockfunction create_watcherfunction check_watcherfunction cleanup_watcherfunction retire_requestsfunction live_hwsp_readfunction for_each_enginefunction live_hwsp_rollover_kernelfunction for_each_enginefunction live_hwsp_rollover_userfunction for_each_enginefunction live_hwsp_recyclefunction intel_timeline_live_selftests
Annotated Snippet
struct mock_hwsp_freelist {
struct intel_gt *gt;
struct radix_tree_root cachelines;
struct intel_timeline **history;
unsigned long count, max;
struct rnd_state prng;
};
enum {
SHUFFLE = BIT(0),
};
static void __mock_hwsp_record(struct mock_hwsp_freelist *state,
unsigned int idx,
struct intel_timeline *tl)
{
tl = xchg(&state->history[idx], tl);
if (tl) {
radix_tree_delete(&state->cachelines, hwsp_cacheline(tl));
intel_timeline_unpin(tl);
intel_timeline_put(tl);
}
}
static int __mock_hwsp_timeline(struct mock_hwsp_freelist *state,
unsigned int count,
unsigned int flags)
{
struct intel_timeline *tl;
unsigned int idx;
while (count--) {
unsigned long cacheline;
int err;
tl = intel_timeline_create(state->gt);
if (IS_ERR(tl))
return PTR_ERR(tl);
err = selftest_tl_pin(tl);
if (err) {
intel_timeline_put(tl);
return err;
}
cacheline = hwsp_cacheline(tl);
err = radix_tree_insert(&state->cachelines, cacheline, tl);
if (err) {
if (err == -EEXIST) {
pr_err("HWSP cacheline %lu already used; duplicate allocation!\n",
cacheline);
}
intel_timeline_unpin(tl);
intel_timeline_put(tl);
return err;
}
idx = state->count++ % state->max;
__mock_hwsp_record(state, idx, tl);
}
if (flags & SHUFFLE)
i915_prandom_shuffle(state->history,
sizeof(*state->history),
min(state->count, state->max),
&state->prng);
count = i915_prandom_u32_max_state(min(state->count, state->max),
&state->prng);
while (count--) {
idx = --state->count % state->max;
__mock_hwsp_record(state, idx, NULL);
}
return 0;
}
static int mock_hwsp_freelist(void *arg)
{
struct mock_hwsp_freelist state;
struct drm_i915_private *i915;
const struct {
const char *name;
unsigned int flags;
} phases[] = {
{ "linear", 0 },
{ "shuffled", SHUFFLE },
{ },
}, *p;
unsigned int na;
Annotation
- Immediate include surface: `linux/prime_numbers.h`, `linux/string_helpers.h`, `intel_context.h`, `intel_engine_heartbeat.h`, `intel_engine_pm.h`, `intel_engine_regs.h`, `intel_gpu_commands.h`, `intel_gt.h`.
- Detected declarations: `struct mock_hwsp_freelist`, `struct __igt_sync`, `struct hwsp_watcher`, `function hwsp_cacheline`, `function selftest_tl_pin`, `function __mock_hwsp_record`, `function __mock_hwsp_timeline`, `function mock_hwsp_freelist`, `function for_each_prime_number_from`, `function __igt_sync`.
- 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.