drivers/gpu/drm/nouveau/nouveau_sgdma.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/nouveau/nouveau_sgdma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/nouveau/nouveau_sgdma.c- Extension
.c- Size
- 1979 bytes
- Lines
- 92
- 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.
- 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
linux/pagemap.hlinux/slab.hdrm/ttm/ttm_tt.hnouveau_drv.hnouveau_mem.hnouveau_ttm.hnouveau_bo.h
Detected Declarations
struct nouveau_sgdma_befunction nouveau_sgdma_destroyfunction nouveau_sgdma_bindfunction nouveau_sgdma_unbindfunction nouveau_sgdma_create_ttm
Annotated Snippet
struct nouveau_sgdma_be {
/* this has to be the first field so populate/unpopulated in
* nouve_bo.c works properly, otherwise have to move them here
*/
struct ttm_tt ttm;
struct nouveau_mem *mem;
};
void
nouveau_sgdma_destroy(struct ttm_device *bdev, struct ttm_tt *ttm)
{
struct nouveau_sgdma_be *nvbe = (struct nouveau_sgdma_be *)ttm;
if (ttm) {
ttm_tt_fini(&nvbe->ttm);
kfree(nvbe);
}
}
int
nouveau_sgdma_bind(struct ttm_device *bdev, struct ttm_tt *ttm, struct ttm_resource *reg)
{
struct nouveau_sgdma_be *nvbe = (struct nouveau_sgdma_be *)ttm;
struct nouveau_drm *drm = nouveau_bdev(bdev);
struct nouveau_mem *mem = nouveau_mem(reg);
int ret;
if (nvbe->mem)
return 0;
ret = nouveau_mem_host(reg, &nvbe->ttm);
if (ret)
return ret;
if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA) {
ret = nouveau_mem_map(mem, &drm->client.vmm.vmm, &mem->vma[0]);
if (ret) {
nouveau_mem_fini(mem);
return ret;
}
}
nvbe->mem = mem;
return 0;
}
void
nouveau_sgdma_unbind(struct ttm_device *bdev, struct ttm_tt *ttm)
{
struct nouveau_sgdma_be *nvbe = (struct nouveau_sgdma_be *)ttm;
if (nvbe->mem) {
nouveau_mem_fini(nvbe->mem);
nvbe->mem = NULL;
}
}
struct ttm_tt *
nouveau_sgdma_create_ttm(struct ttm_buffer_object *bo, uint32_t page_flags)
{
struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
struct nouveau_bo *nvbo = nouveau_bo(bo);
struct nouveau_sgdma_be *nvbe;
enum ttm_caching caching;
if (nvbo->force_coherent)
caching = ttm_uncached;
else if (drm->agp.bridge)
caching = ttm_write_combined;
else
caching = ttm_cached;
nvbe = kzalloc_obj(*nvbe);
if (!nvbe)
return NULL;
if (ttm_sg_tt_init(&nvbe->ttm, bo, page_flags, caching)) {
kfree(nvbe);
return NULL;
}
return &nvbe->ttm;
}
Annotation
- Immediate include surface: `linux/pagemap.h`, `linux/slab.h`, `drm/ttm/ttm_tt.h`, `nouveau_drv.h`, `nouveau_mem.h`, `nouveau_ttm.h`, `nouveau_bo.h`.
- Detected declarations: `struct nouveau_sgdma_be`, `function nouveau_sgdma_destroy`, `function nouveau_sgdma_bind`, `function nouveau_sgdma_unbind`, `function nouveau_sgdma_create_ttm`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
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.