drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c- Extension
.c- Size
- 45368 bytes
- Lines
- 1635
- 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/firmware.hlinux/module.hlinux/dmi.hlinux/pci.hlinux/debugfs.hdrm/drm_drv.hamdgpu.hamdgpu_pm.hamdgpu_vcn.hamdgpu_reset.hsoc15d.h
Detected Declarations
function amdgpu_vcn_early_initfunction amdgpu_vcn_sw_initfunction probedfunction amdgpu_vcn_sw_finifunction amdgpu_vcn_is_disabled_vcnfunction amdgpu_vcn_save_vcpu_bo_instfunction amdgpu_vcn_save_vcpu_bofunction amdgpu_vcn_suspendfunction amdgpu_vcn_resumefunction amdgpu_vcn_get_profilefunction amdgpu_vcn_put_profilefunction amdgpu_vcn_idle_work_handlerfunction amdgpu_vcn_ring_begin_usefunction amdgpu_vcn_ring_end_usefunction amdgpu_vcn_dec_ring_test_ringfunction amdgpu_vcn_dec_sw_ring_test_ringfunction amdgpu_vcn_dec_send_msgfunction amdgpu_vcn_dec_get_create_msgfunction amdgpu_vcn_dec_get_destroy_msgfunction amdgpu_vcn_dec_ring_test_ibfunction amdgpu_vcn_unified_ring_ib_checksumfunction amdgpu_vcn_dec_sw_send_msgfunction amdgpu_vcn_dec_sw_ring_test_ibfunction amdgpu_vcn_enc_ring_test_ringfunction amdgpu_vcn_enc_get_create_msgfunction amdgpu_vcn_enc_get_destroy_msgfunction amdgpu_vcn_enc_ring_test_ibfunction amdgpu_vcn_unified_ring_test_ibfunction amdgpu_vcn_get_enc_ring_priofunction amdgpu_vcn_setup_ucodefunction amdgpu_debugfs_vcn_fwlog_readfunction amdgpu_debugfs_vcn_fwlog_initfunction amdgpu_vcn_fwlog_initfunction amdgpu_vcn_process_poison_irqfunction amdgpu_vcn_ras_late_initfunction amdgpu_vcn_ras_sw_initfunction amdgpu_vcn_psp_update_sramfunction amdgpu_get_vcn_reset_maskfunction amdgpu_vcn_sysfs_reset_mask_initfunction amdgpu_vcn_sysfs_reset_mask_finifunction amdgpu_debugfs_vcn_sched_mask_setfunction amdgpu_debugfs_vcn_sched_mask_getfunction amdgpu_debugfs_vcn_sched_mask_initfunction vcn_set_powergating_statefunction amdgpu_vcn_ring_resetfunction amdgpu_vcn_reg_dump_initfunction amdgpu_vcn_reg_dump_finifunction amdgpu_vcn_dump_ip_state
Annotated Snippet
static const struct file_operations amdgpu_debugfs_vcnfwlog_fops = {
.owner = THIS_MODULE,
.read = amdgpu_debugfs_vcn_fwlog_read,
.llseek = default_llseek
};
#endif
void amdgpu_debugfs_vcn_fwlog_init(struct amdgpu_device *adev, uint8_t i,
struct amdgpu_vcn_inst *vcn)
{
#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_vcn_%d_fwlog", i);
debugfs_create_file_size(name, S_IFREG | 0444, root, vcn,
&amdgpu_debugfs_vcnfwlog_fops,
AMDGPU_VCNFW_LOG_SIZE);
#endif
}
void amdgpu_vcn_fwlog_init(struct amdgpu_vcn_inst *vcn)
{
#if defined(CONFIG_DEBUG_FS)
uint32_t *flag = vcn->fw_shared.cpu_addr;
void *fw_log_cpu_addr = vcn->fw_shared.cpu_addr + vcn->fw_shared.mem_size;
uint64_t fw_log_gpu_addr = vcn->fw_shared.gpu_addr + vcn->fw_shared.mem_size;
struct amdgpu_vcn_fwlog *log_buf = fw_log_cpu_addr;
struct amdgpu_fw_shared_fw_logging *fw_log = vcn->fw_shared.cpu_addr
+ vcn->fw_shared.log_offset;
*flag |= cpu_to_le32(AMDGPU_VCN_FW_LOGGING_FLAG);
fw_log->is_enabled = 1;
fw_log->addr_lo = cpu_to_le32(fw_log_gpu_addr & 0xFFFFFFFF);
fw_log->addr_hi = cpu_to_le32(fw_log_gpu_addr >> 32);
fw_log->size = cpu_to_le32(AMDGPU_VCNFW_LOG_SIZE);
log_buf->header_size = sizeof(struct amdgpu_vcn_fwlog);
log_buf->buffer_size = AMDGPU_VCNFW_LOG_SIZE;
log_buf->rptr = log_buf->header_size;
log_buf->wptr = log_buf->header_size;
log_buf->wrapped = 0;
#endif
}
int amdgpu_vcn_process_poison_irq(struct amdgpu_device *adev,
struct amdgpu_irq_src *source,
struct amdgpu_iv_entry *entry)
{
struct ras_common_if *ras_if = adev->vcn.ras_if;
struct ras_dispatch_if ih_data = {
.entry = entry,
};
if (!ras_if)
return 0;
if (!amdgpu_sriov_vf(adev)) {
ih_data.head = *ras_if;
amdgpu_ras_interrupt_dispatch(adev, &ih_data);
} else {
if (adev->virt.ops && adev->virt.ops->ras_poison_handler)
adev->virt.ops->ras_poison_handler(adev, ras_if->block);
else
dev_warn(adev->dev,
"No ras_poison_handler interface in SRIOV for VCN!\n");
}
return 0;
}
int amdgpu_vcn_ras_late_init(struct amdgpu_device *adev, struct ras_common_if *ras_block)
{
int r, i;
r = amdgpu_ras_block_late_init(adev, ras_block);
if (r)
return r;
if (amdgpu_ras_is_supported(adev, ras_block->block)) {
for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
if (adev->vcn.harvest_config & (1 << i) ||
!adev->vcn.inst[i].ras_poison_irq.funcs)
continue;
r = amdgpu_irq_get(adev, &adev->vcn.inst[i].ras_poison_irq, 0);
if (r)
goto late_fini;
}
}
Annotation
- Immediate include surface: `linux/firmware.h`, `linux/module.h`, `linux/dmi.h`, `linux/pci.h`, `linux/debugfs.h`, `drm/drm_drv.h`, `amdgpu.h`, `amdgpu_pm.h`.
- Detected declarations: `function amdgpu_vcn_early_init`, `function amdgpu_vcn_sw_init`, `function probed`, `function amdgpu_vcn_sw_fini`, `function amdgpu_vcn_is_disabled_vcn`, `function amdgpu_vcn_save_vcpu_bo_inst`, `function amdgpu_vcn_save_vcpu_bo`, `function amdgpu_vcn_suspend`, `function amdgpu_vcn_resume`, `function amdgpu_vcn_get_profile`.
- 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.