Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@nxp.com>
To: Randolph Lin <randolph@andestech.com>
Cc: Bjorn Helgaas <helgaas@kernel.org>,
	linux-pci@vger.kernel.org, ben717@andestech.com, robh@kernel.org,
	krzk+dt@kernel.org, conor+dt@kernel.org,
	paul.walmsley@sifive.com, palmer@dabbelt.com,
	aou@eecs.berkeley.edu, alex@ghiti.fr, jingoohan1@gmail.com,
	mani@kernel.org, lpieralisi@kernel.org, kwilczynski@kernel.org,
	bhelgaas@google.com, randolph.sklin@gmail.com,
	tim609@andestech.com
Subject: Re: [PATCH 5/6] PCI: andes: Add Andes QiLai SoC PCIe host driver support
Date: Tue, 9 Sep 2025 11:02:02 -0400	[thread overview]
Message-ID: <aMBBas7etQND7c24@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <aL_h-HnA8Dtb0G15@swlinux02>

On Tue, Sep 09, 2025 at 04:14:48PM +0800, Randolph Lin wrote:
> Hi Bjorn and Frank,
>
> On Mon, Sep 08, 2025 at 05:07:37PM -0500, Bjorn Helgaas wrote:
> > [EXTERNAL MAIL]
> >
> > [+cc Frank, who can probably answer faster than I can]
> >
...
> > > >
> > > > Sorry, we can't do this.  We're removing .cpu_addr_fixup() because
> > > > it's a workaround for defects in the DT description.  See these
> > > > commits, for example:
> > > >
> > > >     befc86a0b354 ("PCI: dwc: Use parent_bus_offset to remove need for .cpu_addr_fixup()")
> > > >     b9812179f601 ("PCI: imx6: Remove imx_pcie_cpu_addr_fixup()")
> > > >     07ae413e169d ("PCI: intel-gw: Remove intel_pcie_cpu_addr()")
> > >
> > > I’m a bit confused about the following question:
> > > After removing cpu_addr_fixup, should we use pci->parent_bus_offset
> > > to store the offset value, or should pci->parent_bus_offset remain
> > > 0?
> >
> > If you needed qilai_pcie_cpu_addr_fixup(), I would expect your
> > dw_pcie.parent_bus_offset to be non-zero because parent_bus_offset is
> > used instead of ->cpu_addr_fixup().
> >
>
> In this SoC, the dw_pcie.parent_bus_offset should be set to the value of the
> config register base address. Setting the dw_pcie.parent_bus_offset to a
> non-zero value seems to occur only in the path that uses ->cpu_addr_fixup().
>
> The parent_bus_offset is generally used instead of ->cpu_addr_fixup() throughout
> most of the code, but its assignment still seems to rely on ->cpu_addr_fixup()
> when it needs to be set to a non-zero value.
> If no other method exists to set up dw_pcie.parent_bus_offset, can we keep using
> ->cpu_addr_fixup() for the assignment?

Correct your dts file. See below

>
> > > In the commit message:
> > > befc86a0b354 ("PCI: dwc: Use parent_bus_offset to remove need for .cpu_addr_fixup()")
> > >     We know the parent_bus_offset, either computed from a DT reg
> > >     property (the offset is the CPU physical addr - the
> > >     'config'/'addr_space' address on the parent bus) or from a
> > >     .cpu_addr_fixup() (which may have used a host bridge window
> > >     offset).
> > >
> > > We know that "the offset is the CPU physical addr - the
> > > 'config'/'addr_space' address on the parent bus".
> > >
> > > However, in dw_pcie_host_get_resources(), it passes pp->cfg0_base,
> > > which is parsed from the device tree using "config", as the
> > > cpu_phys_addr parameter to dw_pcie_parent_bus_offset(). It also
> > > passes "config" as the 2nd parameter to dw_pcie_parent_bus_offset().
> > >
> > > In dw_pcie_parent_bus_offset(), the 2nd parameter is used to get the
> > > index from the devicetree "reg-names" field, and the result is used
> > > as the 'config'/'addr_space' address.
> > >
> > > It seems that the same value is being obtained through a different
> > > method, and the return value appears to be 0.  Could I be
> > > misunderstanding something?

I missed prevous discussion. Actually address convert happen at PCIe's parent
bus fabric. If your DTS correct reflect this address convert, you needn't
cpu_addr_fixup() at all.

bus {
	ranges = (0x2000_00000, 0x1000_0000, 0x1000_0000)
	^^^^^

	pcie@xxxx {
		reg = <0x2000_00000, 0x1000>;
		reg-names = <config>;
	}
}

0x2000_0000 is actaully address input to your PCI controller although
CPU use 0x1000_0000.  "bus" fabric convert 0x1000_0000 to 0x2000_0000

So dwc common code already can handle this to auto calucate
parent_bus_offset base on ranges of bus.

Frank

> >
>
> Sincerely,
> Randolph

  reply	other threads:[~2025-09-09 15:02 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-20 11:18 [PATCH 0/6] Add support for Andes Qilai SoC PCIe controller Randolph Lin
2025-08-20 11:18 ` [PATCH 1/6] riscv: dts: andes: Define dma-ranges for coherent port Randolph Lin
2025-08-20 11:18 ` [PATCH 2/6] PCI: dwc: Add outbound ATU range check callback Randolph Lin
2025-08-20 15:52   ` Bjorn Helgaas
2025-08-20 11:18 ` [PATCH 3/6] dt-bindings: Add Andes QiLai PCIe support Randolph Lin
2025-08-21  6:11   ` Krzysztof Kozlowski
2025-08-20 11:18 ` [PATCH 4/6] riscv: dts: andes: Add PCIe node into the QiLai SoC Randolph Lin
2025-08-20 11:18 ` [PATCH 5/6] PCI: andes: Add Andes QiLai SoC PCIe host driver support Randolph Lin
2025-08-20 15:54   ` Bjorn Helgaas
2025-08-29  9:41     ` Randolph Lin
2025-09-08 22:07       ` Bjorn Helgaas
2025-09-09  8:14         ` Randolph Lin
2025-09-09 15:02           ` Frank Li [this message]
2025-09-08  7:02   ` Manivannan Sadhasivam
2025-09-09  6:59     ` Randolph Lin
2025-08-20 11:18 ` [PATCH 6/6] MAINTAINERS: Add maintainers for Andes QiLai PCIe driver Randolph Lin

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=aMBBas7etQND7c24@lizhi-Precision-Tower-5810 \
    --to=frank.li@nxp.com \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=ben717@andestech.com \
    --cc=bhelgaas@google.com \
    --cc=conor+dt@kernel.org \
    --cc=helgaas@kernel.org \
    --cc=jingoohan1@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=kwilczynski@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mani@kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=randolph.sklin@gmail.com \
    --cc=randolph@andestech.com \
    --cc=robh@kernel.org \
    --cc=tim609@andestech.com \
    /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