Skip to content

Commit

Permalink
Merge tag 'please-pull-noboot' of git://git.kernel.org/pub/scm/linux/…
Browse files Browse the repository at this point in the history
…kernel/git/aegl/linux

Pull ia64 NO_BOOTMEM conversion from Tony Luck:
 "Mike Rapoport kindly fixed up ia64 to work with NO_BOOTMEM"

* tag 'please-pull-noboot' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux:
  ia64: switch to NO_BOOTMEM
  ia64: use mem_data to detect nodes' minimal and maximal PFNs
  ia64: remove unused num_dma_physpages member from 'struct early_node_data'
  ia64: contig/paging_init: reduce code duplication
  • Loading branch information
torvalds committed Aug 21, 2018
2 parents 6b2edf2 + f628009 commit 778a339
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 188 deletions.
1 change: 1 addition & 0 deletions arch/ia64/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ config IA64
select HAVE_ARCH_TRACEHOOK
select HAVE_MEMBLOCK
select HAVE_MEMBLOCK_NODE_MAP
select NO_BOOTMEM
select HAVE_VIRT_CPU_ACCOUNTING
select ARCH_HAS_DMA_MARK_CLEAN
select ARCH_HAS_SG_CHAIN
Expand Down
11 changes: 10 additions & 1 deletion arch/ia64/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <linux/delay.h>
#include <linux/cpu.h>
#include <linux/kernel.h>
#include <linux/memblock.h>
#include <linux/reboot.h>
#include <linux/sched/mm.h>
#include <linux/sched/clock.h>
Expand Down Expand Up @@ -383,8 +384,16 @@ reserve_memory (void)

sort_regions(rsvd_region, num_rsvd_regions);
num_rsvd_regions = merge_regions(rsvd_region, num_rsvd_regions);
}

/* reserve all regions except the end of memory marker with memblock */
for (n = 0; n < num_rsvd_regions - 1; n++) {
struct rsvd_region *region = &rsvd_region[n];
phys_addr_t addr = __pa(region->start);
phys_addr_t size = region->end - region->start;

memblock_reserve(addr, size);
}
}

/**
* find_initrd - get initrd parameters from the boot parameter structure
Expand Down
75 changes: 6 additions & 69 deletions arch/ia64/mm/contig.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,53 +34,6 @@ static unsigned long max_gap;
/* physical address where the bootmem map is located */
unsigned long bootmap_start;

/**
* find_bootmap_location - callback to find a memory area for the bootmap
* @start: start of region
* @end: end of region
* @arg: unused callback data
*
* Find a place to put the bootmap and return its starting address in
* bootmap_start. This address must be page-aligned.
*/
static int __init
find_bootmap_location (u64 start, u64 end, void *arg)
{
u64 needed = *(unsigned long *)arg;
u64 range_start, range_end, free_start;
int i;

#if IGNORE_PFN0
if (start == PAGE_OFFSET) {
start += PAGE_SIZE;
if (start >= end)
return 0;
}
#endif

free_start = PAGE_OFFSET;

for (i = 0; i < num_rsvd_regions; i++) {
range_start = max(start, free_start);
range_end = min(end, rsvd_region[i].start & PAGE_MASK);

free_start = PAGE_ALIGN(rsvd_region[i].end);

if (range_end <= range_start)
continue; /* skip over empty range */

if (range_end - range_start >= needed) {
bootmap_start = __pa(range_start);
return -1; /* done */
}

/* nothing more available in this segment */
if (range_end == end)
return 0;
}
return 0;
}

#ifdef CONFIG_SMP
static void *cpu_data;
/**
Expand Down Expand Up @@ -196,30 +149,19 @@ setup_per_cpu_areas(void)
void __init
find_memory (void)
{
unsigned long bootmap_size;

reserve_memory();

/* first find highest page frame number */
min_low_pfn = ~0UL;
max_low_pfn = 0;
efi_memmap_walk(find_max_min_low_pfn, NULL);
max_pfn = max_low_pfn;
/* how many bytes to cover all the pages */
bootmap_size = bootmem_bootmap_pages(max_pfn) << PAGE_SHIFT;

/* look for a location to hold the bootmap */
bootmap_start = ~0UL;
efi_memmap_walk(find_bootmap_location, &bootmap_size);
if (bootmap_start == ~0UL)
panic("Cannot find %ld bytes for bootmap\n", bootmap_size);

bootmap_size = init_bootmem_node(NODE_DATA(0),
(bootmap_start >> PAGE_SHIFT), 0, max_pfn);

/* Free all available memory, then mark bootmem-map as being in use. */
efi_memmap_walk(filter_rsvd_memory, free_bootmem);
reserve_bootmem(bootmap_start, bootmap_size, BOOTMEM_DEFAULT);
#ifdef CONFIG_VIRTUAL_MEM_MAP
efi_memmap_walk(filter_memory, register_active_ranges);
#else
memblock_add_node(0, PFN_PHYS(max_low_pfn), 0);
#endif

find_initrd();

Expand All @@ -244,11 +186,9 @@ paging_init (void)
max_zone_pfns[ZONE_NORMAL] = max_low_pfn;

#ifdef CONFIG_VIRTUAL_MEM_MAP
efi_memmap_walk(filter_memory, register_active_ranges);
efi_memmap_walk(find_largest_hole, (u64 *)&max_gap);
if (max_gap < LARGE_GAP) {
vmem_map = (struct page *) 0;
free_area_init_nodes(max_zone_pfns);
} else {
unsigned long map_size;

Expand All @@ -266,13 +206,10 @@ paging_init (void)
*/
NODE_DATA(0)->node_mem_map = vmem_map +
find_min_pfn_with_active_regions();
free_area_init_nodes(max_zone_pfns);

printk("Virtual mem_map starts at 0x%p\n", mem_map);
}
#else /* !CONFIG_VIRTUAL_MEM_MAP */
memblock_add_node(0, PFN_PHYS(max_low_pfn), 0);
free_area_init_nodes(max_zone_pfns);
#endif /* !CONFIG_VIRTUAL_MEM_MAP */
free_area_init_nodes(max_zone_pfns);
zero_page_memmap_ptr = virt_to_page(ia64_imva(empty_zero_page));
}
Loading

0 comments on commit 778a339

Please sign in to comment.