sh: prefer memblock APIs returning virtual address
authorMike Rapoport <[email protected]>
Fri, 8 Mar 2019 00:30:57 +0000 (16:30 -0800)
committerLinus Torvalds <[email protected]>
Fri, 8 Mar 2019 02:32:03 +0000 (18:32 -0800)
Rather than use the memblock_alloc_base that returns a physical address
and then convert this address to the virtual one, use appropriate
memblock function that returns a virtual address.

There is a small functional change in the allocation of then
NODE_DATA().  Instead of panicing if the local allocation failed, the
non-local allocation attempt will be made.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Mike Rapoport <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Greentime Hu <[email protected]>
Cc: Guan Xuetao <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Jonas Bonn <[email protected]>
Cc: Mark Salter <[email protected]>
Cc: Martin Schwidefsky <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Michal Simek <[email protected]>
Cc: Michal Simek <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Rich Felker <[email protected]>
Cc: Russell King <[email protected]>
Cc: Stafford Horne <[email protected]>
Cc: Stefan Kristiansson <[email protected]>
Cc: Vincent Chen <[email protected]>
Cc: Yoshinori Sato <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
arch/sh/mm/init.c
arch/sh/mm/numa.c

index a8e5c0e00fcaef3d85a0ce595db38fbe36c46532..a0fa4de03dd51d7d8a7ee41678e4099913a7127f 100644 (file)
@@ -192,24 +192,16 @@ void __init page_table_range_init(unsigned long start, unsigned long end,
 void __init allocate_pgdat(unsigned int nid)
 {
        unsigned long start_pfn, end_pfn;
-#ifdef CONFIG_NEED_MULTIPLE_NODES
-       unsigned long phys;
-#endif
 
        get_pfn_range_for_nid(nid, &start_pfn, &end_pfn);
 
 #ifdef CONFIG_NEED_MULTIPLE_NODES
-       phys = __memblock_alloc_base(sizeof(struct pglist_data),
-                               SMP_CACHE_BYTES, end_pfn << PAGE_SHIFT);
-       /* Retry with all of system memory */
-       if (!phys)
-               phys = __memblock_alloc_base(sizeof(struct pglist_data),
-                                       SMP_CACHE_BYTES, memblock_end_of_DRAM());
-       if (!phys)
+       NODE_DATA(nid) = memblock_alloc_try_nid_nopanic(
+                               sizeof(struct pglist_data),
+                               SMP_CACHE_BYTES, MEMBLOCK_LOW_LIMIT,
+                               MEMBLOCK_ALLOC_ACCESSIBLE, nid);
+       if (!NODE_DATA(nid))
                panic("Can't allocate pgdat for node %d\n", nid);
-
-       NODE_DATA(nid) = __va(phys);
-       memset(NODE_DATA(nid), 0, sizeof(struct pglist_data));
 #endif
 
        NODE_DATA(nid)->node_start_pfn = start_pfn;
index 830e8b3684e4248417464934b8634e4d303f4a16..c4bde614881086edf4febcd82e47da5e3918a527 100644 (file)
@@ -41,9 +41,8 @@ void __init setup_bootmem_node(int nid, unsigned long start, unsigned long end)
        __add_active_range(nid, start_pfn, end_pfn);
 
        /* Node-local pgdat */
-       NODE_DATA(nid) = __va(memblock_alloc_base(sizeof(struct pglist_data),
-                                            SMP_CACHE_BYTES, end));
-       memset(NODE_DATA(nid), 0, sizeof(struct pglist_data));
+       NODE_DATA(nid) = memblock_alloc_node(sizeof(struct pglist_data),
+                                            SMP_CACHE_BYTES, nid);
 
        NODE_DATA(nid)->node_start_pfn = start_pfn;
        NODE_DATA(nid)->node_spanned_pages = end_pfn - start_pfn;