Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 -10
+1 -10
arch/powerpc/platforms/powernv/opal-core.c
··· 303 303 struct device_node *dn; 304 304 struct opalcore *new; 305 305 loff_t opalcore_off; 306 - struct page *page; 307 306 Elf64_Phdr *phdr; 308 307 Elf64_Ehdr *elf; 309 308 int i, ret; ··· 327 328 oc_conf->opalcorebuf_sz = 0; 328 329 return -ENOMEM; 329 330 } 330 - count = oc_conf->opalcorebuf_sz / PAGE_SIZE; 331 - page = virt_to_page(oc_conf->opalcorebuf); 332 - for (i = 0; i < count; i++) 333 - mark_page_reserved(page + i); 334 - 335 331 pr_debug("opalcorebuf = 0x%llx\n", (u64)oc_conf->opalcorebuf); 336 332 337 333 /* Read OPAL related device-tree entries */ ··· 431 437 432 438 /* free the buffer used for setting up OPAL core */ 433 439 if (oc_conf->opalcorebuf) { 434 - void *end = (void *)((u64)oc_conf->opalcorebuf + 435 - oc_conf->opalcorebuf_sz); 436 - 437 - free_reserved_area(oc_conf->opalcorebuf, end, -1, NULL); 440 + free_pages_exact(oc_conf->opalcorebuf, oc_conf->opalcorebuf_sz); 438 441 oc_conf->opalcorebuf = NULL; 439 442 oc_conf->opalcorebuf_sz = 0; 440 443 }