diff options
author | Heiko Carstens <heiko.carstens@de.ibm.com> | 2013-04-30 13:19:58 -0400 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2013-05-03 08:21:15 -0400 |
commit | 996b4a7d8f4e5dd531369396f2312b97e9400cdc (patch) | |
tree | c827369c3cb23b84a3cd0528e534b4963c7639fa /arch/s390/mm | |
parent | d3383632d4e8e9ae747f582eaee8c2e79f828ae6 (diff) |
s390/mem_detect: remove artificial kdump memory types
Simplify the memory detection code a bit by removing the CHUNK_OLDMEM
and CHUNK_CRASHK memory types.
They are not needed. Everything that is needed is a mechanism to
insert holes into the detected memory.
Reviewed-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390/mm')
-rw-r--r-- | arch/s390/mm/mem_detect.c | 98 | ||||
-rw-r--r-- | arch/s390/mm/vmem.c | 8 |
2 files changed, 30 insertions, 76 deletions
diff --git a/arch/s390/mm/mem_detect.c b/arch/s390/mm/mem_detect.c index ec00576bf8d5..3cbd3b8bf311 100644 --- a/arch/s390/mm/mem_detect.c +++ b/arch/s390/mm/mem_detect.c | |||
@@ -95,82 +95,40 @@ out: | |||
95 | EXPORT_SYMBOL(detect_memory_layout); | 95 | EXPORT_SYMBOL(detect_memory_layout); |
96 | 96 | ||
97 | /* | 97 | /* |
98 | * Move memory chunks array from index "from" to index "to" | 98 | * Create memory hole with given address and size. |
99 | */ | 99 | */ |
100 | static void mem_chunk_move(struct mem_chunk chunk[], int to, int from) | 100 | void create_mem_hole(struct mem_chunk mem_chunk[], unsigned long addr, |
101 | unsigned long size) | ||
101 | { | 102 | { |
102 | int cnt = MEMORY_CHUNKS - to; | 103 | int i; |
103 | |||
104 | memmove(&chunk[to], &chunk[from], cnt * sizeof(struct mem_chunk)); | ||
105 | } | ||
106 | |||
107 | /* | ||
108 | * Initialize memory chunk | ||
109 | */ | ||
110 | static void mem_chunk_init(struct mem_chunk *chunk, unsigned long addr, | ||
111 | unsigned long size, int type) | ||
112 | { | ||
113 | chunk->type = type; | ||
114 | chunk->addr = addr; | ||
115 | chunk->size = size; | ||
116 | } | ||
117 | |||
118 | /* | ||
119 | * Create memory hole with given address, size, and type | ||
120 | */ | ||
121 | void create_mem_hole(struct mem_chunk chunk[], unsigned long addr, | ||
122 | unsigned long size, int type) | ||
123 | { | ||
124 | unsigned long lh_start, lh_end, lh_size, ch_start, ch_end, ch_size; | ||
125 | int i, ch_type; | ||
126 | 104 | ||
127 | for (i = 0; i < MEMORY_CHUNKS; i++) { | 105 | for (i = 0; i < MEMORY_CHUNKS; i++) { |
128 | if (chunk[i].size == 0) | 106 | struct mem_chunk *chunk = &mem_chunk[i]; |
129 | continue; | ||
130 | |||
131 | /* Define chunk properties */ | ||
132 | ch_start = chunk[i].addr; | ||
133 | ch_size = chunk[i].size; | ||
134 | ch_end = ch_start + ch_size - 1; | ||
135 | ch_type = chunk[i].type; | ||
136 | |||
137 | /* Is memory chunk hit by memory hole? */ | ||
138 | if (addr + size <= ch_start) | ||
139 | continue; /* No: memory hole in front of chunk */ | ||
140 | if (addr > ch_end) | ||
141 | continue; /* No: memory hole after chunk */ | ||
142 | 107 | ||
143 | /* Yes: Define local hole properties */ | 108 | if (chunk->size == 0) |
144 | lh_start = max(addr, chunk[i].addr); | 109 | continue; |
145 | lh_end = min(addr + size - 1, ch_end); | 110 | if (addr > chunk->addr + chunk->size) |
146 | lh_size = lh_end - lh_start + 1; | 111 | continue; |
112 | if (addr + size <= chunk->addr) | ||
113 | continue; | ||
114 | /* Split */ | ||
115 | if ((addr > chunk->addr) && | ||
116 | (addr + size < chunk->addr + chunk->size)) { | ||
117 | struct mem_chunk *new = chunk + 1; | ||
147 | 118 | ||
148 | if (lh_start == ch_start && lh_end == ch_end) { | 119 | memmove(new, chunk, (MEMORY_CHUNKS-i-1) * sizeof(*new)); |
149 | /* Hole covers complete memory chunk */ | 120 | new->addr = addr + size; |
150 | mem_chunk_init(&chunk[i], lh_start, lh_size, type); | 121 | new->size = chunk->addr + chunk->size - new->addr; |
151 | } else if (lh_end == ch_end) { | 122 | chunk->size = addr - chunk->addr; |
152 | /* Hole starts in memory chunk and convers chunk end */ | 123 | continue; |
153 | mem_chunk_move(chunk, i + 1, i); | 124 | } else if ((addr <= chunk->addr) && |
154 | mem_chunk_init(&chunk[i], ch_start, ch_size - lh_size, | 125 | (addr + size >= chunk->addr + chunk->size)) { |
155 | ch_type); | 126 | memset(chunk, 0 , sizeof(*chunk)); |
156 | mem_chunk_init(&chunk[i + 1], lh_start, lh_size, type); | 127 | } else if (addr + size < chunk->addr + chunk->size) { |
157 | i += 1; | 128 | chunk->size = chunk->addr + chunk->size - addr - size; |
158 | } else if (lh_start == ch_start) { | 129 | chunk->addr = addr + size; |
159 | /* Hole ends in memory chunk */ | 130 | } else if (addr > chunk->addr) { |
160 | mem_chunk_move(chunk, i + 1, i); | 131 | chunk->size = addr - chunk->addr; |
161 | mem_chunk_init(&chunk[i], lh_start, lh_size, type); | ||
162 | mem_chunk_init(&chunk[i + 1], lh_end + 1, | ||
163 | ch_size - lh_size, ch_type); | ||
164 | break; | ||
165 | } else { | ||
166 | /* Hole splits memory chunk */ | ||
167 | mem_chunk_move(chunk, i + 2, i); | ||
168 | mem_chunk_init(&chunk[i], ch_start, | ||
169 | lh_start - ch_start, ch_type); | ||
170 | mem_chunk_init(&chunk[i + 1], lh_start, lh_size, type); | ||
171 | mem_chunk_init(&chunk[i + 2], lh_end + 1, | ||
172 | ch_end - lh_end, ch_type); | ||
173 | break; | ||
174 | } | 132 | } |
175 | } | 133 | } |
176 | } | 134 | } |
diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c index 35837054f734..8b268fcc4612 100644 --- a/arch/s390/mm/vmem.c +++ b/arch/s390/mm/vmem.c | |||
@@ -375,9 +375,8 @@ void __init vmem_map_init(void) | |||
375 | 375 | ||
376 | ro_start = PFN_ALIGN((unsigned long)&_stext); | 376 | ro_start = PFN_ALIGN((unsigned long)&_stext); |
377 | ro_end = (unsigned long)&_eshared & PAGE_MASK; | 377 | ro_end = (unsigned long)&_eshared & PAGE_MASK; |
378 | for (i = 0; i < MEMORY_CHUNKS && memory_chunk[i].size > 0; i++) { | 378 | for (i = 0; i < MEMORY_CHUNKS; i++) { |
379 | if (memory_chunk[i].type == CHUNK_CRASHK || | 379 | if (!memory_chunk[i].size) |
380 | memory_chunk[i].type == CHUNK_OLDMEM) | ||
381 | continue; | 380 | continue; |
382 | start = memory_chunk[i].addr; | 381 | start = memory_chunk[i].addr; |
383 | end = memory_chunk[i].addr + memory_chunk[i].size; | 382 | end = memory_chunk[i].addr + memory_chunk[i].size; |
@@ -412,9 +411,6 @@ static int __init vmem_convert_memory_chunk(void) | |||
412 | for (i = 0; i < MEMORY_CHUNKS; i++) { | 411 | for (i = 0; i < MEMORY_CHUNKS; i++) { |
413 | if (!memory_chunk[i].size) | 412 | if (!memory_chunk[i].size) |
414 | continue; | 413 | continue; |
415 | if (memory_chunk[i].type == CHUNK_CRASHK || | ||
416 | memory_chunk[i].type == CHUNK_OLDMEM) | ||
417 | continue; | ||
418 | seg = kzalloc(sizeof(*seg), GFP_KERNEL); | 414 | seg = kzalloc(sizeof(*seg), GFP_KERNEL); |
419 | if (!seg) | 415 | if (!seg) |
420 | panic("Out of memory...\n"); | 416 | panic("Out of memory...\n"); |