[PATCH v8 2/5] PCI: dwc: Add support for ELBI resource mapping

Krishna Chaitanya Chundru posted 5 patches 1 month ago
There is a newer version of this series
[PATCH v8 2/5] PCI: dwc: Add support for ELBI resource mapping
Posted by Krishna Chaitanya Chundru 1 month ago
External Local Bus Interface(ELBI) registers are optional registers in
DWC IPs having vendor specific registers.

Since ELBI register space is applicable for all DWC based controllers,
move the resource get code to DWC core and make it optional.

Suggested-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
---
 drivers/pci/controller/dwc/pcie-designware.c | 9 +++++++++
 drivers/pci/controller/dwc/pcie-designware.h | 1 +
 2 files changed, 10 insertions(+)

diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
index 89aad5a08928cc29870ab258d33bee9ff8f83143..4684c671a81bee468f686a83cc992433b38af59d 100644
--- a/drivers/pci/controller/dwc/pcie-designware.c
+++ b/drivers/pci/controller/dwc/pcie-designware.c
@@ -167,6 +167,15 @@ int dw_pcie_get_resources(struct dw_pcie *pci)
 		}
 	}
 
+	if (!pci->elbi_base) {
+		res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "elbi");
+		if (res) {
+			pci->elbi_base = devm_ioremap_resource(pci->dev, res);
+			if (IS_ERR(pci->elbi_base))
+				return PTR_ERR(pci->elbi_base);
+		}
+	}
+
 	/* LLDD is supposed to manually switch the clocks and resets state */
 	if (dw_pcie_cap_is(pci, REQ_RES)) {
 		ret = dw_pcie_get_clocks(pci);
diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
index 00f52d472dcdd794013a865ad6c4c7cc251edb48..ceb022506c3191cd8fe580411526e20cc3758fed 100644
--- a/drivers/pci/controller/dwc/pcie-designware.h
+++ b/drivers/pci/controller/dwc/pcie-designware.h
@@ -492,6 +492,7 @@ struct dw_pcie {
 	resource_size_t		dbi_phys_addr;
 	void __iomem		*dbi_base2;
 	void __iomem		*atu_base;
+	void __iomem		*elbi_base;
 	resource_size_t		atu_phys_addr;
 	size_t			atu_size;
 	resource_size_t		parent_bus_offset;

-- 
2.34.1
Re: [PATCH v8 2/5] PCI: dwc: Add support for ELBI resource mapping
Posted by Manivannan Sadhasivam 1 month ago
On Thu, Aug 28, 2025 at 01:04:23PM GMT, Krishna Chaitanya Chundru wrote:
> External Local Bus Interface(ELBI) registers are optional registers in
> DWC IPs having vendor specific registers.
> 
> Since ELBI register space is applicable for all DWC based controllers,
> move the resource get code to DWC core and make it optional.
> 

As discussed offline, this changes also warrants switching the glue drivers to
use 'dw_pci::elbi' base instead of their own. So I've ammended this commit to
include those changes also while applying (which was straightforward).

- Mani

> Suggested-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
> ---
>  drivers/pci/controller/dwc/pcie-designware.c | 9 +++++++++
>  drivers/pci/controller/dwc/pcie-designware.h | 1 +
>  2 files changed, 10 insertions(+)
> 
> diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
> index 89aad5a08928cc29870ab258d33bee9ff8f83143..4684c671a81bee468f686a83cc992433b38af59d 100644
> --- a/drivers/pci/controller/dwc/pcie-designware.c
> +++ b/drivers/pci/controller/dwc/pcie-designware.c
> @@ -167,6 +167,15 @@ int dw_pcie_get_resources(struct dw_pcie *pci)
>  		}
>  	}
>  
> +	if (!pci->elbi_base) {
> +		res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "elbi");
> +		if (res) {
> +			pci->elbi_base = devm_ioremap_resource(pci->dev, res);
> +			if (IS_ERR(pci->elbi_base))
> +				return PTR_ERR(pci->elbi_base);
> +		}
> +	}
> +
>  	/* LLDD is supposed to manually switch the clocks and resets state */
>  	if (dw_pcie_cap_is(pci, REQ_RES)) {
>  		ret = dw_pcie_get_clocks(pci);
> diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
> index 00f52d472dcdd794013a865ad6c4c7cc251edb48..ceb022506c3191cd8fe580411526e20cc3758fed 100644
> --- a/drivers/pci/controller/dwc/pcie-designware.h
> +++ b/drivers/pci/controller/dwc/pcie-designware.h
> @@ -492,6 +492,7 @@ struct dw_pcie {
>  	resource_size_t		dbi_phys_addr;
>  	void __iomem		*dbi_base2;
>  	void __iomem		*atu_base;
> +	void __iomem		*elbi_base;
>  	resource_size_t		atu_phys_addr;
>  	size_t			atu_size;
>  	resource_size_t		parent_bus_offset;
> 
> -- 
> 2.34.1
> 

-- 
மணிவண்ணன் சதாசிவம்
Re: [PATCH v8 2/5] PCI: dwc: Add support for ELBI resource mapping
Posted by Bjorn Helgaas 4 weeks, 1 day ago
On Mon, Sep 01, 2025 at 07:18:17PM +0530, Manivannan Sadhasivam wrote:
> On Thu, Aug 28, 2025 at 01:04:23PM GMT, Krishna Chaitanya Chundru wrote:
> > External Local Bus Interface(ELBI) registers are optional registers in
> > DWC IPs having vendor specific registers.
> > 
> > Since ELBI register space is applicable for all DWC based controllers,
> > move the resource get code to DWC core and make it optional.
> 
> As discussed offline, this changes also warrants switching the glue
> drivers to use 'dw_pci::elbi' base instead of their own. So I've
> ammended this commit to include those changes also while applying
> (which was straightforward).

I'm glad if we can do this in the DWC core instead of individual
drivers, but in the case of qcom, this changes the mapping from using
devm_pci_remap_cfgspace() to using devm_ioremap_resource():

  qcom_pcie_ep_get_io_resources
    platform_get_resource_byname(pdev, IORESOURCE_MEM, "elbi")
    devm_pci_remap_cfg_resource
      devm_pci_remap_cfgspace
        pci_remap_cfgspace
          ioremap_np                  # (except on arch/arm)

  dw_pcie_get_resources
    platform_get_resource_byname(pdev, IORESOURCE_MEM, "elbi")
    devm_ioremap_resource
      __devm_ioremap_resource(..., DEVM_IOREMAP)
        __devm_ioremap
          switch (type)
          case DEVM_IOREMAP: ioremap

I assume this change from ioremap_np() to ioremap() is fine, but
please verify and update the commit log to mention this change and
explain why it's ok.

(I don't think the qcom changes were posted to the mailing list; you
can see them here:
https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/commit/?h=controller/dwc-ecam&id=d39e0103e38f9889271a77a837b6179b42d6730d)

> > Suggested-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> > Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> > Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
> > ---
> >  drivers/pci/controller/dwc/pcie-designware.c | 9 +++++++++
> >  drivers/pci/controller/dwc/pcie-designware.h | 1 +
> >  2 files changed, 10 insertions(+)
> > 
> > diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
> > index 89aad5a08928cc29870ab258d33bee9ff8f83143..4684c671a81bee468f686a83cc992433b38af59d 100644
> > --- a/drivers/pci/controller/dwc/pcie-designware.c
> > +++ b/drivers/pci/controller/dwc/pcie-designware.c
> > @@ -167,6 +167,15 @@ int dw_pcie_get_resources(struct dw_pcie *pci)
> >  		}
> >  	}
> >  
> > +	if (!pci->elbi_base) {
> > +		res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "elbi");
> > +		if (res) {
> > +			pci->elbi_base = devm_ioremap_resource(pci->dev, res);
> > +			if (IS_ERR(pci->elbi_base))
> > +				return PTR_ERR(pci->elbi_base);
> > +		}
> > +	}
> > +
> >  	/* LLDD is supposed to manually switch the clocks and resets state */
> >  	if (dw_pcie_cap_is(pci, REQ_RES)) {
> >  		ret = dw_pcie_get_clocks(pci);
> > diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
> > index 00f52d472dcdd794013a865ad6c4c7cc251edb48..ceb022506c3191cd8fe580411526e20cc3758fed 100644
> > --- a/drivers/pci/controller/dwc/pcie-designware.h
> > +++ b/drivers/pci/controller/dwc/pcie-designware.h
> > @@ -492,6 +492,7 @@ struct dw_pcie {
> >  	resource_size_t		dbi_phys_addr;
> >  	void __iomem		*dbi_base2;
> >  	void __iomem		*atu_base;
> > +	void __iomem		*elbi_base;
> >  	resource_size_t		atu_phys_addr;
> >  	size_t			atu_size;
> >  	resource_size_t		parent_bus_offset;
> > 
> > -- 
> > 2.34.1
> > 
> 
> -- 
> மணிவண்ணன் சதாசிவம்
Re: [PATCH v8 2/5] PCI: dwc: Add support for ELBI resource mapping
Posted by Manivannan Sadhasivam 1 month ago
On Thu, Aug 28, 2025 at 01:04:23PM GMT, Krishna Chaitanya Chundru wrote:
> External Local Bus Interface(ELBI) registers are optional registers in
> DWC IPs having vendor specific registers.
> 
> Since ELBI register space is applicable for all DWC based controllers,
> move the resource get code to DWC core and make it optional.
> 
> Suggested-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
> ---
>  drivers/pci/controller/dwc/pcie-designware.c | 9 +++++++++
>  drivers/pci/controller/dwc/pcie-designware.h | 1 +
>  2 files changed, 10 insertions(+)
> 
> diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
> index 89aad5a08928cc29870ab258d33bee9ff8f83143..4684c671a81bee468f686a83cc992433b38af59d 100644
> --- a/drivers/pci/controller/dwc/pcie-designware.c
> +++ b/drivers/pci/controller/dwc/pcie-designware.c
> @@ -167,6 +167,15 @@ int dw_pcie_get_resources(struct dw_pcie *pci)
>  		}
>  	}
>  
> +	if (!pci->elbi_base) {

Why this check is needed? Are we expecting any DWC glue drivers to supply
'dw_pcie::elbi_base' on their own?

- Mani

-- 
மணிவண்ணன் சதாசிவம்
Re: [PATCH v8 2/5] PCI: dwc: Add support for ELBI resource mapping
Posted by Krishna Chaitanya Chundru 1 month ago

On 8/31/2025 5:18 PM, Manivannan Sadhasivam wrote:
> On Thu, Aug 28, 2025 at 01:04:23PM GMT, Krishna Chaitanya Chundru wrote:
>> External Local Bus Interface(ELBI) registers are optional registers in
>> DWC IPs having vendor specific registers.
>>
>> Since ELBI register space is applicable for all DWC based controllers,
>> move the resource get code to DWC core and make it optional.
>>
>> Suggested-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
>> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
>> Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
>> ---
>>   drivers/pci/controller/dwc/pcie-designware.c | 9 +++++++++
>>   drivers/pci/controller/dwc/pcie-designware.h | 1 +
>>   2 files changed, 10 insertions(+)
>>
>> diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
>> index 89aad5a08928cc29870ab258d33bee9ff8f83143..4684c671a81bee468f686a83cc992433b38af59d 100644
>> --- a/drivers/pci/controller/dwc/pcie-designware.c
>> +++ b/drivers/pci/controller/dwc/pcie-designware.c
>> @@ -167,6 +167,15 @@ int dw_pcie_get_resources(struct dw_pcie *pci)
>>   		}
>>   	}
>>   
>> +	if (!pci->elbi_base) {
> 
> Why this check is needed? Are we expecting any DWC glue drivers to supply
> 'dw_pcie::elbi_base' on their own?
> 
I was following the same way that existed for for dbi_base, where we are
allowing DWC glue drivers to supply if they had any different approach
like ./pci-dra7xx.c driver.

- Krishna Chaitanya.
> - Mani
>
Re: [PATCH v8 2/5] PCI: dwc: Add support for ELBI resource mapping
Posted by Manivannan Sadhasivam 1 month ago
On Mon, Sep 01, 2025 at 12:25:58PM GMT, Krishna Chaitanya Chundru wrote:
> 
> 
> On 8/31/2025 5:18 PM, Manivannan Sadhasivam wrote:
> > On Thu, Aug 28, 2025 at 01:04:23PM GMT, Krishna Chaitanya Chundru wrote:
> > > External Local Bus Interface(ELBI) registers are optional registers in
> > > DWC IPs having vendor specific registers.
> > > 
> > > Since ELBI register space is applicable for all DWC based controllers,
> > > move the resource get code to DWC core and make it optional.
> > > 
> > > Suggested-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> > > Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> > > Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
> > > ---
> > >   drivers/pci/controller/dwc/pcie-designware.c | 9 +++++++++
> > >   drivers/pci/controller/dwc/pcie-designware.h | 1 +
> > >   2 files changed, 10 insertions(+)
> > > 
> > > diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
> > > index 89aad5a08928cc29870ab258d33bee9ff8f83143..4684c671a81bee468f686a83cc992433b38af59d 100644
> > > --- a/drivers/pci/controller/dwc/pcie-designware.c
> > > +++ b/drivers/pci/controller/dwc/pcie-designware.c
> > > @@ -167,6 +167,15 @@ int dw_pcie_get_resources(struct dw_pcie *pci)
> > >   		}
> > >   	}
> > > +	if (!pci->elbi_base) {
> > 
> > Why this check is needed? Are we expecting any DWC glue drivers to supply
> > 'dw_pcie::elbi_base' on their own?
> > 
> I was following the same way that existed for for dbi_base, where we are
> allowing DWC glue drivers to supply if they had any different approach
> like ./pci-dra7xx.c driver.
> 

DBI is special because vendor glue drivers were using different name other than
'dbi' in DT. But for ELBI, all (both Exynos and Qcom EP) are using 'elbi' only.

- Mani

-- 
மணிவண்ணன் சதாசிவம்
Re: [PATCH v8 2/5] PCI: dwc: Add support for ELBI resource mapping
Posted by Manivannan Sadhasivam 1 month ago
On Mon, Sep 01, 2025 at 12:25:58PM GMT, Krishna Chaitanya Chundru wrote:
> 
> 
> On 8/31/2025 5:18 PM, Manivannan Sadhasivam wrote:
> > On Thu, Aug 28, 2025 at 01:04:23PM GMT, Krishna Chaitanya Chundru wrote:
> > > External Local Bus Interface(ELBI) registers are optional registers in
> > > DWC IPs having vendor specific registers.
> > > 
> > > Since ELBI register space is applicable for all DWC based controllers,
> > > move the resource get code to DWC core and make it optional.
> > > 
> > > Suggested-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> > > Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> > > Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
> > > ---
> > >   drivers/pci/controller/dwc/pcie-designware.c | 9 +++++++++
> > >   drivers/pci/controller/dwc/pcie-designware.h | 1 +
> > >   2 files changed, 10 insertions(+)
> > > 
> > > diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
> > > index 89aad5a08928cc29870ab258d33bee9ff8f83143..4684c671a81bee468f686a83cc992433b38af59d 100644
> > > --- a/drivers/pci/controller/dwc/pcie-designware.c
> > > +++ b/drivers/pci/controller/dwc/pcie-designware.c
> > > @@ -167,6 +167,15 @@ int dw_pcie_get_resources(struct dw_pcie *pci)
> > >   		}
> > >   	}
> > > +	if (!pci->elbi_base) {
> > 
> > Why this check is needed? Are we expecting any DWC glue drivers to supply
> > 'dw_pcie::elbi_base' on their own?
> > 
> I was following the same way that existed for for dbi_base, where we are
> allowing DWC glue drivers to supply if they had any different approach
> like ./pci-dra7xx.c driver.
> 

That's because the glue drivers were using different dbi resource name in DT.
But for ELBI, we have so far seen only 'elbi'. So there is no need to allow
override.

I will remove this check while applying.

- Mani

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