memblock: drop memblock_alloc_base()
authorMike Rapoport <[email protected]>
Tue, 12 Mar 2019 06:29:35 +0000 (23:29 -0700)
committerLinus Torvalds <[email protected]>
Tue, 12 Mar 2019 17:04:01 +0000 (10:04 -0700)
The memblock_alloc_base() function tries to allocate a memory up to the
limit specified by its max_addr parameter and panics if the allocation
fails.  Replace its usage with memblock_phys_alloc_range() and make the
callers check the return value and panic in case of error.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Mike Rapoport <[email protected]>
Acked-by: Michael Ellerman <[email protected]> [powerpc]
Cc: Catalin Marinas <[email protected]>
Cc: Christophe Leroy <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Dennis Zhou <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: Greentime Hu <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Guan Xuetao <[email protected]>
Cc: Guo Ren <[email protected]>
Cc: Guo Ren <[email protected]> [c-sky]
Cc: Heiko Carstens <[email protected]>
Cc: Juergen Gross <[email protected]> [Xen]
Cc: Mark Salter <[email protected]>
Cc: Matt Turner <[email protected]>
Cc: Max Filippov <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Michal Simek <[email protected]>
Cc: Paul Burton <[email protected]>
Cc: Petr Mladek <[email protected]>
Cc: Richard Weinberger <[email protected]>
Cc: Rich Felker <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Russell King <[email protected]>
Cc: Stafford Horne <[email protected]>
Cc: Tony Luck <[email protected]>
Cc: Vineet Gupta <[email protected]>
Cc: Yoshinori Sato <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
arch/powerpc/kernel/rtas.c
arch/powerpc/mm/hash_utils_64.c
arch/s390/kernel/smp.c
drivers/macintosh/smu.c
include/linux/memblock.h
mm/memblock.c

index de35bd8f047fc315e29058223e71bc731bafc6e7..fbc676160adf76f2f007a91685678faf9cad8a54 100644 (file)
@@ -1187,7 +1187,11 @@ void __init rtas_initialize(void)
                ibm_suspend_me_token = rtas_token("ibm,suspend-me");
        }
 #endif
-       rtas_rmo_buf = memblock_alloc_base(RTAS_RMOBUF_MAX, PAGE_SIZE, rtas_region);
+       rtas_rmo_buf = memblock_phys_alloc_range(RTAS_RMOBUF_MAX, PAGE_SIZE,
+                                                0, rtas_region);
+       if (!rtas_rmo_buf)
+               panic("ERROR: RTAS: Failed to allocate %lx bytes below %pa\n",
+                     PAGE_SIZE, &rtas_region);
 
 #ifdef CONFIG_RTAS_ERROR_LOGGING
        rtas_last_error_token = rtas_token("rtas-last-error");
index 3d4b2399192f89359c2ca343d97b3e07a11e7eca..880a366c229c507e4fa690687b710e23306826dd 100644 (file)
@@ -882,8 +882,12 @@ static void __init htab_initialize(void)
                }
 #endif /* CONFIG_PPC_CELL */
 
-               table = memblock_alloc_base(htab_size_bytes, htab_size_bytes,
-                                           limit);
+               table = memblock_phys_alloc_range(htab_size_bytes,
+                                                 htab_size_bytes,
+                                                 0, limit);
+               if (!table)
+                       panic("ERROR: Failed to allocate %pa bytes below %pa\n",
+                             &htab_size_bytes, &limit);
 
                DBG("Hash table allocated at %lx, size: %lx\n", table,
                    htab_size_bytes);
index b198ece2aad63d70f58b2acde1c280ce5534cf7a..5e3cccc408b874081126b97738ec8e5cfe540bce 100644 (file)
@@ -656,7 +656,11 @@ void __init smp_save_dump_cpus(void)
                /* No previous system present, normal boot. */
                return;
        /* Allocate a page as dumping area for the store status sigps */
-       page = memblock_alloc_base(PAGE_SIZE, PAGE_SIZE, 1UL << 31);
+       page = memblock_phys_alloc_range(PAGE_SIZE, PAGE_SIZE, 0, 1UL << 31);
+       if (!page)
+               panic("ERROR: Failed to allocate %x bytes below %lx\n",
+                     PAGE_SIZE, 1UL << 31);
+
        /* Set multi-threading state to the previous system. */
        pcpu_set_smt(sclp.mtid_prev);
        boot_cpu_addr = stap();
index 0a0b8e1f4236f701640a5c0e7c9056c0c3c88d01..42cf68d15da309e4ac32fd7e6c2003736d302201 100644 (file)
@@ -485,7 +485,7 @@ int __init smu_init (void)
         * SMU based G5s need some memory below 2Gb. Thankfully this is
         * called at a time where memblock is still available.
         */
-       smu_cmdbuf_abs = memblock_alloc_base(4096, 4096, 0x80000000UL);
+       smu_cmdbuf_abs = memblock_phys_alloc_range(4096, 4096, 0, 0x80000000UL);
        if (smu_cmdbuf_abs == 0) {
                printk(KERN_ERR "SMU: Command buffer allocation failed !\n");
                ret = -EINVAL;
index 017aeb223b24bb595aa0101de42dfc2eb689ebd3..0c83751203221b16680c23c65fc53cd39b77a935 100644 (file)
@@ -450,8 +450,6 @@ static inline bool memblock_bottom_up(void)
        return memblock.bottom_up;
 }
 
-phys_addr_t memblock_alloc_base(phys_addr_t size, phys_addr_t align,
-                               phys_addr_t max_addr);
 phys_addr_t memblock_phys_mem_size(void);
 phys_addr_t memblock_reserved_size(void);
 phys_addr_t memblock_mem_size(unsigned long limit_pfn);
index 5b6aeb8108d9bbb7e3ed832afae37c7e8b517612..42fe65447d8bf0463f544cc72aa0366106e266a8 100644 (file)
@@ -1306,20 +1306,6 @@ again:
        return ret;
 }
 
-phys_addr_t __init memblock_alloc_base(phys_addr_t size, phys_addr_t align, phys_addr_t max_addr)
-{
-       phys_addr_t alloc;
-
-       alloc = memblock_alloc_range_nid(size, align, 0, max_addr, NUMA_NO_NODE,
-                                       MEMBLOCK_NONE);
-
-       if (alloc == 0)
-               panic("ERROR: Failed to allocate %pa bytes below %pa.\n",
-                     &size, &max_addr);
-
-       return alloc;
-}
-
 phys_addr_t __init memblock_phys_alloc_try_nid(phys_addr_t size, phys_addr_t align, int nid)
 {
        phys_addr_t res = memblock_phys_alloc_nid(size, align, nid);