STRUCT TTM_BUFFER_OBJECT(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 β€” the drm_gem_object superclass 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's NULL, kfree gets used instead. (so, no destroy function? kfree steps 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 β€” True if 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:


πŸ’– sign-off time: this page came from ./include/drm/ttm, dated October 2026, and the header still calls it struct ttm_buffer_object(9). go read the source bestie, ily 🫢✨
πŸ“¦ where this page comes from