drm_gpusvm_init(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… drm_gpusvm_init(9) β€” the Kernel API Manual, bestie edition ✨

okay so this is drm_gpusvm_init(9) from the Kernel API Manual, and it's literally the "get the GPU SVM party started" function. Let's go πŸŽ€


🌸 NAME

drm_gpusvm_init β€” Initialize the GPU SVM.


✨ SYNOPSIS

int drm_gpusvm_init (struct drm_gpusvm *gpusvm , const char *name ,
       struct mm_struct *mm , unsigned long mm_start , unsigned long mm_range ,
       unsigned long notifier_size , const struct drm_gpusvm_ops *ops , const
       unsigned long *chunk_sizes , int num_chunks );

It returns an int, so you already know how this ends β€” it's giving success-or-negative-error-code energy πŸ’€


🫢 ARGUMENTS

  • gpusvm β€” Pointer to the GPU SVM structure. This is the main character, the thing you're initializing 🫢
  • name β€” Name of the GPU SVM. Yes, it gets a lil name, iconic.
  • mm β€” Pointer to the mm_struct for the address space.
  • mm_start β€” Start address of GPU SVM.
  • mm_range β€” Range of the GPU SVM.
  • notifier_size β€” Size of individual notifiers.
  • ops β€” Pointer to the operations structure for GPU SVM.
  • chunk_sizes β€” Pointer to the array of chunk sizes used in range allocation. Hiii bestie, pay attention: entries should be powers of 2 in descending order, with the last entry being SZ_4K. No cap, that's a hard requirement, don't be out here doing SZ_4K first πŸ™ˆ
  • num_chunks β€” Number of chunks. (Just count them, bestie πŸ’…)

πŸ¦‹ DESCRIPTION

This function initializes the GPU SVM. That's it, that's the vibe. It sets the whole thing up ✨


πŸ‘‘ NOTE

okay so this part is actually important, listen up πŸ”₯

If you're only using the simple drm_gpusvm_pages API (get/unmap/free), then only gpusvm and name are expected. The drm drm_device for dma mappings is bound per-pages via drm_gpusvm_init_pages before the first drm_gpusvm_get_pages call.

However β€” and this is the flexible queen moment β€” the same base gpusvm can also be used with both modes together, in which case the full setup is needed. In that case the core drm_gpusvm_pages API will simply never use the other fields. She's got range, literally 🌈


⭐ RETURN

0 on success, a negative error code on failure. So if it's all good you get 0, and if it's not... negative error code, and you get to debug 🫠


🧚 SEE ALSO

Kernel file ./drivers/gpu/drm/drm_gpusvm.c Overview(9), Locking(9), Partial Unmapping of Ranges(9), Examples(9), npages_in_range(9), drm_gpusvm_notifier_find(9), drm_gpusvm_range_find(9), drm_gpusvm_notifier_invalidate(9), to_drm_gpusvm_notifier(9),

drm_gpusvm_notifier_insert(9), drm_gpusvm_notifier_remove(9), drm_gpusvm_fini(9), drm_gpusvm_notifier_alloc(9), drm_gpusvm_notifier_free(9), to_drm_gpusvm_range(9),

drm_gpusvm_range_insert(9), __drm_gpusvm_range_remove(9), drm_gpusvm_range_alloc(9), drm_gpusvm_hmm_pfn_to_order(9), drm_gpusvm_check_pages(9), drm_gpusvm_scan_mm(9),

drm_gpusvm_range_chunk_size(9), drm_gpusvm_driver_lock_held(9), drm_gpusvm_find_vma_start(9), drm_gpusvm_range_find_or_insert(9), __drm_gpusvm_unmap_pages(9),

__drm_gpusvm_free_pages(9), drm_gpusvm_free_pages(9), drm_gpusvm_range_remove(9), drm_gpusvm_range_get(9), drm_gpusvm_range_destroy(9), drm_gpusvm_range_put(9),

drm_gpusvm_pages_valid(9), drm_gpusvm_pages_valid_unlocked(9), drm_gpusvm_get_pages(9), drm_gpusvm_unmap_pages(9), drm_gpusvm_range_evict(9), drm_gpusvm_has_mapping(9),

drm_gpusvm_range_set_unmapped(9)

That's a whole friend group, and honestly? Every single one of them is linked for a reason. Go read them, iykyk πŸ’–


πŸ’œ fr fr, that's the whole page. Now go initialize something.

slay, you made it to the end πŸŽ€ this cutie was served fresh from ./drivers/gpu/drm in October 2026, filename drm_gpusvm_init(9). bye bestie, mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from