ARM: dma-mapping: add support for IOMMU mapper
authorMarek Szyprowski <m.szyprowski@samsung.com>
Wed, 16 May 2012 13:48:21 +0000 (15:48 +0200)
committerMarek Szyprowski <m.szyprowski@samsung.com>
Mon, 21 May 2012 13:06:23 +0000 (15:06 +0200)
commit4ce63fcd919c32d22528e54dcd89506962933719
tree648f7681a5c89209b627e8c3e899d953ed38685d
parentf99d60341238fe73fc514129cd9ae4e44e1b2c47
ARM: dma-mapping: add support for IOMMU mapper

This patch add a complete implementation of DMA-mapping API for
devices which have IOMMU support.

This implementation tries to optimize dma address space usage by remapping
all possible physical memory chunks into a single dma address space chunk.

DMA address space is managed on top of the bitmap stored in the
dma_iommu_mapping structure stored in device->archdata. Platform setup
code has to initialize parameters of the dma address space (base address,
size, allocation precision order) with arm_iommu_create_mapping() function.
To reduce the size of the bitmap, all allocations are aligned to the
specified order of base 4 KiB pages.

dma_alloc_* functions allocate physical memory in chunks, each with
alloc_pages() function to avoid failing if the physical memory gets
fragmented. In worst case the allocated buffer is composed of 4 KiB page
chunks.

dma_map_sg() function minimizes the total number of dma address space
chunks by merging of physical memory chunks into one larger dma address
space chunk. If requested chunk (scatter list entry) boundaries
match physical page boundaries, most calls to dma_map_sg() requests will
result in creating only one chunk in dma address space.

dma_map_page() simply creates a mapping for the given page(s) in the dma
address space.

All dma functions also perform required cache operation like their
counterparts from the arm linear physical memory mapping version.

This patch contains code and fixes kindly provided by:
- Krishna Reddy <vdumpa@nvidia.com>,
- Andrzej Pietrasiewicz <andrzej.p@samsung.com>,
- Hiroshi DOYU <hdoyu@nvidia.com>

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tested-By: Subash Patel <subash.ramaswamy@linaro.org>
arch/arm/Kconfig
arch/arm/include/asm/device.h
arch/arm/include/asm/dma-iommu.h [new file with mode: 0644]
arch/arm/mm/dma-mapping.c
arch/arm/mm/vmregion.h