drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c- Extension
.c- Size
- 10868 bytes
- Lines
- 442
- 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
ummu.hvmm.hsubdev/bar.hsubdev/fb.hnvif/if500d.hnvif/if900d.h
Detected Declarations
struct nvkm_mmu_ptpstruct nvkm_mmu_ptcfunction nvkm_mmu_ptp_putfunction nvkm_mmu_ptp_getfunction nvkm_mmu_ptc_findfunction list_for_each_entryfunction nvkm_mmu_ptc_putfunction nvkm_mmu_ptc_getfunction nvkm_mmu_ptc_dumpfunction list_for_each_entry_safefunction nvkm_mmu_ptc_finifunction list_for_each_entry_safefunction nvkm_mmu_ptc_initfunction nvkm_mmu_typefunction nvkm_mmu_heapfunction nvkm_mmu_hostfunction nvkm_mmu_vramfunction nvkm_mmu_oneinitfunction nvkm_mmu_initfunction nvkm_mmu_dtorfunction nvkm_mmu_ctorfunction nvkm_mmu_new_
Annotated Snippet
struct nvkm_mmu_ptp {
struct nvkm_mmu_pt *pt;
struct list_head head;
u8 shift;
u16 mask;
u16 free;
};
static void
nvkm_mmu_ptp_put(struct nvkm_mmu *mmu, bool force, struct nvkm_mmu_pt *pt)
{
const int slot = pt->base >> pt->ptp->shift;
struct nvkm_mmu_ptp *ptp = pt->ptp;
/* If there were no free slots in the parent allocation before,
* there will be now, so return PTP to the cache.
*/
if (!ptp->free)
list_add(&ptp->head, &mmu->ptp.list);
ptp->free |= BIT(slot);
/* If there's no more sub-allocations, destroy PTP. */
if (ptp->free == ptp->mask) {
nvkm_mmu_ptc_put(mmu, force, &ptp->pt);
list_del(&ptp->head);
kfree(ptp);
}
kfree(pt);
}
static struct nvkm_mmu_pt *
nvkm_mmu_ptp_get(struct nvkm_mmu *mmu, u32 size, bool zero)
{
struct nvkm_mmu_pt *pt;
struct nvkm_mmu_ptp *ptp;
int slot;
if (!(pt = kzalloc_obj(*pt)))
return NULL;
ptp = list_first_entry_or_null(&mmu->ptp.list, typeof(*ptp), head);
if (!ptp) {
/* Need to allocate a new parent to sub-allocate from. */
if (!(ptp = kmalloc_obj(*ptp))) {
kfree(pt);
return NULL;
}
ptp->pt = nvkm_mmu_ptc_get(mmu, 0x1000, 0x1000, false);
if (!ptp->pt) {
kfree(ptp);
kfree(pt);
return NULL;
}
ptp->shift = order_base_2(size);
slot = nvkm_memory_size(ptp->pt->memory) >> ptp->shift;
ptp->mask = (1 << slot) - 1;
ptp->free = ptp->mask;
list_add(&ptp->head, &mmu->ptp.list);
}
pt->ptp = ptp;
pt->sub = true;
/* Sub-allocate from parent object, removing PTP from cache
* if there's no more free slots left.
*/
slot = __ffs(ptp->free);
ptp->free &= ~BIT(slot);
if (!ptp->free)
list_del(&ptp->head);
pt->memory = pt->ptp->pt->memory;
pt->base = slot << ptp->shift;
pt->addr = pt->ptp->pt->addr + pt->base;
return pt;
}
struct nvkm_mmu_ptc {
struct list_head head;
struct list_head item;
u32 size;
u32 refs;
};
static inline struct nvkm_mmu_ptc *
nvkm_mmu_ptc_find(struct nvkm_mmu *mmu, u32 size)
{
struct nvkm_mmu_ptc *ptc;
Annotation
- Immediate include surface: `ummu.h`, `vmm.h`, `subdev/bar.h`, `subdev/fb.h`, `nvif/if500d.h`, `nvif/if900d.h`.
- Detected declarations: `struct nvkm_mmu_ptp`, `struct nvkm_mmu_ptc`, `function nvkm_mmu_ptp_put`, `function nvkm_mmu_ptp_get`, `function nvkm_mmu_ptc_find`, `function list_for_each_entry`, `function nvkm_mmu_ptc_put`, `function nvkm_mmu_ptc_get`, `function nvkm_mmu_ptc_dump`, `function list_for_each_entry_safe`.
- 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.