drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c- Extension
.c- Size
- 71065 bytes
- Lines
- 2213
- 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
linux/firmware.hdrm/drm_drv.hamdgpu.hamdgpu_vcn.hamdgpu_pm.hsoc15.hsoc15d.hvcn_v2_0.hmmsch_v1_0.hvcn_v2_5.hvcn/vcn_2_5_offset.hvcn/vcn_2_5_sh_mask.hivsrcid/vcn/irqsrcs_vcn_2_0.h
Detected Declarations
function vcn_v2_5_idle_work_handlerfunction vcn_v2_5_ring_begin_usefunction vcn_v2_5_ring_end_usefunction vcn_v2_5_early_initfunction vcn_v2_5_sw_initfunction vcn_v2_5_sw_finifunction vcn_v2_5_hw_initfunction vcn_v2_5_hw_finifunction vcn_v2_5_suspendfunction vcn_v2_5_resumefunction vcn_v2_5_mc_resumefunction vcn_v2_5_mc_resume_dpg_modefunction vcn_v2_5_disable_clock_gatingfunction vcn_v2_5_clock_gating_dpg_modefunction vcn_v2_5_enable_clock_gatingfunction vcn_v2_6_enable_rasfunction vcn_v2_5_start_dpg_modefunction vcn_v2_5_startfunction vcn_v2_5_mmsch_startfunction vcn_v2_5_sriov_startfunction vcn_v2_5_stop_dpg_modefunction vcn_v2_5_stopfunction vcn_v2_5_pause_dpg_modefunction vcn_v2_5_dec_ring_get_rptrfunction vcn_v2_5_dec_ring_get_wptrfunction vcn_v2_5_dec_ring_set_wptrfunction vcn_v2_5_enc_ring_get_rptrfunction vcn_v2_5_enc_ring_get_wptrfunction vcn_v2_5_enc_ring_set_wptrfunction vcn_v2_5_set_dec_ring_funcsfunction vcn_v2_5_set_enc_ring_funcsfunction vcn_v2_5_resetfunction vcn_v2_5_is_idlefunction vcn_v2_5_wait_for_idlefunction vcn_v2_5_set_clockgating_statefunction vcn_v2_5_set_pg_statefunction vcn_v2_5_set_interrupt_statefunction vcn_v2_6_set_ras_interrupt_statefunction vcn_v2_5_process_interruptfunction vcn_v2_5_set_irq_funcsfunction vcn_v2_6_query_poison_by_instancefunction vcn_v2_6_query_poison_statusfunction vcn_v2_5_set_ras_funcs
Annotated Snippet
if (ring->funcs->type == AMDGPU_RING_TYPE_VCN_ENC) {
atomic_inc(&v->dpg_enc_submission_cnt);
new_state.fw_based = VCN_DPG_STATE__PAUSE;
} else {
unsigned int fences = 0;
unsigned int i;
for (i = 0; i < v->num_enc_rings; ++i)
fences += amdgpu_fence_count_emitted(&v->ring_enc[i]);
if (fences || atomic_read(&v->dpg_enc_submission_cnt))
new_state.fw_based = VCN_DPG_STATE__PAUSE;
else
new_state.fw_based = VCN_DPG_STATE__UNPAUSE;
}
v->pause_dpg_mode(v, &new_state);
}
mutex_unlock(&adev->vcn.inst[0].vcn_pg_lock);
amdgpu_vcn_get_profile(adev);
}
static void vcn_v2_5_ring_end_use(struct amdgpu_ring *ring)
{
struct amdgpu_device *adev = ring->adev;
/* Only set DPG pause for VCN3 or below, VCN4 and above will be handled by FW */
if (ring->adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG &&
ring->funcs->type == AMDGPU_RING_TYPE_VCN_ENC &&
!adev->vcn.inst[ring->me].using_unified_queue)
atomic_dec(&adev->vcn.inst[ring->me].dpg_enc_submission_cnt);
atomic_dec(&adev->vcn.inst[0].total_submission_cnt);
schedule_delayed_work(&adev->vcn.inst[0].idle_work,
VCN_IDLE_TIMEOUT);
}
/**
* vcn_v2_5_early_init - set function pointers and load microcode
*
* @ip_block: Pointer to the amdgpu_ip_block for this hw instance.
*
* Set ring and irq function pointers
* Load microcode from filesystem
*/
static int vcn_v2_5_early_init(struct amdgpu_ip_block *ip_block)
{
struct amdgpu_device *adev = ip_block->adev;
int i, r;
if (amdgpu_sriov_vf(adev)) {
adev->vcn.num_vcn_inst = 2;
adev->vcn.harvest_config = 0;
for (i = 0; i < adev->vcn.num_vcn_inst; i++)
adev->vcn.inst[i].num_enc_rings = 1;
} else {
u32 harvest;
int i;
for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
harvest = RREG32_SOC15(VCN, i, mmCC_UVD_HARVESTING);
if (harvest & CC_UVD_HARVESTING__UVD_DISABLE_MASK)
adev->vcn.harvest_config |= 1 << i;
adev->vcn.inst[i].num_enc_rings = 2;
}
if (adev->vcn.harvest_config == (AMDGPU_VCN_HARVEST_VCN0 |
AMDGPU_VCN_HARVEST_VCN1))
/* both instances are harvested, disable the block */
return -ENOENT;
}
vcn_v2_5_set_dec_ring_funcs(adev);
vcn_v2_5_set_enc_ring_funcs(adev);
vcn_v2_5_set_irq_funcs(adev);
vcn_v2_5_set_ras_funcs(adev);
for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
adev->vcn.inst[i].set_pg_state = vcn_v2_5_set_pg_state;
r = amdgpu_vcn_early_init(adev, i);
if (r)
return r;
}
return 0;
}
/**
* vcn_v2_5_sw_init - sw init for VCN block
*
Annotation
- Immediate include surface: `linux/firmware.h`, `drm/drm_drv.h`, `amdgpu.h`, `amdgpu_vcn.h`, `amdgpu_pm.h`, `soc15.h`, `soc15d.h`, `vcn_v2_0.h`.
- Detected declarations: `function vcn_v2_5_idle_work_handler`, `function vcn_v2_5_ring_begin_use`, `function vcn_v2_5_ring_end_use`, `function vcn_v2_5_early_init`, `function vcn_v2_5_sw_init`, `function vcn_v2_5_sw_fini`, `function vcn_v2_5_hw_init`, `function vcn_v2_5_hw_fini`, `function vcn_v2_5_suspend`, `function vcn_v2_5_resume`.
- 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.