mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 09:04:39 +02:00
powerpc: opal-core: pair alloc_pages_exact() with free_pages_exact()
opal-core allocates buffers with alloc_pages_exact(), but then marks them as reserved and frees using free_reserved_area(). This is completely unnecessary and the pages allocated with alloc_pages_exact() can be naturally freed with free_pages_exact(). Replace freeing of memory in opalcore_cleanup() with free_pages_exact() and simplify allocation code so that it won't mark allocated pages as reserved. Link: https://patch.msgid.link/20260323074836.3653702-4-rppt@kernel.org Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
This commit is contained in:
parent
25ee3aff99
commit
8ff5d8f200
|
|
@ -303,7 +303,6 @@ static int __init create_opalcore(void)
|
|||
struct device_node *dn;
|
||||
struct opalcore *new;
|
||||
loff_t opalcore_off;
|
||||
struct page *page;
|
||||
Elf64_Phdr *phdr;
|
||||
Elf64_Ehdr *elf;
|
||||
int i, ret;
|
||||
|
|
@ -328,11 +327,6 @@ static int __init create_opalcore(void)
|
|||
oc_conf->opalcorebuf_sz = 0;
|
||||
return -ENOMEM;
|
||||
}
|
||||
count = oc_conf->opalcorebuf_sz / PAGE_SIZE;
|
||||
page = virt_to_page(oc_conf->opalcorebuf);
|
||||
for (i = 0; i < count; i++)
|
||||
mark_page_reserved(page + i);
|
||||
|
||||
pr_debug("opalcorebuf = 0x%llx\n", (u64)oc_conf->opalcorebuf);
|
||||
|
||||
/* Read OPAL related device-tree entries */
|
||||
|
|
@ -437,10 +431,7 @@ static void opalcore_cleanup(void)
|
|||
|
||||
/* free the buffer used for setting up OPAL core */
|
||||
if (oc_conf->opalcorebuf) {
|
||||
void *end = (void *)((u64)oc_conf->opalcorebuf +
|
||||
oc_conf->opalcorebuf_sz);
|
||||
|
||||
free_reserved_area(oc_conf->opalcorebuf, end, -1, NULL);
|
||||
free_pages_exact(oc_conf->opalcorebuf, oc_conf->opalcorebuf_sz);
|
||||
oc_conf->opalcorebuf = NULL;
|
||||
oc_conf->opalcorebuf_sz = 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user