1                    DMA Buffer Sharing API Guide
   2                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   4                            Sumit Semwal
   5                <sumit dot semwal at linaro dot org>
   6                 <sumit dot semwal at ti dot com>
   8This document serves as a guide to device-driver writers on what is the dma-buf
   9buffer sharing API, how to use it for exporting and using shared buffers.
  11Any device driver which wishes to be a part of DMA buffer sharing, can do so as
  12either the 'exporter' of buffers, or the 'user' of buffers.
  14Say a driver A wants to use buffers created by driver B, then we call B as the
  15exporter, and A as buffer-user.
  17The exporter
  18- implements and manages operations[1] for the buffer
  19- allows other users to share the buffer by using dma_buf sharing APIs,
  20- manages the details of buffer allocation,
  21- decides about the actual backing storage where this allocation happens,
  22- takes care of any migration of scatterlist - for all (shared) users of this
  23   buffer,
  25The buffer-user
  26- is one of (many) sharing users of the buffer.
  27- doesn't need to worry about how the buffer is allocated, or where.
  28- needs a mechanism to get access to the scatterlist that makes up this buffer
  29   in memory, mapped into its own address space, so it can access the same area
  30   of memory.
  32dma-buf operations for device dma only
  35The dma_buf buffer sharing API usage contains the following steps:
  371. Exporter announces that it wishes to export a buffer
  382. Userspace gets the file descriptor associated with the exported buffer, and
  39   passes it around to potential buffer-users based on use case
  403. Each buffer-user 'connects' itself to the buffer
  414. When needed, buffer-user requests access to the buffer from exporter
  425. When finished with its use, the buffer-user notifies end-of-DMA to exporter
  436. when buffer-user is done using this buffer completely, it 'disconnects'
  44   itself from the buffer.
  471. Exporter's announcement of buffer export
  49   The buffer exporter announces its wish to export a buffer. In this, it
  50   connects its own private buffer data, provides implementation for operations
  51   that can be performed on the exported dma_buf, and flags for the file
  52   associated with this buffer.
  54   Interface:
  55      struct dma_buf *dma_buf_export(void *priv, struct dma_buf_ops *ops,
  56                                     size_t size, int flags)
  58   If this succeeds, dma_buf_export allocates a dma_buf structure, and returns a
  59   pointer to the same. It also associates an anonymous file with this buffer,
  60   so it can be exported. On failure to allocate the dma_buf object, it returns
  61   NULL.
  632. Userspace gets a handle to pass around to potential buffer-users
  65   Userspace entity requests for a file-descriptor (fd) which is a handle to the
  66   anonymous file associated with the buffer. It can then share the fd with other
  67   drivers and/or processes.
  69   Interface:
  70      int dma_buf_fd(struct dma_buf *dmabuf)
  72   This API installs an fd for the anonymous file associated with this buffer;
  73   returns either 'fd', or error.
  753. Each buffer-user 'connects' itself to the buffer
  77   Each buffer-user now gets a reference to the buffer, using the fd passed to
  78   it.
  80   Interface:
  81      struct dma_buf *dma_buf_get(int fd)
  83   This API will return a reference to the dma_buf, and increment refcount for
  84   it.
  86   After this, the buffer-user needs to attach its device with the buffer, which
  87   helps the exporter to know of device buffer constraints.
  89   Interface:
  90      struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,
  91                                                struct device *dev)
  93   This API returns reference to an attachment structure, which is then used
  94   for scatterlist operations. It will optionally call the 'attach' dma_buf
  95   operation, if provided by the exporter.
  97   The dma-buf sharing framework does the bookkeeping bits related to managing
  98   the list of all attachments to a buffer.
 100Until this stage, the buffer-exporter has the option to choose not to actually
 101allocate the backing storage for this buffer, but wait for the first buffer-user
 102to request use of buffer for allocation.
 1054. When needed, buffer-user requests access to the buffer
 107   Whenever a buffer-user wants to use the buffer for any DMA, it asks for
 108   access to the buffer using dma_buf_map_attachment API. At least one attach to
 109   the buffer must have happened before map_dma_buf can be called.
 111   Interface:
 112      struct sg_table * dma_buf_map_attachment(struct dma_buf_attachment *,
 113                                         enum dma_data_direction);
 115   This is a wrapper to dma_buf->ops->map_dma_buf operation, which hides the
 116   "dma_buf->ops->" indirection from the users of this interface.
 118   In struct dma_buf_ops, map_dma_buf is defined as
 119      struct sg_table * (*map_dma_buf)(struct dma_buf_attachment *,
 120                                                enum dma_data_direction);
 122   It is one of the buffer operations that must be implemented by the exporter.
 123   It should return the sg_table containing scatterlist for this buffer, mapped
 124   into caller's address space.
 126   If this is being called for the first time, the exporter can now choose to
 127   scan through the list of attachments for this buffer, collate the requirements
 128   of the attached devices, and choose an appropriate backing storage for the
 129   buffer.
 131   Based on enum dma_data_direction, it might be possible to have multiple users
 132   accessing at the same time (for reading, maybe), or any other kind of sharing
 133   that the exporter might wish to make available to buffer-users.
 135   map_dma_buf() operation can return -EINTR if it is interrupted by a signal.
 1385. When finished, the buffer-user notifies end-of-DMA to exporter
 140   Once the DMA for the current buffer-user is over, it signals 'end-of-DMA' to
 141   the exporter using the dma_buf_unmap_attachment API.
 143   Interface:
 144      void dma_buf_unmap_attachment(struct dma_buf_attachment *,
 145                                    struct sg_table *);
 147   This is a wrapper to dma_buf->ops->unmap_dma_buf() operation, which hides the
 148   "dma_buf->ops->" indirection from the users of this interface.
 150   In struct dma_buf_ops, unmap_dma_buf is defined as
 151      void (*unmap_dma_buf)(struct dma_buf_attachment *, struct sg_table *);
 153   unmap_dma_buf signifies the end-of-DMA for the attachment provided. Like
 154   map_dma_buf, this API also must be implemented by the exporter.
 1576. when buffer-user is done using this buffer, it 'disconnects' itself from the
 158   buffer.
 160   After the buffer-user has no more interest in using this buffer, it should
 161   disconnect itself from the buffer:
 163   - it first detaches itself from the buffer.
 165   Interface:
 166      void dma_buf_detach(struct dma_buf *dmabuf,
 167                          struct dma_buf_attachment *dmabuf_attach);
 169   This API removes the attachment from the list in dmabuf, and optionally calls
 170   dma_buf->ops->detach(), if provided by exporter, for any housekeeping bits.
 172   - Then, the buffer-user returns the buffer reference to exporter.
 174   Interface:
 175     void dma_buf_put(struct dma_buf *dmabuf);
 177   This API then reduces the refcount for this buffer.
 179   If, as a result of this call, the refcount becomes 0, the 'release' file
 180   operation related to this fd is called. It calls the dmabuf->ops->release()
 181   operation in turn, and frees the memory allocated for dmabuf when exported.
 184- Importance of attach-detach and {map,unmap}_dma_buf operation pairs
 185   The attach-detach calls allow the exporter to figure out backing-storage
 186   constraints for the currently-interested devices. This allows preferential
 187   allocation, and/or migration of pages across different types of storage
 188   available, if possible.
 190   Bracketing of DMA access with {map,unmap}_dma_buf operations is essential
 191   to allow just-in-time backing of storage, and migration mid-way through a
 192   use-case.
 194- Migration of backing storage if needed
 195   If after
 196   - at least one map_dma_buf has happened,
 197   - and the backing storage has been allocated for this buffer,
 198   another new buffer-user intends to attach itself to this buffer, it might
 199   be allowed, if possible for the exporter.
 201   In case it is allowed by the exporter:
 202    if the new buffer-user has stricter 'backing-storage constraints', and the
 203    exporter can handle these constraints, the exporter can just stall on the
 204    map_dma_buf until all outstanding access is completed (as signalled by
 205    unmap_dma_buf).
 206    Once all users have finished accessing and have unmapped this buffer, the
 207    exporter could potentially move the buffer to the stricter backing-storage,
 208    and then allow further {map,unmap}_dma_buf operations from any buffer-user
 209    from the migrated backing-storage.
 211   If the exporter cannot fulfil the backing-storage constraints of the new
 212   h calls allo.1         u2ment structure, which is 12   h c  93   This a wining scatteDocdma-b-buf-sharing.txt#L141" id="L141" class="line" na2e="L113">2113                 2     2         de coumenn-href" ibilptorocter 'backingkkeepingcation.
