drivers/gpu/drm/radeon/ni.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/radeon/ni.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/radeon/ni.c- Extension
.c- Size
- 72658 bytes
- Lines
- 2722
- 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.hlinux/pci.hlinux/slab.hdrm/radeon_drm.hatom.hcayman_blit_shaders.hclearstate_cayman.hevergreen.hni.hni_reg.hnid.hradeon.hradeon_asic.hradeon_audio.hradeon_ucode.h
Detected Declarations
function filesfunction tn_smc_wregfunction ni_init_golden_registersfunction ni_mc_load_microcodefunction ni_init_microcodefunction cayman_get_allowed_info_registerfunction tn_get_tempfunction cayman_gpu_initfunction cayman_pcie_gart_tlb_flushfunction cayman_pcie_gart_enablefunction cayman_pcie_gart_disablefunction cayman_pcie_gart_finifunction cayman_cp_int_cntl_setupfunction cayman_fence_ring_emitfunction cayman_ring_ib_executefunction cayman_cp_enablefunction cayman_gfx_get_rptrfunction cayman_gfx_get_wptrfunction cayman_gfx_set_wptrfunction cayman_cp_load_microcodefunction cayman_cp_startfunction cayman_cp_finifunction cayman_cp_resumefunction cayman_gpu_check_soft_resetfunction cayman_gpu_soft_resetfunction cayman_asic_resetfunction cayman_gfx_is_lockupfunction cayman_uvd_initfunction cayman_uvd_startfunction cayman_uvd_resumefunction cayman_vce_initfunction cayman_vce_startfunction cayman_vce_resumefunction cayman_startupfunction cayman_resumefunction cayman_suspendfunction cayman_initfunction cayman_finifunction cayman_vm_initfunction cayman_vm_finifunction CPfunction tn_set_vce_clocks
Annotated Snippet
if (rdev->mc_fw->size != mc_req_size) {
pr_err("ni_mc: Bogus length %zu in firmware \"%s\"\n",
rdev->mc_fw->size, fw_name);
err = -EINVAL;
}
}
if ((rdev->family >= CHIP_BARTS) && (rdev->family <= CHIP_CAYMAN)) {
snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", chip_name);
err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev);
if (err) {
pr_err("smc: error loading firmware \"%s\"\n", fw_name);
release_firmware(rdev->smc_fw);
rdev->smc_fw = NULL;
err = 0;
} else if (rdev->smc_fw->size != smc_req_size) {
pr_err("ni_mc: Bogus length %zu in firmware \"%s\"\n",
rdev->smc_fw->size, fw_name);
err = -EINVAL;
}
}
out:
if (err) {
if (err != -EINVAL)
pr_err("ni_cp: Failed to load firmware \"%s\"\n",
fw_name);
release_firmware(rdev->pfp_fw);
rdev->pfp_fw = NULL;
release_firmware(rdev->me_fw);
rdev->me_fw = NULL;
release_firmware(rdev->rlc_fw);
rdev->rlc_fw = NULL;
release_firmware(rdev->mc_fw);
rdev->mc_fw = NULL;
}
return err;
}
/**
* cayman_get_allowed_info_register - fetch the register for the info ioctl
*
* @rdev: radeon_device pointer
* @reg: register offset in bytes
* @val: register value
*
* Returns 0 for success or -EINVAL for an invalid register
*
*/
int cayman_get_allowed_info_register(struct radeon_device *rdev,
u32 reg, u32 *val)
{
switch (reg) {
case GRBM_STATUS:
case GRBM_STATUS_SE0:
case GRBM_STATUS_SE1:
case SRBM_STATUS:
case SRBM_STATUS2:
case (DMA_STATUS_REG + DMA0_REGISTER_OFFSET):
case (DMA_STATUS_REG + DMA1_REGISTER_OFFSET):
case UVD_STATUS:
*val = RREG32(reg);
return 0;
default:
return -EINVAL;
}
}
int tn_get_temp(struct radeon_device *rdev)
{
u32 temp = RREG32_SMC(TN_CURRENT_GNB_TEMP) & 0x7ff;
int actual_temp = (temp / 8) - 49;
return actual_temp * 1000;
}
/*
* Core functions
*/
static void cayman_gpu_init(struct radeon_device *rdev)
{
u32 gb_addr_config = 0;
u32 mc_arb_ramcfg;
u32 cgts_tcc_disable;
u32 sx_debug_1;
u32 smx_dc_ctl0;
u32 cgts_sm_ctrl_reg;
u32 hdp_host_path_cntl;
u32 tmp;
u32 disabled_rb_mask;
Annotation
- Immediate include surface: `linux/firmware.h`, `linux/module.h`, `linux/pci.h`, `linux/slab.h`, `drm/radeon_drm.h`, `atom.h`, `cayman_blit_shaders.h`, `clearstate_cayman.h`.
- Detected declarations: `function files`, `function tn_smc_wreg`, `function ni_init_golden_registers`, `function ni_mc_load_microcode`, `function ni_init_microcode`, `function cayman_get_allowed_info_register`, `function tn_get_temp`, `function cayman_gpu_init`, `function cayman_pcie_gart_tlb_flush`, `function cayman_pcie_gart_enable`.
- 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.