drivers/gpu/drm/nouveau/nvkm/core/firmware.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/nouveau/nvkm/core/firmware.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/nouveau/nvkm/core/firmware.c- Extension
.c- Size
- 7434 bytes
- Lines
- 310
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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
core/device.hcore/firmware.hsubdev/fb.hsubdev/mmu.h
Detected Declarations
function Copyrightfunction nvkm_firmware_load_blobfunction nvkm_firmware_getfunction nvkm_firmware_putfunction nvkm_firmware_mem_sglfunction nvkm_firmware_mem_mapfunction nvkm_firmware_mem_sizefunction nvkm_firmware_mem_addrfunction nvkm_firmware_mem_pagefunction nvkm_firmware_mem_targetfunction nvkm_firmware_mem_dtorfunction nvkm_firmware_dtorfunction nvkm_firmware_ctorfunction for_each_sgtable_sg
Annotated Snippet
if (fw->img) {
memcpy(fw->img, src, fw->len);
fw->phys = addr;
}
sg_init_one(&fw->mem.sgl, fw->img, len);
sg_dma_address(&fw->mem.sgl) = fw->phys;
sg_dma_len(&fw->mem.sgl) = len;
}
break;
case NVKM_FIRMWARE_IMG_SGT:
len = ALIGN(fw->len, PAGE_SIZE);
fw->img = vmalloc(len);
if (fw->img) {
int pages = len >> PAGE_SHIFT;
int ret = 0;
memcpy(fw->img, src, fw->len);
ret = sg_alloc_table(&fw->mem.sgt, pages, GFP_KERNEL);
if (ret == 0) {
struct scatterlist *sgl;
u8 *data = fw->img;
int i;
for_each_sgtable_sg(&fw->mem.sgt, sgl, i) {
struct page *page = vmalloc_to_page(data);
if (!page) {
ret = -EFAULT;
break;
}
sg_set_page(sgl, page, PAGE_SIZE, 0);
data += PAGE_SIZE;
}
if (ret == 0) {
ret = dma_map_sgtable(fw->device->dev, &fw->mem.sgt,
DMA_TO_DEVICE, 0);
}
if (ret)
sg_free_table(&fw->mem.sgt);
}
if (ret) {
vfree(fw->img);
fw->img = NULL;
}
}
break;
default:
WARN_ON(1);
return -EINVAL;
}
if (!fw->img)
return -ENOMEM;
nvkm_memory_ctor(&nvkm_firmware_mem, &fw->mem.memory);
return 0;
}
Annotation
- Immediate include surface: `core/device.h`, `core/firmware.h`, `subdev/fb.h`, `subdev/mmu.h`.
- Detected declarations: `function Copyright`, `function nvkm_firmware_load_blob`, `function nvkm_firmware_get`, `function nvkm_firmware_put`, `function nvkm_firmware_mem_sgl`, `function nvkm_firmware_mem_map`, `function nvkm_firmware_mem_size`, `function nvkm_firmware_mem_addr`, `function nvkm_firmware_mem_page`, `function nvkm_firmware_mem_target`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.