drivers/gpu/drm/scheduler/tests/tests_basic.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/scheduler/tests/tests_basic.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/scheduler/tests/tests_basic.c- Extension
.c- Size
- 15370 bytes
- Lines
- 564
- 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/delay.hsched_tests.h
Detected Declarations
struct drm_sched_basic_paramsfunction drm_sched_basic_initfunction drm_sched_basic_exitfunction drm_sched_timeout_initfunction drm_sched_basic_submitfunction drm_sched_basic_descfunction drm_sched_basic_testfunction drm_sched_basic_entity_cleanupfunction drm_sched_basic_cancelfunction drm_sched_basic_timeoutfunction drm_sched_skip_resetfunction drm_sched_prioritiesfunction drm_sched_change_priorityfunction drm_sched_test_modify_schedfunction drm_sched_test_credits
Annotated Snippet
struct drm_sched_basic_params {
const char *description;
unsigned int queue_depth;
unsigned int num_entities;
unsigned int job_us;
bool dep_chain;
};
static const struct drm_sched_basic_params drm_sched_basic_cases[] = {
{
.description = "A queue of jobs in a single entity",
.queue_depth = 100,
.job_us = 1000,
.num_entities = 1,
},
{
.description = "A chain of dependent jobs across multiple entities",
.queue_depth = 100,
.job_us = 1000,
.num_entities = 1,
.dep_chain = true,
},
{
.description = "Multiple independent job queues",
.queue_depth = 100,
.job_us = 1000,
.num_entities = 4,
},
{
.description = "Multiple inter-dependent job queues",
.queue_depth = 100,
.job_us = 1000,
.num_entities = 4,
.dep_chain = true,
},
};
static void
drm_sched_basic_desc(const struct drm_sched_basic_params *params, char *desc)
{
strscpy(desc, params->description, KUNIT_PARAM_DESC_SIZE);
}
KUNIT_ARRAY_PARAM(drm_sched_basic, drm_sched_basic_cases, drm_sched_basic_desc);
static void drm_sched_basic_test(struct kunit *test)
{
const struct drm_sched_basic_params *params = test->param_value;
struct drm_mock_scheduler *sched = test->priv;
struct drm_mock_sched_job *job, *prev = NULL;
struct drm_mock_sched_entity **entity;
unsigned int i, cur_ent = 0;
bool done;
entity = kunit_kcalloc(test, params->num_entities, sizeof(*entity),
GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, entity);
for (i = 0; i < params->num_entities; i++)
entity[i] = drm_mock_sched_entity_new(test,
DRM_SCHED_PRIORITY_NORMAL,
sched);
for (i = 0; i < params->queue_depth; i++) {
job = drm_mock_sched_job_new(test, entity[cur_ent++]);
cur_ent %= params->num_entities;
drm_mock_sched_job_set_duration_us(job, params->job_us);
if (params->dep_chain && prev)
drm_sched_job_add_dependency(&job->base,
dma_fence_get(&prev->base.s_fence->finished));
drm_mock_sched_job_submit(job);
prev = job;
}
done = drm_mock_sched_job_wait_finished(job, HZ);
KUNIT_ASSERT_TRUE(test, done);
for (i = 0; i < params->num_entities; i++)
drm_mock_sched_entity_free(entity[i]);
}
static void drm_sched_basic_entity_cleanup(struct kunit *test)
{
struct drm_mock_sched_job *job, *mid, *prev = NULL;
struct drm_mock_scheduler *sched = test->priv;
struct drm_mock_sched_entity *entity[4];
const unsigned int qd = 100;
unsigned int i, cur_ent = 0;
bool done;
Annotation
- Immediate include surface: `linux/delay.h`, `sched_tests.h`.
- Detected declarations: `struct drm_sched_basic_params`, `function drm_sched_basic_init`, `function drm_sched_basic_exit`, `function drm_sched_timeout_init`, `function drm_sched_basic_submit`, `function drm_sched_basic_desc`, `function drm_sched_basic_test`, `function drm_sched_basic_entity_cleanup`, `function drm_sched_basic_cancel`, `function drm_sched_basic_timeout`.
- 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.