[RFC] [PATCH 0/3] scatterlist: Add support to clone sg_table

From: Franklin S Cooper Jr
Date: Fri Jun 17 2016 - 18:45:38 EST


This patchset creates two new functions within scatterlist that allows a
user to pass in a sg_table and receive a duplicate copy. The sgl in this
copied table are dynamically allocated but its values such as offset,
length and dma_address are the same as its variant within the sgl in the
original sg_table.

This is useful when tweaks to sgl may be needed to alter a future DMA
operation by tweaking the table nents count or the individual sgl
offset/length without changing the original values.

An example use case is also included in this patchset. In the omap2-mcspi
driver on certain OMAP SOCs if certain conditions are met the DMA should
transfer one or two less elements when reading from the SPI. The
remaining bytes are read in CPU mode. To accomplish this the spi's rx_sg
sgl should have the last entry length reduced for the DMA operation.
However, this change should only be done locally so instead of altering
the original sgl this new function allows a clone to be created.

Franklin S Cooper Jr (3):
lib/scatterlist: Add support to clone sg_table
spi: omap2-mcspi: Add comments for RX only DMA buffer workaround
spi: omap2-mcspi: Use the SPI framework to handle DMA mapping

drivers/spi/spi-omap2-mcspi.c | 122 +++++++++++++++++-------------------------
include/linux/scatterlist.h | 2 +
lib/scatterlist.c | 93 ++++++++++++++++++++++++++++++++
3 files changed, 144 insertions(+), 73 deletions(-)

--
1.9.1