export_dmabuf_from_addr(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ export_dmabuf_from_addr(9) β€” kernel API manual πŸŽ€

okay so bestie, this is a page from the Kernel API Manual and it's literally about handing a chunk of device memory to the rest of the world as a dma-buf. no cap, it's a glow-up for your memory allocation πŸ’…


🌸 NAME 🌸

export_dmabuf_from_addr β€” export a dma-buf object for the given memory address and size.


πŸ¦‹ SYNOPSIS πŸ¦‹

int export_dmabuf_from_addr (struct hl_ctx *ctx , u64 addr , u64 size ,
u64 offset , int flags , int *dmabuf_fd );

πŸ’œ ARGUMENTS πŸ’œ

  • ctx β€” pointer to the context structure. like, the whole vibe-holder for this operation.
  • addr β€” the device address. this is where the memory lives, iykyk.
  • size β€” how much device memory you're exporting. the bigger the slay, the bigger the size 🫢
  • offset β€” the offset into the buffer from which to start exporting. yes, you can start partway in, main character energy.
  • flags β€” DMA-BUF file/FD flags. the lil settings that ride along.
  • dmabuf_fd β€” pointer to the result FD that represents the dma-buf object. this is where the shiny new file descriptor lands ✨

🌈 DESCRIPTION 🌈

Create and export a dma-buf object for an existing memory allocation inside the device memory, and return a FD which is associated with the dma-buf object.

that's it, that's the whole flex. existing allocation in device memory β†’ boom, dma-buf object β†’ boom, an FD that represents it. not me being obsessed with a file descriptor 😭


πŸ”₯ RETURN πŸ”₯

0 on success, non-zero for failure.

(tbh 0 is the slay outcome. anything else and it's giving error πŸ’€)


⭐ SEE ALSO ⭐

the kernel file lives here, bestie:

Kernel file ./drivers/accel/habanalabs/common/memory.c

and here's the whole friend group, fr fr:

dma_map_host_va(9), dma_unmap_host_va(9), dram_pg_pool_do_release(9), free_phys_pg_pack(9), free_device_memory(9), clear_va_list_locked(9), print_va_list_locked(9), merge_va_blocks_locked(9), add_va_block_locked(9), add_va_block(9), is_hint_crossing_range(9), get_va_block(9), hl_get_va_range_type(9), hl_unreserve_va_block(9), init_phys_pg_pack_from_userptr(9), map_phys_pg_pack(9), unmap_phys_pg_pack(9), map_device_va(9), unmap_device_va(9), hl_hw_block_mmap(9), allocate_timestamps_buffers(9), hl_pin_host_memory(9), hl_userptr_delete_list(9), hl_userptr_is_pinned(9), va_range_init(9), va_range_fini(9), vm_ctx_init_with_ranges(9), hl_vm_ctx_fini(9), hl_vm_init(9), hl_vm_fini(9), hl_hw_block_mem_init(9), hl_hw_block_mem_fini(9)


okay that's the whole page! πŸ’– this one's from the source at ./drivers/accel/habanalabs/common, dated October 2026, and yes you can absolutely cite it in your group chat. periodt πŸ‘‘

πŸ“¦ where this page comes from