drivers/gpu/drm/i915/selftests/i915_request.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/selftests/i915_request.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/selftests/i915_request.c- Extension
.c- Size
- 73751 bytes
- Lines
- 3304
- 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/pm_qos.hlinux/prime_numbers.hlinux/sort.hdrm/drm_print.hgem/i915_gem_internal.hgem/i915_gem_pm.hgem/selftests/mock_context.hgt/intel_engine_heartbeat.hgt/intel_engine_pm.hgt/intel_engine_user.hgt/intel_gt.hgt/intel_gt_clock_utils.hgt/intel_gt_requests.hgt/selftest_engine_heartbeat.hi915_random.hi915_selftest.hi915_wait_util.higt_flush_test.higt_live_test.higt_spinner.hlib_sw_fence.hmock_drm.hmock_gem_device.h
Detected Declarations
struct smoketeststruct smoke_threadstruct parallel_threadstruct perf_statsstruct perf_seriesstruct signal_cbstruct p_threadfunction filesfunction igt_add_requestfunction igt_wait_requestfunction igt_fence_waitfunction igt_request_rewindfunction __mock_request_allocfunction __live_request_allocfunction __igt_breadcrumbs_smoketestfunction mock_breadcrumbs_smoketestfunction i915_request_mock_selftestsfunction live_nop_requestfunction for_each_uabi_enginefunction for_each_prime_number_fromfunction __cancel_inactivefunction __cancel_activefunction __cancel_completedfunction __cancel_resetfunction live_cancel_requestfunction for_each_uabi_enginefunction emit_bb_startfunction empty_requestfunction live_empty_requestfunction for_each_uabi_enginefunction for_each_prime_number_fromfunction recursive_batch_resolvefunction live_all_enginesfunction live_sequential_enginesfunction __live_parallel_engine1function __live_parallel_engineNfunction wake_allfunction wait_for_allfunction __live_parallel_spinfunction live_parallel_enginesfunction for_each_uabi_enginefunction for_each_uabi_enginefunction max_batchesfunction live_breadcrumbs_smoketestfunction i915_request_live_selftestsfunction switch_to_kernel_syncfunction cmp_u32function trifilter
Annotated Snippet
struct smoketest {
struct intel_engine_cs *engine;
struct i915_gem_context **contexts;
atomic_long_t num_waits, num_fences;
int ncontexts, max_batch;
struct i915_request *(*request_alloc)(struct intel_context *ce);
};
static struct i915_request *
__mock_request_alloc(struct intel_context *ce)
{
return mock_request(ce, 0);
}
static struct i915_request *
__live_request_alloc(struct intel_context *ce)
{
return intel_context_create_request(ce);
}
struct smoke_thread {
struct kthread_worker *worker;
struct kthread_work work;
struct smoketest *t;
bool stop;
int result;
};
static void __igt_breadcrumbs_smoketest(struct kthread_work *work)
{
struct smoke_thread *thread = container_of(work, typeof(*thread), work);
struct smoketest *t = thread->t;
const unsigned int max_batch = min(t->ncontexts, t->max_batch) - 1;
const unsigned int total = 4 * t->ncontexts + 1;
unsigned int num_waits = 0, num_fences = 0;
struct i915_request **requests;
I915_RND_STATE(prng);
unsigned int *order;
int err = 0;
/*
* A very simple test to catch the most egregious of list handling bugs.
*
* At its heart, we simply create oodles of requests running across
* multiple kthreads and enable signaling on them, for the sole purpose
* of stressing our breadcrumb handling. The only inspection we do is
* that the fences were marked as signaled.
*/
requests = kzalloc_objs(*requests, total);
if (!requests) {
thread->result = -ENOMEM;
return;
}
order = i915_random_order(total, &prng);
if (!order) {
err = -ENOMEM;
goto out_requests;
}
while (!READ_ONCE(thread->stop)) {
struct i915_sw_fence *submit, *wait;
unsigned int n, count;
submit = heap_fence_create(GFP_KERNEL);
if (!submit) {
err = -ENOMEM;
break;
}
wait = heap_fence_create(GFP_KERNEL);
if (!wait) {
i915_sw_fence_commit(submit);
heap_fence_put(submit);
err = -ENOMEM;
break;
}
i915_random_reorder(order, total, &prng);
count = 1 + i915_prandom_u32_max_state(max_batch, &prng);
for (n = 0; n < count; n++) {
struct i915_gem_context *ctx =
t->contexts[order[n] % t->ncontexts];
struct i915_request *rq;
struct intel_context *ce;
ce = i915_gem_context_get_engine(ctx, t->engine->legacy_idx);
GEM_BUG_ON(IS_ERR(ce));
Annotation
- Immediate include surface: `linux/pm_qos.h`, `linux/prime_numbers.h`, `linux/sort.h`, `drm/drm_print.h`, `gem/i915_gem_internal.h`, `gem/i915_gem_pm.h`, `gem/selftests/mock_context.h`, `gt/intel_engine_heartbeat.h`.
- Detected declarations: `struct smoketest`, `struct smoke_thread`, `struct parallel_thread`, `struct perf_stats`, `struct perf_series`, `struct signal_cb`, `struct p_thread`, `function files`, `function igt_add_request`, `function igt_wait_request`.
- 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.