[PATCH v6 1/5] PCI: dwc: Allow adjusting the number of ob/ib windows in glue driver

Randolph Lin
2025-10-03T02:40:31Z

The number of ob/ib windows is determined through write-read loops
on registers in the core driver. Some glue drivers need to adjust
the number of ob/ib windows to meet specific requirements,such as
hardware limitations. This change allows the glue driver to adjust
the number of ob/ib windows to satisfy platform-specific constraints.
The glue driver may adjust the number of ob/ib windows, but the values
must stay within hardware limits.

Signed-off-by: Randolph Lin <randolph@andestech.com>
---
drivers/pci/controller/dwc/pcie-designware.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
index 89aad5a08928..56c1e45adc06 100644
--- a/drivers/pci/controller/dwc/pcie-designware.c
+++ b/drivers/pci/controller/dwc/pcie-designware.c
@@ -907,8 +907,16 @@ void dw_pcie_iatu_detect(struct dw_pcie *pci)
max = 0;
}

- pci->num_ob_windows = ob;
- pci->num_ib_windows = ib;
+ if (!pci->num_ob_windows)
+ pci->num_ob_windows = ob;
+ else if (pci->num_ob_windows > ob)
+ dev_err(pci->dev, "Adjusted ob windows exceed the limit\n");
+
+ if (!pci->num_ib_windows)
+ pci->num_ib_windows = ib;
+ else if (pci->num_ib_windows > ib)
+ dev_err(pci->dev, "Adjusted ib windows exceed the limit\n");
+
pci->region_align = 1 << fls(min);
pci->region_limit = (max << 32) | (SZ_4G - 1);