STRUCT DRM_GPUVM_OPS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ struct drm_gpuvm_ops(9) ✨

okay so bestie, we're in the Kernel API Manual today and we're talking about struct drm_gpuvm_ops β€” the callbacks for split/merge steps. yes it's giving "glue code" but it's iconic glue code, trust πŸ’…


🌸 NAME 🌸

struct drm_gpuvm_ops β€” callbacks for split/merge steps. that's it, that's the whole vibe check 🫢


πŸ¦‹ SYNOPSIS πŸ¦‹

struct drm_gpuvm_ops {
    void (*vm_free)(struct drm_gpuvm *gpuvm);
    struct drm_gpuva_op *(*op_alloc)(void);
    void (*op_free)(struct drm_gpuva_op *op);
    struct drm_gpuvm_bo *(*vm_bo_alloc)(void);
    void (*vm_bo_free)(struct drm_gpuvm_bo *vm_bo);
    int (*vm_bo_validate)(struct drm_gpuvm_bo *vm_bo, struct drm_exec
*exec);
    int (*sm_step_map)(struct drm_gpuva_op *op, void *priv);
    int (*sm_step_remap)(struct drm_gpuva_op *op, void *priv);
    int (*sm_step_unmap)(struct drm_gpuva_op *op, void *priv);
 };

like, look at her. nine function pointers. main character energy fr fr πŸ‘‘


πŸ’– Members πŸ’–

  • vm_free β€” called when the last reference of a struct drm_gpuvm is dropped πŸ«‚
This callback is mandatory. no skipping, bestie, this one is NOT optional 😀
  • op_alloc β€” called when the drm_gpuvm allocates a struct drm_gpuva_op πŸŽ€

some drivers may want to embed struct drm_gpuva_op into driver specific structures. by implementing this callback, drivers can allocate memory accordingly. lowkey a cute little customization hook ✨

This callback is optional.

  • op_free β€” called when the drm_gpuvm frees a struct drm_gpuva_op 🧚

some drivers may want to embed struct drm_gpuva_op into driver specific structures. by implementing this callback, drivers can free the previously allocated memory accordingly. the matching-set energy we love to see πŸ’œ

This callback is optional.

  • vm_bo_alloc β€” called when the drm_gpuvm allocates a struct drm_gpuvm_bo 🌈

some drivers may want to embed struct drm_gpuvm_bo into driver specific structures. by implementing this callback, drivers can allocate memory accordingly. yes it's the same speech as op_alloc, no cap 🫢

This callback is optional.

  • vm_bo_free β€” called when the drm_gpuvm frees a struct drm_gpuvm_bo πŸ“

some drivers may want to embed struct drm_gpuvm_bo into driver specific structures. by implementing this callback, drivers can free the previously allocated memory accordingly. alloc/free duo, they're literally a matching set πŸ’…

This callback is optional.

  • vm_bo_validate β€” called from drm_gpuvm_validate πŸ”₯

drivers receive this callback for every evicted drm_gem_object being mapped in the corresponding drm_gpuvm. iykyk, that's the whole point.

typically, drivers would call their driver specific variant of ttm_bo_validate from within this callback. that's the move 🎯

  • sm_step_map β€” called from drm_gpuvm_sm_map to finally insert the mapping once all previous steps were completed ⭐

the priv pointer matches the one the driver passed to drm_gpuvm_sm_map or drm_gpuvm_sm_unmap, respectively.

Can be NULL if drm_gpuvm_sm_map is used.

  • sm_step_remap β€” called from drm_gpuvm_sm_map and drm_gpuvm_sm_unmap to split up an existent mapping πŸ’€

this callback is called when existent mapping needs to be split up. this is the case when either a newly requested mapping overlaps or is enclosed by an existent mapping, or a partial unmap of an existent mapping is requested. messy? a little. necessary? absolutely 🫢

the priv pointer matches the one the driver passed to drm_gpuvm_sm_map or drm_gpuvm_sm_unmap, respectively.

Can be NULL if neither drm_gpuvm_sm_map nor drm_gpuvm_sm_unmap is used.

  • sm_step_unmap β€” called from drm_gpuvm_sm_map and drm_gpuvm_sm_unmap to unmap an existing mapping πŸ™ˆ

this callback is called when existing mapping needs to be unmapped. this is the case when either a newly requested mapping encloses an existing mapping, or an unmap of an existing mapping is requested. bye bestie, we hardly knew ye 😭

the priv pointer matches the one the driver passed to drm_gpuvm_sm_map or drm_gpuvm_sm_unmap, respectively.

Can be NULL if neither drm_gpuvm_sm_map nor drm_gpuvm_sm_unmap is used.


πŸŽ€ Description πŸŽ€

this structure defines the callbacks used by drm_gpuvm_sm_map and drm_gpuvm_sm_unmap to provide the split/merge steps for map and unmap operations to drivers. so it's like the middleman between the core and your driver, and honestly? she's booked and busy πŸ’…


🐚 SEE ALSO 🐚

kernel file ./include/drm/drm_gpuvm.h plus the whole friend group: enum drm_gpuva_flags(9), struct drm_gpuva(9), drm_gpuva_invalidate(9), drm_gpuva_invalidated(9), enum drm_gpuvm_flags(9), struct drm_gpuvm(9), drm_gpuvm_get(9), drm_gpuvm_resv_protected(9), drm_gpuvm_immediate_mode(9), drm_gpuvm_resv(9), drm_gpuvm_resv_obj(9), drm_gpuvm_is_extobj(9), drm_gpuvm_for_each_va_range(9), drm_gpuvm_for_each_va_range_safe(9), drm_gpuvm_for_each_va(9), drm_gpuvm_for_each_va_safe(9), struct drm_gpuvm_exec(9), drm_gpuvm_exec_unlock(9), drm_gpuvm_exec_resv_add_fence(9), drm_gpuvm_exec_validate(9), struct drm_gpuvm_bo(9), drm_gpuvm_bo_get(9), drm_gpuvm_bo_gem_evict(9), drm_gpuvm_bo_for_each_va(9), drm_gpuvm_bo_for_each_va_safe(9), enum drm_gpuva_op_type(9), struct drm_gpuva_op_map(9), struct drm_gpuva_op_unmap(9), struct drm_gpuva_op_remap(9), struct drm_gpuva_op_prefetch(9), struct drm_gpuva_op(9), struct drm_gpuva_ops(9), drm_gpuva_for_each_op(9), drm_gpuva_for_each_op_safe(9), drm_gpuva_for_each_op_from_reverse(9), drm_gpuva_for_each_op_reverse(9), drm_gpuva_first_op(9), drm_gpuva_last_op(9), drm_gpuva_prev_op(9), drm_gpuva_next_op(9), struct drm_gpuvm_map_req(9), drm_gpuva_op_remap_to_unmap_range(9). that's a LOT of reading, hydrate first πŸ“


and that's the whole page bestie!! πŸŽ‰ this one came from the source tree at ./include/drm and it's dated October 2026 β€” go off, you literally know gpuvm callbacks now πŸ‘‘βœ¨πŸ’–

πŸ“¦ where this page comes from