public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
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>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Richard Zhu" <hongxing.zhu@nxp.com>,
	"Lucas Stach" <l.stach@pengutronix.de>,
	"Shawn Guo" <shawnguo@kernel.org>,
	"Sascha Hauer" <s.hauer@pengutronix.de>,
	"Pengutronix Kernel Team" <kernel@pengutronix.de>,
	"Fabio Estevam" <festevam@gmail.com>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	imx@lists.linux.dev, "Niklas Cassel" <cassel@kernel.org>
Subject: Re: [PATCH v9 4/7] PCI: dwc: Use devicetree 'ranges' property to get rid of cpu_addr_fixup() callback
Date: Wed, 26 Feb 2025 17:33:39 -0600	[thread overview]
Message-ID: <20250226233339.GA562682@bhelgaas> (raw)
In-Reply-To: <20250128-pci_fixup_addr-v9-4-3c4bb506f665@nxp.com>

On Tue, Jan 28, 2025 at 05:07:37PM -0500, Frank Li wrote:
> parent_bus_offset in resource_entry can indicate address information just
> ahead of PCIe controller. Most system's bus fabric use 1:1 map between
> input and output address. but some hardware like i.MX8QXP doesn't use 1:1
> map. See below diagram:
> ...

> @@ -448,6 +451,26 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp)
>  	if (IS_ERR(pp->va_cfg0_base))
>  		return PTR_ERR(pp->va_cfg0_base);
>  
> +	if (pci->use_parent_dt_ranges) {
> +		if (pci->ops->cpu_addr_fixup) {
> +			dev_err(dev, "Use parent bus DT ranges, cpu_addr_fixup() must be removed\n");
> +			return -EINVAL;
> +		}
> +
> +		index = of_property_match_string(np, "reg-names", "config");
> +		if (index < 0)
> +			return -EINVAL;
> +
> +		 /*
> +		  * Retrieve the parent bus address of PCI config space.
> +		  * If the parent bus ranges in the device tree provide
> +		  * the correct address conversion information, set
> +		  * 'use_parent_dt_ranges' to true, The
> +		  * 'cpu_addr_fixup()' can be eliminated.
> +		  */
> +		of_property_read_reg(np, index, &pp->cfg0_base, NULL);
> +	}

I think all this code dealing with the "config" resource could go in a
helper function.  It's kind of a lot of clutter in
dw_pcie_host_init().

It would be nice to assign pp->cfg0_base once, not assign res->start
to it and then possibly overwrite it later.

> @@ -841,6 +841,15 @@ void dw_pcie_iatu_detect(struct dw_pcie *pci)
>  	pci->region_align = 1 << fls(min);
>  	pci->region_limit = (max << 32) | (SZ_4G - 1);
>  
> +	if (pci->ops && pci->ops->cpu_addr_fixup) {
> +		/*
> +		 * If the parent 'ranges' property in DT correctly describes
> +		 * the address translation, cpu_addr_fixup() callback is not
> +		 * needed.
> +		 */
> +		dev_warn_once(pci->dev, "cpu_addr_fixup() usage detected. Please fix DT!\n");
> +	}

Can you split the warnings out to a separate patch?  I think we should
warn once in every initialization path where .cpu_addr_fixup() could
be used, i.e.,

  dw_pcie_host_init()
  dw_pcie_ep_init()
  cdns_pcie_host_setup()
  cdns_pcie_ep_setup()

IMO these should warn if .cpu_addr_fixup() is implemented, regardless
of use_parent_dt_ranges.

I'm still puzzling over some of the rest of this, so no need to post a
revised series yet.

Bjorn


  reply	other threads:[~2025-02-26 23:37 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-28 22:07 [PATCH v9 0/7] PCI: dwc: opitimaze RC Host/EP pci_fixup_addr() Frank Li
2025-01-28 22:07 ` [PATCH v9 1/7] PCI: dwc: Use resource start as iomap() input in dw_pcie_pme_turn_off() Frank Li
2025-01-29 23:19   ` Bjorn Helgaas
2025-01-30 16:07     ` Frank Li
2025-01-28 22:07 ` [PATCH v9 2/7] PCI: dwc: Rename cpu_addr to parent_bus_addr for ATU configuration Frank Li
2025-01-29 23:23   ` Bjorn Helgaas
2025-01-30 16:02     ` Frank Li
2025-02-13 16:02       ` Frank Li
2025-01-28 22:07 ` [PATCH v9 3/7] PCI: Add parent_bus_offset to resource_entry Frank Li
2025-02-06 17:11   ` Frank Li
2025-02-27  0:08   ` Bjorn Helgaas
2025-02-27  0:23   ` Bjorn Helgaas
2025-03-03 21:57     ` Frank Li
2025-03-04 17:50       ` Bjorn Helgaas
2025-03-04 22:11         ` Frank Li
2025-03-04 22:25           ` Frank Li
2025-03-07 15:32             ` Frank Li
2025-03-07 23:41               ` Bjorn Helgaas
2025-01-28 22:07 ` [PATCH v9 4/7] PCI: dwc: Use devicetree 'ranges' property to get rid of cpu_addr_fixup() callback Frank Li
2025-02-26 23:33   ` Bjorn Helgaas [this message]
2025-03-03 21:58     ` Frank Li
2025-01-28 22:07 ` [PATCH v9 5/7] PCI: dwc: ep: Add parent_bus_addr for outbound window Frank Li
2025-01-28 22:07 ` [PATCH v9 6/7] PCI: dwc: ep: Ensure proper iteration over outbound map windows Frank Li
2025-02-27  0:12   ` Bjorn Helgaas
2025-02-27  0:14     ` Bjorn Helgaas
2025-01-28 22:07 ` [PATCH v9 7/7] PCI: imx6: Remove cpu_addr_fixup() Frank Li
2025-01-29 10:13 ` [PATCH v9 0/7] PCI: dwc: opitimaze RC Host/EP pci_fixup_addr() Niklas Cassel
2025-01-29 15:28   ` Frank Li
2025-01-29 16:39     ` Niklas Cassel
2025-01-29 17:04       ` Frank Li

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=20250226233339.GA562682@bhelgaas \
    --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