From: Bjorn Helgaas <helgaas@kernel.org>
To: Frank Li <Frank.Li@nxp.com>
Cc: "Rob Herring" <robh@kernel.org>,
"Saravana Kannan" <saravanak@google.com>,
"Jingoo Han" <jingoohan1@gmail.com>,
"Manivannan Sadhasivam" <manivannan.sadhasivam@linaro.org>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Richard Zhu" <hongxing.zhu@nxp.com>,
"Lucas Stach" <l.stach@pengutronix.de>,
"Shawn Guo" <shawnguo@kernel.org>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"Fabio Estevam" <festevam@gmail.com>,
"Niklas Cassel" <cassel@kernel.org>,
"Pengutronix Kernel Team" <kernel@pengutronix.de>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
imx@lists.linux.dev, "Bjorn Helgaas" <bhelgaas@google.com>
Subject: [PATCH v12 07/13] PCI: dwc: Use devicetree 'reg[config]' to derive CPU -> ATU addr offset
Date: Sat, 15 Mar 2025 15:15:42 -0500 [thread overview]
Message-ID: <20250315201548.858189-8-helgaas@kernel.org> (raw)
In-Reply-To: <20250315201548.858189-1-helgaas@kernel.org>
From: Frank Li <Frank.Li@nxp.com>
The 'ranges' property of a PCI controller's parent can indicate address
translation information. Most system use 1:1 map between CPU physical and
PCI controller input addresses.
But some hardware, like i.MX8QXP, doesn't use 1:1 map. See below diagram:
┌─────────┐ ┌────────────┐
┌─────┐ │ │ IA: 0x8ff8_0000 │ │
│ CPU ├───►│ ┌────►├─────────────────┐ │ PCI │
└─────┘ │ │ │ IA: 0x8ff0_0000 │ │ │
CPU Addr │ │ ┌─►├─────────────┐ │ │ Controller │
0x7ff8_0000─┼───┘ │ │ │ │ │ │
│ │ │ │ │ │ │ PCI Addr
0x7ff0_0000─┼──────┘ │ │ └──► IOSpace ─┼────────────►
│ │ │ │ │ 0
0x7000_0000─┼────────►├─────────┐ │ │ │
└─────────┘ │ └──────► CfgSpace ─┼────────────►
Bus Fabric │ │ │ 0
│ │ │
└──────────► MemSpace ─┼────────────►
IA: 0x8000_0000 │ │ 0x8000_0000
└────────────┘
bus@5f000000 {
compatible = "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
ranges = <0x80000000 0x0 0x70000000 0x10000000>;
pcie@5f010000 {
compatible = "fsl,imx8q-pcie";
reg = <0x5f010000 0x10000>, <0x8ff00000 0x80000>;
reg-names = "dbi", "config";
...
};
};
Intermediate address (IA) here means the PCIe controller input address.
The pcie@5f010000 'reg[config]' address is the parent bus (PCIe controller
input) address of CfgSpace.
The ATU in MemSpace is not explicitly described via devicetree, so we
assume the offset from CPU address to intermediate MemSpace address is the
same as that for CfgSpace.
We could use bus@5f000000 'ranges' for the same purpose.
Set parent_bus_offset using dw_pcie_init_parent_bus_offset(). The
parent_bus_offset is not used yet, so no functional change intended.
Link: https://lore.kernel.org/r/20250313-pci_fixup_addr-v11-6-01d2313502ab@nxp.com
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/pci/controller/dwc/pcie-designware-host.c | 6 ++++++
drivers/pci/controller/dwc/pcie-designware.h | 1 +
2 files changed, 7 insertions(+)
diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index 9ce06b1ee266..9e38ac7d1bcb 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -452,6 +452,12 @@ static int dw_pcie_host_get_resources(struct dw_pcie_rp *pp)
pp->io_base = pci_pio_to_address(win->res->start);
}
+ /*
+ * visconti_pcie_cpu_addr_fixup() uses pp->io_base, so we have to
+ * call dw_pcie_parent_bus_offset() after setting pp->io_base.
+ */
+ pci->parent_bus_offset = dw_pcie_parent_bus_offset(pci, "config",
+ pp->cfg0_base);
return 0;
}
diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
index f08d2852cfd5..741c46926ce2 100644
--- a/drivers/pci/controller/dwc/pcie-designware.h
+++ b/drivers/pci/controller/dwc/pcie-designware.h
@@ -445,6 +445,7 @@ struct dw_pcie {
void __iomem *atu_base;
resource_size_t atu_phys_addr;
size_t atu_size;
+ resource_size_t parent_bus_offset;
u32 num_ib_windows;
u32 num_ob_windows;
u32 region_align;
--
2.34.1
next prev parent reply other threads:[~2025-03-15 20:16 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-15 20:15 [PATCH v12 00/13] PCI: Use device bus range info to cleanup RC Host/EP pci_fixup_addr() Bjorn Helgaas
2025-03-15 20:15 ` [PATCH v12 01/13] PCI: dwc: Use resource start as iomap() input in dw_pcie_pme_turn_off() Bjorn Helgaas
2025-03-15 20:15 ` [PATCH v12 02/13] PCI: dwc: Rename cpu_addr to parent_bus_addr for ATU configuration Bjorn Helgaas
2025-03-15 20:15 ` [PATCH v12 03/13] PCI: dwc: Call devm_pci_alloc_host_bridge() early in dw_pcie_host_init() Bjorn Helgaas
2025-03-15 20:15 ` [PATCH v12 04/13] PCI: dwc: Consolidate devicetree handling in dw_pcie_host_get_resources() Bjorn Helgaas
2025-03-16 1:18 ` Frank Li
2025-03-15 20:15 ` [PATCH v12 05/13] PCI: dwc: Add dw_pcie_parent_bus_offset() Bjorn Helgaas
2025-03-16 1:20 ` Frank Li
2025-03-24 17:18 ` Manivannan Sadhasivam
2025-03-24 18:28 ` Bjorn Helgaas
2025-03-25 18:29 ` Manivannan Sadhasivam
2025-03-25 19:22 ` Frank Li
2025-03-15 20:15 ` [PATCH v12 06/13] PCI: dwc: Add dw_pcie_parent_bus_offset() checking and debug Bjorn Helgaas
2025-03-16 1:23 ` Frank Li
2025-03-18 15:38 ` Bjorn Helgaas
2025-03-19 13:22 ` Frank Li
2025-03-24 17:30 ` Manivannan Sadhasivam
2025-03-24 18:32 ` Frank Li
2025-03-24 20:04 ` Bjorn Helgaas
2025-03-25 18:09 ` Manivannan Sadhasivam
2025-03-25 19:01 ` Frank Li
2025-03-15 20:15 ` Bjorn Helgaas [this message]
2025-03-15 20:15 ` [PATCH v12 08/13] PCI: dwc: ep: Call epc_create() early in dw_pcie_ep_init() Bjorn Helgaas
2025-03-16 1:24 ` Frank Li
2025-03-15 20:15 ` [PATCH v12 09/13] PCI: dwc: ep: Consolidate devicetree handling in dw_pcie_ep_get_resources() Bjorn Helgaas
2025-03-16 1:26 ` Frank Li
2025-03-15 20:15 ` [PATCH v12 10/13] PCI: dwc: ep: Use devicetree 'reg[addr_space]' to derive CPU -> ATU addr offset Bjorn Helgaas
2025-03-16 1:32 ` Frank Li
2025-03-15 20:15 ` [PATCH v12 11/13] PCI: dwc: ep: Ensure proper iteration over outbound map windows Bjorn Helgaas
2025-03-15 20:15 ` [PATCH v12 12/13] PCI: dwc: Use parent_bus_offset to remove need for .cpu_addr_fixup() Bjorn Helgaas
2025-03-16 1:34 ` Frank Li
2025-03-15 20:15 ` [PATCH v12 13/13] PCI: imx6: Remove cpu_addr_fixup() Bjorn Helgaas
2025-03-15 22:31 ` [PATCH v12 00/13] PCI: Use device bus range info to cleanup RC Host/EP pci_fixup_addr() Bjorn Helgaas
2025-03-17 22:12 ` Bjorn Helgaas
2025-03-24 14:35 ` Manivannan Sadhasivam
2025-03-24 17:34 ` Manivannan Sadhasivam
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250315201548.858189-8-helgaas@kernel.org \
--to=helgaas@kernel.org \
--cc=Frank.Li@nxp.com \
--cc=bhelgaas@google.com \
--cc=cassel@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=hongxing.zhu@nxp.com \
--cc=imx@lists.linux.dev \
--cc=jingoohan1@gmail.com \
--cc=kernel@pengutronix.de \
--cc=kw@linux.com \
--cc=l.stach@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=saravanak@google.com \
--cc=shawnguo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).