aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaura Abbott <labbott@redhat.com>2017-01-13 16:51:08 -0500
committerRussell King <rmk+kernel@armlinux.org.uk>2017-02-28 06:04:57 -0500
commit374d446d25d6271ee615952a3b7f123ba4983c35 (patch)
treebc6066880b496a81edfaec3979f2f22831c9df2d
parent8a792e9afbce84a0fdaf213fe42bb97382487094 (diff)
ARM: 8636/1: Cleanup sanity_check_meminfo
The logic for sanity_check_meminfo has become difficult to follow. Clean up the code so it's more obvious what the code is actually trying to do. Additionally, meminfo is now removed so rename the function to better describe its purpose. Tested-by: Magnus Lilja <lilja.magnus@gmail.com> Reviewed-by: Nicolas Pitre <nico@linaro.org> Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Laura Abbott <labbott@redhat.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/kernel/setup.c4
-rw-r--r--arch/arm/mm/mmu.c66
-rw-r--r--arch/arm/mm/nommu.c8
3 files changed, 30 insertions, 48 deletions
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 34e3f3c45634..8a8051cf57d1 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -81,7 +81,7 @@ __setup("fpe=", fpe_setup);
81extern void init_default_cache_policy(unsigned long); 81extern void init_default_cache_policy(unsigned long);
82extern void paging_init(const struct machine_desc *desc); 82extern void paging_init(const struct machine_desc *desc);
83extern void early_paging_init(const struct machine_desc *); 83extern void early_paging_init(const struct machine_desc *);
84extern void sanity_check_meminfo(void); 84extern void adjust_lowmem_bounds(void);
85extern enum reboot_mode reboot_mode; 85extern enum reboot_mode reboot_mode;
86extern void setup_dma_zone(const struct machine_desc *desc); 86extern void setup_dma_zone(const struct machine_desc *desc);
87 87
@@ -1093,7 +1093,7 @@ void __init setup_arch(char **cmdline_p)
1093 setup_dma_zone(mdesc); 1093 setup_dma_zone(mdesc);
1094 xen_early_init(); 1094 xen_early_init();
1095 efi_init(); 1095 efi_init();
1096 sanity_check_meminfo(); 1096 adjust_lowmem_bounds();
1097 arm_memblock_init(mdesc); 1097 arm_memblock_init(mdesc);
1098 1098
1099 early_ioremap_reset(); 1099 early_ioremap_reset();
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index 4001dd15818d..b8f70a3bb7f8 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -1152,13 +1152,11 @@ early_param("vmalloc", early_vmalloc);
1152 1152
1153phys_addr_t arm_lowmem_limit __initdata = 0; 1153phys_addr_t arm_lowmem_limit __initdata = 0;
1154 1154
1155void __init sanity_check_meminfo(void) 1155void __init adjust_lowmem_bounds(void)
1156{ 1156{
1157 phys_addr_t memblock_limit = 0; 1157 phys_addr_t memblock_limit = 0;
1158 int highmem = 0;
1159 u64 vmalloc_limit; 1158 u64 vmalloc_limit;
1160 struct memblock_region *reg; 1159 struct memblock_region *reg;
1161 bool should_use_highmem = false;
1162 1160
1163 /* 1161 /*
1164 * Let's use our own (unoptimized) equivalent of __pa() that is 1162 * Let's use our own (unoptimized) equivalent of __pa() that is
@@ -1172,43 +1170,18 @@ void __init sanity_check_meminfo(void)
1172 for_each_memblock(memory, reg) { 1170 for_each_memblock(memory, reg) {
1173 phys_addr_t block_start = reg->base; 1171 phys_addr_t block_start = reg->base;
1174 phys_addr_t block_end = reg->base + reg->size; 1172 phys_addr_t block_end = reg->base + reg->size;
1175 phys_addr_t size_limit = reg->size;
1176 1173
1177 if (reg->base >= vmalloc_limit) 1174 if (reg->base < vmalloc_limit) {
1178 highmem = 1; 1175 if (block_end > arm_lowmem_limit)
1179 else 1176 /*
1180 size_limit = vmalloc_limit - reg->base; 1177 * Compare as u64 to ensure vmalloc_limit does
1181 1178 * not get truncated. block_end should always
1182 1179 * fit in phys_addr_t so there should be no
1183 if (!IS_ENABLED(CONFIG_HIGHMEM) || cache_is_vipt_aliasing()) { 1180 * issue with assignment.
1184 1181 */
1185 if (highmem) { 1182 arm_lowmem_limit = min_t(u64,
1186 pr_notice("Ignoring RAM at %pa-%pa (!CONFIG_HIGHMEM)\n", 1183 vmalloc_limit,
1187 &block_start, &block_end); 1184 block_end);
1188 memblock_remove(reg->base, reg->size);
1189 should_use_highmem = true;
1190 continue;
1191 }
1192
1193 if (reg->size > size_limit) {
1194 phys_addr_t overlap_size = reg->size - size_limit;
1195
1196 pr_notice("Truncating RAM at %pa-%pa",
1197 &block_start, &block_end);
1198 block_end = vmalloc_limit;
1199 pr_cont(" to -%pa", &block_end);
1200 memblock_remove(vmalloc_limit, overlap_size);
1201 should_use_highmem = true;
1202 }
1203 }
1204
1205 if (!highmem) {
1206 if (block_end > arm_lowmem_limit) {
1207 if (reg->size > size_limit)
1208 arm_lowmem_limit = vmalloc_limit;
1209 else
1210 arm_lowmem_limit = block_end;
1211 }
1212 1185
1213 /* 1186 /*
1214 * Find the first non-pmd-aligned page, and point 1187 * Find the first non-pmd-aligned page, and point
@@ -1233,9 +1206,6 @@ void __init sanity_check_meminfo(void)
1233 } 1206 }
1234 } 1207 }
1235 1208
1236 if (should_use_highmem)
1237 pr_notice("Consider using a HIGHMEM enabled kernel.\n");
1238
1239 high_memory = __va(arm_lowmem_limit - 1) + 1; 1209 high_memory = __va(arm_lowmem_limit - 1) + 1;
1240 1210
1241 /* 1211 /*
@@ -1248,6 +1218,18 @@ void __init sanity_check_meminfo(void)
1248 if (!memblock_limit) 1218 if (!memblock_limit)
1249 memblock_limit = arm_lowmem_limit; 1219 memblock_limit = arm_lowmem_limit;
1250 1220
1221 if (!IS_ENABLED(CONFIG_HIGHMEM) || cache_is_vipt_aliasing()) {
1222 if (memblock_end_of_DRAM() > arm_lowmem_limit) {
1223 phys_addr_t end = memblock_end_of_DRAM();
1224
1225 pr_notice("Ignoring RAM at %pa-%pa\n",
1226 &memblock_limit, &end);
1227 pr_notice("Consider using a HIGHMEM enabled kernel.\n");
1228
1229 memblock_remove(memblock_limit, end - memblock_limit);
1230 }
1231 }
1232
1251 memblock_set_current_limit(memblock_limit); 1233 memblock_set_current_limit(memblock_limit);
1252} 1234}
1253 1235
diff --git a/arch/arm/mm/nommu.c b/arch/arm/mm/nommu.c
index 2740967727e2..13a25d6282f8 100644
--- a/arch/arm/mm/nommu.c
+++ b/arch/arm/mm/nommu.c
@@ -85,7 +85,7 @@ static unsigned long irbar_read(void)
85} 85}
86 86
87/* MPU initialisation functions */ 87/* MPU initialisation functions */
88void __init sanity_check_meminfo_mpu(void) 88void __init adjust_lowmem_bounds_mpu(void)
89{ 89{
90 phys_addr_t phys_offset = PHYS_OFFSET; 90 phys_addr_t phys_offset = PHYS_OFFSET;
91 phys_addr_t aligned_region_size, specified_mem_size, rounded_mem_size; 91 phys_addr_t aligned_region_size, specified_mem_size, rounded_mem_size;
@@ -274,7 +274,7 @@ void __init mpu_setup(void)
274 } 274 }
275} 275}
276#else 276#else
277static void sanity_check_meminfo_mpu(void) {} 277static void adjust_lowmem_bounds_mpu(void) {}
278static void __init mpu_setup(void) {} 278static void __init mpu_setup(void) {}
279#endif /* CONFIG_ARM_MPU */ 279#endif /* CONFIG_ARM_MPU */
280 280
@@ -295,10 +295,10 @@ void __init arm_mm_memblock_reserve(void)
295#endif 295#endif
296} 296}
297 297
298void __init sanity_check_meminfo(void) 298void __init adjust_lowmem_bounds(void)
299{ 299{
300 phys_addr_t end; 300 phys_addr_t end;
301 sanity_check_meminfo_mpu(); 301 adjust_lowmem_bounds_mpu();
302 end = memblock_end_of_DRAM(); 302 end = memblock_end_of_DRAM();
303 high_memory = __va(end - 1) + 1; 303 high_memory = __va(end - 1) + 1;
304 memblock_set_current_limit(end); 304 memblock_set_current_limit(end);