Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1438692
| From | "Franklin S Cooper Jr." <fcooper@ti.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist |
| Date | 2016-07-07 18:00 +0200 |
| Message-ID | <rSjSx-vy-1@gated-at.bofh.it> (permalink) |
| References | (2 earlier) <rRCaR-5LK-1@gated-at.bofh.it> <rRYEp-3A0-9@gated-at.bofh.it> <rRZ7s-3Lq-13@gated-at.bofh.it> <rS0Zz-4Zv-1@gated-at.bofh.it> <rS3b3-6AA-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 07/06/2016 05:04 PM, Robert Jarzmik wrote: > "Franklin S Cooper Jr." <fcooper@ti.com> writes: > >> Unfortunately, for the original purpose of this series the scatterlist I >> want to clone is indeed DMA mapped. >> >> The times I've seen dma_length != length is when the dma_map_sg is >> trying to combine contiguous sgl (ex ppc_iommu_map_sg and dma_map_cont). >> So maybe it is better to subtract a value from length and dma_length >> rather than explicitly setting it to a value. This way it wouldn't >> matter that dma_length and length aren't equal. >> >> This looks like a similar approach used by sg_split_mapped. Although >> sg_split skips first x number of bytes while I want to skip the last x >> number of bytes. >> >> Maybe Robert can add his thoughts since he created sg_split. > > Hi, > > I've not read it all, but the above chapter is right : dma_length might be > different from length when a dma mapping operation coallesced 2 sg entries into > a "DMA contiguous one". This coallescing might happen for at least for 2 reasons > as far as I know : > - 2 sg entries are physically contiguous, ie : > sg_phys(sga) + sga.length == sg_phys(sgb) > - 2 sg entries are DMA contiguous when an IOMMU maps them contiguously, ie : > sg_dma_address(sga) + sga.length == sg_dma_address(sgb) > > Moreover, this 2 coallescing cases imply a "shift" between (page_link, length) > and (dma_address and dma_length). For example a mapped sglist might look like : > -sg0: page_link=>page@0k, length=4096, dma_address=0, dma_length=8192 > -sg1: page_link=>page@4k, length=4096, dma_address=8192, dma_length=16 > \=> see the shift here > coming from sg2 > -sg2: page_link=>page@8k, length=16, dma_address=0, dma_length=0 > > For these "tricky" cases, at the time I created sg_split I had done a tester as > well. It's very basic, doesn't cover all the corner cases, is a bit dumb, but > you might have a look, and the brain cost you'll pay to adapt it to test what > you want will hopefully pay off by the knowledge gained on scatterlist. It is > appended at the end of the mail. Thanks Robert for your input and sharing your test program. After looking at sg_split and test program I realized that I can use it instead of creating my own clone function. Seems like you and your patch reviewers already considered and dealt with the above complex scenario. I updated my patchset to use sg_split rather than my custom function since it seems to solve my original problem. I plan on sending out a v3 that incorporates this change. > > Cheers. >
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[RFC] [PATCH v2 0/3] scatterlist: Add support to clone sg_table Franklin S Cooper Jr <fcooper@ti.com> - 2016-06-27 17:00 +0200
[RFC] [PATCH v2 3/3] spi: omap2-mcspi: Use the SPI framework to handle DMA mapping Franklin S Cooper Jr <fcooper@ti.com> - 2016-06-27 17:00 +0200
[RFC] [PATCH v2 2/3] spi: omap2-mcspi: Add comments for RX only DMA buffer workaround Franklin S Cooper Jr <fcooper@ti.com> - 2016-06-27 17:00 +0200
[RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist Franklin S Cooper Jr <fcooper@ti.com> - 2016-06-27 17:00 +0200
Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist Mark Brown <broonie@kernel.org> - 2016-07-05 17:00 +0200
Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist Andy Shevchenko <andy.shevchenko@gmail.com> - 2016-07-05 18:50 +0200
Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist Andy Shevchenko <andy.shevchenko@gmail.com> - 2016-07-05 19:20 +0200
Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist "Franklin S Cooper Jr." <fcooper@ti.com> - 2016-07-06 19:20 +0200
Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist Andy Shevchenko <andy.shevchenko@gmail.com> - 2016-07-06 19:50 +0200
Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist "Franklin S Cooper Jr." <fcooper@ti.com> - 2016-07-06 21:50 +0200
Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist Robert Jarzmik <robert.jarzmik@free.fr> - 2016-07-07 00:10 +0200
Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist Mark Brown <broonie@kernel.org> - 2016-07-07 10:40 +0200
Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist Robert Jarzmik <robert.jarzmik@free.fr> - 2016-07-07 19:50 +0200
Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist Mark Brown <broonie@kernel.org> - 2016-07-08 10:20 +0200
Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist "Franklin S Cooper Jr." <fcooper@ti.com> - 2016-07-07 18:00 +0200
Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist Sekhar Nori <nsekhar@ti.com> - 2016-07-06 12:20 +0200
Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist "Franklin S Cooper Jr." <fcooper@ti.com> - 2016-07-06 19:30 +0200
csiph-web