A few questions about SD/MMC drivers

Warner Losh imp at bsdimp.com
Mon Oct 13 14:57:35 UTC 2014


On Oct 12, 2014, at 11:24 PM, Martin Galvan <omgalvan.86 at gmail.com> wrote:

> Hi again! I'm in the middle of implementing DMA support for the
> Allwinner driver, and I was surprised to see that BSD doesn't have a
> simple DMA API as Linux does. Namely, I didn't see anything like the
> scatterlists used in Linux.

see busdma(8) for all your DMA needs. It also takes care of situations
where bounce buffers are needed, returning properly aligned memory,
etc.

> The host found in Allwinner SoCs uses a DMA controller which works
> with a linked list of descriptors, each having info on a data buffer.
> In the Linux driver they allocate a coherent DMA buffer using
> dma_alloc_coherent to get both the virtual and bus addresses of the
> descriptor list. When it's time to do a DMA transfer, the Linux driver
> allocates a scatterlist with each entry being a buffer corresponding
> to a descriptor; it then loops through the descriptor list setting the
> "buffer pointer" field of each one to the bus address of the
> corresponding scatterlist entry, and the "next descriptor" to the bus
> address of the following descriptor. It's pretty neat, though it's
> worth mentioning the scatterlist that the MMC request handler maps
> already contains the virtual addresses of the requested buffers.
> 
> Do we have anything like that on BSD? If not, what would be a simple
> algorithm to make this work?

Pretty much all of that is covered in busdma(8). The mechanics are a bit
different than Linux, sure, but all that functionality is there.

Warner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/freebsd-drivers/attachments/20141013/95638aa9/attachment.sig>


More information about the freebsd-drivers mailing list