Date: Mon, 13 Oct 2014 08:57:25 -0600 From: Warner Losh <imp@bsdimp.com> To: Martin Galvan <omgalvan.86@gmail.com> Cc: Konstantin Belousov <kostikbel@gmail.com>, freebsd-drivers@freebsd.org, freebsd-embedded@freebsd.org Subject: Re: A few questions about SD/MMC drivers Message-ID: <0B7F1C7B-7E38-48FD-B3CF-A4512A45E4C0@bsdimp.com> 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
--Apple-Mail=_5C375B95-34D5-468C-8AAB-B190D7984D7E Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii On Oct 12, 2014, at 11:24 PM, Martin Galvan <omgalvan.86@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 --Apple-Mail=_5C375B95-34D5-468C-8AAB-B190D7984D7E Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJUO+hVAAoJEGwc0Sh9sBEAxK8QAKrCbArDptS8Zd70zY3wah/L mmii/TgD2aOE/lcB1weJB57lK/2uyRD9EKUOXI4v/TN13mPcUQ9Fo8uaSHSxY8wg NVjiaCmvKHHwB9eQG12SbGnXbcc/ZwY5s8IU58wEC662OEkXShXyUfIOxc+hl1GJ wtIzjS1GQ33WfsgCjhYYMzOIgD04thAhomdrowzo+deWHD7QtOjsiPqn12+OhJdG QDjcSy1+0Z1TA4KtB7hvZR5uDBaSlksGabYzPfPY96yZnfK4ybJSkGRMmKLWpT69 NEgSJ19Fju8egG5tF04Oj2JMV7Retwff5nhA84YFaL0nswY1VxGsT9CdEmyAZq9N 1+l4cMxI01YS2fZRkYdFCzWYO5J42vMqPXoI7+iNfe2QUPIT5fp8XLJdkoyE8Jpo fLg9tGrI+yH8qQq5I31FHG//htSibgG9uUiX57UL6PbVixHANhmkiA3l77/1CpnD 896fs/Den3o1lUSk/eQEa4sJ9ioiyXuOhvykfU2Obpl7IoQ6KwFgLvBOmjgXdNs/ OMXre0F/w7RRFfZ0z8tfEbl7A1gEIox6+oQyTNUP62xit2hrrdizarqy7hPDHdye DGWmgcjLbMGhu3mmOyralyCguJifm+Tuvpr8c6EIFllQrjWcxvP41qalKB+hoM2p xJDJC03VUTUM01kD5GSl =dF3R -----END PGP SIGNATURE----- --Apple-Mail=_5C375B95-34D5-468C-8AAB-B190D7984D7E--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?0B7F1C7B-7E38-48FD-B3CF-A4512A45E4C0>