* [PATCH] ARM: Fix bug in remap_range
@ 2015-11-13 7:53 Sascha Hauer
0 siblings, 0 replies; only message in thread
From: Sascha Hauer @ 2015-11-13 7:53 UTC (permalink / raw)
To: Barebox List
remap_range takes generic MAP_CACHED/MAP_UNCACHED flags which are then
translated into the corresponding ARM specific bits. We call remap_range
internally from dma_alloc_* aswell, but instead of passing the generic
flags we pass the ARM specific bits.
Fix this by creating an internal __remap_range function which takes the
ARM specific bits and use it where appropriate.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/cpu/mmu.c | 38 ++++++++++++++++++++++----------------
1 file changed, 22 insertions(+), 16 deletions(-)
diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index 81c2394..784221c 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -163,23 +163,11 @@ static void dma_inv_range(unsigned long start, unsigned long end)
__dma_inv_range(start, end);
}
-int arch_remap_range(void *_start, size_t size, unsigned flags)
+static int __remap_range(void *_start, size_t size, u32 pte_flags)
{
unsigned long start = (unsigned long)_start;
u32 *p;
int numentries, i;
- u32 pte_flags;
-
- switch (flags) {
- case MAP_CACHED:
- pte_flags = pte_flags_cached;
- break;
- case MAP_UNCACHED:
- pte_flags = pte_flags_uncached;
- break;
- default:
- return -EINVAL;
- }
numentries = size >> PAGE_SHIFT;
p = find_pte(start);
@@ -197,6 +185,24 @@ int arch_remap_range(void *_start, size_t size, unsigned flags)
return 0;
}
+int arch_remap_range(void *start, size_t size, unsigned flags)
+{
+ u32 pte_flags;
+
+ switch (flags) {
+ case MAP_CACHED:
+ pte_flags = pte_flags_cached;
+ break;
+ case MAP_UNCACHED:
+ pte_flags = pte_flags_uncached;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return __remap_range(start, size, pte_flags);
+}
+
void *map_io_sections(unsigned long phys, void *_start, size_t size)
{
unsigned long start = (unsigned long)_start, sec;
@@ -412,7 +418,7 @@ 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_uncached);
return ret;
}
@@ -428,7 +434,7 @@ void *dma_alloc_writecombine(size_t size, dma_addr_t *dma_handle)
dma_inv_range((unsigned long)ret, (unsigned long)ret + size);
- remap_range(ret, size, pte_flags_wc);
+ __remap_range(ret, size, pte_flags_wc);
return ret;
}
@@ -446,7 +452,7 @@ void *phys_to_virt(unsigned long phys)
void dma_free_coherent(void *mem, dma_addr_t dma_handle, size_t size)
{
size = PAGE_ALIGN(size);
- remap_range(mem, size, pte_flags_cached);
+ __remap_range(mem, size, pte_flags_cached);
free(mem);
}
--
2.6.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-11-13 7:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-13 7:53 [PATCH] ARM: Fix bug in remap_range Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox