drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c- Extension
.c- Size
- 25970 bytes
- Lines
- 968
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/seq_file.hlinux/slab.hlinux/uaccess.hlinux/debugfs.hdrm/amdgpu_drm.hamdgpu.hamdgpu_ras_mgr.hatom.h
Detected Declarations
function filesfunction amdgpu_ring_allocfunction amdgpu_ring_insert_nopfunction amdgpu_ring_generic_pad_ibfunction wptrfunction amdgpu_ring_undofunction ringfunction ringfunction amdgpu_ring_emit_reg_write_reg_wait_helperfunction amdgpu_ring_soft_recoveryfunction amdgpu_ras_cper_debugfs_readfunction amdgpu_debugfs_ring_readfunction amdgpu_debugfs_virt_ring_readfunction amdgpu_debugfs_mqd_readfunction amdgpu_debugfs_ring_errorfunction amdgpu_debugfs_ring_initfunction amdgpu_ring_test_helperfunction amdgpu_ring_to_mqd_propfunction amdgpu_ring_init_mqdfunction amdgpu_ring_ib_beginfunction amdgpu_ring_ib_endfunction amdgpu_ring_ib_on_emit_cntlfunction amdgpu_ring_ib_on_emit_cefunction amdgpu_ring_ib_on_emit_defunction amdgpu_ring_sched_readyfunction amdgpu_ring_reset_helper_beginfunction amdgpu_ring_reset_helper_endfunction amdgpu_ring_is_reset_type_supported
Annotated Snippet
static const struct file_operations amdgpu_debugfs_ring_fops = {
.owner = THIS_MODULE,
.read = amdgpu_debugfs_ring_read,
.llseek = default_llseek
};
static const struct file_operations amdgpu_debugfs_virt_ring_fops = {
.owner = THIS_MODULE,
.read = amdgpu_debugfs_virt_ring_read,
.llseek = default_llseek
};
static ssize_t amdgpu_debugfs_mqd_read(struct file *f, char __user *buf,
size_t size, loff_t *pos)
{
struct amdgpu_ring *ring = file_inode(f)->i_private;
ssize_t bytes = min_t(ssize_t, ring->mqd_size - *pos, size);
void *from = ((u8 *)ring->mqd_ptr) + *pos;
if (*pos > ring->mqd_size)
return 0;
if (copy_to_user(buf, from, bytes))
return -EFAULT;
*pos += bytes;
return bytes;
}
static const struct file_operations amdgpu_debugfs_mqd_fops = {
.owner = THIS_MODULE,
.read = amdgpu_debugfs_mqd_read,
.llseek = default_llseek
};
static int amdgpu_debugfs_ring_error(void *data, u64 val)
{
struct amdgpu_ring *ring = data;
amdgpu_fence_driver_set_error(ring, val);
return 0;
}
DEFINE_DEBUGFS_ATTRIBUTE_SIGNED(amdgpu_debugfs_error_fops, NULL,
amdgpu_debugfs_ring_error, "%lld\n");
#endif
void amdgpu_debugfs_ring_init(struct amdgpu_device *adev,
struct amdgpu_ring *ring)
{
#if defined(CONFIG_DEBUG_FS)
struct drm_minor *minor = adev_to_drm(adev)->primary;
struct dentry *root = minor->debugfs_root;
char name[32];
sprintf(name, "amdgpu_ring_%s", ring->name);
if (amdgpu_sriov_vf(adev))
debugfs_create_file_size(name, S_IFREG | 0444, root, ring,
&amdgpu_debugfs_virt_ring_fops,
ring->ring_size + 12);
else
debugfs_create_file_size(name, S_IFREG | 0444, root, ring,
&amdgpu_debugfs_ring_fops,
ring->ring_size + 12);
if (ring->mqd_obj) {
sprintf(name, "amdgpu_mqd_%s", ring->name);
debugfs_create_file_size(name, S_IFREG | 0444, root, ring,
&amdgpu_debugfs_mqd_fops,
ring->mqd_size);
}
sprintf(name, "amdgpu_error_%s", ring->name);
debugfs_create_file(name, 0200, root, ring,
&amdgpu_debugfs_error_fops);
#endif
}
/**
* amdgpu_ring_test_helper - tests ring and set sched readiness status
*
* @ring: ring to try the recovery on
*
* Tests ring and set sched readiness status
*
* Returns 0 on success, error on failure.
*/
int amdgpu_ring_test_helper(struct amdgpu_ring *ring)
Annotation
- Immediate include surface: `linux/seq_file.h`, `linux/slab.h`, `linux/uaccess.h`, `linux/debugfs.h`, `drm/amdgpu_drm.h`, `amdgpu.h`, `amdgpu_ras_mgr.h`, `atom.h`.
- Detected declarations: `function files`, `function amdgpu_ring_alloc`, `function amdgpu_ring_insert_nop`, `function amdgpu_ring_generic_pad_ib`, `function wptr`, `function amdgpu_ring_undo`, `function ring`, `function ring`, `function amdgpu_ring_emit_reg_write_reg_wait_helper`, `function amdgpu_ring_soft_recovery`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.