usb_alloc_coherent(9)
π usb_alloc_coherent(9) β Kernel API Manual π
πΈ NAME πΈ
usb_alloc_coherent β allocate a dma-consistent buffer for URB_NO_xxx_DMA_MAP. thatβs the whole assignment, bestie π
β¨ SYNOPSIS β¨
okay so the signature is literally:
void * usb_alloc_coherent (struct usb_device *dev , size_t size , gfp_t
mem_flags , dma_addr_t *dma );
π¦ ARGUMENTS π¦
devβ the device the buffer will be used with π«Άsizeβ requested buffer size, no capmem_flagsβ affect whether allocation may block πdmaβ used to return DMA address of buffer β¨
π RETURN π
so it returns either null β which means no buffer could be allocated, sad β or the cpu-space pointer to a buffer that may be used to perform DMA to the specified device. those cpu-space buffers come back along with the DMA address (through the pointer you provided), periodt π
π₯ NOTE π₯
these buffers are used with URB_NO_xxx_DMA_MAP set in urb->transfer_flags to avoid behaviors like using βDMA bounce buffersβ, or thrashing IOMMU hardware during URB completion/resubmit. the implementation varies between platforms, depending on details of how DMA will work to this device. using these buffers also eliminates cacheline sharing problems on architectures where CPU caches are not DMA-coherent. on systems without bus-snooping caches, these buffers are uncached.
when the buffer is no longer used, free it with usb_free_coherent. donβt leave it hanging, bestie π
π SEE ALSO π
Kernel file ./drivers/usb/core/usb.c plus the whole linked-up crew:
usb_find_common_endpoints(9)usb_find_common_endpoints_reverse(9)usb_find_endpoint(9)usb_check_bulk_endpoints(9)usb_check_int_endpoints(9)usb_find_alt_setting(9)usb_ifnum_to_if(9)usb_altnum_to_altsetting(9)usb_find_interface(9)usb_for_each_dev(9)usb_release_dev(9)usb_alloc_dev(9)usb_get_dev(9)usb_put_dev(9)usb_get_intf(9)usb_put_intf(9)usb_intf_get_dma_device(9)usb_lock_device_for_reset(9)usb_get_current_frame_number(9)usb_free_coherent(9)usb_alloc_noncoherent(9)usb_free_noncoherent(9)usb_endpoint_max_periodic_payload(9)usb_endpoint_is_hs_isoc_double(9)
mwah π β source/version ./drivers/usb/core, dated October 2026, page usb_alloc_coherent(9). byeee π«Ά
π¦ 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