drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c- Extension
.c- Size
- 78500 bytes
- Lines
- 2758
- 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.
- 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/pm_runtime.hamdgpu.hamdgpu_gfx.hamdgpu_rlc.hamdgpu_ras.hamdgpu_reset.hamdgpu_xcp.hamdgpu_xgmi.hamdgpu_mes.hnvd.h
Detected Declarations
function filesfunction amdgpu_queue_mask_bit_to_mec_queuefunction amdgpu_gfx_is_mec_queue_enabledfunction amdgpu_gfx_me_queue_to_bitfunction amdgpu_gfx_is_me_queue_enabledfunction amdgpu_gfx_parse_disable_cufunction amdgpu_gfx_is_graphics_multipipe_capablefunction amdgpu_gfx_is_compute_multipipe_capablefunction amdgpu_gfx_is_high_priority_graphics_queuefunction amdgpu_gfx_is_high_priority_compute_queuefunction amdgpu_gfx_compute_queue_acquirefunction amdgpu_gfx_graphics_queue_acquirefunction amdgpu_gfx_kiq_acquirefunction amdgpu_gfx_kiq_init_ringfunction amdgpu_gfx_kiq_free_ringfunction amdgpu_gfx_kiq_finifunction amdgpu_gfx_kiq_initfunction amdgpu_gfx_mqd_sw_initfunction amdgpu_gfx_mqd_sw_finifunction amdgpu_gfx_mqd_symmetrically_map_cu_maskfunction amdgpu_gfx_disable_kcqfunction amdgpu_gfx_disable_kgqfunction amdgpu_queue_mask_bit_to_set_resource_bitfunction amdgpu_gfx_mes_enable_kcqfunction amdgpu_gfx_enable_kcqfunction amdgpu_gfx_enable_kgqfunction amdgpu_gfx_do_off_ctrlfunction amdgpu_gfx_off_ctrlfunction amdgpu_gfx_off_ctrl_immediatefunction amdgpu_set_gfx_off_residencyfunction amdgpu_get_gfx_off_residencyfunction amdgpu_get_gfx_off_entrycountfunction amdgpu_get_gfx_off_statusfunction amdgpu_gfx_ras_late_initfunction amdgpu_gfx_ras_suspendfunction amdgpu_gfx_ras_finifunction amdgpu_gfx_ras_sw_initfunction amdgpu_gfx_poison_consumption_handlerfunction amdgpu_gfx_process_ras_data_cbfunction amdgpu_gfx_cp_ecc_error_irqfunction amdgpu_gfx_ras_error_funcfunction amdgpu_kiq_rregfunction amdgpu_kiq_wregfunction amdgpu_gfx_get_hdp_flush_maskfunction amdgpu_kiq_hdp_flushfunction amdgpu_gfx_get_num_kcqfunction amdgpu_gfx_cp_init_microcodefunction amdgpu_gfx_is_master_xcc
Annotated Snippet
if (ret < 3) {
drm_err(adev_to_drm(adev), "could not parse disable_cu\n");
return;
}
if (se < max_se && sh < max_sh && cu < 16) {
drm_info(adev_to_drm(adev), "Disabling CU %u.%u.%u\n", se, sh, cu);
mask[se * max_sh + sh] |= 1u << cu;
} else {
drm_err(adev_to_drm(adev), "disable_cu %u.%u.%u is out of range\n",
se, sh, cu);
}
next = strchr(p, ',');
if (!next)
break;
p = next + 1;
}
}
static bool amdgpu_gfx_is_graphics_multipipe_capable(struct amdgpu_device *adev)
{
return amdgpu_async_gfx_ring && adev->gfx.me.num_pipe_per_me > 1;
}
static bool amdgpu_gfx_is_compute_multipipe_capable(struct amdgpu_device *adev)
{
if (amdgpu_compute_multipipe != -1) {
dev_info(adev->dev, " forcing compute pipe policy %d\n",
amdgpu_compute_multipipe);
return amdgpu_compute_multipipe == 1;
}
if (amdgpu_ip_version(adev, GC_HWIP, 0) > IP_VERSION(9, 0, 0))
return true;
/* FIXME: spreading the queues across pipes causes perf regressions
* on POLARIS11 compute workloads */
if (adev->asic_type == CHIP_POLARIS11)
return false;
return adev->gfx.mec.num_mec > 1;
}
bool amdgpu_gfx_is_high_priority_graphics_queue(struct amdgpu_device *adev,
struct amdgpu_ring *ring)
{
int queue = ring->queue;
int pipe = ring->pipe;
/* Policy: use pipe1 queue0 as high priority graphics queue if we
* have more than one gfx pipe.
*/
if (amdgpu_gfx_is_graphics_multipipe_capable(adev) &&
adev->gfx.num_gfx_rings > 1 && pipe == 1 && queue == 0) {
int me = ring->me;
int bit;
bit = amdgpu_gfx_me_queue_to_bit(adev, me, pipe, queue);
if (ring == &adev->gfx.gfx_ring[bit])
return true;
}
return false;
}
bool amdgpu_gfx_is_high_priority_compute_queue(struct amdgpu_device *adev,
struct amdgpu_ring *ring)
{
/* Policy: use 1st queue as high priority compute queue if we
* have more than one compute queue.
*/
if (adev->gfx.num_compute_rings > 1 &&
ring == &adev->gfx.compute_ring[0])
return true;
return false;
}
void amdgpu_gfx_compute_queue_acquire(struct amdgpu_device *adev)
{
int i, j, queue, pipe;
bool multipipe_policy = amdgpu_gfx_is_compute_multipipe_capable(adev);
int max_queues_per_mec = min(adev->gfx.mec.num_pipe_per_mec *
adev->gfx.mec.num_queue_per_pipe,
adev->gfx.num_compute_rings);
int num_xcc = adev->gfx.xcc_mask ? NUM_XCC(adev->gfx.xcc_mask) : 1;
if (multipipe_policy) {
/* policy: make queues evenly cross all pipes on MEC1 only
Annotation
- Immediate include surface: `linux/firmware.h`, `linux/pm_runtime.h`, `amdgpu.h`, `amdgpu_gfx.h`, `amdgpu_rlc.h`, `amdgpu_ras.h`, `amdgpu_reset.h`, `amdgpu_xcp.h`.
- Detected declarations: `function files`, `function amdgpu_queue_mask_bit_to_mec_queue`, `function amdgpu_gfx_is_mec_queue_enabled`, `function amdgpu_gfx_me_queue_to_bit`, `function amdgpu_gfx_is_me_queue_enabled`, `function amdgpu_gfx_parse_disable_cu`, `function amdgpu_gfx_is_graphics_multipipe_capable`, `function amdgpu_gfx_is_compute_multipipe_capable`, `function amdgpu_gfx_is_high_priority_graphics_queue`, `function amdgpu_gfx_is_high_priority_compute_queue`.
- 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.