Skip to content

Commit 4421cca

Browse files
rppttorvalds
authored andcommitted
memblock: use memblock_free for freeing virtual pointers
Rename memblock_free_ptr() to memblock_free() and use memblock_free() when freeing a virtual pointer so that memblock_free() will be a counterpart of memblock_alloc() The callers are updated with the below semantic patch and manual addition of (void *) casting to pointers that are represented by unsigned long variables. @@ identifier vaddr; expression size; @@ ( - memblock_phys_free(__pa(vaddr), size); + memblock_free(vaddr, size); | - memblock_free_ptr(vaddr, size); + memblock_free(vaddr, size); ) [[email protected]: fixup] Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Mike Rapoport <[email protected]> Signed-off-by: Stephen Rothwell <[email protected]> Cc: Christophe Leroy <[email protected]> Cc: Juergen Gross <[email protected]> Cc: Shahab Vahedi <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 3ecc683 commit 4421cca

File tree

29 files changed

+40
-43
lines changed

29 files changed

+40
-43
lines changed

arch/alpha/kernel/core_irongate.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,7 @@ albacore_init_arch(void)
233233
unsigned long size;
234234

235235
size = initrd_end - initrd_start;
236-
memblock_phys_free(__pa(initrd_start),
237-
PAGE_ALIGN(size));
236+
memblock_free((void *)initrd_start, PAGE_ALIGN(size));
238237
if (!move_initrd(pci_mem))
239238
printk("irongate_init_arch: initrd too big "
240239
"(%ldK)\ndisabling initrd\n",

arch/mips/mm/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ static void * __init pcpu_fc_alloc(unsigned int cpu, size_t size,
529529

530530
static void __init pcpu_fc_free(void *ptr, size_t size)
531531
{
532-
memblock_phys_free(__pa(ptr), size);
532+
memblock_free(ptr, size);
533533
}
534534

535535
void __init setup_per_cpu_areas(void)

arch/powerpc/kernel/dt_cpu_ftrs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,8 +1095,8 @@ static int __init dt_cpu_ftrs_scan_callback(unsigned long node, const char
10951095

10961096
cpufeatures_setup_finished();
10971097

1098-
memblock_phys_free(__pa(dt_cpu_features),
1099-
sizeof(struct dt_cpu_feature) * nr_dt_cpu_features);
1098+
memblock_free(dt_cpu_features,
1099+
sizeof(struct dt_cpu_feature) * nr_dt_cpu_features);
11001100

11011101
return 0;
11021102
}

arch/powerpc/kernel/setup-common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ static void __init smp_setup_pacas(void)
825825
set_hard_smp_processor_id(cpu, cpu_to_phys_id[cpu]);
826826
}
827827

828-
memblock_phys_free(__pa(cpu_to_phys_id), nr_cpu_ids * sizeof(u32));
828+
memblock_free(cpu_to_phys_id, nr_cpu_ids * sizeof(u32));
829829
cpu_to_phys_id = NULL;
830830
}
831831
#endif

arch/powerpc/kernel/setup_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ static void * __init pcpu_alloc_bootmem(unsigned int cpu, size_t size,
812812

813813
static void __init pcpu_free_bootmem(void *ptr, size_t size)
814814
{
815-
memblock_phys_free(__pa(ptr), size);
815+
memblock_free(ptr, size);
816816
}
817817

818818
static int pcpu_cpu_distance(unsigned int from, unsigned int to)

arch/powerpc/platforms/powernv/pci-ioda.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2981,7 +2981,7 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np,
29812981
if (!phb->hose) {
29822982
pr_err(" Can't allocate PCI controller for %pOF\n",
29832983
np);
2984-
memblock_phys_free(__pa(phb), sizeof(struct pnv_phb));
2984+
memblock_free(phb, sizeof(struct pnv_phb));
29852985
return;
29862986
}
29872987

arch/powerpc/platforms/pseries/svm.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ void __init svm_swiotlb_init(void)
5656
return;
5757

5858

59-
memblock_phys_free(__pa(vstart),
60-
PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT));
59+
memblock_free(vstart, PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT));
6160
panic("SVM: Cannot allocate SWIOTLB buffer");
6261
}
6362

arch/riscv/kernel/setup.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,13 @@ static void __init init_resources(void)
230230

231231
/* Clean-up any unused pre-allocated resources */
232232
if (res_idx >= 0)
233-
memblock_phys_free(__pa(mem_res),
234-
(res_idx + 1) * sizeof(*mem_res));
233+
memblock_free(mem_res, (res_idx + 1) * sizeof(*mem_res));
235234
return;
236235

237236
error:
238237
/* Better an empty resource tree than an inconsistent one */
239238
release_child_resources(&iomem_resource);
240-
memblock_phys_free(__pa(mem_res), mem_res_sz);
239+
memblock_free(mem_res, mem_res_sz);
241240
}
242241

243242

arch/sparc/kernel/smp_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,7 @@ static void * __init pcpu_alloc_bootmem(unsigned int cpu, size_t size,
15671567

15681568
static void __init pcpu_free_bootmem(void *ptr, size_t size)
15691569
{
1570-
memblock_phys_free(__pa(ptr), size);
1570+
memblock_free(ptr, size);
15711571
}
15721572

15731573
static int __init pcpu_cpu_distance(unsigned int from, unsigned int to)

arch/um/kernel/mem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void __init mem_init(void)
4747
*/
4848
brk_end = (unsigned long) UML_ROUND_UP(sbrk(0));
4949
map_memory(brk_end, __pa(brk_end), uml_reserved - brk_end, 1, 1, 0);
50-
memblock_phys_free(__pa(brk_end), uml_reserved - brk_end);
50+
memblock_free((void *)brk_end, uml_reserved - brk_end);
5151
uml_reserved = brk_end;
5252

5353
/* this will put all low memory onto the freelists */

0 commit comments

Comments
 (0)