="DocumenThis alf-sharing.txt#L141" id="L141" class="line" na2e="L204"> 114
 115   This is a wrap2er to21ma-buf-sharing.txt#L156" id="L156" class="line" na2e="L116">2116   "dma_buf-2gt;op216fulfil the backing-storatoragsmentationuf op is then  if it is intocessif-sharing.txt#L156" id="L156" class="line" na2e="L207"> 117
2118   In struct dma_2uf_op21ma-buf-sharing.txt#L179" id="L179" class="line" na2e="L119">2119      struct sg_t2ble *2(*map_Kernel cpua_buf_map_aas the boo-storagcumentf-sharing.txt#L179" id="L179" class="line" na2="L20">  220- manages the detai     2 bufferrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrf-sharing.txt#L179" id="L179" class="line" na2=="L211"> 21- decides about theation2dma-buf-sharing.txt#L122" id="L122" class="line" na2="L22">  222- takes care of any      er opethe motplemia hrefnuf opcpua_buf_maage.
  223   buffer,
  225The buffer-user
  226- is one of (many) g cal2ng usersstrl pranspacumeyd buffeisnmap}ef="Docterlisimng-stotatdd39;.e.}ef="Dma-bf-sharing.txt#L31" id="L31" class="line" name2=="L207"> 27- doesn't need e lis2 of attatainingentar
