Re: [PATCH v9 4/7] PCI: dwc: Use devicetree 'ranges' property to get rid of cpu_addr_fixup() callback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 26, 2025 at 05:33:39PM -0600, Bjorn Helgaas wrote:
> 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.

Do you have additional comments, so I can post a revised series?

Frank

>
> Bjorn




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux