ttm_bo_init_validate(9)
π ttm_bo_init_validate(9) π
okay so bestie, welcome to the Kernel API Manual page for ttm_bo_init_validate β yes that's a mouthful, yes we're gonna get through it together, and yes I have my iced coffee ready ββ¨
πΈ NAME πΈ
ttm_bo_init_validate β (the page doesn't spell it out for us, but hi, this is the one that inits and validates your buffer object, iykyk π«Ά)
β¨ SYNOPSIS β¨
int ttm_bo_init_validate (struct ttm_device *bdev , struct
ttm_buffer_object *bo , enum ttm_bo_type type , struct ttm_placement
*placement , uint32_t alignment , bool interruptible , struct sg_table
*sg , struct dma_resv *resv , void (*destroy) (struct ttm_buffer_object
*) );
literally just look at that signature. nine (9) whole parameters. main character energy, no cap π
π ARGUMENTS π
bdevβ pointer to attm_devicestruct. that's your device babe π₯οΈboβ pointer to thettm_buffer_objectthat's about to get initialized. this is the star of the show βtypeβ the requested type of buffer object π«placementβ the initial placement for the buffer object πalignmentβ data alignment in pages. pages, bestie, not bytes, don't get it twisted πinterruptibleβ if it needs to sleep to wait for GPU resources, sleep interruptible. β οΈ heads up: the upstream doc text for this argument is straight-up merged with some other text (it's giving copy-paste glitch π), so here's the whole blob verbatim-ish so nothing gets lost: "pinned in physical memory. If this behaviour is not desired, this member holds a pointer to a persistent shmem object. Typically, this would point to the shmem object backing a GEM object if TTM is used to back a GEM user interface." β I'm not gonna pretend I know which argument that chunk originally belonged to, and I will NOT be guessing. facts only πsgβ scatter-gather table π§Ίresvβ pointer to adma_resv, orNULLto let ttm allocate one. your call, queen πdestroyβ the destroy function. useNULLforkfreeποΈ
π¦ DESCRIPTION π¦
okay so what does this actually do π
This function initializes a pre-allocated struct ttm_buffer_object. And because this object may be part of a larger structure, this function β together with the destroy function β enables driver-specific objects derived from a ttm_buffer_object. it's giving "we support your customization era" π
On successful return, the caller owns an object kref to bo. The kref and list_kref are usually set to 1, but note that in some situations, other tasks may already be holding references to bo as well. so likeβ¦ you're not always the only one holding the aux cord π
β οΈ okay this part is IMPORTANT, fr fr: if a failure occurs, the function will call thedestroyfunction. Thus, after a failure, dereferencingbois illegal and will likely cause memory corruption. ππ not a vibe. do not touch. do not poke. do not dereference. it's giving "the bridge is out." walk away π«
and the returns, bestie:
-ENOMEMβ out of memory π-EINVALβ invalid placement flags π©-ERESTARTSYSβ interrupted by signal while sleeping waiting for resources π΄β‘
π SEE ALSO π
kernel file ./drivers/gpu/drm/ttm/ttm_bo.c β and the whole friend group π:
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_reserved(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 page!! mwah π this one lives in ./drivers/gpu/drm/ttm, dated October 2026 β go read the sibling pages, they ate too π«Άβ¨
π¦ 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