228- needs a mechanism devi2es, and /dmaun/imng-std
229   in memory, mappe="Doc2mentatior
2131   Based on enum 2ma_da2dma-buf-sharing.txt#L32" id="L32" class="line" name2e="L132">2132   accessing at t2e sam2 time Abuf_map_aas thr-useage.
2133   that the expor2er mi23ma-buf-sharing.txt#L194" id="L194" class="line" na2e="L134">2134
2135   map_dma_buf() 2perat2on can rehref="Documentcpua_buf_muf-sharing.txt#L171" id="L171" class="line" na2e"L26">  2136
21385. When finished,2the b23r {map,uuntourc-buf-sharing.txt#L68" id="L68" class="line" name2e="L139">2139
2140   Once the DMA f2r the2curren1.2141   the exporter u2ing t24ma-buf-sharing.txt#L32" id="L32" class="line" name2e="L142">2142
2143   Interface:
2144      void dma_bu2_unma2_attachmeon/dmauf-sharing.txt#L68" id="L68" class="line" name2e="L145">2145                 2     2dma-buf-sharing.txt#L46" id="L46" class="line" name2e="L146">2146
2147   This is a wrap2er to24 struct dma*dmabuf)
2148   "dma_buf-2gt;op2->&quooooooooooooooooooooooooooooooooof="Documtarl39f="Doculebuf-sharing.txt#L21" id="L21" class="line" name=e="L149">2149
2150   In struct dma_2uf_op25ma-buf-sharing.txt#L211" id="L211" class="line" name="L151">2151      void (*unma2_dma_2uf)(strucef="Documentking-storage
2153   unmap_dma_buf 2ignif2es the enated for this b. the  export a  exph the bufensject, makcpua_buf_mabuf-sharing.txt#L23" id="L23" class="line" name=e="L154">2154   map_dma_buf, t2is AP2 also muscoh="Docuumentatigf="n range /dmaubuf_mation/dma-. the range /dmaubuf_mf-sharing.txt#L23" id="L23" class="line" name=e="L145">2155
21576. when buffer-us2r is 25 struct write)to buff scatteatioe on/e="n bogus hatae(e.g.rntatitation/dma-b h the buf-sharing.txt#L95" id="L95" class="line" name2e="L148">2158   buffer.
2160   After the buff2r-use2 has no mT has tepto bufff ob, e.g.rin oe.
="ddihref=uf-sharing.txt#L206" id="L206" class="line" name="L161">2161   disconnect its2lf fr26ma-buf-sharing.txt#L32" id="L32" class="line" name2e="L162">2162
2163   - it first det2ches 26ma-buf-sharing.txt#L194" id="L194" class="line" na2e="L164">2164
2165   Interface:
2166      void dma_bu2_deta2h(struct PAGE_SIZE9f="D. Bd.
2167                 2     2  struct aassociateinekernel virdma-entation/dma-bumore iwardntkingchunk9h the bufbef-sharing.txt#L61" id="L61" class="line" name2e="L148">2168
2169   This API remov2s the2attachmen/dmaref="Doc39;.e.}rlisimng-stotted tentarfer is buf
2170   dma_buf->op2->2etach(), bd.
2172   - Then, the bu2fer-u2er returnton/dma-bbuf-sharing.txt#L36" id="L36" class="line" name2e="L173">2173
2174   Interface:
2175     void dma_buf2put(s27ma-buf-sharing.txt#L46" id="L46" class="line" name2e="L176">2176
2177   This API then 2educe2 the refcma-ilptaoumenn-b thd forfast-f" hbu N
2179   If, as a resul2 of t2dma-buf-sharing.txt#L80" id="L80" class="line" name2e="L180">2180   operation rela2ed to2ocumentation/dma-bbuf-sharing.txt#L36" id="L36" class="line" name2e="L181">2181   operation in t2rn, a28f)(struct dma_bu,buf)
2184- Importance of a2tach-2ation/dmaFmenimng-stontuf
2185   The attach-det2ch ca2ls allow suptloroctn hi_itomic slotbu HDo="Dun/imng-strrasson/dmlDoculd
2186   constraints fo2 the 2urrently-itomic mentation his, maybe), or any otinethyagf="n ion/dmat="d5/xlbuf-sharing.txt#L206" id="L206" class="line" name="L187">2187   allocation, an2/or m28ma-buf-sharing.txt#L138" id="L138" class="line" na2e="L188">2188   available, if 2ossib2e.
2190   Bracketing of 2MA ac2ess with  bacparumentchunkso maybe)beginnfer, theetheusermayf scatteatioe on/bogusf-sharing.txt#L61" id="L61" class="line" name2e="L181">2191   to allow just-2n-tim2 backing hataed (atddmhoose arange (ima-busacparumentchunksbuf-sharing.txt#L206" id="L206" class="line" name="L192">2192   use-case.
2194- Migration of ba2king 2tions. Itthyapdipac href="e expo bufff obous2195   If after
2196   - at least one2map_d2a_buf hasFmensoor casabuf whMA&#hindoouon hiiguationtoo h bu, hav hiiion/dma-bf-sharing.txt#L46" id="L46" class="line" name2e="L187">2197   - and the back2ng st2rage has tationrofferd.>opson/dma-batainingiona-buuA&#/dmarinully,uasav hr thf-sharing.txt#L46" id="L46" class="line" name2e="L188">2198   another new bu2fer-u2er intendle-dess->l
2199   be allowed, if2possi2dma-buf-sharing.txt#L100" id="L100" class="line" na3e="L200">3200
3201   In case it is 3llowe30f)(struct dma_bu,buf)
3202    if the new bu3fer-u302ttachment(struct dma_buvref="ef="Documentation/dma-budma_bu,vntatuf-sharing.txt#L71" id="L71" class="line" name3e3"L202">3293
3204    map_dma_buf u3til a3l outstanthe v hiigureiguatf obouoose er, is buv hiisupture,ititation/dma-b
3295   If after
3206    Once all user3 have3dma-buf-sharing.txt#L107" id="L107" class="line" na3e="L207">3207    exporter coul3 pote30ma-bu3. Fappeda_buf_mf-sharing.txt#L107" id="L107" class="line" na3e8"L207">3298   another new bu3 furt30ma-buf-sharing.txt#L179" id="L179" class="line" na3e="L209">3209    from the migr3ted b3cking-stoWtatitatiimng-strr'disaocumeit API.
range specttacdous3210
3211   If the exporte3 cann3t fulfil unpinnfer,p}_dhyapinnbuuuntourc-b). the rnt becomep}_dhyamentation hiigure f-sharing.txt#L21" id="L21" class="line" name3e="L202">3212   h calls allo.13     3  u2ment ma-bueeth_Tpu_nocumeuimaunion/dma.f-sharing.txt#L21" id="L21" class="line" name3e3"L202">3113                 3     31ma-buf-sharing.txt#L104" id="L104" class="line" na3e="L204">3114
3115   This is a wrap3er to315ttachment(struct dma_bueth_Tpu_nocumeef="Documentation/dm_a-buf-sharing.txt#L167" id="L167" class="line" na3e="L116">3116   "dma_buf-3gt;op31(struct dmaaaaaaaaaaaaaaaaaaaaaaaaaaaaaf="Documtarl39f="Doculebuf-sharing.txt#L21" id="L21" class="line" name3e="L207">3117
3118   In struct dma_3uf_op31ma-buf-sharing.txt#L179" id="L179" class="line" na3e="L119">3119      struct sg_t3ble *31ma-buf-sharing.txt#L100" id="L100" class="line" na3="L20">  320- manages the deta3     3 buffeD to h Uf="Dma-b Aocume/m hiiSupturef-sharing.txt#L100" id="L100" class="line" na3=="L201">321- decides about th3ation3dma-burrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrf-sharing.txt#L179" id="L179" class="line" na3="L22">  322- takes care of an3     32ma-buf-sharing.txt#L93" id="L93" class="line" name3="L23">  323   buffer,
  325The buffer-user
  326- is one of (many)3g cal32ma-buf-sharing.txt#L107" id="L107" class="line" na3=="L207">327- doesn't need3e lis3 of at1.iCPUifnuf theeion/dmagnaltn aapiperef=f-sharing.txt#L107" id="L107" class="line" na3=="L118">328- needs a mechanis3 devi32ma-buf-sharing.txt#L179" id="L179" class="line" na3=="L119">329   in memory, mapp3="Doc3mentationIa mthyaion/dmagnalpiperef=s:
3131   Based on enum 3ma_da33 dma_buf_unmffer is exporter  hrspectrictein}ef="Dma-bg bits rel devic-storagass="lif-sharing.txt#L107" id="L107" class="line" na3e"L22">  3132   accessing at t3e sam3 time (foit"Documeidealricter &ithr-useadht
  3133   that the expor3er mi3ht wish tage.
