Skip to content

Commit bb8a694

Browse files
YuryNorovmaddy-kerneldev
authored andcommitted
powerpc: pci-ioda: Optimize pnv_ioda_pick_m64_pe()
bitmap_empty() in pnv_ioda_pick_m64_pe() is O(N) and useless because the following find_next_bit() does the same work. Drop it, and while there replace a while() loop with the dedicated for_each_set_bit(). Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com> 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-3-yury.norov@gmail.com
1 parent 550fd7d commit bb8a694

1 file changed

Lines changed: 6 additions & 13 deletions

File tree

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

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ static struct pnv_ioda_pe *pnv_ioda_pick_m64_pe(struct pci_bus *bus, bool all)
295295
unsigned long *pe_alloc __free(bitmap) = NULL;
296296
struct pnv_phb *phb = pci_bus_to_pnvhb(bus);
297297
struct pnv_ioda_pe *master_pe, *pe;
298-
int i;
298+
unsigned int i;
299299

300300
/* Root bus shouldn't use M64 */
301301
if (pci_is_root_bus(bus))
@@ -311,23 +311,16 @@ static struct pnv_ioda_pe *pnv_ioda_pick_m64_pe(struct pci_bus *bus, bool all)
311311
/* Figure out reserved PE numbers by the PE */
312312
pnv_ioda_reserve_m64_pe(bus, pe_alloc, all);
313313

314-
/*
315-
* the current bus might not own M64 window and that's all
316-
* contributed by its child buses. For the case, we needn't
317-
* pick M64 dependent PE#.
318-
*/
319-
if (bitmap_empty(pe_alloc, phb->ioda.total_pe_num)) {
320-
return NULL;
321-
}
322-
323314
/*
324315
* Figure out the master PE and put all slave PEs to master
325316
* PE's list to form compound PE.
317+
*
318+
* The current bus might not own M64 window and that's all
319+
* contributed by its child buses. For the case, we needn't
320+
* pick M64 dependent PE#.
326321
*/
327322
master_pe = NULL;
328-
i = -1;
329-
while ((i = find_next_bit(pe_alloc, phb->ioda.total_pe_num, i + 1)) <
330-
phb->ioda.total_pe_num) {
323+
for_each_set_bit(i, pe_alloc, phb->ioda.total_pe_num) {
331324
pe = &phb->ioda.pe_array[i];
332325

333326
phb->ioda.m64_segmap[pe->pe_number] = pe->pe_number;

0 commit comments

Comments
 (0)