Skip to content

Commit 550fd7d

Browse files
YuryNorovmaddy-kerneldev
authored andcommitted
powerpc: pci-ioda: use bitmap_alloc() in pnv_ioda_pick_m64_pe()
Use the dedicated bitmap_alloc() in pnv_ioda_pick_m64_pe() and drop some housekeeping code. Because pe_alloc is local, annotate it with __free() and get rid of the explicit kfree() calls. Suggested-by: Jiri Slaby <jirislaby@kernel.org> Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com> Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com> Link: https://patch.msgid.link/20250814190936.381346-2-yury.norov@gmail.com
1 parent d220a73 commit 550fd7d

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,18 +292,16 @@ static void pnv_ioda_reserve_m64_pe(struct pci_bus *bus,
292292

293293
static struct pnv_ioda_pe *pnv_ioda_pick_m64_pe(struct pci_bus *bus, bool all)
294294
{
295+
unsigned long *pe_alloc __free(bitmap) = NULL;
295296
struct pnv_phb *phb = pci_bus_to_pnvhb(bus);
296297
struct pnv_ioda_pe *master_pe, *pe;
297-
unsigned long size, *pe_alloc;
298298
int i;
299299

300300
/* Root bus shouldn't use M64 */
301301
if (pci_is_root_bus(bus))
302302
return NULL;
303303

304-
/* Allocate bitmap */
305-
size = ALIGN(phb->ioda.total_pe_num / 8, sizeof(unsigned long));
306-
pe_alloc = kzalloc(size, GFP_KERNEL);
304+
pe_alloc = bitmap_zalloc(phb->ioda.total_pe_num, GFP_KERNEL);
307305
if (!pe_alloc) {
308306
pr_warn("%s: Out of memory !\n",
309307
__func__);
@@ -319,7 +317,6 @@ static struct pnv_ioda_pe *pnv_ioda_pick_m64_pe(struct pci_bus *bus, bool all)
319317
* pick M64 dependent PE#.
320318
*/
321319
if (bitmap_empty(pe_alloc, phb->ioda.total_pe_num)) {
322-
kfree(pe_alloc);
323320
return NULL;
324321
}
325322

@@ -345,7 +342,6 @@ static struct pnv_ioda_pe *pnv_ioda_pick_m64_pe(struct pci_bus *bus, bool all)
345342
}
346343
}
347344

348-
kfree(pe_alloc);
349345
return master_pe;
350346
}
351347

0 commit comments

Comments
 (0)