drivers/gpu/drm/nouveau/nvkm/subdev/fb/ram.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/nouveau/nvkm/subdev/fb/ram.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/nouveau/nvkm/subdev/fb/ram.c- Extension
.c- Size
- 6625 bytes
- Lines
- 264
- 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
ram.hcore/memory.hsubdev/instmem.hsubdev/mmu.h
Detected Declarations
struct nvkm_vramfunction nvkm_vram_kmapfunction nvkm_vram_mapfunction nvkm_vram_sizefunction nvkm_vram_addrfunction nvkm_vram_pagefunction nvkm_vram_targetfunction nvkm_vram_dtorfunction nvkm_ram_wrapfunction nvkm_ram_getfunction nvkm_ram_initfunction nvkm_ram_delfunction nvkm_ram_ctorfunction nvkm_ram_new_
Annotated Snippet
struct nvkm_vram {
struct nvkm_memory memory;
struct nvkm_ram *ram;
u8 page;
struct nvkm_mm_node *mn;
};
static int
nvkm_vram_kmap(struct nvkm_memory *memory, struct nvkm_memory **pmemory)
{
return nvkm_instobj_wrap(nvkm_vram(memory)->ram->fb->subdev.device, memory, pmemory);
}
static int
nvkm_vram_map(struct nvkm_memory *memory, u64 offset, struct nvkm_vmm *vmm,
struct nvkm_vma *vma, void *argv, u32 argc)
{
struct nvkm_vram *vram = nvkm_vram(memory);
struct nvkm_vmm_map map = {
.memory = &vram->memory,
.offset = offset,
.mem = vram->mn,
};
return nvkm_vmm_map(vmm, vma, argv, argc, &map);
}
static u64
nvkm_vram_size(struct nvkm_memory *memory)
{
return (u64)nvkm_mm_size(nvkm_vram(memory)->mn) << NVKM_RAM_MM_SHIFT;
}
static u64
nvkm_vram_addr(struct nvkm_memory *memory)
{
struct nvkm_vram *vram = nvkm_vram(memory);
if (!nvkm_mm_contiguous(vram->mn))
return ~0ULL;
return (u64)nvkm_mm_addr(vram->mn) << NVKM_RAM_MM_SHIFT;
}
static u8
nvkm_vram_page(struct nvkm_memory *memory)
{
return nvkm_vram(memory)->page;
}
static enum nvkm_memory_target
nvkm_vram_target(struct nvkm_memory *memory)
{
return NVKM_MEM_TARGET_VRAM;
}
static void *
nvkm_vram_dtor(struct nvkm_memory *memory)
{
struct nvkm_vram *vram = nvkm_vram(memory);
struct nvkm_mm_node *next = vram->mn;
struct nvkm_mm_node *node;
if (next) {
if (likely(next->nl_entry.next)){
mutex_lock(&vram->ram->mutex);
while ((node = next)) {
next = node->next;
nvkm_mm_free(&vram->ram->vram, &node);
}
mutex_unlock(&vram->ram->mutex);
} else {
kfree(vram->mn);
}
}
return vram;
}
static const struct nvkm_memory_func
nvkm_vram = {
.dtor = nvkm_vram_dtor,
.target = nvkm_vram_target,
.page = nvkm_vram_page,
.addr = nvkm_vram_addr,
.size = nvkm_vram_size,
.map = nvkm_vram_map,
.kmap = nvkm_vram_kmap,
};
int
nvkm_ram_wrap(struct nvkm_device *device, u64 addr, u64 size,
Annotation
- Immediate include surface: `ram.h`, `core/memory.h`, `subdev/instmem.h`, `subdev/mmu.h`.
- Detected declarations: `struct nvkm_vram`, `function nvkm_vram_kmap`, `function nvkm_vram_map`, `function nvkm_vram_size`, `function nvkm_vram_addr`, `function nvkm_vram_page`, `function nvkm_vram_target`, `function nvkm_vram_dtor`, `function nvkm_ram_wrap`, `function nvkm_ram_get`.
- 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.