Re: [net-next PATCH RFC 07/26] arch/c6x: Add option to skip sync on DMA map and unmap

From: Mark Salter
Date: Fri Oct 28 2016 - 10:59:07 EST


On Mon, 2016-10-24 at 08:05 -0400, Alexander Duyck wrote:
> This change allows us to pass DMA_ATTR_SKIP_CPU_SYNC which allows us to
> avoid invoking cache line invalidation if the driver will just handle it
> later via a sync_for_cpu or sync_for_device call.
>
> Cc: Mark Salter <msalter@xxxxxxxxxx>
> Cc: Aurelien Jacquiot <a-jacquiot@xxxxxx>
> Cc: linux-c6x-dev@xxxxxxxxxxxxx
> Signed-off-by: Alexander Duyck <alexander.h.duyck@xxxxxxxxx>
> ---

Acked-by: Mark Salter <msalter@xxxxxxxxxx>

> Âarch/c6x/kernel/dma.c |ÂÂÂ16 +++++++++++-----
> Â1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/arch/c6x/kernel/dma.c b/arch/c6x/kernel/dma.c
> index db4a6a3..d28df74 100644
> --- a/arch/c6x/kernel/dma.c
> +++ b/arch/c6x/kernel/dma.c
> @@ -42,14 +42,17 @@ static dma_addr_t c6x_dma_map_page(struct device *dev, struct page *page,
> Â{
> Â dma_addr_t handle = virt_to_phys(page_address(page) + offset);
> Â
> - c6x_dma_sync(handle, size, dir);
> + if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
> + c6x_dma_sync(handle, size, dir);
> +
> Â return handle;
> Â}
> Â
> Âstatic void c6x_dma_unmap_page(struct device *dev, dma_addr_t handle,
> Â size_t size, enum dma_data_direction dir, unsigned long attrs)
> Â{
> - c6x_dma_sync(handle, size, dir);
> + if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
> + c6x_dma_sync(handle, size, dir);
> Â}
> Â
> Âstatic int c6x_dma_map_sg(struct device *dev, struct scatterlist *sglist,
> @@ -60,7 +63,8 @@ static int c6x_dma_map_sg(struct device *dev, struct scatterlist *sglist,
> Â
> Â for_each_sg(sglist, sg, nents, i) {
> Â sg->dma_address = sg_phys(sg);
> - c6x_dma_sync(sg->dma_address, sg->length, dir);
> + if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
> + c6x_dma_sync(sg->dma_address, sg->length, dir);
> Â }
> Â
> Â return nents;
> @@ -72,8 +76,10 @@ static void c6x_dma_unmap_sg(struct device *dev, struct scatterlist *sglist,
> Â struct scatterlist *sg;
> Â int i;
> Â
> - for_each_sg(sglist, sg, nents, i)
> - c6x_dma_sync(sg_dma_address(sg), sg->length, dir);
> + for_each_sg(sglist, sg, nents, i) {
> + if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
> + c6x_dma_sync(sg_dma_address(sg), sg->length, dir);
> + }
> Â
> Â}
> Â
>