title: How to allocate DMA descriptor in u-boot
body: <p>In Linux kernel , we can allocate DMA descriptor(structure containing DMA controller property) using dma_alloc_coherent but I don't see such an api in u-boot source .</p>
  
  <p>How can we allocate DMA descriptor in u-boot?</p>
  
  <p>From given source <a href="https://github.com/siemens/u-boot/blob/master/drivers/dma/apbh_dma.c#L339" rel="nofollow">https://github.com/siemens/u-boot/blob/master/drivers/dma/apbh_dma.c#L339</a> </p>
  
  <pre><code>/*
  * Allocate DMA descriptor
  */
  struct mxs_dma_desc *mxs_dma_desc_alloc(void)
  {
  struct mxs_dma_desc *pdesc;
  uint32_t size;
  
  size = roundup(sizeof(struct mxs_dma_desc), MXS_DMA_ALIGNMENT);
  pdesc = memalign(MXS_DMA_ALIGNMENT, size);
  
  if (pdesc == NULL)
      return NULL;
  
  memset(pdesc, 0, sizeof(*pdesc));
  pdesc-&gt;address = (dma_addr_t)pdesc;
  
  return pdesc;
  };
  </code></pre>
  
  <p>I can see that descriptor is allocated using memalign but how it would make sure that allocation is from consistent memory ?</p>