x86/boot/e820: Create coherent API function names for E820 range operations
We have these three related functions: extern void e820_add_region(u64 start, u64 size, int type); extern u64 e820_update_range(u64 start, u64 size, unsigned old_type, unsigned new_type); extern u64 e820_remove_range(u64 start, u64 size, unsigned old_type, int checktype); But it's not clear from the naming that they are 3 operations based around the same 'memory range' concept. Rename them to better signal this, and move the prototypes next to each other: extern void e820__range_add (u64 start, u64 size, int type); extern u64 e820__range_update(u64 start, u64 size, unsigned old_type, unsigned new_type); extern u64 e820__range_remove(u64 start, u64 size, unsigned old_type, int checktype); Note that this improved organization of the functions shows another problem that was easy to miss before: sometimes the E820 entry type is 'int', sometimes 'unsigned int' - but this will be fixed in a separate patch. No change in functionality. Cc: Alex Thorlton <athorlton@sgi.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Huang, Ying <ying.huang@intel.com> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Juergen Gross <jgross@suse.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Paul Jackson <pj@sgi.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Rafael J. Wysocki <rjw@sisk.pl> Cc: Tejun Heo <tj@kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Wei Yang <richard.weiyang@gmail.com> Cc: Yinghai Lu <yinghai@kernel.org> Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
parent
2df908baf5
commit
ab6bc04cfd
|
@ -10,11 +10,13 @@ extern unsigned long pci_mem_start;
|
|||
|
||||
extern int e820__mapped_any(u64 start, u64 end, unsigned type);
|
||||
extern int e820__mapped_all(u64 start, u64 end, unsigned type);
|
||||
extern void e820_add_region(u64 start, u64 size, int type);
|
||||
|
||||
extern void e820__range_add (u64 start, u64 size, int type);
|
||||
extern u64 e820__range_update(u64 start, u64 size, unsigned old_type, unsigned new_type);
|
||||
extern u64 e820__range_remove(u64 start, u64 size, unsigned old_type, int checktype);
|
||||
|
||||
extern void e820_print_map(char *who);
|
||||
extern int e820__update_table(struct e820_entry *biosmap, int max_nr_map, u32 *pnr_map);
|
||||
extern u64 e820_update_range(u64 start, u64 size, unsigned old_type, unsigned new_type);
|
||||
extern u64 e820_remove_range(u64 start, u64 size, unsigned old_type, int checktype);
|
||||
extern void e820__update_table_print(void);
|
||||
extern void e820__setup_pci_gap(void);
|
||||
extern void e820__memory_setup_extended(u64 phys_addr, u32 data_len);
|
||||
|
|
|
@ -1715,6 +1715,6 @@ int __acpi_release_global_lock(unsigned int *lock)
|
|||
|
||||
void __init arch_reserve_mem_area(acpi_physical_address addr, size_t size)
|
||||
{
|
||||
e820_add_region(addr, size, E820_ACPI);
|
||||
e820__range_add(addr, size, E820_ACPI);
|
||||
e820__update_table_print();
|
||||
}
|
||||
|
|
|
@ -311,7 +311,7 @@ void __init early_gart_iommu_check(void)
|
|||
/* reserve it, so we can reuse it in second kernel */
|
||||
pr_info("e820: reserve [mem %#010Lx-%#010Lx] for GART\n",
|
||||
aper_base, aper_base + aper_size - 1);
|
||||
e820_add_region(aper_base, aper_size, E820_RESERVED);
|
||||
e820__range_add(aper_base, aper_size, E820_RESERVED);
|
||||
e820__update_table_print();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -860,7 +860,7 @@ real_trim_memory(unsigned long start_pfn, unsigned long limit_pfn)
|
|||
trim_size <<= PAGE_SHIFT;
|
||||
trim_size -= trim_start;
|
||||
|
||||
return e820_update_range(trim_start, trim_size, E820_RAM, E820_RESERVED);
|
||||
return e820__range_update(trim_start, trim_size, E820_RAM, E820_RESERVED);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -125,7 +125,7 @@ int __init e820__mapped_all(u64 start, u64 end, unsigned type)
|
|||
/*
|
||||
* Add a memory region to the kernel E820 map.
|
||||
*/
|
||||
static void __init __e820_add_region(struct e820_table *table, u64 start, u64 size, int type)
|
||||
static void __init __e820__range_add(struct e820_table *table, u64 start, u64 size, int type)
|
||||
{
|
||||
int x = table->nr_entries;
|
||||
|
||||
|
@ -140,9 +140,9 @@ static void __init __e820_add_region(struct e820_table *table, u64 start, u64 si
|
|||
table->nr_entries++;
|
||||
}
|
||||
|
||||
void __init e820_add_region(u64 start, u64 size, int type)
|
||||
void __init e820__range_add(u64 start, u64 size, int type)
|
||||
{
|
||||
__e820_add_region(e820_table, start, size, type);
|
||||
__e820__range_add(e820_table, start, size, type);
|
||||
}
|
||||
|
||||
static void __init e820_print_type(u32 type)
|
||||
|
@ -380,7 +380,7 @@ static int __init __append_e820_table(struct e820_entry *biosmap, int nr_map)
|
|||
if (start > end && likely(size))
|
||||
return -1;
|
||||
|
||||
e820_add_region(start, size, type);
|
||||
e820__range_add(start, size, type);
|
||||
|
||||
biosmap++;
|
||||
nr_map--;
|
||||
|
@ -407,7 +407,7 @@ static int __init append_e820_table(struct e820_entry *biosmap, int nr_map)
|
|||
}
|
||||
|
||||
static u64 __init
|
||||
__e820_update_range(struct e820_table *table, u64 start, u64 size, unsigned old_type, unsigned new_type)
|
||||
__e820__range_update(struct e820_table *table, u64 start, u64 size, unsigned old_type, unsigned new_type)
|
||||
{
|
||||
u64 end;
|
||||
unsigned int i;
|
||||
|
@ -444,8 +444,8 @@ __e820_update_range(struct e820_table *table, u64 start, u64 size, unsigned old_
|
|||
|
||||
/* New range is completely covered? */
|
||||
if (entry->addr < start && entry_end > end) {
|
||||
__e820_add_region(table, start, size, new_type);
|
||||
__e820_add_region(table, end, entry_end - end, entry->type);
|
||||
__e820__range_add(table, start, size, new_type);
|
||||
__e820__range_add(table, end, entry_end - end, entry->type);
|
||||
entry->size = start - entry->addr;
|
||||
real_updated_size += size;
|
||||
continue;
|
||||
|
@ -457,7 +457,7 @@ __e820_update_range(struct e820_table *table, u64 start, u64 size, unsigned old_
|
|||
if (final_start >= final_end)
|
||||
continue;
|
||||
|
||||
__e820_add_region(table, final_start, final_end - final_start, new_type);
|
||||
__e820__range_add(table, final_start, final_end - final_start, new_type);
|
||||
|
||||
real_updated_size += final_end - final_start;
|
||||
|
||||
|
@ -474,18 +474,18 @@ __e820_update_range(struct e820_table *table, u64 start, u64 size, unsigned old_
|
|||
return real_updated_size;
|
||||
}
|
||||
|
||||
u64 __init e820_update_range(u64 start, u64 size, unsigned old_type, unsigned new_type)
|
||||
u64 __init e820__range_update(u64 start, u64 size, unsigned old_type, unsigned new_type)
|
||||
{
|
||||
return __e820_update_range(e820_table, start, size, old_type, new_type);
|
||||
return __e820__range_update(e820_table, start, size, old_type, new_type);
|
||||
}
|
||||
|
||||
static u64 __init e820_update_range_firmware(u64 start, u64 size, unsigned old_type, unsigned new_type)
|
||||
static u64 __init e820__range_update_firmware(u64 start, u64 size, unsigned old_type, unsigned new_type)
|
||||
{
|
||||
return __e820_update_range(e820_table_firmware, start, size, old_type, new_type);
|
||||
return __e820__range_update(e820_table_firmware, start, size, old_type, new_type);
|
||||
}
|
||||
|
||||
/* Remove a range of memory from the E820 table: */
|
||||
u64 __init e820_remove_range(u64 start, u64 size, unsigned old_type, int checktype)
|
||||
u64 __init e820__range_remove(u64 start, u64 size, unsigned old_type, int checktype)
|
||||
{
|
||||
int i;
|
||||
u64 end;
|
||||
|
@ -519,7 +519,7 @@ u64 __init e820_remove_range(u64 start, u64 size, unsigned old_type, int checkty
|
|||
|
||||
/* Is the new range completely covered? */
|
||||
if (entry->addr < start && entry_end > end) {
|
||||
e820_add_region(end, entry_end - end, entry->type);
|
||||
e820__range_add(end, entry_end - end, entry->type);
|
||||
entry->size = start - entry->addr;
|
||||
real_removed_size += size;
|
||||
continue;
|
||||
|
@ -747,7 +747,7 @@ u64 __init e820__memblock_alloc_reserved(u64 size, u64 align)
|
|||
|
||||
addr = __memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ACCESSIBLE);
|
||||
if (addr) {
|
||||
e820_update_range_firmware(addr, size, E820_RAM, E820_RESERVED);
|
||||
e820__range_update_firmware(addr, size, E820_RAM, E820_RESERVED);
|
||||
pr_info("e820: update e820_table_firmware for e820__memblock_alloc_reserved()\n");
|
||||
e820__update_table_firmware();
|
||||
}
|
||||
|
@ -846,7 +846,7 @@ static int __init parse_memopt(char *p)
|
|||
if (mem_size == 0)
|
||||
return -EINVAL;
|
||||
|
||||
e820_remove_range(mem_size, ULLONG_MAX - mem_size, E820_RAM, 1);
|
||||
e820__range_remove(mem_size, ULLONG_MAX - mem_size, E820_RAM, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -882,18 +882,18 @@ static int __init parse_memmap_one(char *p)
|
|||
userdef = 1;
|
||||
if (*p == '@') {
|
||||
start_at = memparse(p+1, &p);
|
||||
e820_add_region(start_at, mem_size, E820_RAM);
|
||||
e820__range_add(start_at, mem_size, E820_RAM);
|
||||
} else if (*p == '#') {
|
||||
start_at = memparse(p+1, &p);
|
||||
e820_add_region(start_at, mem_size, E820_ACPI);
|
||||
e820__range_add(start_at, mem_size, E820_ACPI);
|
||||
} else if (*p == '$') {
|
||||
start_at = memparse(p+1, &p);
|
||||
e820_add_region(start_at, mem_size, E820_RESERVED);
|
||||
e820__range_add(start_at, mem_size, E820_RESERVED);
|
||||
} else if (*p == '!') {
|
||||
start_at = memparse(p+1, &p);
|
||||
e820_add_region(start_at, mem_size, E820_PRAM);
|
||||
e820__range_add(start_at, mem_size, E820_PRAM);
|
||||
} else {
|
||||
e820_remove_range(mem_size, ULLONG_MAX - mem_size, E820_RAM, 1);
|
||||
e820__range_remove(mem_size, ULLONG_MAX - mem_size, E820_RAM, 1);
|
||||
}
|
||||
|
||||
return *p == '\0' ? 0 : -EINVAL;
|
||||
|
@ -926,7 +926,7 @@ void __init e820_reserve_setup_data(void)
|
|||
|
||||
while (pa_data) {
|
||||
data = early_memremap(pa_data, sizeof(*data));
|
||||
e820_update_range(pa_data, sizeof(*data)+data->len, E820_RAM, E820_RESERVED_KERN);
|
||||
e820__range_update(pa_data, sizeof(*data)+data->len, E820_RAM, E820_RESERVED_KERN);
|
||||
pa_data = data->next;
|
||||
early_memunmap(data, sizeof(*data));
|
||||
}
|
||||
|
@ -1146,8 +1146,8 @@ char *__init e820__memory_setup_default(void)
|
|||
}
|
||||
|
||||
e820_table->nr_entries = 0;
|
||||
e820_add_region(0, LOWMEMSIZE(), E820_RAM);
|
||||
e820_add_region(HIGH_MEMORY, mem_size << 10, E820_RAM);
|
||||
e820__range_add(0, LOWMEMSIZE(), E820_RAM);
|
||||
e820__range_add(HIGH_MEMORY, mem_size << 10, E820_RAM);
|
||||
}
|
||||
|
||||
return who;
|
||||
|
|
|
@ -546,7 +546,7 @@ intel_graphics_stolen(int num, int slot, int func,
|
|||
&base, &end);
|
||||
|
||||
/* Mark this space as reserved */
|
||||
e820_add_region(base, size, E820_RESERVED);
|
||||
e820__range_add(base, size, E820_RESERVED);
|
||||
e820__update_table(e820_table->entries, ARRAY_SIZE(e820_table->entries), &e820_table->nr_entries);
|
||||
}
|
||||
|
||||
|
|
|
@ -731,14 +731,14 @@ static void __init trim_bios_range(void)
|
|||
* since some BIOSes are known to corrupt low memory. See the
|
||||
* Kconfig help text for X86_RESERVE_LOW.
|
||||
*/
|
||||
e820_update_range(0, PAGE_SIZE, E820_RAM, E820_RESERVED);
|
||||
e820__range_update(0, PAGE_SIZE, E820_RAM, E820_RESERVED);
|
||||
|
||||
/*
|
||||
* special case: Some BIOSen report the PC BIOS
|
||||
* area (640->1Mb) as ram even though it is not.
|
||||
* take them out.
|
||||
*/
|
||||
e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
|
||||
e820__range_remove(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
|
||||
|
||||
e820__update_table(e820_table->entries, ARRAY_SIZE(e820_table->entries), &e820_table->nr_entries);
|
||||
}
|
||||
|
@ -760,8 +760,8 @@ static void __init e820_add_kernel_range(void)
|
|||
return;
|
||||
|
||||
pr_warn(".text .data .bss are not marked as E820_RAM!\n");
|
||||
e820_remove_range(start, size, E820_RAM, 0);
|
||||
e820_add_region(start, size, E820_RAM);
|
||||
e820__range_remove(start, size, E820_RAM, 0);
|
||||
e820__range_add(start, size, E820_RAM);
|
||||
}
|
||||
|
||||
static unsigned reserve_low = CONFIG_X86_RESERVE_LOW << 10;
|
||||
|
@ -1031,7 +1031,7 @@ void __init setup_arch(char **cmdline_p)
|
|||
trim_bios_range();
|
||||
#ifdef CONFIG_X86_32
|
||||
if (ppro_with_ram_bug()) {
|
||||
e820_update_range(0x70000000ULL, 0x40000ULL, E820_RAM,
|
||||
e820__range_update(0x70000000ULL, 0x40000ULL, E820_RAM,
|
||||
E820_RESERVED);
|
||||
e820__update_table(e820_table->entries, ARRAY_SIZE(e820_table->entries), &e820_table->nr_entries);
|
||||
printk(KERN_INFO "fixed physical RAM map:\n");
|
||||
|
|
|
@ -1178,7 +1178,7 @@ static __init char *lguest_memory_setup(void)
|
|||
* The Linux bootloader header contains an "e820" memory map: the
|
||||
* Launcher populated the first entry with our memory limit.
|
||||
*/
|
||||
e820_add_region(boot_params.e820_table[0].addr,
|
||||
e820__range_add(boot_params.e820_table[0].addr,
|
||||
boot_params.e820_table[0].size,
|
||||
boot_params.e820_table[0].type);
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ static void __init do_add_efi_memmap(void)
|
|||
e820_type = E820_RESERVED;
|
||||
break;
|
||||
}
|
||||
e820_add_region(start, size, e820_type);
|
||||
e820__range_add(start, size, e820_type);
|
||||
}
|
||||
e820__update_table(e820_table->entries, ARRAY_SIZE(e820_table->entries), &e820_table->nr_entries);
|
||||
}
|
||||
|
|
|
@ -596,7 +596,7 @@ static void __init xen_align_and_add_e820_region(phys_addr_t start,
|
|||
end &= ~((phys_addr_t)PAGE_SIZE - 1);
|
||||
}
|
||||
|
||||
e820_add_region(start, end - start, type);
|
||||
e820__range_add(start, end - start, type);
|
||||
}
|
||||
|
||||
static void __init xen_ignore_unusable(void)
|
||||
|
@ -858,7 +858,7 @@ char * __init xen_memory_setup(void)
|
|||
* reserve ISA memory anyway because too many things poke
|
||||
* about in there.
|
||||
*/
|
||||
e820_add_region(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS,
|
||||
e820__range_add(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS,
|
||||
E820_RESERVED);
|
||||
|
||||
e820__update_table(e820_table->entries, ARRAY_SIZE(e820_table->entries), &e820_table->nr_entries);
|
||||
|
@ -936,7 +936,7 @@ char * __init xen_auto_xlated_memory_setup(void)
|
|||
&xen_e820_table_entries);
|
||||
|
||||
for (i = 0; i < xen_e820_table_entries; i++)
|
||||
e820_add_region(xen_e820_table[i].addr, xen_e820_table[i].size,
|
||||
e820__range_add(xen_e820_table[i].addr, xen_e820_table[i].size,
|
||||
xen_e820_table[i].type);
|
||||
|
||||
/* Remove p2m info, it is not needed. */
|
||||
|
|
|
@ -556,7 +556,7 @@ void __init acpi_table_upgrade(void)
|
|||
* But it's not enough on X86 because ioremap will
|
||||
* complain later (used by acpi_os_map_memory) that the pages
|
||||
* that should get mapped are not marked "reserved".
|
||||
* Both memblock_reserve and e820_add_region (via arch_reserve_mem_area)
|
||||
* Both memblock_reserve and e820__range_add (via arch_reserve_mem_area)
|
||||
* works fine.
|
||||
*/
|
||||
memblock_reserve(acpi_tables_addr, all_tables_size);
|
||||
|
|
Loading…
Reference in New Issue