drivers/gpu/drm/nouveau/nouveau_bo.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/nouveau/nouveau_bo.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/nouveau/nouveau_bo.c- Extension
.c- Size
- 37313 bytes
- Lines
- 1501
- 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
linux/dma-mapping.hdrm/ttm/ttm_tt.hnouveau_drv.hnouveau_chan.hnouveau_fence.hnouveau_bo.hnouveau_ttm.hnouveau_gem.hnouveau_mem.hnouveau_vmm.hnvif/class.hnvif/if500b.hnvif/if900b.h
Detected Declarations
function nv10_bo_update_tile_regionfunction nv10_bo_get_tile_regionfunction nv10_bo_put_tile_regionfunction nv10_bo_set_tilingfunction nouveau_bo_del_ttmfunction nouveau_bo_newfunction roundup_64function nouveau_bo_fixup_alignfunction nouveau_bo_allocfunction nouveau_gem_newfunction nouveau_bo_initfunction nouveau_bo_newfunction nouveau_bo_unpin_delfunction nouveau_bo_new_pinfunction nouveau_bo_new_mapfunction nouveau_bo_new_map_gpufunction set_placement_rangefunction nouveau_bo_placement_setfunction nouveau_bo_pin_lockedfunction nouveau_bo_unpin_lockedfunction nouveau_bo_pinfunction nouveau_bo_unpinfunction nouveau_bo_mapfunction nouveau_bo_unmapfunction nouveau_bo_sync_for_devicefunction nouveau_bo_sync_for_cpufunction nouveau_bo_add_io_reserve_lrufunction nouveau_bo_del_io_reserve_lrufunction nouveau_bo_validatefunction nouveau_bo_wr16function nouveau_bo_rd32function nouveau_bo_wr32function nouveau_ttm_tt_createfunction nouveau_ttm_tt_bindfunction nouveau_ttm_tt_unbindfunction nouveau_bo_evict_flagsfunction nouveau_bo_move_prepfunction nouveau_bo_move_m2mffunction nouveau_bo_move_initfunction nouveau_bo_move_ntfyfunction list_for_each_entryfunction nouveau_bo_vm_bindfunction nouveau_bo_vm_cleanupfunction nouveau_bo_movefunction nouveau_ttm_io_mem_free_lockedfunction nouveau_ttm_io_mem_reservefunction nouveau_ttm_io_mem_freefunction nouveau_ttm_fault_reserve_notify
Annotated Snippet
if (pitch && !found) {
found = tile;
continue;
} else if (tile && fb->tile.region[i].pitch) {
/* Kill an unused tile region. */
nv10_bo_update_tile_region(dev, tile, 0, 0, 0, 0);
}
nv10_bo_put_tile_region(dev, tile, NULL);
}
if (found)
nv10_bo_update_tile_region(dev, found, addr, size, pitch, zeta);
return found;
}
static void
nouveau_bo_del_ttm(struct ttm_buffer_object *bo)
{
struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
struct drm_device *dev = drm->dev;
struct nouveau_bo *nvbo = nouveau_bo(bo);
WARN_ON(nvbo->bo.pin_count > 0);
nouveau_bo_del_io_reserve_lru(bo);
nv10_bo_put_tile_region(dev, nvbo->tile, NULL);
if (drm_gem_is_imported(&bo->base))
drm_prime_gem_destroy(&bo->base, bo->sg);
/*
* If nouveau_bo_new() allocated this buffer, the GEM object was never
* initialized, so don't attempt to release it.
*/
if (bo->base.dev) {
/* Gem objects not being shared with other VMs get their
* dma_resv from a root GEM object.
*/
if (nvbo->no_share)
drm_gem_object_put(nvbo->r_obj);
drm_gem_object_release(&bo->base);
} else {
dma_resv_fini(&bo->base._resv);
}
kfree(nvbo);
}
static inline u64
roundup_64(u64 x, u32 y)
{
x += y - 1;
do_div(x, y);
return x * y;
}
static void
nouveau_bo_fixup_align(struct nouveau_bo *nvbo, int *align, u64 *size)
{
struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev);
struct nvif_device *device = &drm->client.device;
if (device->info.family < NV_DEVICE_INFO_V0_TESLA) {
if (nvbo->mode) {
if (device->info.chipset >= 0x40) {
*align = 65536;
*size = roundup_64(*size, 64 * nvbo->mode);
} else if (device->info.chipset >= 0x30) {
*align = 32768;
*size = roundup_64(*size, 64 * nvbo->mode);
} else if (device->info.chipset >= 0x20) {
*align = 16384;
*size = roundup_64(*size, 64 * nvbo->mode);
} else if (device->info.chipset >= 0x10) {
*align = 16384;
*size = roundup_64(*size, 32 * nvbo->mode);
}
}
} else {
*size = roundup_64(*size, (1 << nvbo->page));
*align = max((1 << nvbo->page), *align);
}
*size = roundup_64(*size, PAGE_SIZE);
}
Annotation
- Immediate include surface: `linux/dma-mapping.h`, `drm/ttm/ttm_tt.h`, `nouveau_drv.h`, `nouveau_chan.h`, `nouveau_fence.h`, `nouveau_bo.h`, `nouveau_ttm.h`, `nouveau_gem.h`.
- Detected declarations: `function nv10_bo_update_tile_region`, `function nv10_bo_get_tile_region`, `function nv10_bo_put_tile_region`, `function nv10_bo_set_tiling`, `function nouveau_bo_del_ttm`, `function nouveau_bo_new`, `function roundup_64`, `function nouveau_bo_fixup_align`, `function nouveau_bo_alloc`, `function nouveau_gem_new`.
- 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.