Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: Malta: Remove fw_memblock_t abstraction

The fw_getmdesc function & fw_memblock_t abstraction is only used by
Malta, and so far as I can tell serves no purpose beyond making the code
less clear than it could be. Remove the useless level of abstraction.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Markos Chandras <markos.chandras@imgtec.com>
Patchwork: https://patchwork.linux-mips.org/patch/11221/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Paul Burton and committed by
Ralf Baechle
ea050714 e1137e1d

+29 -80
-16
arch/mips/include/asm/fw/fw.h
··· 10 10 11 11 #include <asm/bootinfo.h> /* For cleaner code... */ 12 12 13 - enum fw_memtypes { 14 - fw_dontuse, 15 - fw_code, 16 - fw_free, 17 - }; 18 - 19 - typedef struct { 20 - unsigned long base; /* Within KSEG0 */ 21 - unsigned int size; /* bytes */ 22 - enum fw_memtypes type; /* fw_memtypes */ 23 - } fw_memblock_t; 24 - 25 - /* Maximum number of memory block descriptors. */ 26 - #define FW_MAX_MEMBLOCKS 32 27 - 28 13 extern int fw_argc; 29 14 extern int *_fw_argv; 30 15 extern int *_fw_envp; ··· 23 38 24 39 extern void fw_init_cmdline(void); 25 40 extern char *fw_getcmdline(void); 26 - extern fw_memblock_t *fw_getmdesc(int); 27 41 extern void fw_meminit(void); 28 42 extern char *fw_getenv(char *name); 29 43 extern unsigned long fw_getenvl(char *name);
+29 -64
arch/mips/mti-malta/malta-memory.c
··· 21 21 #include <asm/sections.h> 22 22 #include <asm/fw/fw.h> 23 23 24 - static fw_memblock_t mdesc[FW_MAX_MEMBLOCKS]; 25 - 26 24 /* determined physical memory size, not overridden by command line args */ 27 25 unsigned long physical_memsize = 0L; 28 26 29 - fw_memblock_t * __init fw_getmdesc(int eva) 27 + static void free_init_pages_eva_malta(void *begin, void *end) 28 + { 29 + free_init_pages("unused kernel", __pa_symbol((unsigned long *)begin), 30 + __pa_symbol((unsigned long *)end)); 31 + } 32 + 33 + void __init fw_meminit(void) 30 34 { 31 35 char *memsize_str, *ememsize_str = NULL, *ptr; 32 36 unsigned long memsize = 0, ememsize = 0; 37 + unsigned long kernel_start_phys, kernel_end_phys; 33 38 static char cmdline[COMMAND_LINE_SIZE] __initdata; 39 + bool eva = config_enabled(CONFIG_EVA); 34 40 int tmp; 35 41 36 - /* otherwise look in the environment */ 42 + free_init_pages_eva = eva ? free_init_pages_eva_malta : NULL; 37 43 38 44 memsize_str = fw_getenv("memsize"); 39 45 if (memsize_str) { ··· 98 92 if (memsize > 0x7fff0000) 99 93 memsize = 0x7fff0000; 100 94 101 - memset(mdesc, 0, sizeof(mdesc)); 95 + add_memory_region(PHYS_OFFSET, 0x00001000, BOOT_MEM_RESERVED); 102 96 103 - mdesc[0].type = fw_dontuse; 104 - mdesc[0].base = PHYS_OFFSET; 105 - mdesc[0].size = 0x00001000; 106 - 107 - mdesc[1].type = fw_code; 108 - mdesc[1].base = mdesc[0].base + 0x00001000UL; 109 - mdesc[1].size = 0x000ef000; 97 + /* 98 + * YAMON may still be using the region of memory from 0x1000 to 0xfffff 99 + * if it has started secondary CPUs. 100 + */ 101 + add_memory_region(PHYS_OFFSET + 0x00001000, 0x000ef000, 102 + BOOT_MEM_ROM_DATA); 110 103 111 104 /* 112 105 * The area 0x000f0000-0x000fffff is allocated for BIOS memory by the ··· 114 109 * This mean that this area can't be used as DMA memory for PCI 115 110 * devices. 116 111 */ 117 - mdesc[2].type = fw_dontuse; 118 - mdesc[2].base = mdesc[0].base + 0x000f0000UL; 119 - mdesc[2].size = 0x00010000; 112 + add_memory_region(PHYS_OFFSET + 0x000f0000, 0x00010000, 113 + BOOT_MEM_RESERVED); 120 114 121 - mdesc[3].type = fw_dontuse; 122 - mdesc[3].base = mdesc[0].base + 0x00100000UL; 123 - mdesc[3].size = CPHYSADDR(PFN_ALIGN((unsigned long)&_end)) - 124 - 0x00100000UL; 125 - 126 - mdesc[4].type = fw_free; 127 - mdesc[4].base = mdesc[0].base + CPHYSADDR(PFN_ALIGN(&_end)); 128 - mdesc[4].size = memsize - CPHYSADDR(mdesc[4].base); 129 - 130 - return &mdesc[0]; 131 - } 132 - 133 - static void free_init_pages_eva_malta(void *begin, void *end) 134 - { 135 - free_init_pages("unused kernel", __pa_symbol((unsigned long *)begin), 136 - __pa_symbol((unsigned long *)end)); 137 - } 138 - 139 - static int __init fw_memtype_classify(unsigned int type) 140 - { 141 - switch (type) { 142 - case fw_free: 143 - return BOOT_MEM_RAM; 144 - case fw_code: 145 - return BOOT_MEM_ROM_DATA; 146 - default: 147 - return BOOT_MEM_RESERVED; 148 - } 149 - } 150 - 151 - void __init fw_meminit(void) 152 - { 153 - fw_memblock_t *p; 154 - 155 - p = fw_getmdesc(config_enabled(CONFIG_EVA)); 156 - free_init_pages_eva = (config_enabled(CONFIG_EVA) ? 157 - free_init_pages_eva_malta : NULL); 158 - 159 - while (p->size) { 160 - long type; 161 - unsigned long base, size; 162 - 163 - type = fw_memtype_classify(p->type); 164 - base = p->base; 165 - size = p->size; 166 - 167 - add_memory_region(base, size, type); 168 - p++; 169 - } 115 + /* 116 + * Reserve the memory used by kernel code, and allow the rest of RAM to 117 + * be used. 118 + */ 119 + kernel_start_phys = PHYS_OFFSET + 0x00100000; 120 + kernel_end_phys = PHYS_OFFSET + CPHYSADDR(PFN_ALIGN(&_end)); 121 + add_memory_region(kernel_start_phys, kernel_end_phys, 122 + BOOT_MEM_RESERVED); 123 + add_memory_region(kernel_end_phys, memsize - kernel_end_phys, 124 + BOOT_MEM_RAM); 170 125 } 171 126 172 127 void __init prom_free_prom_memory(void)