STRUCT TTM_BUFFER_OBJECT(9)
π struct ttm_buffer_object(9)
okay bestie, welcome to the Kernel API Manual β¨ β this one's about struct ttm_buffer_object, which is genuinely one of those lowkey iconic kernel structs. no cap. π«Ά
β¨ NAME β¨
struct ttm_buffer_object β literally the base class for TTM buffer objects π
πΈ SYNOPSIS πΈ
struct ttm_buffer_object {
struct drm_gem_object base;
struct ttm_device *bdev;
enum ttm_bo_type type;
uint32_t page_alignment;
void (*destroy) (struct ttm_buffer_object *);
struct kref kref;
struct ttm_resource *resource;
struct ttm_tt *ttm;
bool deleted;
struct ttm_lru_bulk_move *bulk_move;
unsigned priority;
unsigned pin_count;
struct work_struct delayed_delete;
struct sg_table *sg;
};
π Members π
baseβ thedrm_gem_objectsuperclass data. like, the main character it inherits from πbdevβ pointer to the buffer object device structure.typeβ the bo type, iykyk.page_alignmentβ page alignment. that's it, that's the whole vibe β¨destroyβ the destruction function. if it'sNULL,kfreegets used instead. (so, no destroy function?kfreesteps in. slay.)krefβ reference count of this buffer object. the moment this refcount hits zero, the object gets destroyed or yeeted onto the delayed delete list π«resourceβ structure describing the current placement.ttmβ the TTM structure holding system pages.deletedβTrueif the object is only a zombie and is already deleted π§ββοΈπbulk_moveβ the bulk move object.priorityβ priority for LRU. BOs with lower priority get evicted first π₯pin_countβ pin count.delayed_deleteβ the work item used when we can't delete the BO immediately. it's giving "i'll deal with this later" πsgβ external source of pages and DMA addresses, and it's protected by the reservation lock π
π¦ Description π¦
so this is the base class for TTM buffer objects β it's the one that deals with data placement and CPU mappings π«
GPU mappings are really up to the driver, but for simpler GPUs the driver can usually just use the placement offset offset directly as the GPU virtual address. (yes, "offset offset" β that's exactly how it's written, no touchy π₯)
for drivers implementing multiple GPU memory manager contexts, the driver should manage the address space in these contexts separately, and use these objects to get the correct placement and caching for these GPU maps. the way this makes it possible to use these objects for even quite elaborate memory management schemes is honestly so iconic π
and the destroy member plus the API visibility of this object? that's what makes it possible to derive driver specific types. periodt. π
π SEE ALSO π
kernel file ./include/drm/ttm/ttm_bo.h β and also these besties:
enum ttm_bo_type(9)struct ttm_bo_kmap_obj(9)struct ttm_operation_ctx(9)struct ttm_lru_walk_arg(9)struct ttm_lru_walk(9)struct ttm_bo_shrink_flags(9)ttm_bo_reserve(9)ttm_bo_reserve_slowpath(9)ttm_bo_move_null(9)ttm_bo_unreserve(9)ttm_kmap_obj_virtual(9)struct ttm_bo_lru_cursor(9)ttm_bo_lru_for_each_reserved_guarded(9)
π sign-off time: this page came from./include/drm/ttm, dated October 2026, and the header still calls itstruct ttm_buffer_object(9). go read the source bestie, ily π«Άβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms