summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYury Norov (NVIDIA) <yury.norov@gmail.com>2025-08-14 22:09:36 +0300
committerMadhavan Srinivasan <maddy@linux.ibm.com>2026-04-01 06:51:07 +0300
commitbd77a34e9a619ee92c03cbb227ca86d814aa6601 (patch)
tree5e8c7c7c1ac03e272e7d40194b917187c57112cd
parentf73338d089deedb4f4f1e49751c30b8b7f595ecd (diff)
downloadlinux-bd77a34e9a619ee92c03cbb227ca86d814aa6601.tar.xz
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
-rw-r--r--arch/powerpc/platforms/powernv/pci-ioda.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 83f75d88e53b..32ecbc46e74b 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -295,7 +295,7 @@ 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;
- int i;
+ unsigned int i;
/* Root bus shouldn't use M64 */
if (pci_is_root_bus(bus))
@@ -312,22 +312,15 @@ static struct pnv_ioda_pe *pnv_ioda_pick_m64_pe(struct pci_bus *bus, bool all)
pnv_ioda_reserve_m64_pe(bus, pe_alloc, all);
/*
- * the current bus might not own M64 window and that's all
- * contributed by its child buses. For the case, we needn't
- * pick M64 dependent PE#.
- */
- if (bitmap_empty(pe_alloc, phb->ioda.total_pe_num)) {
- return NULL;
- }
-
- /*
* Figure out the master PE and put all slave PEs to master
* PE's list to form compound PE.
+ *
+ * The current bus might not own M64 window and that's all
+ * contributed by its child buses. For the case, we needn't
+ * pick M64 dependent PE#.
*/
master_pe = NULL;
- i = -1;
- while ((i = find_next_bit(pe_alloc, phb->ioda.total_pe_num, i + 1)) <
- phb->ioda.total_pe_num) {
+ for_each_set_bit(i, pe_alloc, phb->ioda.total_pe_num) {
pe = &phb->ioda.pe_array[i];
phb->ioda.m64_segmap[pe->pe_number] = pe->pe_number;