drivers/gpu/drm/scheduler/tests/sched_tests.h
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/scheduler/tests/sched_tests.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/scheduler/tests/sched_tests.h- Extension
.h- Size
- 6260 bytes
- Lines
- 225
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
kunit/test.hlinux/atomic.hlinux/completion.hlinux/dma-fence.hlinux/hrtimer.hlinux/ktime.hlinux/list.hlinux/mutex.hlinux/types.hdrm/gpu_scheduler.h
Detected Declarations
struct drm_mock_schedulerstruct drm_mock_sched_entitystruct drm_mock_sched_jobfunction drm_sched_to_mock_schedfunction drm_sched_entity_to_mock_entityfunction drm_sched_job_to_mock_jobfunction drm_mock_sched_job_submitfunction drm_mock_sched_advancefunction drm_mock_sched_job_is_finishedfunction drm_mock_sched_job_wait_finishedfunction drm_mock_sched_job_wait_scheduled
Annotated Snippet
struct drm_mock_scheduler {
struct drm_gpu_scheduler base;
struct kunit *test;
spinlock_t lock;
struct list_head job_list;
struct {
u64 context;
atomic_t next_seqno;
unsigned int cur_seqno;
} hw_timeline;
};
/**
* struct drm_mock_sched_entity - implements a mock GPU sched entity
*
* @base: DRM scheduler entity base class
* @test: Backpointer to owning the kunit test case
*
* Mock GPU sched entity is used by the test cases to submit jobs to the mock
* scheduler.
*/
struct drm_mock_sched_entity {
struct drm_sched_entity base;
struct kunit *test;
};
/**
* struct drm_mock_sched_job - implements a mock GPU job
*
* @base: DRM sched job base class
* @done: Completion signaling job completion.
* @flags: Flags designating job state.
* @link: List head element used by job tracking by the drm_mock_scheduler
* @timer: Timer used for simulating job execution duration
* @duration_us: Simulated job duration in micro seconds, or zero if in manual
* timeline advance mode
* @finish_at: Absolute time when the jobs with set duration will complete
* @lock: Lock used for @hw_fence
* @hw_fence: Fence returned to DRM scheduler as the hardware fence
* @test: Backpointer to owning the kunit test case
*
* Mock GPU sched job is used by the test cases to submit jobs to the mock
* scheduler.
*/
struct drm_mock_sched_job {
struct drm_sched_job base;
struct completion done;
#define DRM_MOCK_SCHED_JOB_DONE 0x1
#define DRM_MOCK_SCHED_JOB_TIMEDOUT 0x2
#define DRM_MOCK_SCHED_JOB_DONT_RESET 0x4
#define DRM_MOCK_SCHED_JOB_RESET_SKIPPED 0x8
unsigned long flags;
struct list_head link;
struct hrtimer timer;
unsigned int duration_us;
ktime_t finish_at;
struct dma_fence hw_fence;
struct kunit *test;
};
static inline struct drm_mock_scheduler *
drm_sched_to_mock_sched(struct drm_gpu_scheduler *sched)
{
return container_of(sched, struct drm_mock_scheduler, base);
};
static inline struct drm_mock_sched_entity *
drm_sched_entity_to_mock_entity(struct drm_sched_entity *sched_entity)
{
return container_of(sched_entity, struct drm_mock_sched_entity, base);
};
static inline struct drm_mock_sched_job *
drm_sched_job_to_mock_job(struct drm_sched_job *sched_job)
{
return container_of(sched_job, struct drm_mock_sched_job, base);
};
struct drm_mock_scheduler *drm_mock_sched_new(struct kunit *test,
long timeout);
Annotation
- Immediate include surface: `kunit/test.h`, `linux/atomic.h`, `linux/completion.h`, `linux/dma-fence.h`, `linux/hrtimer.h`, `linux/ktime.h`, `linux/list.h`, `linux/mutex.h`.
- Detected declarations: `struct drm_mock_scheduler`, `struct drm_mock_sched_entity`, `struct drm_mock_sched_job`, `function drm_sched_to_mock_sched`, `function drm_sched_entity_to_mock_entity`, `function drm_sched_job_to_mock_job`, `function drm_mock_sched_job_submit`, `function drm_mock_sched_advance`, `function drm_mock_sched_job_is_finished`, `function drm_mock_sched_job_wait_finished`.
- 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.