drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c- Extension
.c- Size
- 16394 bytes
- Lines
- 608
- 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.
- 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
priv.hcore/memory.hcore/tegra.hsubdev/ltc.hsubdev/mmu.h
Detected Declarations
struct gk20a_instobjstruct gk20a_instobj_dmastruct gk20a_instobj_iommustruct gk20a_instmemfunction gk20a_instobj_targetfunction gk20a_instobj_pagefunction gk20a_instobj_addrfunction gk20a_instobj_sizefunction gk20a_instobj_iommu_recycle_vaddrfunction gk20a_instmem_vaddr_gcfunction gk20a_instobj_acquire_dmafunction gk20a_instobj_acquire_iommufunction gk20a_instobj_release_dmafunction gk20a_instobj_release_iommufunction gk20a_instobj_rd32function gk20a_instobj_wr32function gk20a_instobj_mapfunction gk20a_instobj_dtor_dmafunction gk20a_instobj_dtor_iommufunction gk20a_instobj_ctor_dmafunction gk20a_instobj_ctor_iommufunction gk20a_instobj_newfunction gk20a_instmem_dtorfunction gk20a_instmem_new
Annotated Snippet
struct gk20a_instobj {
struct nvkm_instobj base;
struct nvkm_mm_node *mn;
struct gk20a_instmem *imem;
/* CPU mapping */
u32 *vaddr;
};
#define gk20a_instobj(p) container_of((p), struct gk20a_instobj, base.memory)
/*
* Used for objects allocated using the DMA API
*/
struct gk20a_instobj_dma {
struct gk20a_instobj base;
dma_addr_t handle;
struct nvkm_mm_node r;
};
#define gk20a_instobj_dma(p) \
container_of(gk20a_instobj(p), struct gk20a_instobj_dma, base)
/*
* Used for objects flattened using the IOMMU API
*/
struct gk20a_instobj_iommu {
struct gk20a_instobj base;
/* to link into gk20a_instmem::vaddr_lru */
struct list_head vaddr_node;
/* how many clients are using vaddr? */
u32 use_cpt;
/* will point to the higher half of pages */
dma_addr_t *dma_addrs;
/* array of base.mem->size pages (+ dma_addr_ts) */
struct page *pages[];
};
#define gk20a_instobj_iommu(p) \
container_of(gk20a_instobj(p), struct gk20a_instobj_iommu, base)
struct gk20a_instmem {
struct nvkm_instmem base;
/* protects vaddr_* and gk20a_instobj::vaddr* */
struct mutex lock;
/* CPU mappings LRU */
unsigned int vaddr_use;
unsigned int vaddr_max;
struct list_head vaddr_lru;
/* Only used if IOMMU if present */
struct mutex *mm_mutex;
struct nvkm_mm *mm;
struct iommu_domain *domain;
unsigned long iommu_pgshift;
u16 iommu_bit;
/* Only used by DMA API */
unsigned long attrs;
};
#define gk20a_instmem(p) container_of((p), struct gk20a_instmem, base)
static enum nvkm_memory_target
gk20a_instobj_target(struct nvkm_memory *memory)
{
return NVKM_MEM_TARGET_NCOH;
}
static u8
gk20a_instobj_page(struct nvkm_memory *memory)
{
return 12;
}
static u64
gk20a_instobj_addr(struct nvkm_memory *memory)
{
return (u64)gk20a_instobj(memory)->mn->offset << 12;
}
static u64
gk20a_instobj_size(struct nvkm_memory *memory)
{
return (u64)gk20a_instobj(memory)->mn->length << 12;
}
/*
* Recycle the vaddr of obj. Must be called with gk20a_instmem::lock held.
Annotation
- Immediate include surface: `priv.h`, `core/memory.h`, `core/tegra.h`, `subdev/ltc.h`, `subdev/mmu.h`.
- Detected declarations: `struct gk20a_instobj`, `struct gk20a_instobj_dma`, `struct gk20a_instobj_iommu`, `struct gk20a_instmem`, `function gk20a_instobj_target`, `function gk20a_instobj_page`, `function gk20a_instobj_addr`, `function gk20a_instobj_size`, `function gk20a_instobj_iommu_recycle_vaddr`, `function gk20a_instmem_vaddr_gc`.
- 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.
- 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.