ARM: 8571/1: nommu: fix PMSAv7 setup

Commit 1c2f87c (ARM: 8025/1: Get rid of meminfo) broke the support for
MPU on ARMv7-R. This patch adapts the code inside CONFIG_ARM_MPU to use
memblocks appropriately.

MPU initialisation only uses the first memory region, and removes all
subsequent ones. Because looping over all regions that need removal is
inefficient, and memblock_remove already handles memory ranges, we can
flatten the 'for_each_memblock' part.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
This commit is contained in:
Jean-Philippe Brucker 2016-05-04 10:37:22 +01:00 committed by Russell King
parent ac36a881b7
commit 695665b0c5

View File

@ -87,7 +87,6 @@ static unsigned long irbar_read(void)
/* MPU initialisation functions */ /* MPU initialisation functions */
void __init sanity_check_meminfo_mpu(void) void __init sanity_check_meminfo_mpu(void)
{ {
int i;
phys_addr_t phys_offset = PHYS_OFFSET; phys_addr_t phys_offset = PHYS_OFFSET;
phys_addr_t aligned_region_size, specified_mem_size, rounded_mem_size; phys_addr_t aligned_region_size, specified_mem_size, rounded_mem_size;
struct memblock_region *reg; struct memblock_region *reg;
@ -110,11 +109,13 @@ void __init sanity_check_meminfo_mpu(void)
} else { } else {
/* /*
* memblock auto merges contiguous blocks, remove * memblock auto merges contiguous blocks, remove
* all blocks afterwards * all blocks afterwards in one go (we can't remove
* blocks separately while iterating)
*/ */
pr_notice("Ignoring RAM after %pa, memory at %pa ignored\n", pr_notice("Ignoring RAM after %pa, memory at %pa ignored\n",
&mem_start, &reg->base); &mem_end, &reg->base);
memblock_remove(reg->base, reg->size); memblock_remove(reg->base, 0 - reg->base);
break;
} }
} }
@ -144,7 +145,7 @@ void __init sanity_check_meminfo_mpu(void)
pr_warn("Truncating memory from %pa to %pa (MPU region constraints)", pr_warn("Truncating memory from %pa to %pa (MPU region constraints)",
&specified_mem_size, &aligned_region_size); &specified_mem_size, &aligned_region_size);
memblock_remove(mem_start + aligned_region_size, memblock_remove(mem_start + aligned_region_size,
specified_mem_size - aligned_round_size); specified_mem_size - aligned_region_size);
mem_end = mem_start + aligned_region_size; mem_end = mem_start + aligned_region_size;
} }
@ -261,7 +262,7 @@ void __init mpu_setup(void)
return; return;
region_err = mpu_setup_region(MPU_RAM_REGION, PHYS_OFFSET, region_err = mpu_setup_region(MPU_RAM_REGION, PHYS_OFFSET,
ilog2(meminfo.bank[0].size), ilog2(memblock.memory.regions[0].size),
MPU_AP_PL1RW_PL0RW | MPU_RGN_NORMAL); MPU_AP_PL1RW_PL0RW | MPU_RGN_NORMAL);
if (region_err) { if (region_err) {
panic("MPU region initialization failure! %d", region_err); panic("MPU region initialization failure! %d", region_err);