summaryrefslogtreecommitdiffstats
path: root/arch/sh/mm/consistent.c
diff options
context:
space:
mode:
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>2017-12-04 16:09:01 +0100
committerRich Felker <dalias@libc.org>2018-04-13 01:47:53 +0200
commitce88313069c36eef80f21fd7403f16620ecd21a2 (patch)
tree6d0733fa5f58aead4d68ffbdd846038cbd306ff1 /arch/sh/mm/consistent.c
parentarch/sh: add sh7786_mm_sel() function (diff)
downloadlinux-ce88313069c36eef80f21fd7403f16620ecd21a2.tar.xz
linux-ce88313069c36eef80f21fd7403f16620ecd21a2.zip
arch/sh: make the DMA mapping operations observe dev->dma_pfn_offset
Some devices may have a non-zero DMA offset, i.e an offset between the DMA address and the physical address. Such an offset can be encoded into the dma_pfn_offset field of "struct device", but the SuperH implementation of the DMA mapping API does not observe this information. This commit fixes that by ensuring the DMA address is properly calculated depending on this DMA offset. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Rich Felker <dalias@libc.org>
Diffstat (limited to '')
-rw-r--r--arch/sh/mm/consistent.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/sh/mm/consistent.c b/arch/sh/mm/consistent.c
index 6ea3aab508f2..8ce98691d822 100644
--- a/arch/sh/mm/consistent.c
+++ b/arch/sh/mm/consistent.c
@@ -59,7 +59,7 @@ void *dma_generic_alloc_coherent(struct device *dev, size_t size,
split_page(pfn_to_page(virt_to_phys(ret) >> PAGE_SHIFT), order);
- *dma_handle = virt_to_phys(ret);
+ *dma_handle = virt_to_phys(ret) - PFN_PHYS(dev->dma_pfn_offset);
return ret_nocache;
}
@@ -69,7 +69,7 @@ void dma_generic_free_coherent(struct device *dev, size_t size,
unsigned long attrs)
{
int order = get_order(size);
- unsigned long pfn = dma_handle >> PAGE_SHIFT;
+ unsigned long pfn = (dma_handle >> PAGE_SHIFT) + dev->dma_pfn_offset;
int k;
for (k = 0; k < (1 << order); k++)