Skip to content

Commit 8ff5d8f

Browse files
committed
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>
1 parent 25ee3af commit 8ff5d8f

1 file changed

Lines changed: 1 addition & 10 deletions

File tree

arch/powerpc/platforms/powernv/opal-core.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ static int __init create_opalcore(void)
303303
struct device_node *dn;
304304
struct opalcore *new;
305305
loff_t opalcore_off;
306-
struct page *page;
307306
Elf64_Phdr *phdr;
308307
Elf64_Ehdr *elf;
309308
int i, ret;
@@ -328,11 +327,6 @@ static int __init create_opalcore(void)
328327
oc_conf->opalcorebuf_sz = 0;
329328
return -ENOMEM;
330329
}
331-
count = oc_conf->opalcorebuf_sz / PAGE_SIZE;
332-
page = virt_to_page(oc_conf->opalcorebuf);
333-
for (i = 0; i < count; i++)
334-
mark_page_reserved(page + i);
335-
336330
pr_debug("opalcorebuf = 0x%llx\n", (u64)oc_conf->opalcorebuf);
337331

338332
/* Read OPAL related device-tree entries */
@@ -437,10 +431,7 @@ static void opalcore_cleanup(void)
437431

438432
/* free the buffer used for setting up OPAL core */
439433
if (oc_conf->opalcorebuf) {
440-
void *end = (void *)((u64)oc_conf->opalcorebuf +
441-
oc_conf->opalcorebuf_sz);
442-
443-
free_reserved_area(oc_conf->opalcorebuf, end, -1, NULL);
434+
free_pages_exact(oc_conf->opalcorebuf, oc_conf->opalcorebuf_sz);
444435
oc_conf->opalcorebuf = NULL;
445436
oc_conf->opalcorebuf_sz = 0;
446437
}

0 commit comments

Comments
 (0)