diff options
Diffstat (limited to 'drivers/base/memory.c')
-rw-r--r-- | drivers/base/memory.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 3e9aa3d00044..c4c443db7cbf 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c | |||
@@ -229,10 +229,11 @@ int memory_isolate_notify(unsigned long val, void *v) | |||
229 | * OK to have direct references to sparsemem variables in here. | 229 | * OK to have direct references to sparsemem variables in here. |
230 | */ | 230 | */ |
231 | static int | 231 | static int |
232 | memory_section_action(unsigned long phys_index, unsigned long action) | 232 | memory_block_action(unsigned long phys_index, unsigned long action) |
233 | { | 233 | { |
234 | int i; | 234 | int i; |
235 | unsigned long start_pfn, start_paddr; | 235 | unsigned long start_pfn, start_paddr; |
236 | unsigned long nr_pages = PAGES_PER_SECTION * sections_per_block; | ||
236 | struct page *first_page; | 237 | struct page *first_page; |
237 | int ret; | 238 | int ret; |
238 | 239 | ||
@@ -244,7 +245,7 @@ memory_section_action(unsigned long phys_index, unsigned long action) | |||
244 | * that way. | 245 | * that way. |
245 | */ | 246 | */ |
246 | if (action == MEM_ONLINE) { | 247 | if (action == MEM_ONLINE) { |
247 | for (i = 0; i < PAGES_PER_SECTION; i++) { | 248 | for (i = 0; i < nr_pages; i++) { |
248 | if (PageReserved(first_page+i)) | 249 | if (PageReserved(first_page+i)) |
249 | continue; | 250 | continue; |
250 | 251 | ||
@@ -258,12 +259,12 @@ memory_section_action(unsigned long phys_index, unsigned long action) | |||
258 | switch (action) { | 259 | switch (action) { |
259 | case MEM_ONLINE: | 260 | case MEM_ONLINE: |
260 | start_pfn = page_to_pfn(first_page); | 261 | start_pfn = page_to_pfn(first_page); |
261 | ret = online_pages(start_pfn, PAGES_PER_SECTION); | 262 | ret = online_pages(start_pfn, nr_pages); |
262 | break; | 263 | break; |
263 | case MEM_OFFLINE: | 264 | case MEM_OFFLINE: |
264 | start_paddr = page_to_pfn(first_page) << PAGE_SHIFT; | 265 | start_paddr = page_to_pfn(first_page) << PAGE_SHIFT; |
265 | ret = remove_memory(start_paddr, | 266 | ret = remove_memory(start_paddr, |
266 | PAGES_PER_SECTION << PAGE_SHIFT); | 267 | nr_pages << PAGE_SHIFT); |
267 | break; | 268 | break; |
268 | default: | 269 | default: |
269 | WARN(1, KERN_WARNING "%s(%ld, %ld) unknown action: " | 270 | WARN(1, KERN_WARNING "%s(%ld, %ld) unknown action: " |
@@ -289,20 +290,11 @@ static int memory_block_change_state(struct memory_block *mem, | |||
289 | if (to_state == MEM_OFFLINE) | 290 | if (to_state == MEM_OFFLINE) |
290 | mem->state = MEM_GOING_OFFLINE; | 291 | mem->state = MEM_GOING_OFFLINE; |
291 | 292 | ||
292 | for (i = 0; i < sections_per_block; i++) { | 293 | ret = memory_block_action(mem->start_section_nr, to_state); |
293 | ret = memory_section_action(mem->start_section_nr + i, | ||
294 | to_state); | ||
295 | if (ret) | ||
296 | break; | ||
297 | } | ||
298 | |||
299 | if (ret) { | ||
300 | for (i = 0; i < sections_per_block; i++) | ||
301 | memory_section_action(mem->start_section_nr + i, | ||
302 | from_state_req); | ||
303 | 294 | ||
295 | if (ret) | ||
304 | mem->state = from_state_req; | 296 | mem->state = from_state_req; |
305 | } else | 297 | else |
306 | mem->state = to_state; | 298 | mem->state = to_state; |
307 | 299 | ||
308 | out: | 300 | out: |