drivers/gpu/drm/ttm/ttm_bo_util.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/ttm/ttm_bo_util.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/ttm/ttm_bo_util.c- Extension
.c- Size
- 32083 bytes
- Lines
- 1167
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/export.hlinux/swap.hlinux/vmalloc.hdrm/ttm/ttm_bo.hdrm/ttm/ttm_placement.hdrm/ttm/ttm_tt.hdrm/drm_cache.httm_bo_internal.h
Detected Declarations
struct ttm_transfer_objfunction ttm_mem_io_reservefunction ttm_mem_io_freefunction ttm_move_memcpyfunction thefunction ttm_transfered_destroyfunction ttm_buffer_object_transferfunction ttm_io_protfunction ttm_bo_ioremapfunction ttm_bo_kmap_ttmfunction kmap_local_page_try_from_panicfunction ttm_bo_kmapfunction ttm_bo_kunmapfunction ttm_bo_vmapfunction ttm_bo_vmapfunction ttm_bo_wait_free_nodefunction ttm_bo_move_to_ghostfunction ttm_bo_move_pipeline_evictfunction ttm_bo_move_accel_cleanupfunction ttm_bo_move_sync_cleanupfunction ttm_bo_pipeline_guttingfunction ttm_lru_walk_trylockfunction ttm_lru_walk_ticketlockfunction ttm_lru_walk_for_evictfunction ttm_bo_lru_for_each_reserved_guardedfunction ttm_bo_lru_cursor_cleanup_bofunction ttm_bo_lru_cursor_finifunction ttm_bo_lru_cursor_initfunction __ttm_bo_lru_cursor_nextfunction ttm_bo_lru_cursor_nextfunction ttm_bo_lru_cursor_firstfunction ttm_bo_shrinkfunction ttm_bo_shrink_suitablefunction ttm_bo_shrink_avoid_waitexport ttm_move_memcpyexport ttm_bo_move_memcpyexport ttm_io_protexport ttm_bo_kmap_try_from_panicexport ttm_bo_kmapexport ttm_bo_kunmapexport ttm_bo_vmapexport ttm_bo_vunmapexport ttm_bo_move_accel_cleanupexport ttm_bo_move_sync_cleanupexport ttm_lru_walk_for_evictexport ttm_bo_lru_cursor_finiexport ttm_bo_lru_cursor_initexport ttm_bo_lru_cursor_next
Annotated Snippet
struct ttm_transfer_obj {
struct ttm_buffer_object base;
struct ttm_buffer_object *bo;
};
int ttm_mem_io_reserve(struct ttm_device *bdev,
struct ttm_resource *mem)
{
if (mem->bus.offset || mem->bus.addr)
return 0;
mem->bus.is_iomem = false;
if (!bdev->funcs->io_mem_reserve)
return 0;
return bdev->funcs->io_mem_reserve(bdev, mem);
}
void ttm_mem_io_free(struct ttm_device *bdev,
struct ttm_resource *mem)
{
if (!mem)
return;
if (!mem->bus.offset && !mem->bus.addr)
return;
if (bdev->funcs->io_mem_free)
bdev->funcs->io_mem_free(bdev, mem);
mem->bus.offset = 0;
mem->bus.addr = NULL;
}
/**
* ttm_move_memcpy - Helper to perform a memcpy ttm move operation.
* @clear: Whether to clear rather than copy.
* @num_pages: Number of pages of the operation.
* @dst_iter: A struct ttm_kmap_iter representing the destination resource.
* @src_iter: A struct ttm_kmap_iter representing the source resource.
*
* This function is intended to be able to move out async under a
* dma-fence if desired.
*/
void ttm_move_memcpy(bool clear,
u32 num_pages,
struct ttm_kmap_iter *dst_iter,
struct ttm_kmap_iter *src_iter)
{
const struct ttm_kmap_iter_ops *dst_ops = dst_iter->ops;
const struct ttm_kmap_iter_ops *src_ops = src_iter->ops;
struct iosys_map src_map, dst_map;
pgoff_t i;
/* Single TTM move. NOP */
if (dst_ops->maps_tt && src_ops->maps_tt)
return;
/* Don't move nonexistent data. Clear destination instead. */
if (clear) {
for (i = 0; i < num_pages; ++i) {
dst_ops->map_local(dst_iter, &dst_map, i);
if (dst_map.is_iomem)
memset_io(dst_map.vaddr_iomem, 0, PAGE_SIZE);
else
memset(dst_map.vaddr, 0, PAGE_SIZE);
if (dst_ops->unmap_local)
dst_ops->unmap_local(dst_iter, &dst_map);
}
return;
}
for (i = 0; i < num_pages; ++i) {
dst_ops->map_local(dst_iter, &dst_map, i);
src_ops->map_local(src_iter, &src_map, i);
drm_memcpy_from_wc(&dst_map, &src_map, PAGE_SIZE);
if (src_ops->unmap_local)
src_ops->unmap_local(src_iter, &src_map);
if (dst_ops->unmap_local)
dst_ops->unmap_local(dst_iter, &dst_map);
}
}
EXPORT_SYMBOL(ttm_move_memcpy);
/**
* ttm_bo_move_memcpy
*
* @bo: A pointer to a struct ttm_buffer_object.
Annotation
- Immediate include surface: `linux/export.h`, `linux/swap.h`, `linux/vmalloc.h`, `drm/ttm/ttm_bo.h`, `drm/ttm/ttm_placement.h`, `drm/ttm/ttm_tt.h`, `drm/drm_cache.h`, `ttm_bo_internal.h`.
- Detected declarations: `struct ttm_transfer_obj`, `function ttm_mem_io_reserve`, `function ttm_mem_io_free`, `function ttm_move_memcpy`, `function the`, `function ttm_transfered_destroy`, `function ttm_buffer_object_transfer`, `function ttm_io_prot`, `function ttm_bo_ioremap`, `function ttm_bo_kmap_ttm`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: integration 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.