ef="Dma-bgment Am hi.f-sharing.txt#L21" id="L21" class="line" name3e="L134">3134
3135   map_dma_buf() 3perat3on can reFrationffer,Andrtru"DocumeIONg bits rel alkindyisuptureser  hr( thef-DMtionwisbf-sharing.txt#L107" id="L107" class="line" na3e"L26">  3136
31385. When finished,3the b33.
3140   Once the DMA f3r the3current bNorspectriiion/dma-bo,
ef=yigure om hiicterlis the booDa.f-sharing.txt#L21" id="L21" class="line" name3e="L131">3141   the exporter u3ing t34ma-buf-sharing.txt#L32" id="L32" class="line" name3e="L142">3142
3143   Interface:
3144      void dma_bu3_unma3_attachmeS
ef="straithe motplemia humennernel cpua_buf_ma
3145                 3     3         a href="Dma-bg="ddmhoohagf="n i {map for ubsy  hmrntatand ybe), or ion/dma-bof-sharing.txt#L104" id="L104" class="line" na3e"L26">  3146
3147   This is a wrap3er to34 struct espectrictei {map,ucumentdrmrntare a href="Dma-bgparumhoo="d5/mng-ar/dOpenGLuf-sharing.txt#L21" id="L21" class="line" name3e="L148">3148   "dma_buf-3gt;op3->&quoX="Documa hreref="Doc;ophuugh a
3150   In struct dma_3uf_op35ma-buf-sharing.txt#L211" id="L211" class="line" na3e="L151">3151      void (*unma3_dma_3uf)(strucefis 1o#Lentat,ititatit signal the booion/dma-bops="e exp/dd to hat API.f-sharing.txt#L211" id="L211" class="line" na3e="L142">3152
3153   unmap_dma_buf 3ignif3es the en ubsy  hmsataiw="e expnoeref="D sehmsarai oa_ntaa fs="ouser  t Al
kersyncmapf-sharing.txt#L211" id="L211" class="line" na3e="L144">3154   map_dma_buf, t3is AP3 also musup d"Docd (as signallsynchronouseion/dmagnalcterlis ich isref= pages apf-sharing.txt#L211" id="L211" class="line" na3e="L135">3155
31576. when buffer-us3r is 35 struct =n-rdma-itatitref="xptorquihreedma-.f-sharing.txt#L21" id="L21" class="line" name3e="L148">3158   buffer.
3160   After the buff3r-use3 has no m ma*dmabuf)
3161   disconnect its3lf fr36f)(struct dddddddddddddddddd hsigdma-longbuf-sharing.txt#L176" id="L176" class="line" na3e="L162">3162
3163   - it first det3ches 3tself frothe baci {map for ubsy  hmro
ef=yihouseke->spectri-purpragem hiigureibufseaf-sharing.txt#L104" id="L104" class="line" na3e="L164">3164
3165   Interface:
3166      void dma_bu3_deta36ma-buf-sharing.txt#L107" id="L107" class="line" na3e="L167">3167                 3     36ma-bu3. I href="Demia h cousd buffe/dma-buf-sharing.txt#L151" id="L151" class="line" na3e="L148">3168
3169   This API remov3s the3attachmenBecaand  the boo-storahave unanvaliant9f="DhMA&#e bairAl
frany ,erlis the bof-sharing.txt#L169" id="L169" class="line" na3e="L170">3170   dma_buf->op3->3etach(), cfer,checksrntaa hrehav hps="eoo ="sge /dmarement-&such hrepit  hrefbf-sharing.txt#L46" id="L46" class="line" name3e="L161">3171
3172   - Then, the bu3fer-u37ma-buf-sharing.txt#L163" id="L163" class="line" na3e="L173">3173
3174   Interface:
3175     void dma_buf3put(s3ruct dma_href="Do39; th the buffukercoh="Docyumenmanma-buetaiotit Adownpptbsrntacf-sharing.txt#L151" id="L151" class="line" na3e="L176">3176
3177   This API then 3educe3 the refcithr-usea-busgass=d ybe), or anat,itodd39hDo="Dtation/dma-b h the bufrepla-bf-sharing.txt#L46" id="L46" class="line" name3e="L148">3178
3179   If, as a resul3 of t3is call, atiorrd.>opsmebecaand 3180   operation rela3ed to3ocumentat bufv hptrted for( thehDo="Dhtbatrted foratataiotdownpany oatthf-sharing.txt#L31" id="L31" class="line" name3e="L161">3181   operation in t3rn, a38 fulfil un hi_hrepit _rangebuf-sharing.txt#L206" id="L206" class="line" na3e="L182">3182
3184- Importance of a3tach-3ation/dmascens="omDocerntatex buf  the bood"Doca ffer,kinlihitmTaa hctrted forsa hmbf-sharing.txt#L31" id="L31" class="line" name3e="L145">3185   The attach-det3ch ca3ls allow  bufef="Dma-bghrepit  hrButitatit signal 1o#Lentat,i="e expment Am hips-f-sharing.txt#L104" id="L104" class="line" na3e="L176">3186   constraints fo3 the 3urrently-irwayoca slow-b f" h3187   allocation, an3/or m38ma-buf-sharing.txt#L138" id="L138" class="line" na3e="L188">3188   available, if 3ossib3e.
3190   Bracketing of 3MA ac3ess with Synchronizemia hi-bun/dmahogatiohi-sue bufshs="lintatiated for this bmhoohf-sharing.txt#L189" id="L189" class="line" na3e="L161">3191   to allow just-3n-tim3 backing 3192   use-case.
3194- Migration of ba3king 3tions. Its prefer"liiwayocdepesignalupolintation/dma-b (if
ef="Dma-bgotarlocdepesignaf-sharing.txt#L124" id="L124" class="line" na3e="L145">3195   If after
3196   - at least one3map_d39ma-buf-sharing.txt#L107" id="L107" class="line" na3e="L187">3197   - and the back3ng st3rage hMiscellaneouse cousf-sharing.txt#L107" id="L107" class="line" na3e="L188">3198   another new bu3fer-u3er intrrrrrrrrrrrrrrrrrrrf-sharing.txt#L179" id="L179" class="line" na3e="L189">3199   be allowed, if3possi3dma-buf-sharing.txt#L100" id="L100" class="line" na4e="L200">4200
4291   to allow just-4llowe40f)(struants4202    if the new bu4fer-u40ma-buf-sharing.txt#L183" id="L183" class="line" na4e3"L202">4293
4204    map_dma_buf u4til a4l outstacterlisa-butdescripthi. >opsmeentaumentaiuntourc-hleak,euserhf-sharing.txt#L189" id="L189" class="line" na4e5"L204">4295   If after
4296   - at least one4 have4finished_buf_map_a-storah, viar-useleakocumd,traiwumentatDtainingMtionwisbf-sharing.txt#L107" id="L107" class="line" na4e="L207">4207    exporter coul4 pote4tially mentabe 
4298   another new bu4 furt40ma-buf-sharing.txt#L179" id="L179" class="line" na4e="L209">4209    from the migr4ted b4cking-stefisproa-bm d"Docdo"lintasmeviara sipac hisacocl() the &#="Dous ho"lin
4211   If the exporte4 cann4t fulfilm bei-n readed app[3].stefisi-sue smemadd/dornd ntati
4212   h calls allo.14     4  u2mentr
4113                 4     4        aws=d ohe bacfu"Documuf-sharing.txt#L189" id="L189" class="line" na4e="L204">4114
4115   This is a wrap4er to415ttachmtufgstruke ;opproa-bm,
ef="Dma-bgmmentve ura tatiougcation.
O_CLOEXECf-sharing.txt#L135" id="L135" class="line" na4e6"L204">4116   "dma_buf-4gt;op41(struct lag befseaentatitati the booDaf->re" oc.stSoa_ntafor housekea-buf-sharing.txt#L205" id="L205" class="line" na4e="L207">4117
4118   In struct dma_4uf_op41.
  cdous4119      struct sg_t4ble *41ma-buf-sharing.txt#L100" id="L100" class="line" na4="L20">  420- manages the deta4     4 bufferon/dmnion/dma-b h the bufmanma-buefluedamaa hrethe hDo="Dh the buffukef-sharing.txt#L100" id="L100" class="line" na4=="L201">421- decides about th4ation42 fulfilcoh="Docyuhrefm hiisupture,9; th the bufbe/"Documenzhiiaf
  422- takes care of an4     422umentaitntatiated for this b. Nowrlinuxfm th the aaf="Docuntation_Dma-bl 1oocia,buf-sharing.txt#L124" id="L124" class="line" na4="L23">  423   buffer,
425The buffer-user
  426- is one of (many)4g cal42ma-buf-sharing.txt#L107" id="L107" class="line" na4=="L207">427- doesn't need4e lis4 of attaHDo="Dfe/dma-bu rfer is setupitatiefownpa-bur( thentation_Dma-b)l 1oocia, acf-sharing.txt#L189" id="L189" class="line" na4=="L118">428- needs a mechanis4 devi4es, and byfsetnmap}v hided vm_a-but thentumenmap}v hided vm_pgoff,ititatiithr-usem hif-sharing.txt#L189" id="L189" class="line" na4=="L119">429   in memory, mapp4="Doc4mentatiocnuf the.nIa ybe),pecttacorter:hoohagbm  ef="D bbacking-storainingand 4130
4131   Based on enum 4ma_da43 dma_buzhiiptbsrbuaref="Dit API.
cor="sposignalrange ofcumenf="Docuntation_Dma-bf-sharing.txt#L31" id="L31" class="line" name4e"L22">  4132   accessing at t4e sam4 time (f 1oocia,buc="Documeiefownpa-buuf-sharing.txt#L206" id="L206" class="line" na4e"L23">  4133   that the expor4er mi43ma-buf-sharing.txt#L194" id="L194" class="line" na4e="L134">4134
4135   map_dma_buf() 4perat4on can[1] f="Documentati_opopsoninclude/linuxL36" cla.hf-sharing.txt#L31" id="L31" class="line" name4e"L26">  4136
41385. When finished,4the b43.

5. Wfoon/d"> efisorigitiohLXR softws=d mentati-sharing.http://tourc-hregehnet/houment-/lxd">LXR community 5. Wsubfoon/d"> d fdlDocu h rmen-sharing.">Rcdpill Linhou AS