From 4a45b7460cf458012a6930f675e141256b81dcf4 Mon Sep 17 00:00:00 2001 From: Christophe Leroy Date: Tue, 20 Aug 2019 14:07:19 +0000 Subject: powerpc/mm: refactor ioremap vm area setup. PPC32 and PPC64 are doing the same once SLAB is available. Create a do_ioremap() function that calls get_vm_area and do the mapping. For PPC64, we add the 4K PFN hack sanity check to __ioremap_caller() in order to avoid using __ioremap_at(). Other checks in __ioremap_at() are irrelevant for __ioremap_caller(). On PPC64, VM area is allocated in the range [ioremap_bot ; IOREMAP_END] On PPC32, VM area is allocated in the range [VMALLOC_START ; VMALLOC_END] Lets define IOREMAP_START is ioremap_bot for PPC64, and alias IOREMAP_START/END to VMALLOC_START/END on PPC32 Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/42e7e36ad32e0fdf76692426cc642799c9f689b8.1566309263.git.christophe.leroy@c-s.fr --- arch/powerpc/mm/ioremap_32.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'arch/powerpc/mm/ioremap_32.c') diff --git a/arch/powerpc/mm/ioremap_32.c b/arch/powerpc/mm/ioremap_32.c index 85b90a62e084..fcf343dbf2bf 100644 --- a/arch/powerpc/mm/ioremap_32.c +++ b/arch/powerpc/mm/ioremap_32.c @@ -18,7 +18,7 @@ void __iomem * __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *caller) { unsigned long v; - phys_addr_t p; + phys_addr_t p, offset; int err; /* @@ -28,6 +28,7 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *call * (ioremap_bot records where we're up to). */ p = addr & PAGE_MASK; + offset = addr & ~PAGE_MASK; size = PAGE_ALIGN(addr + size) - p; /* @@ -62,12 +63,7 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *call goto out; if (slab_is_available()) { - struct vm_struct *area; - area = get_vm_area_caller(size, VM_IOREMAP, caller); - if (area == 0) - return NULL; - area->phys_addr = p; - v = (unsigned long)area->addr; + return do_ioremap(p, offset, size, prot, caller); } else { v = (ioremap_bot -= size); } @@ -77,11 +73,8 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *call */ err = ioremap_range((unsigned long)v, p, size, prot); - if (err) { - if (slab_is_available()) - vunmap((void *)v); + if (err) return NULL; - } out: return (void __iomem *)(v + ((unsigned long)addr & ~PAGE_MASK)); -- cgit v1.2.3