drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h- Extension
.h- Size
- 20642 bytes
- Lines
- 598
- 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
drm/amdgpu_drm.hdrm/gpu_scheduler.hdrm/drm_print.hdrm/drm_suballoc.h
Detected Declarations
struct amdgpu_devicestruct amdgpu_ringstruct amdgpu_ibstruct amdgpu_cs_parserstruct amdgpu_jobstruct amdgpu_vmstruct amdgpu_ibstruct amdgpu_schedstruct amdgpu_fence_driverstruct amdgpu_fencestruct amdgpu_ring_funcsstruct amdgpu_ringenum amdgpu_ring_priority_levelenum amdgpu_ring_typeenum amdgpu_ib_pool_typefunction amdgpu_ring_set_preempt_cond_execfunction amdgpu_ring_clear_ringfunction amdgpu_ring_writefunction amdgpu_ring_write_multiplefunction amdgpu_ring_get_dw_distancefunction amdgpu_ring_patch_cond_execfunction amdgpu_ib_get_valuefunction amdgpu_ib_set_value
Annotated Snippet
struct amdgpu_ib {
struct drm_suballoc *sa_bo;
uint32_t length_dw;
uint64_t gpu_addr;
uint32_t *ptr;
uint32_t flags;
};
struct amdgpu_sched {
u32 num_scheds;
struct drm_gpu_scheduler *sched[AMDGPU_MAX_HWIP_RINGS];
};
/*
* Fences.
*/
struct amdgpu_fence_driver {
uint64_t gpu_addr;
uint32_t *cpu_addr;
/* sync_seq is protected by ring emission lock */
uint32_t sync_seq;
atomic_t last_seq;
bool initialized;
struct amdgpu_irq_src *irq_src;
unsigned irq_type;
struct timer_list fallback_timer;
unsigned num_fences_mask;
spinlock_t lock;
struct dma_fence **fences;
};
/*
* Fences mark an event in the GPUs pipeline and are used
* for GPU/CPU synchronization. When the fence is written,
* it is expected that all buffers associated with that fence
* are no longer in use by the associated ring on the GPU and
* that the relevant GPU caches have been flushed.
*/
struct amdgpu_fence {
struct dma_fence base;
/* RB, DMA, etc. */
struct amdgpu_ring *ring;
ktime_t start_timestamp;
/* location and size of the IB */
u64 ib_wptr;
unsigned int ib_dw_size;
unsigned int skip_ib_dw_start_offset;
unsigned int skip_ib_dw_end_offset;
/* fence context for resets */
u64 context;
/* idx for ring backups */
unsigned int backup_idx;
};
extern const struct drm_sched_backend_ops amdgpu_sched_ops;
void amdgpu_fence_driver_set_error(struct amdgpu_ring *ring, int error);
void amdgpu_fence_driver_force_completion(struct amdgpu_ring *ring,
struct dma_fence *timedout_fence);
void amdgpu_ring_set_fence_errors_and_reemit(struct amdgpu_ring *ring,
struct amdgpu_fence *guilty_fence);
int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring);
int amdgpu_fence_driver_start_ring(struct amdgpu_ring *ring,
struct amdgpu_irq_src *irq_src,
unsigned irq_type);
void amdgpu_fence_driver_hw_init(struct amdgpu_device *adev);
void amdgpu_fence_driver_hw_fini(struct amdgpu_device *adev);
int amdgpu_fence_driver_sw_init(struct amdgpu_device *adev);
void amdgpu_fence_driver_sw_fini(struct amdgpu_device *adev);
void amdgpu_fence_emit(struct amdgpu_ring *ring, struct amdgpu_fence *af,
unsigned int flags);
int amdgpu_fence_emit_polling(struct amdgpu_ring *ring, uint32_t *s,
uint32_t timeout);
bool amdgpu_fence_process(struct amdgpu_ring *ring);
int amdgpu_fence_wait_empty(struct amdgpu_ring *ring);
signed long amdgpu_fence_wait_polling(struct amdgpu_ring *ring,
uint32_t wait_seq,
signed long timeout);
unsigned amdgpu_fence_count_emitted(struct amdgpu_ring *ring);
void amdgpu_fence_driver_isr_toggle(struct amdgpu_device *adev, bool stop);
u64 amdgpu_fence_last_unsignaled_time_us(struct amdgpu_ring *ring);
void amdgpu_fence_update_start_timestamp(struct amdgpu_ring *ring, uint32_t seq,
ktime_t timestamp);
Annotation
- Immediate include surface: `drm/amdgpu_drm.h`, `drm/gpu_scheduler.h`, `drm/drm_print.h`, `drm/drm_suballoc.h`.
- Detected declarations: `struct amdgpu_device`, `struct amdgpu_ring`, `struct amdgpu_ib`, `struct amdgpu_cs_parser`, `struct amdgpu_job`, `struct amdgpu_vm`, `struct amdgpu_ib`, `struct amdgpu_sched`, `struct amdgpu_fence_driver`, `struct amdgpu_fence`.
- 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.