Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ad4001c5 authored by Scott Branden's avatar Scott Branden Committed by Sudarshan Rajagopalan
Browse files

arm64: memory-hotplug: Add MEMORY_HOTPLUG, MEMORY_HOTREMOVE, MEMORY_PROBE



Add memory-hotplug support for ARM64 platform.

This requires addition of
ARCH_ENABLE_MEMORY_HOTPLUG and ARCH_ENABLE_MEMORY_HOTREMOVE config options.

MEMORY_PROBE config option is added to support
/sys/devices/system/memory/probe functionality.

In addition architecture specific arch_add_memory and
arch_remove memory management functions are added.

Change-Id: I1fc4e8c93cfe1b9722b2fc8d811390e6cdfa7995
Signed-off-by: default avatarScott Branden <scott.branden@broadcom.com>
Patch-mainline: linux-kernel @ 11 Apr 2017, 18:24
Signed-off-by: default avatarSrivatsa Vaddagiri <vatsa@codeaurora.org>
[sudaraja@codeaurora.org: remove explicit zone calculation]
Signed-off-by: default avatarSudarshan Rajagopalan <sudaraja@codeaurora.org>
parent 86f750c3
Loading
Loading
Loading
Loading
+10 −0
Original line number Original line Diff line number Diff line
@@ -645,6 +645,12 @@ config HOTPLUG_CPU
	  Say Y here to experiment with turning CPUs off and on.  CPUs
	  Say Y here to experiment with turning CPUs off and on.  CPUs
	  can be controlled through /sys/devices/system/cpu.
	  can be controlled through /sys/devices/system/cpu.


config ARCH_ENABLE_MEMORY_HOTPLUG
	def_bool y

config ARCH_ENABLE_MEMORY_HOTREMOVE
	def_bool y

# The GPIO number here must be sorted by descending number. In case of
# The GPIO number here must be sorted by descending number. In case of
# a multiplatform kernel, we just want the highest value required by the
# a multiplatform kernel, we just want the highest value required by the
# selected platforms.
# selected platforms.
@@ -762,6 +768,10 @@ config ARM64_DMA_IOMMU_ALIGNMENT


endif
endif


config ARCH_MEMORY_PROBE
	def_bool y
	depends on MEMORY_HOTPLUG

config SECCOMP
config SECCOMP
	bool "Enable seccomp to safely compute untrusted bytecode"
	bool "Enable seccomp to safely compute untrusted bytecode"
	---help---
	---help---
+39 −0
Original line number Original line Diff line number Diff line
@@ -726,3 +726,42 @@ static int __init register_mem_limit_dumper(void)
	return 0;
	return 0;
}
}
__initcall(register_mem_limit_dumper);
__initcall(register_mem_limit_dumper);

#ifdef CONFIG_MEMORY_HOTPLUG
int arch_add_memory(int nid, u64 start, u64 size, bool want_memblock)
{
	pg_data_t *pgdat;
	unsigned long start_pfn = start >> PAGE_SHIFT;
	unsigned long nr_pages = size >> PAGE_SHIFT;
	int ret;

	pgdat = NODE_DATA(nid);

	ret = __add_pages(nid, start_pfn, nr_pages, want_memblock);

	if (ret)
		pr_warn("%s: Problem encountered in __add_pages() ret=%d\n",
			__func__, ret);

	return ret;
}

#ifdef CONFIG_MEMORY_HOTREMOVE
int arch_remove_memory(u64 start, u64 size)
{
	unsigned long start_pfn = start >> PAGE_SHIFT;
	unsigned long nr_pages = size >> PAGE_SHIFT;
	struct zone *zone;
	int ret;

	zone = page_zone(pfn_to_page(start_pfn));
	ret = __remove_pages(zone, start_pfn, nr_pages);
	if (ret)
		pr_warn("%s: Problem encountered in __remove_pages() ret=%d\n",
			__func__, ret);

	return ret;
}
#endif
#endif