@@ -1132,13 +1132,6 @@ void __init setup_arch(char **cmdline_p)
early_acpi_boot_init();
initmem_init();
-
- /*
- * When ACPI SRAT is parsed, which is done in initmem_init(),
- * set memblock back to the top-down direction.
- */
- memblock_set_bottom_up(false);
-
memblock_find_dma_reserve();
/*
@@ -569,6 +569,8 @@ static int __init numa_init(int (*init_func)(void))
memset(&numa_meminfo, 0, sizeof(numa_meminfo));
WARN_ON(memblock_set_node(0, ULLONG_MAX, &memblock.memory,
MAX_NUMNODES));
+ /* In case that parsing SRAT failed. */
+ WARN_ON(memblock_clear_hotplug(0, ULLONG_MAX));
numa_reset_distance();
ret = init_func();
@@ -181,6 +181,11 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
(unsigned long long) start, (unsigned long long) end - 1,
hotpluggable ? " hotplug" : "");
+ /* Mark hotplug range in memblock. */
+ if (hotpluggable && memblock_mark_hotplug(start, ma->length))
+ pr_warn("SRAT: Failed to mark hotplug range [mem %#010Lx-%#010Lx] in memblock\n",
+ (unsigned long long) start, (unsigned long long) end - 1);
+
return 0;
out_err_bad_srat:
bad_srat();
@@ -197,5 +202,13 @@ int __init x86_acpi_numa_init(void)
ret = acpi_numa_init();
if (ret < 0)
return ret;
+
+ /*
+ * When ACPI SRAT is parsed, and hotpluggable range in
+ * memblock is marked, set memblock back to the top-down
+ * direction.
+ */
+ memblock_set_bottom_up(false);
+
return srat_disabled() ? -EINVAL : 0;
}