drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c- Extension
.c- Size
- 14743 bytes
- Lines
- 594
- 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.
- 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
amdgpu.hatom.hlinux/device.hlinux/pci.hlinux/slab.hlinux/acpi.hlinux/vgaarb.h
Detected Declarations
function filesfunction amdgpu_bios_releasefunction amdgpu_read_bios_from_vramfunction amdgpu_read_biosfunction amdgpu_read_bios_from_romfunction amdgpu_read_platform_biosfunction systemsfunction amdgpu_atrm_get_biosfunction amdgpu_atrm_get_biosfunction amdgpu_read_disabled_biosfunction amdgpu_acpi_vfct_biosfunction amdgpu_acpi_vfct_biosfunction amdgpu_get_bios_apufunction amdgpu_prefer_rom_resourcefunction amdgpu_get_bios_dgpufunction amdgpu_get_biosfunction amdgpu_soc15_read_bios_from_rom
Annotated Snippet
if (!bios) {
amdgpu_bios_release(adev);
return false;
}
memcpy_fromio(adev->bios, bios, size);
iounmap(bios);
}
adev->bios_size = size;
if (!check_atom_bios(adev, size)) {
amdgpu_bios_release(adev);
return false;
}
return true;
}
bool amdgpu_read_bios(struct amdgpu_device *adev)
{
uint8_t __iomem *bios;
size_t size;
adev->bios = NULL;
/* XXX: some cards may return 0 for rom size? ddx has a workaround */
bios = pci_map_rom(adev->pdev, &size);
if (!bios)
return false;
adev->bios = kzalloc(size, GFP_KERNEL);
if (adev->bios == NULL) {
pci_unmap_rom(adev->pdev, bios);
return false;
}
adev->bios_size = size;
memcpy_fromio(adev->bios, bios, size);
pci_unmap_rom(adev->pdev, bios);
if (!check_atom_bios(adev, size)) {
amdgpu_bios_release(adev);
return false;
}
return true;
}
static bool amdgpu_read_bios_from_rom(struct amdgpu_device *adev)
{
u8 header[AMD_VBIOS_SIGNATURE_END+1] = {0};
int len;
if (!adev->asic_funcs || !adev->asic_funcs->read_bios_from_rom)
return false;
/* validate VBIOS signature */
if (amdgpu_asic_read_bios_from_rom(adev, &header[0], sizeof(header)) == false)
return false;
header[AMD_VBIOS_SIGNATURE_END] = 0;
if ((!AMD_IS_VALID_VBIOS(header)) ||
memcmp((char *)&header[AMD_VBIOS_SIGNATURE_OFFSET],
AMD_VBIOS_SIGNATURE,
strlen(AMD_VBIOS_SIGNATURE)) != 0)
return false;
/* valid vbios, go on */
len = AMD_VBIOS_LENGTH(header);
len = ALIGN(len, 4);
adev->bios = kmalloc(len, GFP_KERNEL);
if (!adev->bios) {
DRM_ERROR("no memory to allocate for BIOS\n");
return false;
}
adev->bios_size = len;
/* read complete BIOS */
amdgpu_asic_read_bios_from_rom(adev, adev->bios, len);
if (!check_atom_bios(adev, len)) {
amdgpu_bios_release(adev);
return false;
}
return true;
}
static bool amdgpu_read_platform_bios(struct amdgpu_device *adev)
{
phys_addr_t rom = adev->pdev->rom;
Annotation
- Immediate include surface: `amdgpu.h`, `atom.h`, `linux/device.h`, `linux/pci.h`, `linux/slab.h`, `linux/acpi.h`, `linux/vgaarb.h`.
- Detected declarations: `function files`, `function amdgpu_bios_release`, `function amdgpu_read_bios_from_vram`, `function amdgpu_read_bios`, `function amdgpu_read_bios_from_rom`, `function amdgpu_read_platform_bios`, `function systems`, `function amdgpu_atrm_get_bios`, `function amdgpu_atrm_get_bios`, `function amdgpu_read_disabled_bios`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
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.