summaryrefslogtreecommitdiffstats
path: root/arch/arm/cpu/mmu.c
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2018-05-17 13:58:30 -0700
committerSascha Hauer <s.hauer@pengutronix.de>2018-05-18 08:13:19 +0200
commitf9f233130b1bc0c28d4c5a754a4d5266f3fb3eb9 (patch)
tree3c5c0af73b02839d3ed056da2f2b4223ca6bb932 /arch/arm/cpu/mmu.c
parentf42c864d3ee3bdc876f7fe6142a71d36a3bb597a (diff)
downloadbarebox-f9f233130b1bc0c28d4c5a754a4d5266f3fb3eb9.tar.gz
barebox-f9f233130b1bc0c28d4c5a754a4d5266f3fb3eb9.tar.xz
ARM: mmu: Share code between dma_alloc_*() functions
Code of dma_alloc_coherent() and dma_alloc_writecombine() is almost identical with exception of the flags passed to undelying call to __remap_range(). Move commong code into a shared subroutine and convert both functions to use it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/cpu/mmu.c')
-rw-r--r--arch/arm/cpu/mmu.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index fc4046e85c..7d4432b989 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -500,7 +500,7 @@ void mmu_disable(void)
__mmu_cache_off();
}
-void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
+static void *dma_alloc(size_t size, dma_addr_t *dma_handle, uint32_t pte_flags)
{
void *ret;
@@ -511,25 +511,19 @@ void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
dma_inv_range((unsigned long)ret, (unsigned long)ret + size);
- __remap_range(ret, size, pte_flags_uncached);
+ __remap_range(ret, size, pte_flags);
return ret;
}
-void *dma_alloc_writecombine(size_t size, dma_addr_t *dma_handle)
+void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
{
- void *ret;
-
- size = PAGE_ALIGN(size);
- ret = xmemalign(PAGE_SIZE, size);
- if (dma_handle)
- *dma_handle = (dma_addr_t)ret;
-
- dma_inv_range((unsigned long)ret, (unsigned long)ret + size);
-
- __remap_range(ret, size, pte_flags_wc);
+ return dma_alloc(size, dma_handle, pte_flags_uncached);
+}
- return ret;
+void *dma_alloc_writecombine(size_t size, dma_addr_t *dma_handle)
+{
+ return dma_alloc(size, dma_handle, pte_flags_wc);
}
unsigned long virt_to_phys(volatile void *virt)