[PATCH v11 10/11] PCI: dwc: Print warning message when cpu_addr_fixup() exists

Frank Li posted 11 patches 9 months, 1 week ago
There is a newer version of this series
[PATCH v11 10/11] PCI: dwc: Print warning message when cpu_addr_fixup() exists
Posted by Frank Li 9 months, 1 week ago
If the parent 'ranges' property in DT correctly describes the address
translation, the cpu_addr_fixup() callback is not needed. Print a warning
message to inform users to correct their DTB files and prepare to remove
cpu_addr_fixup().

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
change from v10 to v11
- change to dev_warn()
- Bjorn: this is opitional patches to encourage user fix their dtb file.

change from v9 to v10
- new patch
---
 drivers/pci/controller/dwc/pcie-designware.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
index 8b546131b97f6..d4dc8bf06d4c1 100644
--- a/drivers/pci/controller/dwc/pcie-designware.c
+++ b/drivers/pci/controller/dwc/pcie-designware.c
@@ -1125,6 +1125,8 @@ int dw_pcie_init_parent_bus_offset(struct dw_pcie *pci, const char *reg_name,
 
 	fixup = pci->ops->cpu_addr_fixup;
 	if (fixup) {
+		dev_warn(pci->dev, "cpu_addr_fixup() usage detected. Please fix your DTB!\n");
+
 		fixup_addr = fixup(pci, cpu_phy_addr);
 		if (reg_addr == fixup_addr) {
 			dev_warn(dev, "%#010llx %s reg[%d] == %#010llx; %ps is redundant\n",

-- 
2.34.1
Re: [PATCH v11 10/11] PCI: dwc: Print warning message when cpu_addr_fixup() exists
Posted by Manivannan Sadhasivam 6 months, 1 week ago
On Thu, Mar 13, 2025 at 11:38:46AM -0400, Frank Li wrote:
> If the parent 'ranges' property in DT correctly describes the address
> translation, the cpu_addr_fixup() callback is not needed. Print a warning
> message to inform users to correct their DTB files and prepare to remove
> cpu_addr_fixup().
> 

This patch seem to have dropped, but I do see a value in printing the warning to
encourage developers/users to fix the DTB in some way. Since we fixed the driver
to parse the DT 'ranges' properly, the presence of cpu_addr_fixup() callback
indicates that the translation is not properly described in DT. So DT has to be
fixed.

Bjorn, thoughts?

- Mani

> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
> change from v10 to v11
> - change to dev_warn()
> - Bjorn: this is opitional patches to encourage user fix their dtb file.
> 
> change from v9 to v10
> - new patch
> ---
>  drivers/pci/controller/dwc/pcie-designware.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
> index 8b546131b97f6..d4dc8bf06d4c1 100644
> --- a/drivers/pci/controller/dwc/pcie-designware.c
> +++ b/drivers/pci/controller/dwc/pcie-designware.c
> @@ -1125,6 +1125,8 @@ int dw_pcie_init_parent_bus_offset(struct dw_pcie *pci, const char *reg_name,
>  
>  	fixup = pci->ops->cpu_addr_fixup;
>  	if (fixup) {
> +		dev_warn(pci->dev, "cpu_addr_fixup() usage detected. Please fix your DTB!\n");
> +
>  		fixup_addr = fixup(pci, cpu_phy_addr);
>  		if (reg_addr == fixup_addr) {
>  			dev_warn(dev, "%#010llx %s reg[%d] == %#010llx; %ps is redundant\n",
> 
> -- 
> 2.34.1
> 

-- 
மணிவண்ணன் சதாசிவம்
Re: [PATCH v11 10/11] PCI: dwc: Print warning message when cpu_addr_fixup() exists
Posted by Frank Li 6 months, 1 week ago
On Thu, Jun 12, 2025 at 08:16:03PM +0530, Manivannan Sadhasivam wrote:
> On Thu, Mar 13, 2025 at 11:38:46AM -0400, Frank Li wrote:
> > If the parent 'ranges' property in DT correctly describes the address
> > translation, the cpu_addr_fixup() callback is not needed. Print a warning
> > message to inform users to correct their DTB files and prepare to remove
> > cpu_addr_fixup().
> >
>
> This patch seem to have dropped, but I do see a value in printing the warning to
> encourage developers/users to fix the DTB in some way. Since we fixed the driver
> to parse the DT 'ranges' properly, the presence of cpu_addr_fixup() callback
> indicates that the translation is not properly described in DT. So DT has to be
> fixed.

This patch already in mainline with Bjorn's fine tuned at when merge.

	fixup = pci->ops ? pci->ops->cpu_addr_fixup : NULL;
        if (fixup) {
                fixup_addr = fixup(pci, cpu_phys_addr);
                if (reg_addr == fixup_addr) {
                        dev_info(dev, "%s reg[%d] %#010llx == %#010llx == fixup(cpu %#010llx); %ps is redundant with this devicetree\n",
                                 reg_name, index, reg_addr, fixup_addr,
                                 (unsigned long long) cpu_phys_addr, fixup);
                } else {
                        dev_warn(dev, "%s reg[%d] %#010llx != %#010llx == fixup(cpu %#010llx); devicetree is broken\n",
                                 reg_name, index, reg_addr, fixup_addr,
                                 (unsigned long long) cpu_phys_addr);
                        reg_addr = fixup_addr;
                }

                return cpu_phys_addr - reg_addr;
        }

I have not seen this "dev_warn(pci->dev, "cpu_addr_fixup() usage detected. Please fix your DTB!\n");"

Frank

>
> Bjorn, thoughts?
>
> - Mani
>
> > Signed-off-by: Frank Li <Frank.Li@nxp.com>
> > ---
> > change from v10 to v11
> > - change to dev_warn()
> > - Bjorn: this is opitional patches to encourage user fix their dtb file.
> >
> > change from v9 to v10
> > - new patch
> > ---
> >  drivers/pci/controller/dwc/pcie-designware.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
> > index 8b546131b97f6..d4dc8bf06d4c1 100644
> > --- a/drivers/pci/controller/dwc/pcie-designware.c
> > +++ b/drivers/pci/controller/dwc/pcie-designware.c
> > @@ -1125,6 +1125,8 @@ int dw_pcie_init_parent_bus_offset(struct dw_pcie *pci, const char *reg_name,
> >
> >  	fixup = pci->ops->cpu_addr_fixup;
> >  	if (fixup) {
> > +		dev_warn(pci->dev, "cpu_addr_fixup() usage detected. Please fix your DTB!\n");
> > +
> >  		fixup_addr = fixup(pci, cpu_phy_addr);
> >  		if (reg_addr == fixup_addr) {
> >  			dev_warn(dev, "%#010llx %s reg[%d] == %#010llx; %ps is redundant\n",
> >
> > --
> > 2.34.1
> >
>
> --
> மணிவண்ணன் சதாசிவம்
Re: [PATCH v11 10/11] PCI: dwc: Print warning message when cpu_addr_fixup() exists
Posted by Manivannan Sadhasivam 6 months, 1 week ago
On Thu, Jun 12, 2025 at 11:51:56AM -0400, Frank Li wrote:
> On Thu, Jun 12, 2025 at 08:16:03PM +0530, Manivannan Sadhasivam wrote:
> > On Thu, Mar 13, 2025 at 11:38:46AM -0400, Frank Li wrote:
> > > If the parent 'ranges' property in DT correctly describes the address
> > > translation, the cpu_addr_fixup() callback is not needed. Print a warning
> > > message to inform users to correct their DTB files and prepare to remove
> > > cpu_addr_fixup().
> > >
> >
> > This patch seem to have dropped, but I do see a value in printing the warning to
> > encourage developers/users to fix the DTB in some way. Since we fixed the driver
> > to parse the DT 'ranges' properly, the presence of cpu_addr_fixup() callback
> > indicates that the translation is not properly described in DT. So DT has to be
> > fixed.
> 
> This patch already in mainline with Bjorn's fine tuned at when merge.
> 
> 	fixup = pci->ops ? pci->ops->cpu_addr_fixup : NULL;
>         if (fixup) {
>                 fixup_addr = fixup(pci, cpu_phys_addr);
>                 if (reg_addr == fixup_addr) {
>                         dev_info(dev, "%s reg[%d] %#010llx == %#010llx == fixup(cpu %#010llx); %ps is redundant with this devicetree\n",
>                                  reg_name, index, reg_addr, fixup_addr,
>                                  (unsigned long long) cpu_phys_addr, fixup);
>                 } else {
>                         dev_warn(dev, "%s reg[%d] %#010llx != %#010llx == fixup(cpu %#010llx); devicetree is broken\n",
>                                  reg_name, index, reg_addr, fixup_addr,
>                                  (unsigned long long) cpu_phys_addr);
>                         reg_addr = fixup_addr;
>                 }
> 
>                 return cpu_phys_addr - reg_addr;
>         }
> 
> I have not seen this "dev_warn(pci->dev, "cpu_addr_fixup() usage detected. Please fix your DTB!\n");"
> 

This patch is supposed to add this warning and nothing else.

- Mani

-- 
மணிவண்ணன் சதாசிவம்
Re: [PATCH v11 10/11] PCI: dwc: Print warning message when cpu_addr_fixup() exists
Posted by Frank Li 6 months, 1 week ago
On Thu, Jun 12, 2025 at 09:38:32PM +0530, Manivannan Sadhasivam wrote:
> On Thu, Jun 12, 2025 at 11:51:56AM -0400, Frank Li wrote:
> > On Thu, Jun 12, 2025 at 08:16:03PM +0530, Manivannan Sadhasivam wrote:
> > > On Thu, Mar 13, 2025 at 11:38:46AM -0400, Frank Li wrote:
> > > > If the parent 'ranges' property in DT correctly describes the address
> > > > translation, the cpu_addr_fixup() callback is not needed. Print a warning
> > > > message to inform users to correct their DTB files and prepare to remove
> > > > cpu_addr_fixup().
> > > >
> > >
> > > This patch seem to have dropped, but I do see a value in printing the warning to
> > > encourage developers/users to fix the DTB in some way. Since we fixed the driver
> > > to parse the DT 'ranges' properly, the presence of cpu_addr_fixup() callback
> > > indicates that the translation is not properly described in DT. So DT has to be
> > > fixed.
> >
> > This patch already in mainline with Bjorn's fine tuned at when merge.
> >
> > 	fixup = pci->ops ? pci->ops->cpu_addr_fixup : NULL;
> >         if (fixup) {
> >                 fixup_addr = fixup(pci, cpu_phys_addr);
> >                 if (reg_addr == fixup_addr) {
> >                         dev_info(dev, "%s reg[%d] %#010llx == %#010llx == fixup(cpu %#010llx); %ps is redundant with this devicetree\n",
> >                                  reg_name, index, reg_addr, fixup_addr,
> >                                  (unsigned long long) cpu_phys_addr, fixup);
> >                 } else {
> >                         dev_warn(dev, "%s reg[%d] %#010llx != %#010llx == fixup(cpu %#010llx); devicetree is broken\n",
> >                                  reg_name, index, reg_addr, fixup_addr,
> >                                  (unsigned long long) cpu_phys_addr);
> >                         reg_addr = fixup_addr;
> >                 }
> >
> >                 return cpu_phys_addr - reg_addr;
> >         }
> >
> > I have not seen this "dev_warn(pci->dev, "cpu_addr_fixup() usage detected. Please fix your DTB!\n");"
> >
>
> This patch is supposed to add this warning and nothing else.

We can forget this one. Can help check doorbell patch if you have time

https://lore.kernel.org/imx/202506101649.UpwblcVd-lkp@intel.com/T/#t

Frank

>
> - Mani
>
> --
> மணிவண்ணன் சதாசிவம்
Re: [PATCH v11 10/11] PCI: dwc: Print warning message when cpu_addr_fixup() exists
Posted by Manivannan Sadhasivam 6 months, 1 week ago
On Thu, Jun 12, 2025 at 12:19:04PM -0400, Frank Li wrote:
> On Thu, Jun 12, 2025 at 09:38:32PM +0530, Manivannan Sadhasivam wrote:
> > On Thu, Jun 12, 2025 at 11:51:56AM -0400, Frank Li wrote:
> > > On Thu, Jun 12, 2025 at 08:16:03PM +0530, Manivannan Sadhasivam wrote:
> > > > On Thu, Mar 13, 2025 at 11:38:46AM -0400, Frank Li wrote:
> > > > > If the parent 'ranges' property in DT correctly describes the address
> > > > > translation, the cpu_addr_fixup() callback is not needed. Print a warning
> > > > > message to inform users to correct their DTB files and prepare to remove
> > > > > cpu_addr_fixup().
> > > > >
> > > >
> > > > This patch seem to have dropped, but I do see a value in printing the warning to
> > > > encourage developers/users to fix the DTB in some way. Since we fixed the driver
> > > > to parse the DT 'ranges' properly, the presence of cpu_addr_fixup() callback
> > > > indicates that the translation is not properly described in DT. So DT has to be
> > > > fixed.
> > >
> > > This patch already in mainline with Bjorn's fine tuned at when merge.
> > >
> > > 	fixup = pci->ops ? pci->ops->cpu_addr_fixup : NULL;
> > >         if (fixup) {
> > >                 fixup_addr = fixup(pci, cpu_phys_addr);
> > >                 if (reg_addr == fixup_addr) {
> > >                         dev_info(dev, "%s reg[%d] %#010llx == %#010llx == fixup(cpu %#010llx); %ps is redundant with this devicetree\n",
> > >                                  reg_name, index, reg_addr, fixup_addr,
> > >                                  (unsigned long long) cpu_phys_addr, fixup);
> > >                 } else {
> > >                         dev_warn(dev, "%s reg[%d] %#010llx != %#010llx == fixup(cpu %#010llx); devicetree is broken\n",
> > >                                  reg_name, index, reg_addr, fixup_addr,
> > >                                  (unsigned long long) cpu_phys_addr);
> > >                         reg_addr = fixup_addr;
> > >                 }
> > >
> > >                 return cpu_phys_addr - reg_addr;
> > >         }
> > >
> > > I have not seen this "dev_warn(pci->dev, "cpu_addr_fixup() usage detected. Please fix your DTB!\n");"
> > >
> >
> > This patch is supposed to add this warning and nothing else.
> 
> We can forget this one. Can help check doorbell patch if you have time
> 
> https://lore.kernel.org/imx/202506101649.UpwblcVd-lkp@intel.com/T/#t
> 

I'm going through the queue. Will get to it.

- Mani

-- 
மணிவண்ணன் சதாசிவம்