ioremap: Delay sanity check until after a successful mapping
[firefly-linux-kernel-4.4.55.git] / arch / x86 / mm / ioremap.c
index 3ba6e0608c55c3b81300db30e465093f58367f0a..be1ef574ce9a7a933c22133be78f6a24bac6a80c 100644 (file)
@@ -90,13 +90,6 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
        if (is_ISA_range(phys_addr, last_addr))
                return (__force void __iomem *)phys_to_virt(phys_addr);
 
-       /*
-        * Check if the request spans more than any BAR in the iomem resource
-        * tree.
-        */
-       WARN_ONCE(iomem_map_sanity_check(phys_addr, size),
-                 KERN_INFO "Info: mapping multiple BARs. Your kernel is fine.");
-
        /*
         * Don't allow anybody to remap normal RAM that we're using..
         */
@@ -170,6 +163,13 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
        ret_addr = (void __iomem *) (vaddr + offset);
        mmiotrace_ioremap(unaligned_phys_addr, unaligned_size, ret_addr);
 
+       /*
+        * Check if the request spans more than any BAR in the iomem resource
+        * tree.
+        */
+       WARN_ONCE(iomem_map_sanity_check(unaligned_phys_addr, unaligned_size),
+                 KERN_INFO "Info: mapping multiple BARs. Your kernel is fine.");
+
        return ret_addr;
 err_free_area:
        free_vm_area(area);
@@ -362,6 +362,11 @@ static inline pte_t * __init early_ioremap_pte(unsigned long addr)
        return &bm_pte[pte_index(addr)];
 }
 
+bool __init is_early_ioremap_ptep(pte_t *ptep)
+{
+       return ptep >= &bm_pte[0] && ptep < &bm_pte[PAGE_SIZE/sizeof(pte_t)];
+}
+
 static unsigned long slot_virt[FIX_BTMAPS_SLOTS] __initdata;
 
 void __init early_ioremap_init(void)