drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c- Extension
.c- Size
- 30379 bytes
- Lines
- 1214
- 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.hlinux/module.hdrm/drm.hdrm/drm_drv.hamdgpu.hamdgpu_pm.hamdgpu_vce.hamdgpu_cs.hcikd.h
Detected Declarations
function amdgpu_vce_firmware_namefunction amdgpu_vce_early_initfunction amdgpu_vce_sw_initfunction amdgpu_vce_sw_finifunction amdgpu_vce_entity_initfunction amdgpu_vce_suspendfunction amdgpu_vce_resumefunction amdgpu_vce_idle_work_handlerfunction amdgpu_vce_ring_begin_usefunction amdgpu_vce_ring_end_usefunction amdgpu_vce_free_handlesfunction amdgpu_vce_get_create_msgfunction amdgpu_vce_get_destroy_msgfunction amdgpu_vce_validate_bofunction amdgpu_vce_cs_relocfunction amdgpu_vce_validate_handlefunction amdgpu_vce_ring_parse_csfunction amdgpu_vce_ring_parse_cs_vmfunction amdgpu_vce_ring_emit_ibfunction amdgpu_vce_ring_emit_fencefunction amdgpu_vce_ring_test_ringfunction amdgpu_vce_ring_test_ibfunction amdgpu_vce_get_ring_prio
Annotated Snippet
if (r != 0) {
DRM_ERROR("Failed setting up VCE run queue.\n");
return r;
}
}
return 0;
}
/**
* amdgpu_vce_suspend - unpin VCE fw memory
*
* @adev: amdgpu_device pointer
*
*/
int amdgpu_vce_suspend(struct amdgpu_device *adev)
{
int i;
cancel_delayed_work_sync(&adev->vce.idle_work);
if (adev->vce.vcpu_bo == NULL)
return 0;
for (i = 0; i < AMDGPU_MAX_VCE_HANDLES; ++i)
if (atomic_read(&adev->vce.handles[i]))
break;
if (i == AMDGPU_MAX_VCE_HANDLES)
return 0;
/* TODO: suspending running encoding sessions isn't supported */
return -EINVAL;
}
/**
* amdgpu_vce_resume - pin VCE fw memory
*
* @adev: amdgpu_device pointer
*
*/
int amdgpu_vce_resume(struct amdgpu_device *adev)
{
const struct common_firmware_header *hdr;
unsigned int offset;
int idx;
if (adev->vce.vcpu_bo == NULL)
return -EINVAL;
hdr = (const struct common_firmware_header *)adev->vce.fw->data;
offset = le32_to_cpu(hdr->ucode_array_offset_bytes);
if (drm_dev_enter(adev_to_drm(adev), &idx)) {
memset_io(adev->vce.cpu_addr, 0, amdgpu_bo_size(adev->vce.vcpu_bo));
memcpy_toio(adev->vce.cpu_addr, adev->vce.fw->data + offset,
adev->vce.fw->size - offset);
drm_dev_exit(idx);
}
return 0;
}
/**
* amdgpu_vce_idle_work_handler - power off VCE
*
* @work: pointer to work structure
*
* power of VCE when it's not used any more
*/
static void amdgpu_vce_idle_work_handler(struct work_struct *work)
{
struct amdgpu_device *adev =
container_of(work, struct amdgpu_device, vce.idle_work.work);
unsigned int i, count = 0;
for (i = 0; i < adev->vce.num_rings; i++)
count += amdgpu_fence_count_emitted(&adev->vce.ring[i]);
if (count == 0) {
if (adev->pm.dpm_enabled) {
amdgpu_dpm_enable_vce(adev, false);
} else {
amdgpu_asic_set_vce_clocks(adev, 0, 0);
amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCE,
AMD_PG_STATE_GATE);
amdgpu_device_ip_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_VCE,
AMD_CG_STATE_GATE);
}
} else {
Annotation
- Immediate include surface: `linux/firmware.h`, `linux/module.h`, `drm/drm.h`, `drm/drm_drv.h`, `amdgpu.h`, `amdgpu_pm.h`, `amdgpu_vce.h`, `amdgpu_cs.h`.
- Detected declarations: `function amdgpu_vce_firmware_name`, `function amdgpu_vce_early_init`, `function amdgpu_vce_sw_init`, `function amdgpu_vce_sw_fini`, `function amdgpu_vce_entity_init`, `function amdgpu_vce_suspend`, `function amdgpu_vce_resume`, `function amdgpu_vce_idle_work_handler`, `function amdgpu_vce_ring_begin_use`, `function amdgpu_vce_ring_end_use`.
- 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.