Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Oct 2014 17:21:32 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Martin Galvan <omgalvan.86@gmail.com>
Cc:        freebsd-drivers@freebsd.org, freebsd-embedded@freebsd.org
Subject:   Re: A few questions about SD/MMC drivers
Message-ID:  <20141013142132.GN2153@kib.kiev.ua>
In-Reply-To: <CAN19L9E0K4rhffRwAo-oyxtajCy4R3Y1bF%2BS7RkSD-NKA_MH%2BA@mail.gmail.com>
References:  <CAN19L9ENsuAR6_aXwJSRdfDz6UgE6kU%2BrCkGGsdK7tRcUes%2B0w@mail.gmail.com> <20141006171521.GD26076@kib.kiev.ua> <CAN19L9E0K4rhffRwAo-oyxtajCy4R3Y1bF%2BS7RkSD-NKA_MH%2BA@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Oct 13, 2014 at 02:24:52AM -0300, Martin Galvan 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.
> 
> 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?

I am not sure about the scope of your question.  Are you aware of
busdma(9) ?  This is the KPI to use for DMA programming on *BSD, and
it is typically enough for most hardware.

If you do know about busdma(9) and do not consider it not suitable for
the task, this is completely different situation, and you should
describe why.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20141013142132.GN2153>