diff mbox series

[v9,6/7] PCI: dwc: ep: Ensure proper iteration over outbound map windows

Message ID 20250128-pci_fixup_addr-v9-6-3c4bb506f665@nxp.com (mailing list archive)
State New
Headers show
Series PCI: dwc: opitimaze RC Host/EP pci_fixup_addr() | expand

Commit Message

Frank Li Jan. 28, 2025, 10:07 p.m. UTC
Most systems' PCIe outbound map windows have non-zero physical addresses,
but the possibility of encountering zero increased with commit
700cafbb642b ("PCI: dwc: ep: Add bus_addr_base for outbound window").

'ep->outbound_addr[n]', representing 'parent_bus_address', might be 0 on
some hardware, which trims high address bits through bus fabric before
sending to the PCIe controller.

Replace the iteration logic with 'for_each_set_bit()' to ensure only
allocated map windows are iterated when determining the ATU index from a
given address.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
change from v8 to v9
- new patch
---
 drivers/pci/controller/dwc/pcie-designware-ep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Bjorn Helgaas Feb. 27, 2025, 12:12 a.m. UTC | #1
On Tue, Jan 28, 2025 at 05:07:39PM -0500, Frank Li wrote:
> Most systems' PCIe outbound map windows have non-zero physical addresses,
> but the possibility of encountering zero increased with commit
> 700cafbb642b ("PCI: dwc: ep: Add bus_addr_base for outbound window").

I don't know what commit 700cafbb642b is.  It doesn't appear
upstream, and there's no subject line or patch match for
bus_addr_base.

Bjorn
Bjorn Helgaas Feb. 27, 2025, 12:14 a.m. UTC | #2
On Wed, Feb 26, 2025 at 06:12:13PM -0600, Bjorn Helgaas wrote:
> On Tue, Jan 28, 2025 at 05:07:39PM -0500, Frank Li wrote:
> > Most systems' PCIe outbound map windows have non-zero physical addresses,
> > but the possibility of encountering zero increased with commit
> > 700cafbb642b ("PCI: dwc: ep: Add bus_addr_base for outbound window").
> 
> I don't know what commit 700cafbb642b is.  It doesn't appear
> upstream, and there's no subject line or patch match for
> bus_addr_base.

Never mind, I see it's patch 5/7 of *this* series.  I looked at the
0/7 list, but missed it.

In any case, the commit ID will be different since we apply patches
from email, so the ID from your tree won't be useful.

Bjorn
diff mbox series

Patch

diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
index d0d6c4e8df80c..c1767450541a4 100644
--- a/drivers/pci/controller/dwc/pcie-designware-ep.c
+++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
@@ -284,7 +284,7 @@  static int dw_pcie_find_index(struct dw_pcie_ep *ep, phys_addr_t addr,
 	u32 index;
 	struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
 
-	for (index = 0; index < pci->num_ob_windows; index++) {
+	for_each_set_bit(index, ep->ob_window_map, pci->num_ob_windows) {
 		if (ep->outbound_addr[index] != parent_bus_addr)
 			continue;
 		*atu_index = index;