linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH dwc-next v2 0/2] PCI: dwc: remove useless dw_pcie_ops
@ 2020-11-20 11:16 Jisheng Zhang
  2020-11-20 11:17 ` [PATCH dwc-next v2 2/2] PCI: dwc: al: Remove " Jisheng Zhang
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Jisheng Zhang @ 2020-11-20 11:16 UTC (permalink / raw)
  To: Jonathan Chocron, Lorenzo Pieralisi, Rob Herring, Bjorn Helgaas,
	Jingoo Han, Gustavo Pimentel
  Cc: linux-pci, linux-kernel

Some designware based device driver especially host only driver may
work well with the default read_dbi/write_dbi/link_up implementation
in pcie-designware.c, thus remove the assumption to simplify those
drivers.

Since v1:
  - rebase to the latest dwc-next

Jisheng Zhang (2):
  PCI: dwc: Don't assume the ops in dw_pcie always exists
  PCI: dwc: al: Remove useless dw_pcie_ops

 drivers/pci/controller/dwc/pcie-al.c              |  4 ----
 drivers/pci/controller/dwc/pcie-designware-ep.c   |  8 +++-----
 drivers/pci/controller/dwc/pcie-designware-host.c |  2 +-
 drivers/pci/controller/dwc/pcie-designware.c      | 14 +++++++-------
 4 files changed, 11 insertions(+), 17 deletions(-)

-- 
2.29.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH dwc-next v2 2/2] PCI: dwc: al: Remove useless dw_pcie_ops
  2020-11-20 11:16 [PATCH dwc-next v2 0/2] PCI: dwc: remove useless dw_pcie_ops Jisheng Zhang
@ 2020-11-20 11:17 ` Jisheng Zhang
  2021-01-25 20:57   ` Chocron, Jonathan
  2020-11-20 11:17 ` [PATCH dwc-next v2 1/2] PCI: dwc: Don't assume the ops in dw_pcie always exists Jisheng Zhang
  2021-01-25 16:25 ` [PATCH dwc-next v2 0/2] PCI: dwc: remove useless dw_pcie_ops Lorenzo Pieralisi
  2 siblings, 1 reply; 5+ messages in thread
From: Jisheng Zhang @ 2020-11-20 11:17 UTC (permalink / raw)
  To: Jonathan Chocron, Lorenzo Pieralisi, Rob Herring, Bjorn Helgaas,
	Jingoo Han, Gustavo Pimentel
  Cc: linux-pci, linux-kernel

We have removed the dw_pcie_ops always exists assumption in dwc
core driver, we can remove the useless dw_pcie_ops now.

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
---
 drivers/pci/controller/dwc/pcie-al.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-al.c b/drivers/pci/controller/dwc/pcie-al.c
index 7ac8a37d9ce0..36977c48a7ae 100644
--- a/drivers/pci/controller/dwc/pcie-al.c
+++ b/drivers/pci/controller/dwc/pcie-al.c
@@ -322,9 +322,6 @@ static const struct dw_pcie_host_ops al_pcie_host_ops = {
 	.host_init = al_pcie_host_init,
 };
 
-static const struct dw_pcie_ops dw_pcie_ops = {
-};
-
 static int al_pcie_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -342,7 +339,6 @@ static int al_pcie_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	pci->dev = dev;
-	pci->ops = &dw_pcie_ops;
 	pci->pp.ops = &al_pcie_host_ops;
 
 	al_pcie->pci = pci;
-- 
2.29.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH dwc-next v2 1/2] PCI: dwc: Don't assume the ops in dw_pcie always exists
  2020-11-20 11:16 [PATCH dwc-next v2 0/2] PCI: dwc: remove useless dw_pcie_ops Jisheng Zhang
  2020-11-20 11:17 ` [PATCH dwc-next v2 2/2] PCI: dwc: al: Remove " Jisheng Zhang
@ 2020-11-20 11:17 ` Jisheng Zhang
  2021-01-25 16:25 ` [PATCH dwc-next v2 0/2] PCI: dwc: remove useless dw_pcie_ops Lorenzo Pieralisi
  2 siblings, 0 replies; 5+ messages in thread
From: Jisheng Zhang @ 2020-11-20 11:17 UTC (permalink / raw)
  To: Jonathan Chocron, Lorenzo Pieralisi, Rob Herring, Bjorn Helgaas,
	Jingoo Han, Gustavo Pimentel
  Cc: linux-pci, linux-kernel

Some designware based device driver especially host only driver may
work well with the default read_dbi/write_dbi/link_up implementation
in pcie-designware.c, thus remove the assumption to simplify those
drivers.

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
---
 drivers/pci/controller/dwc/pcie-designware-ep.c   |  8 +++-----
 drivers/pci/controller/dwc/pcie-designware-host.c |  2 +-
 drivers/pci/controller/dwc/pcie-designware.c      | 14 +++++++-------
 3 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
