---
name: "usb_alloc_coherent"
section: "9"
platform: "linux"
package: "linux-manual-4.9"
version: "4.9.228-1"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/usb_alloc_coherent"
---

# usb\_alloc\_coherent(9)

allocate dma-consistent buffer for URB\_NO\_xxx\_DMA\_MAP

## NAME

usb\_alloc\_coherent - allocate dma-consistent buffer for URB\_NO\_xxx\_DMA\_MAP

## SYNOPSIS

**void \* usb\_alloc\_coherent(struct usb\_device \*** *dev***, size\_t** *size***, gfp\_t** *mem\_flags***, dma\_addr\_t \*** *dma***);**

## ARGUMENTS

*dev*

device the buffer will be used with

*size*

requested buffer size

*mem\_flags*

affect whether allocation may block

*dma*

used to return DMA address of buffer

## RETURN

Either null (indicating no buffer could be allocated), or the cpu-space pointer to a buffer that may be used to perform DMA to the specified device. Such cpu-space buffers are returned along with the DMA address (through the pointer provided).

## 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**.

## COPYRIGHT
