Skip to content

Commit 1b02ec0

Browse files
rppttorvalds
authored andcommitted
unicore32: simplify detection of memory zone boundaries
free_area_init() only requires the definition of maximal PFN for each of the supported zone rater than calculation of actual zone sizes and the sizes of the holes between the zones. After removal of CONFIG_HAVE_MEMBLOCK_NODE_MAP the free_area_init() is available to all architectures. Using this function instead of free_area_init_node() simplifies the zone detection. Signed-off-by: Mike Rapoport <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Tested-by: Hoan Tran <[email protected]> [arm64] Cc: Baoquan He <[email protected]> Cc: Brian Cain <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: Greentime Hu <[email protected]> Cc: Greg Ungerer <[email protected]> Cc: Guan Xuetao <[email protected]> Cc: Guo Ren <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Helge Deller <[email protected]> Cc: "James E.J. Bottomley" <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Ley Foon Tan <[email protected]> Cc: Mark Salter <[email protected]> Cc: Matt Turner <[email protected]> Cc: Max Filippov <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Michal Simek <[email protected]> Cc: Nick Hu <[email protected]> Cc: Paul Walmsley <[email protected]> Cc: Richard Weinberger <[email protected]> Cc: Rich Felker <[email protected]> Cc: Russell King <[email protected]> Cc: Stafford Horne <[email protected]> Cc: Thomas Bogendoerfer <[email protected]> Cc: Tony Luck <[email protected]> Cc: Vineet Gupta <[email protected]> Cc: Yoshinori Sato <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent bee3b3c commit 1b02ec0

File tree

4 files changed

+15
-50
lines changed

4 files changed

+15
-50
lines changed

arch/unicore32/include/asm/memory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
#ifndef __ASSEMBLY__
6161

6262
#ifndef arch_adjust_zones
63-
#define arch_adjust_zones(size, holes) do { } while (0)
63+
#define arch_adjust_zones(max_zone_pfn) do { } while (0)
6464
#endif
6565

6666
/*

arch/unicore32/include/mach/memory.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525

2626
#if !defined(__ASSEMBLY__) && defined(CONFIG_PCI)
2727

28-
void puv3_pci_adjust_zones(unsigned long *size, unsigned long *holes);
28+
void puv3_pci_adjust_zones(unsigned long *max_zone_pfn);
2929

30-
#define arch_adjust_zones(size, holes) \
31-
puv3_pci_adjust_zones(size, holes)
30+
#define arch_adjust_zones(max_zone_pfn) \
31+
puv3_pci_adjust_zones(max_zone_pfn)
3232

3333
#endif
3434

arch/unicore32/kernel/pci.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -133,21 +133,11 @@ static int pci_puv3_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
133133
* This is really ugly and we need a better way of specifying
134134
* DMA-capable regions of memory.
135135
*/
136-
void __init puv3_pci_adjust_zones(unsigned long *zone_size,
137-
unsigned long *zhole_size)
136+
void __init puv3_pci_adjust_zones(unsigned long max_zone_pfn)
138137
{
139138
unsigned int sz = SZ_128M >> PAGE_SHIFT;
140139

141-
/*
142-
* Only adjust if > 128M on current system
143-
*/
144-
if (zone_size[0] <= sz)
145-
return;
146-
147-
zone_size[1] = zone_size[0] - sz;
148-
zone_size[0] = sz;
149-
zhole_size[1] = zhole_size[0];
150-
zhole_size[0] = 0;
140+
max_zone_pfn[ZONE_DMA] = sz;
151141
}
152142

153143
/*

arch/unicore32/mm/init.c

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -61,46 +61,21 @@ static void __init find_limits(unsigned long *min, unsigned long *max_low,
6161
}
6262
}
6363

64-
static void __init uc32_bootmem_free(unsigned long min, unsigned long max_low,
65-
unsigned long max_high)
64+
static void __init uc32_bootmem_free(unsigned long max_low)
6665
{
67-
unsigned long zone_size[MAX_NR_ZONES], zhole_size[MAX_NR_ZONES];
68-
struct memblock_region *reg;
66+
unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 };
6967

70-
/*
71-
* initialise the zones.
72-
*/
73-
memset(zone_size, 0, sizeof(zone_size));
74-
75-
/*
76-
* The memory size has already been determined. If we need
77-
* to do anything fancy with the allocation of this memory
78-
* to the zones, now is the time to do it.
79-
*/
80-
zone_size[0] = max_low - min;
81-
82-
/*
83-
* Calculate the size of the holes.
84-
* holes = node_size - sum(bank_sizes)
85-
*/
86-
memcpy(zhole_size, zone_size, sizeof(zhole_size));
87-
for_each_memblock(memory, reg) {
88-
unsigned long start = memblock_region_memory_base_pfn(reg);
89-
unsigned long end = memblock_region_memory_end_pfn(reg);
90-
91-
if (start < max_low) {
92-
unsigned long low_end = min(end, max_low);
93-
zhole_size[0] -= low_end - start;
94-
}
95-
}
68+
max_zone_pfn[ZONE_DMA] = max_low;
69+
max_zone_pfn[ZONE_NORMAL] = max_low;
9670

9771
/*
9872
* Adjust the sizes according to any special requirements for
9973
* this machine type.
74+
* This might lower ZONE_DMA limit.
10075
*/
101-
arch_adjust_zones(zone_size, zhole_size);
76+
arch_adjust_zones(max_zone_pfn);
10277

103-
free_area_init_node(0, zone_size, min, zhole_size);
78+
free_area_init(max_zone_pfn);
10479
}
10580

10681
int pfn_valid(unsigned long pfn)
@@ -176,11 +151,11 @@ void __init bootmem_init(void)
176151
sparse_init();
177152

178153
/*
179-
* Now free the memory - free_area_init_node needs
154+
* Now free the memory - free_area_init needs
180155
* the sparse mem_map arrays initialized by sparse_init()
181156
* for memmap_init_zone(), otherwise all PFNs are invalid.
182157
*/
183-
uc32_bootmem_free(min, max_low, max_high);
158+
uc32_bootmem_free(max_low);
184159

185160
high_memory = __va((max_low << PAGE_SHIFT) - 1) + 1;
186161

0 commit comments

Comments
 (0)