ARM: fix ioremap to allow mapping some specific RAM areas
PATCH 1/1 ARM: fix ioremap to allow mapping some specific RAM areas
Creating more than one mapping on ARMv6+ might cause unspecified behavior, so ioremap() should fail if it was called with area that matches low memory. However if the board code removes the specific area from low memory mapping on boot (for example by calling memblock_remove()), then creating a mapping with ioremap might be desired.
This patch enables creating mapping for RAM by ioremap call, but only if the target area has no low memory mapping yet. This enables board code to reserve particular memory areas with memblock_remove() and provide them to device drivers with a declare_coherent_memory() call.
--- arch/arm/mm/ioremap.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
arch/arm/mm/ioremap.c +4 -2
@@ -25,6 +25,7 @@#include <linux/mm.h> #include <linux/vmalloc.h> #include <linux/io.h> +#include <linux/memblock.h> #include <asm/cputype.h> #include <asm/cacheflush.h>
@@ -202,9 +203,10 @@ void __iomem * __arm_ioremap_pfn_caller(unsigned long pfn,return NULL ;/* -* Don't allow RAM to be mapped - this causes problems with ARMv6+ +* Don't allow low memory to be mapped again - this causes problems +* with ARMv6+ */ -if (WARN_ON (pfn_valid (pfn))) +if (WARN_ON (memblock_is_memory (pfn <<PAGE_SHIFT )))return NULL ; type =get_mem_type (mtype);
Signature · 1 line
1.7.1.569.g6f426
PATCH 1/1 ARM: fix ioremap to allow mapping some specific RAM areas
Quoted 10 lines · Marek Szyprowski
Creating more than one mapping on ARMv6+ might cause unspecified behavior, so
ioremap()should fail if it was called with area that matches low memory. However if the board code removes the specific area from low memory mapping on boot (for example by callingmemblock_remove()), then creating a mapping with ioremap might be desired.This patch enables creating mapping for RAM by ioremap call, but only if the target area has no low memory mapping yet. This enables board code to reserve particular memory areas with
memblock_remove()and provide them to device drivers with adeclare_coherent_memory()call.
NAK. pfn_valid is already defined like this:
int pfn_valid(unsigned long pfn)
{
return memblock_is_memory(pfn << PAGE_SHIFT);
}provided you enable ARCH_HAS_HOLES_MEMORYMODEL, which you must do if you're punching holes in the memory map.
PATCH 1/1 ARM: fix ioremap to allow mapping some specific RAM areas
Hello,
Quoted 16 lines · Russell King - ARM Linux
Quoted 2 lines · Marek Szyprowski
Creating more than one mapping on ARMv6+ might cause unspecified behavior, so
ioremap()should fail if it was called with area that matches lowmemory.
Quoted 7 lines
However if the board code removes the specific area from low memory mapping on boot (for example by calling
memblock_remove()), then creating a mapping with ioremap might be desired.This patch enables creating mapping for RAM by ioremap call, but only if the target area has no low memory mapping yet. This enables board code to reserve particular memory areas with
memblock_remove()and provide themto
Quoted 1 line
device drivers with a
declare_coherent_memory()call.NAK.
pfn_validis already defined like this:
Quoted 7 lines
int
pfn_valid(unsigned long pfn){ return memblock_is_memory(pfn << PAGE_SHIFT); }provided you enable
ARCH_HAS_HOLES_MEMORYMODEL, which you must do if you're punching holes in the memory map.
Ok, I see the point in ARCH_HAS_HOLES_MEMORYMODEL, but it doesn't solve my problem. In case of Samsung Exynos4 and S5PV210 platforms we use SPARSEMEM, but the above definition of pfn_valid() function is correct only if SPARSEMEM is not enabled.
How do you suggest to solve this issue in case of SPARSEMEM platforms?
Best regards
Signature · 2 lines
Marek Szyprowski Samsung Poland R&D Center
PATCH 1/1 ARM: fix ioremap to allow mapping some specific RAM areas
Quoted 8 lines · Marek Szyprowski
Quoted 7 lines · Russell King - ARM Linux
NAK.
pfn_validis already defined like this:int
pfn_valid(unsigned long pfn){ return memblock_is_memory(pfn << PAGE_SHIFT); }
Quoted 7 lines
Quoted 2 lines
provided you enable
ARCH_HAS_HOLES_MEMORYMODEL, which you must do if you're punching holes in the memory map.Ok, I see the point in
ARCH_HAS_HOLES_MEMORYMODEL, but it doesn't solve my problem. In case of Samsung Exynos4 and S5PV210 platforms we use SPARSEMEM, but the above definition ofpfn_valid()function is correct only if SPARSEMEM is not enabled.
Sparsemem has been fixed recently (during the merge window) so that this is now correct.
PATCH 1/1 ARM: fix ioremap to allow mapping some specific RAM areas
Hello,
Quoted 14 lines · Russell King - ARM Linux
Quoted 8 lines · Marek Szyprowski
Quoted 7 lines · Russell King - ARM Linux
NAK.
pfn_validis already defined like this:int
pfn_valid(unsigned long pfn){ return memblock_is_memory(pfn << PAGE_SHIFT); }Quoted 4 lines
Quoted 2 lines
provided you enable
ARCH_HAS_HOLES_MEMORYMODEL, which you must do if you're punching holes in the memory map.Ok, I see the point in
ARCH_HAS_HOLES_MEMORYMODEL, but it doesn't solvemy
Quoted 8 lines
Quoted 1 line
problem. In case of Samsung Exynos4 and S5PV210 platforms we use
SPARSEMEM,
Quoted 1 line
but the above definition of
pfn_valid()function is correct only ifSPARSEMEM
Quoted 1 line
is not enabled.
Sparsemem has been fixed recently (during the merge window) so that this is now correct.
OK, thanks for help.
Best regards
Signature · 2 lines
Marek Szyprowski Samsung Poland R&D Center