drm_gpusvm_init(9)
π 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 themm_structfor 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 beingSZ_4K. No cap, that's a hard requirement, don't be out here doingSZ_4Kfirst π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
- 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