1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>usb_alloc_coherent</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="The Linux-USB Host Side API"><link rel="up" href="usbcore.html" title="Chapter&#160;5.&#160;USB Core APIs"><link rel="prev" href="API-usb-get-current-frame-number.html" title="usb_get_current_frame_number"><link rel="next" href="API-usb-free-coherent.html" title="usb_free_coherent"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="phrase">usb_alloc_coherent</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-usb-get-current-frame-number.html">Prev</a>&#160;</td><th width="60%" align="center">Chapter&#160;5.&#160;USB Core APIs</th><td width="20%" align="right">&#160;<a accesskey="n" href="API-usb-free-coherent.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-usb-alloc-coherent"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>usb_alloc_coherent &#8212; 
2     allocate dma-consistent buffer for URB_NO_xxx_DMA_MAP
3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void * <b class="fsfunc">usb_alloc_coherent </b>(</code></td><td>struct usb_device * <var class="pdparam">dev</var>, </td></tr><tr><td>&#160;</td><td>size_t <var class="pdparam">size</var>, </td></tr><tr><td>&#160;</td><td>gfp_t <var class="pdparam">mem_flags</var>, </td></tr><tr><td>&#160;</td><td>dma_addr_t * <var class="pdparam">dma</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer">&#160;</div></div></div><div class="refsect1"><a name="idp1116565676"></a><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>dev</code></em></span></dt><dd><p>
4     device the buffer will be used with
5    </p></dd><dt><span class="term"><em class="parameter"><code>size</code></em></span></dt><dd><p>
6     requested buffer size
7    </p></dd><dt><span class="term"><em class="parameter"><code>mem_flags</code></em></span></dt><dd><p>
8     affect whether allocation may block
9    </p></dd><dt><span class="term"><em class="parameter"><code>dma</code></em></span></dt><dd><p>
10     used to return DMA address of buffer
11    </p></dd></dl></div></div><div class="refsect1"><a name="idp1116570380"></a><h2>Return</h2><p>
12   Either null (indicating no buffer could be allocated), or the
13   cpu-space pointer to a buffer that may be used to perform DMA to the
14   specified device.  Such cpu-space buffers are returned along with the DMA
15   address (through the pointer provided).
16</p></div><div class="refsect1"><a name="idp1116571236"></a><h2>Note</h2><p>
17   These buffers are used with URB_NO_xxx_DMA_MAP set in urb-&gt;transfer_flags
18   to avoid behaviors like using <span class="quote">&#8220;<span class="quote">DMA bounce buffers</span>&#8221;</span>, or thrashing IOMMU
19   hardware during URB completion/resubmit.  The implementation varies between
20   platforms, depending on details of how DMA will work to this device.
21   Using these buffers also eliminates cacheline sharing problems on
22   architectures where CPU caches are not DMA-coherent.  On systems without
23   bus-snooping caches, these buffers are uncached.
24   </p><p>
25
26   When the buffer is no longer used, free it with <code class="function">usb_free_coherent</code>.
27</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-usb-get-current-frame-number.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="usbcore.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="API-usb-free-coherent.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">usb_get_current_frame_number</span>&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;<span class="phrase">usb_free_coherent</span></td></tr></table></div></body></html>
28