STRUCT DRM_GEM_OBJECT_FUNCS(9)
π struct drm_gem_object_funcs (9) π
okay so bestie, welcome to the Kernel API Manual β¨ this one's all about the GEM object function table, and honestly? it's giving "the plug for everything your GEM object can do." buckle up π
πΈ NAME πΈ
struct drm_gem_object_funcs β GEM object functions. yep, that's the whole name, no cap π
β¨ SYNOPSIS β¨
like, here's the whole vibe, every single pointer, verbatim, do not touch π₯
struct drm_gem_object_funcs {
void (*free)(struct drm_gem_object *obj);
int (*open)(struct drm_gem_object *obj, struct drm_file *file);
void (*close)(struct drm_gem_object *obj, struct drm_file *file);
void (*print_info)(struct drm_printer *p, unsigned int indent, const struct drm_gem_object *obj);
struct dma_buf *(*export)(struct drm_gem_object *obj, int flags);
int (*pin)(struct drm_gem_object *obj);
void (*unpin)(struct drm_gem_object *obj);
struct sg_table *(*get_sg_table)(struct drm_gem_object *obj);
int (*vmap)(struct drm_gem_object *obj, struct iosys_map *map);
void (*vunmap)(struct drm_gem_object *obj, struct iosys_map *map);
int (*mmap)(struct drm_gem_object *obj, struct vm_area_struct *vma);
int (*evict)(struct drm_gem_object *obj);
enum drm_gem_object_status (*status)(struct drm_gem_object *obj);
size_t (*rss)(struct drm_gem_object *obj);
const struct vm_operations_struct *vm_ops;
};
π¦ Members π¦
π free
Deconstructor for drm_gem_objects. that's the cleanup girlie, the one who takes out the trash on the way out ποΈ
This callback is mandatory. like, you literally cannot skip it, it's not optional, bestie π
π open
Called upon GEM handle creation. new handle just dropped π
This callback is optional.
π close
Called upon GEM handle release. bye bestie, handle's gone π«Ά
This callback is optional.
π print_info
If your driver subclasses struct drm_gem_object, it can implement this optional hook for printing additional driver specific info. extra lore, driver edition π
drm_printf_indent should be used in the callback, passing it the indent argument. don't freehand the indentation, that's the whole point β¨
This callback is called from drm_gem_print_info.
This callback is optional.
π export
Export the backing buffer as a dma_buf. If this is not set, drm_gem_prime_export is used instead. so like, a fallback exists, slay π
This callback is optional.
π pin
Pin the backing buffer in memory, such that dma-buf importers can access it. Used by the drm_gem_map_attach helper. keep it in place, no moving, periodt π§²
This callback is optional.
π unpin
Unpin the backing buffer. Used by the drm_gem_map_detach helper. okay you can move again, freed π¦
This callback is optional.
π get_sg_table
Returns a Scatter-Gather table representation of the buffer. Used when exporting a buffer by the drm_gem_map_dma_buf helper.
Releasing is done by calling dma_unmap_sg_attrs and sg_free_table in drm_gem_unmap_buf, therefore these helpers and this callback here cannot be used for sg tables pointing at driver private memory ranges. like, read that twice, it's a real one β οΈ
See also drm_prime_pages_to_sg.
π vmap
Returns a virtual address for the buffer. Used by the drm_gem_dmabuf_vmap helper. Called with a held GEM reservation lock. π
This callback is optional.
π vunmap
Releases the address previously returned by vmap. Used by the drm_gem_dmabuf_vunmap helper. Called with a held GEM reservation lock. π
This callback is optional.
π mmap
Handle mmap of the gem object, setup vma accordingly. it's giving memory-mapped main character energy π
This callback is optional.
The callback is used by both drm_gem_mmap_obj and drm_gem_prime_mmap. When mmap is present, vm_ops is not used β the mmap callback must set vma->vm_ops instead. pick one, bestie, don't do both π€
π evict
Evicts the gem object out from memory. Used by the drm_gem_object_evict helper. Returns 0 on success, -errno otherwise. Called with a held GEM reservation lock. π
This callback is optional.
π status
The optional status callback can return additional object state which determines which stats the object is counted against. The callback is called under table_lock. Racing against object status change is "harmless", and the callback can expect to not race against object destruction. so like, relax, the quote marks around "harmless" are doing a lot of work but you're fine π
Called by drm_show_memory_stats.
π rss
Return resident size of the object in physical memory. π
Called by drm_show_memory_stats.
π vm_ops
Virtual memory operations used with mmap. πΊοΈ
This is optional but necessary for mmap support. so like, optional in the same way a phone case is optional, iykyk π
π SEE ALSO π
Kernel file ./include/drm/drm_gem.h β and the whole friend group:
enum drm_gem_object_status(9)struct drm_gem_lru(9)struct drm_gem_object(9)DRM_GEM_FOPS(9)DEFINE_DRM_GEM_FOPS(9)drm_gem_get_huge_mnt(9)drm_gem_object_get(9)drm_gem_object_put(9)drm_gem_object_is_shared_for_memory_stats(9)drm_gem_is_imported(9)drm_gem_gpuva_init(9)drm_gem_for_each_gpuvm_bo(9)drm_gem_for_each_gpuvm_bo_safe(9)
okay that's the whole page, you ate that π«Ά this little beauty lives in ./include/drm, dated October 2026, and it's filed under struct drm_gem_object_funcs(9) β go build something iconic with it, mwah πβ¨
π¦ 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