From: Jonathan Neuschäfer <j.neuschaefer@gmx.net> Date: 2018-03-28 00:25:53
v1: https://www.spinics.net/lists/linux-mm/msg145939.html
This patchset makes it possible to allocate MMIO ranges that are between
the two RAM chunks on the Wii, MEM1 and MEM2, not only with ioremap
(which previously worked through a hack) but also with kernel/resource.c.
Changes in v2:
- I added back the p < virt_to_phys(high_memory) check in
__ioremap_caller because high memory should be allocatable through
ioremap
- I expanded the commit messages a bit
Jonathan Neuschäfer (5):
powerpc: mm: Simplify page_is_ram by using memblock_is_memory
powerpc: mm: Use memblock API for PPC32 page_is_ram
powerpc/mm/32: Use page_is_ram to check for RAM
powerpc: wii: Don't rely on the reserved memory hack
powerpc/mm/32: Remove the reserved memory hack
arch/powerpc/mm/init_32.c | 5 -----
arch/powerpc/mm/mem.c | 12 +-----------
arch/powerpc/mm/mmu_decl.h | 1 -
arch/powerpc/mm/pgtable_32.c | 2 +-
arch/powerpc/platforms/embedded6xx/wii.c | 14 +-------------
5 files changed, 3 insertions(+), 31 deletions(-)
--
2.16.2
@@ -85,13 +85,7 @@ int page_is_ram(unsigned long pfn)#ifndef CONFIG_PPC64 /* XXX for now */returnpfn<max_pfn;#else-unsignedlongpaddr=(pfn<<PAGE_SHIFT);-structmemblock_region*reg;--for_each_memblock(memory,reg)-if(paddr>=reg->base&&paddr<(reg->base+reg->size))-return1;-return0;+returnmemblock_is_memory(__pfn_to_phys(pfn));#endif}
From: Jonathan Neuschäfer <j.neuschaefer@gmx.net> Date: 2018-03-28 00:26:21
Because the two memory blocks (usually called MEM1 and MEM2) are not
merged anymore, __request_region in kernel/resource.c will correctly
allow reserving regions in the physical address space between MEM1 and
MEM2, where many important peripherals are (GPIO, MMC, USB, ...).
A previous change to __ioremap_caller in arch/powerpc/mm/pgtable_32.c
ensures that multiple memblocks are properly considered in ioremap; this
makes it unnecessary to set __allow_ioremap_reserved.
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
---
v2:
Add some text to the commit message.
---
arch/powerpc/platforms/embedded6xx/wii.c | 14 +-------------
1 file changed, 1 insertion(+), 13 deletions(-)
@@ -81,21 +81,9 @@ void __init wii_memory_fixups(void)BUG_ON(memblock.memory.cnt!=2);BUG_ON(!page_aligned(p[0].base)||!page_aligned(p[1].base));-/* trim unaligned tail */-memblock_remove(ALIGN(p[1].base+p[1].size,PAGE_SIZE),-(phys_addr_t)ULLONG_MAX);--/* determine hole, add & reserve them */+/* determine hole */wii_hole_start=ALIGN(p[0].base+p[0].size,PAGE_SIZE);wii_hole_size=p[1].base-wii_hole_start;-memblock_add(wii_hole_start,wii_hole_size);-memblock_reserve(wii_hole_start,wii_hole_size);--BUG_ON(memblock.memory.cnt!=1);-__memblock_dump_all();--/* allow ioremapping the address space in the hole */-__allow_ioremap_reserved=1;}unsignedlong__initwii_mmu_mapin_mem2(unsignedlongtop)
From: Jonathan Neuschäfer <j.neuschaefer@gmx.net> Date: 2018-03-28 00:26:34
To support accurate checking for different blocks of memory on PPC32,
use the same memblock-based approach that's already used on PPC64 also
on PPC32.
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
---
v2: no changes
---
arch/powerpc/mm/mem.c | 4 ----
1 file changed, 4 deletions(-)
@@ -88,11 +88,6 @@ void MMU_init(void);int__map_without_bats;int__map_without_ltlbs;-/*-*Thistellsthesystemtoallowioremappingmemorymarkedasreserved.-*/-int__allow_ioremap_reserved;-/* max amount of low RAM to map in */unsignedlong__max_low_memory=MAX_LOW_MEM;
@@ -148,8 +148,7 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, unsigned long flags,*mem_init()setshigh_memorysoonlydothecheckafterthat.*/if(slab_is_available()&&(p<virt_to_phys(high_memory))&&-page_is_ram(__phys_to_pfn(p))&&-!(__allow_ioremap_reserved&&memblock_is_region_reserved(p,size))){+page_is_ram(__phys_to_pfn(p))){printk("__ioremap(): phys addr 0x%llx is RAM lr %ps\n",(unsignedlonglong)p,__builtin_return_address(0));returnNULL;
From: Jonathan Neuschäfer <j.neuschaefer@gmx.net> Date: 2018-03-28 00:32:04
On systems where there is MMIO space between different blocks of RAM in
the physical address space, __ioremap_caller did not allow mapping these
MMIO areas, because they were below the end RAM and thus considered RAM
as well. Use the memblock-based page_is_ram function, which returns
false for such MMIO holes.
v2:
Keep the check for p < virt_to_phys(high_memory). On 32-bit systems
with high memory (memory above physical address 4GiB), the high memory
is expected to be available though ioremap. The high_memory variable
marks the end of low memory; comparing against it means that only
ioremap requests for low RAM will be denied.
Reported by Michael Ellerman.
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
---
arch/powerpc/mm/pgtable_32.c | 1 +
1 file changed, 1 insertion(+)
@@ -148,6 +148,7 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, unsigned long flags,*mem_init()setshigh_memorysoonlydothecheckafterthat.*/if(slab_is_available()&&(p<virt_to_phys(high_memory))&&+page_is_ram(__phys_to_pfn(p))&&!(__allow_ioremap_reserved&&memblock_is_region_reserved(p,size))){printk("__ioremap(): phys addr 0x%llx is RAM lr %ps\n",(unsignedlonglong)p,__builtin_return_address(0));