]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
powerpc: pci-ioda: use bitmap_alloc() in pnv_ioda_pick_m64_pe()
authorYury Norov (NVIDIA) <yury.norov@gmail.com>
Thu, 14 Aug 2025 19:09:35 +0000 (15:09 -0400)
committerMadhavan Srinivasan <maddy@linux.ibm.com>
Wed, 1 Apr 2026 03:51:07 +0000 (09:21 +0530)
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
arch/powerpc/platforms/powernv/pci-ioda.c

index 885392f4cd94fc69d801d482bca3e18eb6283325..83f75d88e53b8acac5cd8618870f8ac3ae37bde9 100644 (file)
@@ -292,18 +292,16 @@ static void pnv_ioda_reserve_m64_pe(struct pci_bus *bus,
 
 static struct pnv_ioda_pe *pnv_ioda_pick_m64_pe(struct pci_bus *bus, bool all)
 {
+       unsigned long *pe_alloc __free(bitmap) = NULL;
        struct pnv_phb *phb = pci_bus_to_pnvhb(bus);
        struct pnv_ioda_pe *master_pe, *pe;
-       unsigned long size, *pe_alloc;
        int i;
 
        /* Root bus shouldn't use M64 */
        if (pci_is_root_bus(bus))
                return NULL;
 
-       /* Allocate bitmap */
-       size = ALIGN(phb->ioda.total_pe_num / 8, sizeof(unsigned long));
-       pe_alloc = kzalloc(size, GFP_KERNEL);
+       pe_alloc = bitmap_zalloc(phb->ioda.total_pe_num, GFP_KERNEL);
        if (!pe_alloc) {
                pr_warn("%s: Out of memory !\n",
                        __func__);
@@ -319,7 +317,6 @@ static struct pnv_ioda_pe *pnv_ioda_pick_m64_pe(struct pci_bus *bus, bool all)
         * pick M64 dependent PE#.
         */
        if (bitmap_empty(pe_alloc, phb->ioda.total_pe_num)) {
-               kfree(pe_alloc);
                return NULL;
        }
 
@@ -345,7 +342,6 @@ static struct pnv_ioda_pe *pnv_ioda_pick_m64_pe(struct pci_bus *bus, bool all)
                }
        }
 
-       kfree(pe_alloc);
        return master_pe;
 }