diff mbox series

[v10,09/10] PCI: dwc: ep: Ensure proper iteration over outbound map windows

Message ID 20250310-pci_fixup_addr-v10-9-409dafc950d1@nxp.com (mailing list archive)
State Superseded
Headers show
Series PCI: Use device bus range info to cleanup RC Host/EP pci_fixup_addr() | expand

Commit Message

Frank Li March 10, 2025, 8:16 p.m. UTC
Most systems' PCIe outbound map windows have non-zero physical addresses,
but the possibility of encountering zero increased with commit
("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 v9 to v10
- remove commit hash value

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 March 12, 2025, 9:47 p.m. UTC | #1
On Mon, Mar 10, 2025 at 04:16:47PM -0400, Frank Li wrote:
> Most systems' PCIe outbound map windows have non-zero physical addresses,
> but the possibility of encountering zero increased with commit
> ("PCI: dwc: ep: Add bus_addr_base for outbound window").

What is this commit?  I don't see it in the tree, and I don't see it
in this series.

It look like it might be a fixup for something in this series.  In
that case it should go *before* the other commit (or be squashed into
it if it's logically part of it).

I don't think this series touches ep->ob_window_map, so if it's a fix
it looks like it could go anywhere earlier.

> '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 v9 to v10
> - remove commit hash value
> 
> change from v8 to v9
> - new patch
> ---
>  drivers/pci/controller/dwc/pcie-designware-ep.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
> index 62bc71ad20719..e333855633a77 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-ep.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
> @@ -282,7 +282,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] != addr)
>  			continue;
>  		*atu_index = index;
> 
> -- 
> 2.34.1
>
Frank Li March 13, 2025, 2:27 p.m. UTC | #2
On Wed, Mar 12, 2025 at 04:47:00PM -0500, Bjorn Helgaas wrote:
> On Mon, Mar 10, 2025 at 04:16:47PM -0400, Frank Li wrote:
> > Most systems' PCIe outbound map windows have non-zero physical addresses,
> > but the possibility of encountering zero increased with commit
> > ("PCI: dwc: ep: Add bus_addr_base for outbound window").
>
> What is this commit?  I don't see it in the tree, and I don't see it
> in this series.

Sorry, it refer to old version of this series. It should be

PCI: dwc: Use parent_bus_offset

>
> It look like it might be a fixup for something in this series.  In
> that case it should go *before* the other commit (or be squashed into
> it if it's logically part of it).

Yes it should before PCI: dwc: Use parent_bus_offset to support bisect.

>
> I don't think this series touches ep->ob_window_map, so if it's a fix
> it looks like it could go anywhere earlier.

dw_pcie_ep_outbound_atu() touch ob_window_map.

Frank

>
> > '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 v9 to v10
> > - remove commit hash value
> >
> > change from v8 to v9
> > - new patch
> > ---
> >  drivers/pci/controller/dwc/pcie-designware-ep.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
> > index 62bc71ad20719..e333855633a77 100644
> > --- a/drivers/pci/controller/dwc/pcie-designware-ep.c
> > +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
> > @@ -282,7 +282,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] != addr)
> >  			continue;
> >  		*atu_index = index;
> >
> > --
> > 2.34.1
> >
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 62bc71ad20719..e333855633a77 100644
--- a/drivers/pci/controller/dwc/pcie-designware-ep.c
+++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
@@ -282,7 +282,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] != addr)
 			continue;
 		*atu_index = index;