]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
drivers: dma-coherent: Account dma_pfn_offset when used with device tree
authorVladimir Murzin <vladimir.murzin@arm.com>
Mon, 26 Jun 2017 09:18:57 +0000 (10:18 +0100)
committerChristoph Hellwig <hch@lst.de>
Wed, 28 Jun 2017 13:55:02 +0000 (06:55 -0700)
commitc41f9ea998f3ba61f38fa350eef28ec6caf0a07d
tree6973acbeacd3b807b1a33608ca9bc08395743b4c
parent25f1e18870881f3366a5abec27b651983ce9032c
drivers: dma-coherent: Account dma_pfn_offset when used with device tree

dma_declare_coherent_memory() and friends are designed to account
difference in CPU and device addresses. However, when it is used with
reserved memory regions there is assumption that CPU and device have
the same view on address space. This assumption gets invalid when
reserved memory for coherent DMA allocations is referenced by device
with non-empty "dma-range" property.

Simply feeding device address as rmem->base + dev->dma_pfn_offset
would not work due to reserved memory region can be shared, so this
patch turns device address to be expressed with help of CPU address
and device's dma_pfn_offset in case memory reservation has been done
via device tree; non device tree users continue to use the old scheme.

Cc: Michal Nazarewicz <mina86@mina86.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Roger Quadros <rogerq@ti.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Tested-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Tested-by: Andras Szemzo <sza@esh.hu>
Tested-by: Alexandre TORGUE <alexandre.torgue@st.com>
Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/base/dma-coherent.c