drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/uvmm.c- Extension
.c- Size
- 14481 bytes
- Lines
- 589
- 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
uvmm.humem.hummu.hcore/client.hcore/memory.hnvif/if000c.hnvif/unpack.h
Detected Declarations
function nvkm_uvmm_searchfunction nvkm_uvmm_mthd_pfnclrfunction nvkm_uvmm_mthd_pfnmapfunction nvkm_uvmm_mthd_unmapfunction nvkm_uvmm_mthd_mapfunction nvkm_uvmm_mthd_putfunction nvkm_uvmm_mthd_getfunction nvkm_uvmm_mthd_pagefunction nvkm_uvmm_page_indexfunction nvkm_uvmm_mthd_raw_getfunction nvkm_uvmm_mthd_raw_putfunction nvkm_uvmm_mthd_raw_mapfunction nvkm_uvmm_mthd_raw_unmapfunction nvkm_uvmm_mthd_raw_sparsefunction nvkm_uvmm_mthd_rawfunction nvkm_uvmm_mthdfunction NVIF_VMM_V0_MTHDfunction nvkm_uvmm_dtorfunction nvkm_uvmm_new
Annotated Snippet
if (!vma) {
ret = -ENOMEM;
goto fail;
}
}
vma->busy = true;
mutex_unlock(&vmm->mutex.vmm);
ret = nvkm_memory_map(memory, offset, vmm, vma, argv, argc);
if (ret == 0) {
/* Successful map will clear vma->busy. */
nvkm_memory_unref(&memory);
return 0;
}
mutex_lock(&vmm->mutex.vmm);
vma->busy = false;
nvkm_vmm_unmap_region(vmm, vma);
fail:
mutex_unlock(&vmm->mutex.vmm);
nvkm_memory_unref(&memory);
return ret;
}
static int
nvkm_uvmm_mthd_put(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
{
union {
struct nvif_vmm_put_v0 v0;
} *args = argv;
struct nvkm_vmm *vmm = uvmm->vmm;
struct nvkm_vma *vma;
int ret = -ENOSYS;
u64 addr;
if (!(ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, false))) {
addr = args->v0.addr;
} else
return ret;
mutex_lock(&vmm->mutex.vmm);
vma = nvkm_vmm_node_search(vmm, args->v0.addr);
if (ret = -ENOENT, !vma || vma->addr != addr || vma->part) {
VMM_DEBUG(vmm, "lookup %016llx: %016llx %d", addr,
vma ? vma->addr : ~0ULL, vma ? vma->part : 0);
goto done;
}
if (ret = -ENOENT, vma->busy) {
VMM_DEBUG(vmm, "denied %016llx: %d", addr, vma->busy);
goto done;
}
nvkm_vmm_put_locked(vmm, vma);
ret = 0;
done:
mutex_unlock(&vmm->mutex.vmm);
return ret;
}
static int
nvkm_uvmm_mthd_get(struct nvkm_uvmm *uvmm, void *argv, u32 argc)
{
union {
struct nvif_vmm_get_v0 v0;
} *args = argv;
struct nvkm_vmm *vmm = uvmm->vmm;
struct nvkm_vma *vma;
int ret = -ENOSYS;
bool getref, mapref, sparse;
u8 page, align;
u64 size;
if (!(ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, false))) {
getref = args->v0.type == NVIF_VMM_GET_V0_PTES;
mapref = args->v0.type == NVIF_VMM_GET_V0_ADDR;
sparse = args->v0.sparse;
page = args->v0.page;
align = args->v0.align;
size = args->v0.size;
} else
return ret;
mutex_lock(&vmm->mutex.vmm);
ret = nvkm_vmm_get_locked(vmm, getref, mapref, sparse,
page, align, size, &vma);
mutex_unlock(&vmm->mutex.vmm);
if (ret)
return ret;
Annotation
- Immediate include surface: `uvmm.h`, `umem.h`, `ummu.h`, `core/client.h`, `core/memory.h`, `nvif/if000c.h`, `nvif/unpack.h`.
- Detected declarations: `function nvkm_uvmm_search`, `function nvkm_uvmm_mthd_pfnclr`, `function nvkm_uvmm_mthd_pfnmap`, `function nvkm_uvmm_mthd_unmap`, `function nvkm_uvmm_mthd_map`, `function nvkm_uvmm_mthd_put`, `function nvkm_uvmm_mthd_get`, `function nvkm_uvmm_mthd_page`, `function nvkm_uvmm_page_index`, `function nvkm_uvmm_mthd_raw_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.