Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 38bdbdc7 authored by Alexander Duyck's avatar Alexander Duyck Committed by Linus Torvalds
Browse files

arch/metag: add option to skip DMA sync as a part of map and unmap

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
via a sync_for_cpu or sync_for_device call.

Link: http://lkml.kernel.org/r/20161110113503.76501.80809.stgit@ahduyck-blue-test.jf.intel.com


Signed-off-by: default avatarAlexander Duyck <alexander.h.duyck@intel.com>
Cc: James Hogan <james.hogan@imgtec.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 5140d234
Loading
Loading
Loading
Loading
+13 −3
Original line number Original line Diff line number Diff line
@@ -484,8 +484,9 @@ static dma_addr_t metag_dma_map_page(struct device *dev, struct page *page,
		unsigned long offset, size_t size,
		unsigned long offset, size_t size,
		enum dma_data_direction direction, unsigned long attrs)
		enum dma_data_direction direction, unsigned long attrs)
{
{
	dma_sync_for_device((void *)(page_to_phys(page) + offset), size,
	if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
			    direction);
		dma_sync_for_device((void *)(page_to_phys(page) + offset),
				    size, direction);
	return page_to_phys(page) + offset;
	return page_to_phys(page) + offset;
}
}


@@ -493,6 +494,7 @@ static void metag_dma_unmap_page(struct device *dev, dma_addr_t dma_address,
		size_t size, enum dma_data_direction direction,
		size_t size, enum dma_data_direction direction,
		unsigned long attrs)
		unsigned long attrs)
{
{
	if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
		dma_sync_for_cpu(phys_to_virt(dma_address), size, direction);
		dma_sync_for_cpu(phys_to_virt(dma_address), size, direction);
}
}


@@ -507,6 +509,10 @@ static int metag_dma_map_sg(struct device *dev, struct scatterlist *sglist,
		BUG_ON(!sg_page(sg));
		BUG_ON(!sg_page(sg));


		sg->dma_address = sg_phys(sg);
		sg->dma_address = sg_phys(sg);

		if (attrs & DMA_ATTR_SKIP_CPU_SYNC)
			continue;

		dma_sync_for_device(sg_virt(sg), sg->length, direction);
		dma_sync_for_device(sg_virt(sg), sg->length, direction);
	}
	}


@@ -525,6 +531,10 @@ static void metag_dma_unmap_sg(struct device *dev, struct scatterlist *sglist,
		BUG_ON(!sg_page(sg));
		BUG_ON(!sg_page(sg));


		sg->dma_address = sg_phys(sg);
		sg->dma_address = sg_phys(sg);

		if (attrs & DMA_ATTR_SKIP_CPU_SYNC)
			continue;

		dma_sync_for_cpu(sg_virt(sg), sg->length, direction);
		dma_sync_for_cpu(sg_virt(sg), sg->length, direction);
	}
	}
}
}