ttm_bo_init_reserved(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… ttm_bo_init_reserved β€” the Kernel API Manual era πŸŽ€

okay bestie, so this is a page from the Kernel API Manual, which is giving very "the source of truth is a text file and it knows it" energy. The star of the show is ttm_bo_init_reserved(9), and she's here to set up your buffer object for you. let's get into it ✨


✨ NAME ✨

ttm_bo_init_reserved β€”

(fr fr, the description is literally blank on this one 😭 the manpage said "she's mysterious" and refused to elaborate. iconic of her. moving on 🫢)


🌸 SYNOPSIS 🌸

int ttm_bo_init_reserved (struct ttm_device *bdev , struct
ttm_buffer_object *bo , enum ttm_bo_type type , struct ttm_placement
*placement , uint32_t alignment , struct ttm_operation_ctx *ctx , struct
sg_table *sg , struct dma_resv *resv , void (*destroy) (struct
ttm_buffer_object *) );

like, nine whole parameters, she's highkey thorough πŸ’…


πŸŽ€ ARGUMENTS πŸŽ€

  • bdev β€” a pointer to a ttm_device struct. that's your device bestie, the whole vibe.
  • bo β€” a pointer to the ttm_buffer_object that's about to get initialized. she's pre-allocated, she's ready, she's the main character.
  • type β€” the requested type of the buffer object. what flavour are we today ✨
  • placement β€” the initial placement for the buffer object. where she lives at first 🏠
  • alignment β€” data alignment, measured in pages. not bytes, bestie, pages πŸ‘€
  • ctx β€” the TTM operation context used for memory allocation. it's giving "hold my hand while I malloc" 🫢
  • sg β€” the scatter-gather table.
  • resv β€” a pointer to a dma_resv, or NULL to let ttm allocate one. doing it yourself? bold. letting ttm do it? also valid πŸ’…
  • destroy β€” the destroy function. and listen: use NULL for kfree. that's the shortcut, no cap.

πŸ’– DESCRIPTION πŸ’–

so the way this function works: it initializes a pre-allocated struct ttm_buffer_object. like, you bring the memory, she brings the setup ✨

and because this object might be part of a larger structure, this function β€” together with the destroy function β€” is what enables driver-specific objects that are derived from a ttm_buffer_object. it's giving "inheritance but make it C" πŸ¦‹

🫢 good-news moment: on successful return, the caller owns an object kref to bo. the kref and list_kref are usually set to 1 β€” but heads up, in some situations other tasks may already be holding references to bo as well. so don't go assuming you're the only one in the group chat πŸ’€

and also, real talk: if resv == NULL, the buffer's reservation lock will be held, and it's your responsibility to call ttm_bo_unreserve. nobody else is gonna do it for you, bestie 😀

πŸ’€ BIG RED FLAG WARNING, PLEASE READ THIS ONE: if a failure occurs, the function will call the destroy function. so after a failure, dereferencing bo is illegal and will likely cause memory corruption. do NOT touch her. do NOT look at her. she's gone. periodt. πŸ™ˆ

Returns:

  • -ENOMEM β€” out of memory 😭
  • -EINVAL β€” invalid placement flags πŸ™ƒ
  • -ERESTARTSYS β€” interrupted by a signal while sleeping waiting for resources πŸ’€

πŸ”₯ SEE ALSO πŸ”₯

kernel file ./drivers/gpu/drm/ttm/ttm_bo.c β€” and the whole friend group, gathered for you:


and that's the whole page, bestie πŸŽ€ this cutie came to you from ./drivers/gpu/drm/ttm, dated October 2026 β€” so mark your calendar, she's from the future and she ate πŸ’…βœ¨ slay 🌈

πŸ“¦ where this page comes from