From: Frank Li <Frank.li@nxp.com>
To: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Cc: "Bjorn Helgaas" <helgaas@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Saravana Kannan" <saravanak@google.com>,
"Jingoo Han" <jingoohan1@gmail.com>,
"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: Re: [PATCH v12 05/13] PCI: dwc: Add dw_pcie_parent_bus_offset()
Date: Tue, 25 Mar 2025 15:22:45 -0400 [thread overview]
Message-ID: <Z+MChacLT8iehI5p@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <5hkzuqptaor4v5fc7ljxb36zdipeg67lsjfkcah5fkxfyyjt6e@oknqdtbwjitj>
On Tue, Mar 25, 2025 at 11:59:14PM +0530, Manivannan Sadhasivam wrote:
> On Mon, Mar 24, 2025 at 01:28:27PM -0500, Bjorn Helgaas wrote:
> > On Mon, Mar 24, 2025 at 10:48:23PM +0530, Manivannan Sadhasivam wrote:
> > > On Sat, Mar 15, 2025 at 03:15:40PM -0500, Bjorn Helgaas wrote:
> > > > From: Frank Li <Frank.Li@nxp.com>
> > > >
> > > > Return the offset from CPU physical address to the parent bus address of
> > > > the specified element of the devicetree 'reg' property.
> >
> > > > +resource_size_t dw_pcie_parent_bus_offset(struct dw_pcie *pci,
> > > > + const char *reg_name,
> > > > + resource_size_t cpu_phy_addr)
> > > > +{
> > >
> > > s/cpu_phy_addr/cpu_phys_addr/g
> >
> > Fixed, thanks!
> >
> > > > + struct device *dev = pci->dev;
> > > > + struct device_node *np = dev->of_node;
> > > > + int index;
> > > > + u64 reg_addr;
> > > > +
> > > > + /* Look up reg_name address on parent bus */
> > >
> > > 'parent bus' is not accurate as the below code checks for the 'reg_name' in
> > > current PCI controller node.
> >
> > We want the address of "reg_name" on the node's primary side. We've
> > been calling that the "parent bus address", I guess because it's the
> > address on the "parent bus" of the node.
> >
>
> Yeah, 'parent bus address' sounds bogus to me. 'ranges' property is described
> as:
>
> ranges = <child_addr parent_addr child_size>
>
> Here, child_addr refers to the PCIe host controller's view of the address space
> and parent_addr refers to the CPU's view of the address space.
>
> So the register address described in the PCIe controller node is not a 'parent
> bus address'.
All should be parent bus address. See Rob's comments
https://lore.kernel.org/imx/20240927221831.GA135061-robh@kernel.org/
bus{
ranges = <child_addr parent_addr child_size>
pcie {
All address here, will be translated by bus's ranges, which
use 1:1 map if out of ranges by default.
from pcie node (children node of bus) view, the 'child_addr'
is parent node (bus)'s output address.
}
}
bus may not only one layer to CPU.
bus1 {
ranges = <...>
bus2 {
ranges = <...>
bus3 {
ranges = <...>
All address here is parent's node (bus3)'s bus address
So, 'parent bus address' means the parent node's
output bus address.
};
};
};
Frank
>
> > I'm not sure what the best term is for this. Do you have a
> > suggestion?
> >
>
> We are just extracting the offset between translated (cpu_phy_addr) and
> untranslated (reg_addr) addresses of a specific register. Maybe the function
> should just return the 'untranslated address' and the caller should compute the
> offset to make it simple?
>
> > If "parent bus address" is the wrong term, maybe we need to rename
> > dw_pcie_parent_bus_offset() itself?
> >
>
> Yes!
>
> > Currently we pass in cpu_phys_addr, but this function doesn't need it
> > except for the debug code added later. I would really rather have
> > something like this in the callers:
> >
> > pci->parent_bus_offset = pp->cfg0_base -
> > dw_pcie_parent_bus_addr(pci, "config");
> >
>
> I agree. This should become, dw_pcie_get_untranslated_addr().
>
> > because then the offset is computed sort of at the same level where
> > it's used, and a grep for "cfg0_base" would find both the set and the
> > use and they would be easy to match up.
> >
> > > > + index = of_property_match_string(np, "reg-names", reg_name);
> > > > +
> > > > + if (index < 0) {
> > > > + dev_err(dev, "No %s in devicetree \"reg\" property\n", reg_name);
> > >
> > > Both of these callers are checking for the existence of the
> > > 'reg_name' property before calling this API. So this check seems to
> > > be redundant (for now).
> >
> > True, but I don't see a way to enforce the caller checks. I don't
> > like the idea of calling of_property_read_reg(np, index, ...) where we
> > have to look the caller to verify that "index" is valid.
> >
>
> Ok.
>
> - Mani
>
> --
> மணிவண்ணன் சதாசிவம்
next prev parent reply other threads:[~2025-03-25 19:25 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 [this message]
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 ` [PATCH v12 07/13] PCI: dwc: Use devicetree 'reg[config]' to derive CPU -> ATU addr offset Bjorn Helgaas
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=Z+MChacLT8iehI5p@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.com \
--cc=bhelgaas@google.com \
--cc=cassel@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=helgaas@kernel.org \
--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