STRUCT TTM_TT(9)
π struct ttm_tt(9) π
okay so bestie, we're in the Kernel API Manual today and this one's a whole vibe β it's giving "structure holding the pages, caching- and aperture binding status for a buffer object that isn't backed by fixed (VRAM / AGP) memory." literally that's the whole NAME, no notes π
β¨ SYNOPSIS β¨
struct ttm_tt {
struct page **pages;
#define TTM_TT_FLAG_SWAPPED BIT(0);
#define TTM_TT_FLAG_ZERO_ALLOC BIT(1);
#define TTM_TT_FLAG_EXTERNAL BIT(2);
#define TTM_TT_FLAG_EXTERNAL_MAPPABLE BIT(3);
#define TTM_TT_FLAG_DECRYPTED BIT(4);
#define TTM_TT_FLAG_BACKED_UP BIT(5);
#define TTM_TT_FLAG_PRIV_POPULATED BIT(6);
uint32_t page_flags;
uint32_t num_pages;
struct sg_table *sg;
dma_addr_t *dma_address;
struct file *swap_storage;
struct file *backup;
enum ttm_caching caching;
struct ttm_pool_tt_restore *restore;
};
πΈ Members πΈ
the actual fields, let's go π«Ά
pagesβ the Array of pages backing the data. iconic, foundational, we love her πpage_flagsβ The page flags. and babes, there are so many valid values, buckle up:
Supported values:
TTM_TT_FLAG_SWAPPEDβ Set by TTM when the pages have been unpopulated and swapped out by TTM. Callingttm_tt_populatewill then swap the pages back in, and unset the flag. Drivers should in general never need to touch this. like fr, hands off, TTM's got it πTTM_TT_FLAG_ZERO_ALLOCβ Set if the pages will be zeroed on allocation. squeaky clean β¨TTM_TT_FLAG_EXTERNALβ Set if the underlying pages were allocated externally, like with dma-buf or userptr. This effectively disables TTM swapping out such pages. Also important is to prevent TTM from ever directly mapping these pages. ngl, this one means business π₯
Note that enum ttm_bo_type.ttm_bo_type_sg objects will always enable this flag. no cap, always.
TTM_TT_FLAG_EXTERNAL_MAPPABLEβ Same behaviour asTTM_TT_FLAG_EXTERNAL, but with the reduced restriction that it is still valid to use TTM to map the pages directly. This is useful when implementing attm_ttbackend which still allocates driver owned pages underneath(say with shmem). lowkey the chill version of EXTERNAL π
Note that since this also implies TTM_TT_FLAG_EXTERNAL, the usage here should always be:
page_flags = TTM_TT_FLAG_EXTERNAL | TTM_TT_FLAG_EXTERNAL_MAPPABLE;
like, always always. iykyk π
TTM_TT_FLAG_DECRYPTEDβ The mapped ttm pages should be marked as not encrypted. The framework will try to match what the dma layer is doing, but note that it is a little fragile because ttm page fault handling abuses the DMA api a bit anddma_map_attrscan't be used to assurepgprotalways matches. π she's doing her best okayTTM_TT_FLAG_BACKED_UPβ TTM internal only. This is set if thestruct ttm_tthas been (possibly partially) backed up. back up bestie, back up πTTM_TT_FLAG_PRIV_POPULATEDβ TTM internal only. DO NOT USE. π¨ This is set by TTM afterttm_tt_populatehas successfully returned, and is then unset when TTM callsttm_tt_unpopulate. like seriously do not touch, this is main character energy reserved for TTM itself π
num_pagesβ Number of pages in the page array. maths πsgβ for SG objects via dma-buf.dma_addressβ The DMA (bus) addresses of the pages.swap_storageβ Pointer to shmemstruct filefor swap storage.backupβ Pointer to backup struct for backed up tts. Could be unified withswap_storage. Meanwhile, the driver'sttm_tt_createcallback is responsible for assigning this field. not me assigning responsibilities πcachingβ The current caching state of the pages, seeenum ttm_caching.restoreβ Partial restoration from backup state. TTM private. π€«
π¦ SEE ALSO π¦
Kernel file ./include/drm/ttm/ttm_tt.h plus the whole friend group:
struct ttm_kmap_iter_tt(9)ttm_tt_is_swapped(9)ttm_tt_is_backed_up(9)ttm_tt_clear_backed_up(9)ttm_tt_create(9)ttm_tt_init(9)ttm_tt_fini(9)ttm_tt_destroy(9)ttm_tt_swapin(9)ttm_tt_populate(9)ttm_tt_unpopulate(9)ttm_tt_mark_for_clear(9)struct ttm_backup_flags(9)ttm_agp_tt_create(9)
and that's the whole page bestie, we ATE π β¨
okay so this came from ./include/drm/ttm, dated October 2026 β manifesting that future for us, periodt πΈπ«Άπ
π¦ 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