spi: Make core DMA mapping functions generate scatterlists
authorMark Brown <broonie@linaro.org>
Sun, 2 Feb 2014 13:47:47 +0000 (13:47 +0000)
committerStephane Desneux <stephane.desneux@open.eurogiciel.org>
Wed, 4 Feb 2015 10:13:25 +0000 (11:13 +0100)
commitcb98bab06b1dd1fd8a44ded490f2b1a600e8908f
treed29f9f35a38a042668c1f07df0d8c66f4ccc2caf
parent9cdb64e24b9f268df05527990733069dce597ec7
spi: Make core DMA mapping functions generate scatterlists

We cannot unconditionally use dma_map_single() to map data for use with
SPI since transfers may exceed a page and virtual addresses may not be
provided with physically contiguous pages. Further, addresses allocated
using vmalloc() need to be mapped differently to other addresses.

Currently only the MXS driver handles all this, a few drivers do handle
the possibility that buffers may not be physically contiguous which is
the main potential problem but many don't even do that. Factoring this
out into the core will make it easier for drivers to do a good job so if
the driver is using the core DMA code then generate a scatterlist
instead of mapping to a single address so do that.

This code is mainly based on a combination of the existing code in the MXS
and PXA2xx drivers. In future we should be able to extend it to allow the
core to concatenate adjacent transfers if they are compatible, improving
performance.

Currently for simplicity clients are not allowed to use the scatterlist
when they do DMA mapping, in the future the existing single address
mappings will be replaced with use of the scatterlist most likely as
part of pre-verifying transfers.

This change makes it mandatory to use scatterlists when using the core DMA
mapping so update the s3c64xx driver to do this when used with dmaengine.
Doing so makes the code more ugly but it is expected that the old s3c-dma
code can be removed very soon.

Signed-off-by: Mark Brown <broonie@linaro.org>
(cherry picked from commit 6ad45a27cbe343ec8d7888e5edf6335499a4b555)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
drivers/spi/spi-s3c64xx.c
drivers/spi/spi.c
include/linux/spi/spi.h