iwlwifi: mvm: allow transport sleep when FW is operational
[cascardo/linux.git] / mm / memblock.c
index 018e55d..39a31e7 100644 (file)
@@ -266,31 +266,34 @@ static void __init_memblock memblock_remove_region(struct memblock_type *type, u
        }
 }
 
+#ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
+
 phys_addr_t __init_memblock get_allocated_memblock_reserved_regions_info(
                                        phys_addr_t *addr)
 {
        if (memblock.reserved.regions == memblock_reserved_init_regions)
                return 0;
 
-       /*
-        * Don't allow nobootmem allocator to free reserved memory regions
-        * array if
-        *  - CONFIG_DEBUG_FS is enabled;
-        *  - CONFIG_ARCH_DISCARD_MEMBLOCK is not enabled;
-        *  - reserved memory regions array have been resized during boot.
-        * Otherwise debug_fs entry "sys/kernel/debug/memblock/reserved"
-        * will show garbage instead of state of memory reservations.
-        */
-       if (IS_ENABLED(CONFIG_DEBUG_FS) &&
-           !IS_ENABLED(CONFIG_ARCH_DISCARD_MEMBLOCK))
-               return 0;
-
        *addr = __pa(memblock.reserved.regions);
 
        return PAGE_ALIGN(sizeof(struct memblock_region) *
                          memblock.reserved.max);
 }
 
+phys_addr_t __init_memblock get_allocated_memblock_memory_regions_info(
+                                       phys_addr_t *addr)
+{
+       if (memblock.memory.regions == memblock_memory_init_regions)
+               return 0;
+
+       *addr = __pa(memblock.memory.regions);
+
+       return PAGE_ALIGN(sizeof(struct memblock_region) *
+                         memblock.memory.max);
+}
+
+#endif
+
 /**
  * memblock_double_array - double the size of the memblock regions array
  * @type: memblock type of the regions array being doubled
@@ -785,11 +788,9 @@ void __init_memblock __next_free_mem_range(u64 *idx, int nid,
        struct memblock_type *rsv = &memblock.reserved;
        int mi = *idx & 0xffffffff;
        int ri = *idx >> 32;
-       bool check_node = (nid != NUMA_NO_NODE) && (nid != MAX_NUMNODES);
 
-       if (nid == MAX_NUMNODES)
-               pr_warn_once("%s: Usage of MAX_NUMNODES is deprecated. Use NUMA_NO_NODE instead\n",
-                            __func__);
+       if (WARN_ONCE(nid == MAX_NUMNODES, "Usage of MAX_NUMNODES is deprecated. Use NUMA_NO_NODE instead\n"))
+               nid = NUMA_NO_NODE;
 
        for ( ; mi < mem->cnt; mi++) {
                struct memblock_region *m = &mem->regions[mi];
@@ -797,7 +798,7 @@ void __init_memblock __next_free_mem_range(u64 *idx, int nid,
                phys_addr_t m_end = m->base + m->size;
 
                /* only memory regions are associated with nodes, check it */
-               if (check_node && nid != memblock_get_region_node(m))
+               if (nid != NUMA_NO_NODE && nid != memblock_get_region_node(m))
                        continue;
 
                /* scan areas before each reservation for intersection */
@@ -858,11 +859,9 @@ void __init_memblock __next_free_mem_range_rev(u64 *idx, int nid,
        struct memblock_type *rsv = &memblock.reserved;
        int mi = *idx & 0xffffffff;
        int ri = *idx >> 32;
-       bool check_node = (nid != NUMA_NO_NODE) && (nid != MAX_NUMNODES);
 
-       if (nid == MAX_NUMNODES)
-               pr_warn_once("%s: Usage of MAX_NUMNODES is deprecated. Use NUMA_NO_NODE instead\n",
-                            __func__);
+       if (WARN_ONCE(nid == MAX_NUMNODES, "Usage of MAX_NUMNODES is deprecated. Use NUMA_NO_NODE instead\n"))
+               nid = NUMA_NO_NODE;
 
        if (*idx == (u64)ULLONG_MAX) {
                mi = mem->cnt - 1;
@@ -875,7 +874,7 @@ void __init_memblock __next_free_mem_range_rev(u64 *idx, int nid,
                phys_addr_t m_end = m->base + m->size;
 
                /* only memory regions are associated with nodes, check it */
-               if (check_node && nid != memblock_get_region_node(m))
+               if (nid != NUMA_NO_NODE && nid != memblock_get_region_node(m))
                        continue;
 
                /* skip hotpluggable memory regions if needed */
@@ -985,9 +984,6 @@ static phys_addr_t __init memblock_alloc_base_nid(phys_addr_t size,
        if (!align)
                align = SMP_CACHE_BYTES;
 
-       /* align @size to avoid excessive fragmentation on reserved array */
-       size = round_up(size, align);
-
        found = memblock_find_in_range_node(size, align, 0, max_addr, nid);
        if (found && !memblock_reserve(found, size))
                return found;
@@ -1067,9 +1063,8 @@ static void * __init memblock_virt_alloc_internal(
        phys_addr_t alloc;
        void *ptr;
 
-       if (nid == MAX_NUMNODES)
-               pr_warn("%s: usage of MAX_NUMNODES is deprecated. Use NUMA_NO_NODE\n",
-                       __func__);
+       if (WARN_ONCE(nid == MAX_NUMNODES, "Usage of MAX_NUMNODES is deprecated. Use NUMA_NO_NODE instead\n"))
+               nid = NUMA_NO_NODE;
 
        /*
         * Detect any accidental use of these APIs after slab is ready, as at
@@ -1082,8 +1077,8 @@ static void * __init memblock_virt_alloc_internal(
        if (!align)
                align = SMP_CACHE_BYTES;
 
-       /* align @size to avoid excessive fragmentation on reserved array */
-       size = round_up(size, align);
+       if (max_addr > memblock.current_limit)
+               max_addr = memblock.current_limit;
 
 again:
        alloc = memblock_find_in_range_node(size, align, min_addr, max_addr,