forked from Minki/linux
powerpc/fadump: use helper functions to reserve/release cpu notes buffer
Use helper functions to simplify memory allocation, pinning down and freeing the memory used for CPU notes buffer. Signed-off-by: Hari Bathini <hbathini@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/156821323555.5656.2486038022572739622.stgit@hbathini.in.ibm.com
This commit is contained in:
parent
8468d15545
commit
72aa651795
@ -786,33 +786,24 @@ void fadump_update_elfcore_header(char *bufp)
|
|||||||
|
|
||||||
static void *fadump_alloc_buffer(unsigned long size)
|
static void *fadump_alloc_buffer(unsigned long size)
|
||||||
{
|
{
|
||||||
void *vaddr;
|
unsigned long count, i;
|
||||||
struct page *page;
|
struct page *page;
|
||||||
unsigned long order, count, i;
|
void *vaddr;
|
||||||
|
|
||||||
order = get_order(size);
|
vaddr = alloc_pages_exact(size, GFP_KERNEL | __GFP_ZERO);
|
||||||
vaddr = (void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO, order);
|
|
||||||
if (!vaddr)
|
if (!vaddr)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
count = 1 << order;
|
count = PAGE_ALIGN(size) / PAGE_SIZE;
|
||||||
page = virt_to_page(vaddr);
|
page = virt_to_page(vaddr);
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
SetPageReserved(page + i);
|
mark_page_reserved(page + i);
|
||||||
return vaddr;
|
return vaddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fadump_free_buffer(unsigned long vaddr, unsigned long size)
|
static void fadump_free_buffer(unsigned long vaddr, unsigned long size)
|
||||||
{
|
{
|
||||||
struct page *page;
|
free_reserved_area((void *)vaddr, (void *)(vaddr + size), -1, NULL);
|
||||||
unsigned long order, count, i;
|
|
||||||
|
|
||||||
order = get_order(size);
|
|
||||||
count = 1 << order;
|
|
||||||
page = virt_to_page(vaddr);
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
ClearPageReserved(page + i);
|
|
||||||
__free_pages(page, order);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 fadump_setup_cpu_notes_buf(u32 num_cpus)
|
s32 fadump_setup_cpu_notes_buf(u32 num_cpus)
|
||||||
|
Loading…
Reference in New Issue
Block a user