index bcd1cd9ba8c8..1c25d8337151 100644
--- a/drivers/pci/controller/dwc/pcie-designware-ep.c
+++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
@@ -434,10 +434,8 @@ static void dw_pcie_ep_stop(struct pci_epc *epc)
 	struct dw_pcie_ep *ep = epc_get_drvdata(epc);
 	struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
 
-	if (!pci->ops->stop_link)
-		return;
-
-	pci->ops->stop_link(pci);
+	if (pci->ops && pci->ops->stop_link)
+		pci->ops->stop_link(pci);
 }
 
 static int dw_pcie_ep_start(struct pci_epc *epc)
@@ -445,7 +443,7 @@ static int dw_pcie_ep_start(struct pci_epc *epc)
 	struct dw_pcie_ep *ep = epc_get_drvdata(epc);
 	struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
 
-	if (!pci->ops->start_link)
+	if (!pci->ops || !pci->ops->start_link)
 		return -EINVAL;
 
 	return pci->ops->start_link(pci);
diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index e1db9056df0b..082ff75b14c4 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -420,7 +420,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 
 	dw_pcie_setup_rc(pp);
 
-	if (!dw_pcie_link_up(pci) && pci->ops->start_link) {
+	if (!dw_pcie_link_up(pci) && pci->ops && pci->ops->start_link) {
 		ret = pci->ops->start_link(pci);
 		if (ret)
 			goto err_free_msi;
diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
index 645fa1892375..cf895c12f71f 100644
--- a/drivers/pci/controller/dwc/pcie-designware.c
+++ b/drivers/pci/controller/dwc/pcie-designware.c
@@ -141,7 +141,7 @@ u32 dw_pcie_read_dbi(struct dw_pcie *pci, u32 reg, size_t size)
 	int ret;
 	u32 val;
 
-	if (pci->ops->read_dbi)
+	if (pci->ops && pci->ops->read_dbi)
 		return pci->ops->read_dbi(pci, pci->dbi_base, reg, size);
 
 	ret = dw_pcie_read(pci->dbi_base + reg, size, &val);
@@ -156,7 +156,7 @@ void dw_pcie_write_dbi(struct dw_pcie *pci, u32 reg, size_t size, u32 val)
 {
 	int ret;
 
-	if (pci->ops->write_dbi) {
+	if (pci->ops && pci->ops->write_dbi) {
 		pci->ops->write_dbi(pci, pci->dbi_base, reg, size, val);
 		return;
 	}
@@ -171,7 +171,7 @@ void dw_pcie_write_dbi2(struct dw_pcie *pci, u32 reg, size_t size, u32 val)
 {
 	int ret;
 
-	if (pci->ops->write_dbi2) {
+	if (pci->ops && pci->ops->write_dbi2) {
 		pci->ops->write_dbi2(pci, pci->dbi_base2, reg, size, val);
 		return;
 	}
@@ -186,7 +186,7 @@ static u32 dw_pcie_readl_atu(struct dw_pcie *pci, u32 reg)
 	int ret;
 	u32 val;
 
-	if (pci->ops->read_dbi)
+	if (pci->ops && pci->ops->read_dbi)
 		return pci->ops->read_dbi(pci, pci->atu_base, reg, 4);
 
 	ret = dw_pcie_read(pci->atu_base + reg, 4, &val);
@@ -200,7 +200,7 @@ static void dw_pcie_writel_atu(struct dw_pcie *pci, u32 reg, u32 val)
 {
 	int ret;
 
-	if (pci->ops->write_dbi) {
+	if (pci->ops && pci->ops->write_dbi) {
 		pci->ops->write_dbi(pci, pci->atu_base, reg, 4, val);
 		return;
 	}
@@ -273,7 +273,7 @@ static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no,
 {
 	u32 retries, val;
 
-	if (pci->ops->cpu_addr_fixup)
+	if (pci->ops && pci->ops->cpu_addr_fixup)
 		cpu_addr = pci->ops->cpu_addr_fixup(pci, cpu_addr);
 
 	if (pci->iatu_unroll_enabled) {
@@ -481,7 +481,7 @@ int dw_pcie_link_up(struct dw_pcie *pci)
 {
 	u32 val;
 
-	if (pci->ops->link_up)
+	if (pci->ops && pci->ops->link_up)
 		return pci->ops->link_up(pci);
 
 	val = readl(pci->dbi_base + PCIE_PORT_DEBUG1);
-- 
2.29.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH dwc-next v2 0/2] PCI: dwc: remove useless dw_pcie_ops
  2020-11-20 11:16 [PATCH dwc-next v2 0/2] PCI: dwc: remove useless dw_pcie_ops Jisheng Zhang
  2020-11-20 11:17 ` [PATCH dwc-next v2 2/2] PCI: dwc: al: Remove " Jisheng Zhang
  2020-11-20 11:17 ` [PATCH dwc-next v2 1/2] PCI: dwc: Don't assume the ops in dw_pcie always exists Jisheng Zhang
@ 2021-01-25 16:25 ` Lorenzo Pieralisi
  2 siblings, 0 replies; 5+ messages in thread
From: Lorenzo Pieralisi @ 2021-01-25 16:25 UTC (permalink / raw)
  To: Jisheng Zhang
  Cc: Jonathan Chocron, Rob Herring, Bjorn Helgaas, Jingoo Han,
	Gustavo Pimentel, linux-pci, linux-kernel

On Fri, Nov 20, 2020 at 07:16:11PM +0800, Jisheng Zhang wrote:
> Some designware based device driver especially host only driver may
> work well with the default read_dbi/write_dbi/link_up implementation
> in pcie-designware.c, thus remove the assumption to simplify those
> drivers.
> 
> Since v1:
>   - rebase to the latest dwc-next
> 
> Jisheng Zhang (2):
>   PCI: dwc: Don't assume the ops in dw_pcie always exists
>   PCI: dwc: al: Remove useless dw_pcie_ops
> 
>  drivers/pci/controller/dwc/pcie-al.c              |  4 ----
>  drivers/pci/controller/dwc/pcie-designware-ep.c   |  8 +++-----
>  drivers/pci/controller/dwc/pcie-designware-host.c |  2 +-
>  drivers/pci/controller/dwc/pcie-designware.c      | 14 +++++++-------
>  4 files changed, 11 insertions(+), 17 deletions(-)

Would you mind rebasing it against my current pci/dwc branch please ?

I shall apply it then.

Thanks,
Lorenzo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH dwc-next v2 2/2] PCI: dwc: al: Remove useless dw_pcie_ops
  2020-11-20 11:17 ` [PATCH dwc-next v2 2/2] PCI: dwc: al: Remove " Jisheng Zhang
@ 2021-01-25 20:57   ` Chocron, Jonathan
  0 siblings, 0 replies; 5+ messages in thread
From: Chocron, Jonathan @ 2021-01-25 20:57 UTC (permalink / raw)
  To: robh, jingoohan1, lorenzo.pieralisi, bhelgaas, Jisheng.Zhang,
	gustavo.pimentel
  Cc: linux-kernel, linux-pci

On Fri, 2020-11-20 at 19:17 +0800, Jisheng Zhang wrote:
> CAUTION: This email originated from outside of the organization. Do
> not click links or open attachments unless you can confirm the sender
> and know the content is safe.
> 
> 
> 
> We have removed the dw_pcie_ops always exists assumption in dwc
> core driver, we can remove the useless dw_pcie_ops now.
> 
> Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
> ---
>  drivers/pci/controller/dwc/pcie-al.c | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/drivers/pci/controller/dwc/pcie-al.c
> b/drivers/pci/controller/dwc/pcie-al.c
> index 7ac8a37d9ce0..36977c48a7ae 100644
> --- a/drivers/pci/controller/dwc/pcie-al.c
> +++ b/drivers/pci/controller/dwc/pcie-al.c
> @@ -322,9 +322,6 @@ static const struct dw_pcie_host_ops
> al_pcie_host_ops = {
>         .host_init = al_pcie_host_init,
>  };
> 
> -static const struct dw_pcie_ops dw_pcie_ops = {
> -};
> -
>  static int al_pcie_probe(struct platform_device *pdev)
>  {
>         struct device *dev = &pdev->dev;
> @@ -342,7 +339,6 @@ static int al_pcie_probe(struct platform_device
> *pdev)
>                 return -ENOMEM;
> 
>         pci->dev = dev;
> -       pci->ops = &dw_pcie_ops;
>         pci->pp.ops = &al_pcie_host_ops;
> 
>         al_pcie->pci = pci;
> --
> 2.29.2
> 

Acked-by: Jonathan Chocron <jonnyc@amazon.com>


Thanks,
   Jonathan

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-01-25 20:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-20 11:16 [PATCH dwc-next v2 0/2] PCI: dwc: remove useless dw_pcie_ops Jisheng Zhang
2020-11-20 11:17 ` [PATCH dwc-next v2 2/2] PCI: dwc: al: Remove " Jisheng Zhang
2021-01-25 20:57   ` Chocron, Jonathan
2020-11-20 11:17 ` [PATCH dwc-next v2 1/2] PCI: dwc: Don't assume the ops in dw_pcie always exists Jisheng Zhang
2021-01-25 16:25 ` [PATCH dwc-next v2 0/2] PCI: dwc: remove useless dw_pcie_ops Lorenzo Pieralisi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).