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

Commit 716a3dc2 authored by Russell King's avatar Russell King
Browse files

ARM: Add arm_memblock_steal() to allocate memory away from the kernel



Several platforms are now using the memblock_alloc+memblock_free+
memblock_remove trick to obtain memory which won't be mapped in the
kernel's page tables.  Most platforms do this (correctly) in the
->reserve callback.  However, OMAP has started to call these functions
outside of this callback, and this is extremely unsafe - memory will
not be unmapped, and could well be given out after memblock is no
longer responsible for its management.

So, provide arm_memblock_steal() to perform this function, and ensure
that it panic()s if it is used inappropriately.  Convert everyone
over, including OMAP.

As a result, OMAP with OMAP4_ERRATA_I688 enabled will panic on boot
with this change.  Mark this option as BROKEN and make it depend on
BROKEN.  OMAP needs to be fixed, or 137d105d (ARM: OMAP4: Fix
errata i688 with MPU interconnect barriers.) reverted until such
time it can be fixed correctly.

Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent 4de3a8e1
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -6,4 +6,6 @@ struct machine_desc;

extern void arm_memblock_init(struct meminfo *, struct machine_desc *);

phys_addr_t arm_memblock_steal(phys_addr_t size, phys_addr_t align);

#endif
+2 −3
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@
#include <asm/mach/time.h>
#include <asm/memory.h>
#include <asm/mach/map.h>
#include <asm/memblock.h>
#include <mach/common.h>
#include <mach/iomux-mx3.h>
#include <mach/3ds_debugboard.h>
@@ -754,10 +755,8 @@ static struct sys_timer mx31_3ds_timer = {
static void __init mx31_3ds_reserve(void)
{
	/* reserve MX31_3DS_CAMERA_BUF_SIZE bytes for mx3-camera */
	mx3_camera_base = memblock_alloc(MX31_3DS_CAMERA_BUF_SIZE,
	mx3_camera_base = arm_memblock_steal(MX31_3DS_CAMERA_BUF_SIZE,
					 MX31_3DS_CAMERA_BUF_SIZE);
	memblock_free(mx3_camera_base, MX31_3DS_CAMERA_BUF_SIZE);
	memblock_remove(mx3_camera_base, MX31_3DS_CAMERA_BUF_SIZE);
}

MACHINE_START(MX31_3DS, "Freescale MX31PDK (3DS)")
+2 −3
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@
#include <asm/mach/arch.h>
#include <asm/mach/time.h>
#include <asm/mach/map.h>
#include <asm/memblock.h>
#include <mach/board-mx31moboard.h>
#include <mach/common.h>
#include <mach/hardware.h>
@@ -584,10 +585,8 @@ struct sys_timer mx31moboard_timer = {
static void __init mx31moboard_reserve(void)
{
	/* reserve 4 MiB for mx3-camera */
	mx3_camera_base = memblock_alloc(MX3_CAMERA_BUF_SIZE,
	mx3_camera_base = arm_memblock_steal(MX3_CAMERA_BUF_SIZE,
			MX3_CAMERA_BUF_SIZE);
	memblock_free(mx3_camera_base, MX3_CAMERA_BUF_SIZE);
	memblock_remove(mx3_camera_base, MX3_CAMERA_BUF_SIZE);
}

MACHINE_START(MX31MOBOARD, "EPFL Mobots mx31moboard")
+2 −3
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@
#include <asm/mach/arch.h>
#include <asm/mach/time.h>
#include <asm/mach/map.h>
#include <asm/memblock.h>
#include <mach/common.h>
#include <mach/hardware.h>
#include <mach/iomux-mx3.h>
@@ -680,10 +681,8 @@ struct sys_timer pcm037_timer = {
static void __init pcm037_reserve(void)
{
	/* reserve 4 MiB for mx3-camera */
	mx3_camera_base = memblock_alloc(MX3_CAMERA_BUF_SIZE,
	mx3_camera_base = arm_memblock_steal(MX3_CAMERA_BUF_SIZE,
			MX3_CAMERA_BUF_SIZE);
	memblock_free(mx3_camera_base, MX3_CAMERA_BUF_SIZE);
	memblock_remove(mx3_camera_base, MX3_CAMERA_BUF_SIZE);
}

MACHINE_START(PCM037, "Phytec Phycore pcm037")
+2 −2
Original line number Diff line number Diff line
@@ -366,8 +366,8 @@ config OMAP3_SDRC_AC_TIMING
	  going on could result in system crashes;

config OMAP4_ERRATA_I688
	bool "OMAP4 errata: Async Bridge Corruption"
	depends on ARCH_OMAP4
	bool "OMAP4 errata: Async Bridge Corruption (BROKEN)"
	depends on ARCH_OMAP4 && BROKEN
	select ARCH_HAS_BARRIERS
	help
	  If a data is stalled inside asynchronous bridge because of back
Loading