ttm_bo_init_reserved(9)
π 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 attm_devicestruct. that's your device bestie, the whole vibe.boβ a pointer to thettm_buffer_objectthat'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 adma_resv, orNULLto let ttm allocate one. doing it yourself? bold. letting ttm do it? also valid πdestroyβ the destroy function. and listen: useNULLforkfree. 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 tobo. the kref andlist_krefare usually set to1β but heads up, in some situations other tasks may already be holding references toboas 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:
ttm_bo_move_to_lru_tail(9)ttm_bo_set_bulk_move(9)ttm_bo_eviction_valuable(9)ttm_bo_evict_first(9)ttm_bo_alloc_at_place(9)struct ttm_bo_evict_walk(9)ttm_bo_evict_cgroup(9)ttm_bo_pin(9)ttm_bo_unpin(9)ttm_bo_alloc_resource(9)ttm_bo_validate(9)ttm_bo_init_validate(9)ttm_bo_unmap_virtual(9)ttm_bo_wait_ctx(9)struct ttm_bo_swapout_walk(9)ttm_bo_swapout(9)ttm_bo_populate(9)
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
- 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