linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] PCI: dwc: Add support to add GEN3 related equalization quirks
       [not found] <CGME20190913104018epcas5p3d93265a6786dc2b7b8a7d3231bfe9c14@epcas5p3.samsung.com>
@ 2019-09-13 10:39 ` Pankaj Dubey
  2019-09-16  9:16   ` Gustavo Pimentel
  2019-09-16 10:15   ` Andrew Murray
  0 siblings, 2 replies; 14+ messages in thread
From: Pankaj Dubey @ 2019-09-13 10:39 UTC (permalink / raw)
  To: linux-pci, linux-kernel
  Cc: jingoohan1, gustavo.pimentel, lorenzo.pieralisi, bhelgaas,
	andrew.murray, Anvesh Salveru, Pankaj Dubey

From: Anvesh Salveru <anvesh.s@samsung.com>

In some platforms, PCIe PHY may have issues which will prevent linkup
to happen in GEN3 or higher speed. In case equalization fails, link will
fallback to GEN1.

DesignWare controller gives flexibility to disable GEN3 equalization
completely or only phase 2 and 3 of equalization.

This patch enables the DesignWare driver to disable the PCIe GEN3
equalization by enabling one of the following quirks:
 - DWC_EQUALIZATION_DISABLE: To disable GEN3 equalization all phases
 - DWC_EQ_PHASE_2_3_DISABLE: To disable GEN3 equalization phase 2 & 3

Platform drivers can set these quirks via "quirk" variable of "dw_pcie"
struct.

Signed-off-by: Anvesh Salveru <anvesh.s@samsung.com>
Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
---
Patchset v1 can be found at:
 - 1/2: https://lkml.org/lkml/2019/9/10/443
 - 2/2: https://lkml.org/lkml/2019/9/10/444

Changes w.r.t v1:
 - Squashed two patches from v1 into one as suggested by Gustavo
 - Addressed review comments from Andrew

 drivers/pci/controller/dwc/pcie-designware.c | 12 ++++++++++++
 drivers/pci/controller/dwc/pcie-designware.h |  9 +++++++++
 2 files changed, 21 insertions(+)

diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
index 7d25102..97fb18d 100644
--- a/drivers/pci/controller/dwc/pcie-designware.c
+++ b/drivers/pci/controller/dwc/pcie-designware.c
@@ -466,4 +466,16 @@ void dw_pcie_setup(struct dw_pcie *pci)
 		break;
 	}
 	dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, val);
+
+	if (pci->quirk & DWC_EQUALIZATION_DISABLE) {
+		val = dw_pcie_readl_dbi(pci, PCIE_PORT_GEN3_RELATED);
+		val |= PORT_LOGIC_GEN3_EQ_DISABLE;
+		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED, val);
+	}
+
+	if (pci->quirk & DWC_EQ_PHASE_2_3_DISABLE) {
+		val = dw_pcie_readl_dbi(pci, PCIE_PORT_GEN3_RELATED);
+		val |= PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE;
+		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED, val);
+	}
 }
diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
index ffed084..e428b62 100644
--- a/drivers/pci/controller/dwc/pcie-designware.h
+++ b/drivers/pci/controller/dwc/pcie-designware.h
@@ -29,6 +29,10 @@
 #define LINK_WAIT_MAX_IATU_RETRIES	5
 #define LINK_WAIT_IATU			9
 
+/* Parameters for GEN3 related quirks */
+#define DWC_EQUALIZATION_DISABLE	BIT(1)
+#define DWC_EQ_PHASE_2_3_DISABLE	BIT(2)
+
 /* Synopsys-specific PCIe configuration registers */
 #define PCIE_PORT_LINK_CONTROL		0x710
 #define PORT_LINK_MODE_MASK		GENMASK(21, 16)
@@ -60,6 +64,10 @@
 #define PCIE_MSI_INTR0_MASK		0x82C
 #define PCIE_MSI_INTR0_STATUS		0x830
 
+#define PCIE_PORT_GEN3_RELATED		0x890
+#define PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE	BIT(9)
+#define PORT_LOGIC_GEN3_EQ_DISABLE		BIT(16)
+
 #define PCIE_ATU_VIEWPORT		0x900
 #define PCIE_ATU_REGION_INBOUND		BIT(31)
 #define PCIE_ATU_REGION_OUTBOUND	0
@@ -244,6 +252,7 @@ struct dw_pcie {
 	struct dw_pcie_ep	ep;
 	const struct dw_pcie_ops *ops;
 	unsigned int		version;
+	unsigned int		quirk;
 };
 
 #define to_dw_pcie_from_pp(port) container_of((port), struct dw_pcie, pp)
-- 
2.7.4


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

* RE: [PATCH v2] PCI: dwc: Add support to add GEN3 related equalization quirks
  2019-09-13 10:39 ` [PATCH v2] PCI: dwc: Add support to add GEN3 related equalization quirks Pankaj Dubey
@ 2019-09-16  9:16   ` Gustavo Pimentel
  2019-09-16 10:15   ` Andrew Murray
  1 sibling, 0 replies; 14+ messages in thread
From: Gustavo Pimentel @ 2019-09-16  9:16 UTC (permalink / raw)
  To: Pankaj Dubey, linux-pci, linux-kernel
  Cc: jingoohan1, gustavo.pimentel@synopsys.com, lorenzo.pieralisi,
	bhelgaas, andrew.murray, Anvesh Salveru

On Fri, Sep 13, 2019 at 11:39:50, Pankaj Dubey <pankaj.dubey@samsung.com> 
wrote:

> From: Anvesh Salveru <anvesh.s@samsung.com>
> 
> In some platforms, PCIe PHY may have issues which will prevent linkup
> to happen in GEN3 or higher speed. In case equalization fails, link will
> fallback to GEN1.
> 
> DesignWare controller gives flexibility to disable GEN3 equalization
> completely or only phase 2 and 3 of equalization.
> 
> This patch enables the DesignWare driver to disable the PCIe GEN3
> equalization by enabling one of the following quirks:
>  - DWC_EQUALIZATION_DISABLE: To disable GEN3 equalization all phases
>  - DWC_EQ_PHASE_2_3_DISABLE: To disable GEN3 equalization phase 2 & 3
> 
> Platform drivers can set these quirks via "quirk" variable of "dw_pcie"
> struct.
> 
> Signed-off-by: Anvesh Salveru <anvesh.s@samsung.com>
> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> ---
> Patchset v1 can be found at:
>  - 1/2: https://urldefense.proofpoint.com/v2/url?u=https-3A__lkml.org_lkml_2019_9_10_443&d=DwIBaQ&c=DPL6_X_6JkXFx7AXWqB0tg&r=bkWxpLoW-f-E3EdiDCCa0_h0PicsViasSlvIpzZvPxs&m=5Bl547vvEgw0xPMh4kZvKIUj2nsu5wQxtXk6lj0J0X8&s=r0J-EATorWbw9L2P4gG0zUt1jqKDCyYY7B5zcZutnP0&e= 
>  - 2/2: https://urldefense.proofpoint.com/v2/url?u=https-3A__lkml.org_lkml_2019_9_10_444&d=DwIBaQ&c=DPL6_X_6JkXFx7AXWqB0tg&r=bkWxpLoW-f-E3EdiDCCa0_h0PicsViasSlvIpzZvPxs&m=5Bl547vvEgw0xPMh4kZvKIUj2nsu5wQxtXk6lj0J0X8&s=Ii2svOQQzPyci6Gztr3_-RlCe_Fzv-lCavUYhHwZvbA&e= 
> 
> Changes w.r.t v1:
>  - Squashed two patches from v1 into one as suggested by Gustavo
>  - Addressed review comments from Andrew
> 
>  drivers/pci/controller/dwc/pcie-designware.c | 12 ++++++++++++
>  drivers/pci/controller/dwc/pcie-designware.h |  9 +++++++++
>  2 files changed, 21 insertions(+)
> 
> diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
> index 7d25102..97fb18d 100644
> --- a/drivers/pci/controller/dwc/pcie-designware.c
> +++ b/drivers/pci/controller/dwc/pcie-designware.c
> @@ -466,4 +466,16 @@ void dw_pcie_setup(struct dw_pcie *pci)
>  		break;
>  	}
>  	dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, val);
> +
> +	if (pci->quirk & DWC_EQUALIZATION_DISABLE) {
> +		val = dw_pcie_readl_dbi(pci, PCIE_PORT_GEN3_RELATED);
> +		val |= PORT_LOGIC_GEN3_EQ_DISABLE;
> +		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED, val);
> +	}
> +
> +	if (pci->quirk & DWC_EQ_PHASE_2_3_DISABLE) {
> +		val = dw_pcie_readl_dbi(pci, PCIE_PORT_GEN3_RELATED);
> +		val |= PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE;
> +		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED, val);
> +	}
>  }
> diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
> index ffed084..e428b62 100644
> --- a/drivers/pci/controller/dwc/pcie-designware.h
> +++ b/drivers/pci/controller/dwc/pcie-designware.h
> @@ -29,6 +29,10 @@
>  #define LINK_WAIT_MAX_IATU_RETRIES	5
>  #define LINK_WAIT_IATU			9
>  
> +/* Parameters for GEN3 related quirks */
> +#define DWC_EQUALIZATION_DISABLE	BIT(1)
> +#define DWC_EQ_PHASE_2_3_DISABLE	BIT(2)
> +
>  /* Synopsys-specific PCIe configuration registers */
>  #define PCIE_PORT_LINK_CONTROL		0x710
>  #define PORT_LINK_MODE_MASK		GENMASK(21, 16)
> @@ -60,6 +64,10 @@
>  #define PCIE_MSI_INTR0_MASK		0x82C
>  #define PCIE_MSI_INTR0_STATUS		0x830
>  
> +#define PCIE_PORT_GEN3_RELATED		0x890
> +#define PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE	BIT(9)
> +#define PORT_LOGIC_GEN3_EQ_DISABLE		BIT(16)
> +
>  #define PCIE_ATU_VIEWPORT		0x900
>  #define PCIE_ATU_REGION_INBOUND		BIT(31)
>  #define PCIE_ATU_REGION_OUTBOUND	0
> @@ -244,6 +252,7 @@ struct dw_pcie {
>  	struct dw_pcie_ep	ep;
>  	const struct dw_pcie_ops *ops;
>  	unsigned int		version;
> +	unsigned int		quirk;
>  };
>  
>  #define to_dw_pcie_from_pp(port) container_of((port), struct dw_pcie, pp)
> -- 
> 2.7.4


Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>



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

* Re: [PATCH v2] PCI: dwc: Add support to add GEN3 related equalization quirks
  2019-09-13 10:39 ` [PATCH v2] PCI: dwc: Add support to add GEN3 related equalization quirks Pankaj Dubey
  2019-09-16  9:16   ` Gustavo Pimentel
@ 2019-09-16 10:15   ` Andrew Murray
  2019-09-16 11:06     ` Pankaj Dubey
  1 sibling, 1 reply; 14+ messages in thread
From: Andrew Murray @ 2019-09-16 10:15 UTC (permalink / raw)
  To: Pankaj Dubey
  Cc: linux-pci, linux-kernel, jingoohan1, gustavo.pimentel,
	lorenzo.pieralisi, bhelgaas, Anvesh Salveru

On Fri, Sep 13, 2019 at 04:09:50PM +0530, Pankaj Dubey wrote:
> From: Anvesh Salveru <anvesh.s@samsung.com>
> 
> In some platforms, PCIe PHY may have issues which will prevent linkup
> to happen in GEN3 or higher speed. In case equalization fails, link will
> fallback to GEN1.
> 
> DesignWare controller gives flexibility to disable GEN3 equalization
> completely or only phase 2 and 3 of equalization.
> 
> This patch enables the DesignWare driver to disable the PCIe GEN3
> equalization by enabling one of the following quirks:
>  - DWC_EQUALIZATION_DISABLE: To disable GEN3 equalization all phases
>  - DWC_EQ_PHASE_2_3_DISABLE: To disable GEN3 equalization phase 2 & 3
> 
> Platform drivers can set these quirks via "quirk" variable of "dw_pcie"
> struct.
> 
> Signed-off-by: Anvesh Salveru <anvesh.s@samsung.com>
> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> ---
> Patchset v1 can be found at:
>  - 1/2: https://lkml.org/lkml/2019/9/10/443
>  - 2/2: https://lkml.org/lkml/2019/9/10/444
> 
> Changes w.r.t v1:
>  - Squashed two patches from v1 into one as suggested by Gustavo
>  - Addressed review comments from Andrew
> 
>  drivers/pci/controller/dwc/pcie-designware.c | 12 ++++++++++++
>  drivers/pci/controller/dwc/pcie-designware.h |  9 +++++++++
>  2 files changed, 21 insertions(+)
> 
> diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
> index 7d25102..97fb18d 100644
> --- a/drivers/pci/controller/dwc/pcie-designware.c
> +++ b/drivers/pci/controller/dwc/pcie-designware.c
> @@ -466,4 +466,16 @@ void dw_pcie_setup(struct dw_pcie *pci)
>  		break;
>  	}
>  	dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, val);
> +
> +	if (pci->quirk & DWC_EQUALIZATION_DISABLE) {
> +		val = dw_pcie_readl_dbi(pci, PCIE_PORT_GEN3_RELATED);
> +		val |= PORT_LOGIC_GEN3_EQ_DISABLE;
> +		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED, val);
> +	}
> +
> +	if (pci->quirk & DWC_EQ_PHASE_2_3_DISABLE) {
> +		val = dw_pcie_readl_dbi(pci, PCIE_PORT_GEN3_RELATED);
> +		val |= PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE;
> +		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED, val);
> +	}
>  }
> diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
> index ffed084..e428b62 100644
> --- a/drivers/pci/controller/dwc/pcie-designware.h
> +++ b/drivers/pci/controller/dwc/pcie-designware.h
> @@ -29,6 +29,10 @@
>  #define LINK_WAIT_MAX_IATU_RETRIES	5
>  #define LINK_WAIT_IATU			9
>  
> +/* Parameters for GEN3 related quirks */
> +#define DWC_EQUALIZATION_DISABLE	BIT(1)
> +#define DWC_EQ_PHASE_2_3_DISABLE	BIT(2)
> +
>  /* Synopsys-specific PCIe configuration registers */
>  #define PCIE_PORT_LINK_CONTROL		0x710
>  #define PORT_LINK_MODE_MASK		GENMASK(21, 16)
> @@ -60,6 +64,10 @@
>  #define PCIE_MSI_INTR0_MASK		0x82C
>  #define PCIE_MSI_INTR0_STATUS		0x830
>  
> +#define PCIE_PORT_GEN3_RELATED		0x890

I hadn't noticed this in the previous version - what is the proper
name for this register? Does it end in _RELATED?

Thanks,

Andrew Murray

> +#define PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE	BIT(9)
> +#define PORT_LOGIC_GEN3_EQ_DISABLE		BIT(16)
> +
>  #define PCIE_ATU_VIEWPORT		0x900
>  #define PCIE_ATU_REGION_INBOUND		BIT(31)
>  #define PCIE_ATU_REGION_OUTBOUND	0
> @@ -244,6 +252,7 @@ struct dw_pcie {
>  	struct dw_pcie_ep	ep;
>  	const struct dw_pcie_ops *ops;
>  	unsigned int		version;
> +	unsigned int		quirk;
>  };
>  
>  #define to_dw_pcie_from_pp(port) container_of((port), struct dw_pcie, pp)
> -- 
> 2.7.4
> 

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

* RE: [PATCH v2] PCI: dwc: Add support to add GEN3 related equalization quirks
  2019-09-16 10:15   ` Andrew Murray
@ 2019-09-16 11:06     ` Pankaj Dubey
  2019-09-16 12:24       ` Andrew Murray
  0 siblings, 1 reply; 14+ messages in thread
From: Pankaj Dubey @ 2019-09-16 11:06 UTC (permalink / raw)
  To: 'Andrew Murray'
  Cc: linux-pci, linux-kernel, jingoohan1, gustavo.pimentel,
	lorenzo.pieralisi, bhelgaas, 'Anvesh Salveru'



> -----Original Message-----
> From: Andrew Murray <andrew.murray@arm.com>
> Sent: Monday, September 16, 2019 3:46 PM
> To: Pankaj Dubey <pankaj.dubey@samsung.com>
> Cc: linux-pci@vger.kernel.org; linux-kernel@vger.kernel.org;
> jingoohan1@gmail.com; gustavo.pimentel@synopsys.com;
> lorenzo.pieralisi@arm.com; bhelgaas@google.com; Anvesh Salveru
> <anvesh.s@samsung.com>
> Subject: Re: [PATCH v2] PCI: dwc: Add support to add GEN3 related
equalization
> quirks
> 
> On Fri, Sep 13, 2019 at 04:09:50PM +0530, Pankaj Dubey wrote:
> > From: Anvesh Salveru <anvesh.s@samsung.com>
> >
> > In some platforms, PCIe PHY may have issues which will prevent linkup
> > to happen in GEN3 or higher speed. In case equalization fails, link
> > will fallback to GEN1.
> >
> > DesignWare controller gives flexibility to disable GEN3 equalization
> > completely or only phase 2 and 3 of equalization.
> >
> > This patch enables the DesignWare driver to disable the PCIe GEN3
> > equalization by enabling one of the following quirks:
> >  - DWC_EQUALIZATION_DISABLE: To disable GEN3 equalization all phases
> >  - DWC_EQ_PHASE_2_3_DISABLE: To disable GEN3 equalization phase 2 & 3
> >
> > Platform drivers can set these quirks via "quirk" variable of "dw_pcie"
> > struct.
> >
> > Signed-off-by: Anvesh Salveru <anvesh.s@samsung.com>
> > Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> > ---
> > Patchset v1 can be found at:
> >  - 1/2: https://lkml.org/lkml/2019/9/10/443
> >  - 2/2: https://lkml.org/lkml/2019/9/10/444
> >
> > Changes w.r.t v1:
> >  - Squashed two patches from v1 into one as suggested by Gustavo
> >  - Addressed review comments from Andrew
> >
> >  drivers/pci/controller/dwc/pcie-designware.c | 12 ++++++++++++
> > drivers/pci/controller/dwc/pcie-designware.h |  9 +++++++++
> >  2 files changed, 21 insertions(+)
> >
> > diff --git a/drivers/pci/controller/dwc/pcie-designware.c
> > b/drivers/pci/controller/dwc/pcie-designware.c
> > index 7d25102..97fb18d 100644
> > --- a/drivers/pci/controller/dwc/pcie-designware.c
> > +++ b/drivers/pci/controller/dwc/pcie-designware.c
> > @@ -466,4 +466,16 @@ void dw_pcie_setup(struct dw_pcie *pci)
> >  		break;
> >  	}
> >  	dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, val);
> > +
> > +	if (pci->quirk & DWC_EQUALIZATION_DISABLE) {
> > +		val = dw_pcie_readl_dbi(pci, PCIE_PORT_GEN3_RELATED);
> > +		val |= PORT_LOGIC_GEN3_EQ_DISABLE;
> > +		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED, val);
> > +	}
> > +
> > +	if (pci->quirk & DWC_EQ_PHASE_2_3_DISABLE) {
> > +		val = dw_pcie_readl_dbi(pci, PCIE_PORT_GEN3_RELATED);
> > +		val |= PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE;
> > +		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED, val);
> > +	}
> >  }
> > diff --git a/drivers/pci/controller/dwc/pcie-designware.h
> > b/drivers/pci/controller/dwc/pcie-designware.h
> > index ffed084..e428b62 100644
> > --- a/drivers/pci/controller/dwc/pcie-designware.h
> > +++ b/drivers/pci/controller/dwc/pcie-designware.h
> > @@ -29,6 +29,10 @@
> >  #define LINK_WAIT_MAX_IATU_RETRIES	5
> >  #define LINK_WAIT_IATU			9
> >
> > +/* Parameters for GEN3 related quirks */
> > +#define DWC_EQUALIZATION_DISABLE	BIT(1)
> > +#define DWC_EQ_PHASE_2_3_DISABLE	BIT(2)
> > +
> >  /* Synopsys-specific PCIe configuration registers */
> >  #define PCIE_PORT_LINK_CONTROL		0x710
> >  #define PORT_LINK_MODE_MASK		GENMASK(21, 16)
> > @@ -60,6 +64,10 @@
> >  #define PCIE_MSI_INTR0_MASK		0x82C
> >  #define PCIE_MSI_INTR0_STATUS		0x830
> >
> > +#define PCIE_PORT_GEN3_RELATED		0x890
> 
> I hadn't noticed this in the previous version - what is the proper name
for this
> register? Does it end in _RELATED?

As per SNPS databook the name of the register is "GEN3_RELATED_OFF". It is
port logic register so, to keep similarity with other port logic registers
in this file we named it as "PCIE_PORT_GEN3_RELATED". 

> 
> Thanks,
> 
> Andrew Murray
> 
> > +#define PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE	BIT(9)
> > +#define PORT_LOGIC_GEN3_EQ_DISABLE		BIT(16)
> > +
> >  #define PCIE_ATU_VIEWPORT		0x900
> >  #define PCIE_ATU_REGION_INBOUND		BIT(31)
> >  #define PCIE_ATU_REGION_OUTBOUND	0
> > @@ -244,6 +252,7 @@ struct dw_pcie {
> >  	struct dw_pcie_ep	ep;
> >  	const struct dw_pcie_ops *ops;
> >  	unsigned int		version;
> > +	unsigned int		quirk;
> >  };
> >
> >  #define to_dw_pcie_from_pp(port) container_of((port), struct dw_pcie,
> > pp)
> > --
> > 2.7.4
> >


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

* Re: [PATCH v2] PCI: dwc: Add support to add GEN3 related equalization quirks
  2019-09-16 11:06     ` Pankaj Dubey
@ 2019-09-16 12:24       ` Andrew Murray
  2019-09-16 12:52         ` Gustavo Pimentel
  0 siblings, 1 reply; 14+ messages in thread
From: Andrew Murray @ 2019-09-16 12:24 UTC (permalink / raw)
  To: Pankaj Dubey
  Cc: linux-pci, linux-kernel, jingoohan1, gustavo.pimentel,
	lorenzo.pieralisi, bhelgaas, 'Anvesh Salveru'

On Mon, Sep 16, 2019 at 04:36:33PM +0530, Pankaj Dubey wrote:
> 
> 
> > -----Original Message-----
> > From: Andrew Murray <andrew.murray@arm.com>
> > Sent: Monday, September 16, 2019 3:46 PM
> > To: Pankaj Dubey <pankaj.dubey@samsung.com>
> > Cc: linux-pci@vger.kernel.org; linux-kernel@vger.kernel.org;
> > jingoohan1@gmail.com; gustavo.pimentel@synopsys.com;
> > lorenzo.pieralisi@arm.com; bhelgaas@google.com; Anvesh Salveru
> > <anvesh.s@samsung.com>
> > Subject: Re: [PATCH v2] PCI: dwc: Add support to add GEN3 related
> equalization
> > quirks
> > 
> > On Fri, Sep 13, 2019 at 04:09:50PM +0530, Pankaj Dubey wrote:
> > > From: Anvesh Salveru <anvesh.s@samsung.com>
> > >
> > > In some platforms, PCIe PHY may have issues which will prevent linkup
> > > to happen in GEN3 or higher speed. In case equalization fails, link
> > > will fallback to GEN1.
> > >
> > > DesignWare controller gives flexibility to disable GEN3 equalization
> > > completely or only phase 2 and 3 of equalization.
> > >
> > > This patch enables the DesignWare driver to disable the PCIe GEN3
> > > equalization by enabling one of the following quirks:
> > >  - DWC_EQUALIZATION_DISABLE: To disable GEN3 equalization all phases
> > >  - DWC_EQ_PHASE_2_3_DISABLE: To disable GEN3 equalization phase 2 & 3
> > >
> > > Platform drivers can set these quirks via "quirk" variable of "dw_pcie"
> > > struct.
> > >
> > > Signed-off-by: Anvesh Salveru <anvesh.s@samsung.com>
> > > Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> > > ---
> > > Patchset v1 can be found at:
> > >  - 1/2: https://lkml.org/lkml/2019/9/10/443
> > >  - 2/2: https://lkml.org/lkml/2019/9/10/444
> > >
> > > Changes w.r.t v1:
> > >  - Squashed two patches from v1 into one as suggested by Gustavo
> > >  - Addressed review comments from Andrew
> > >
> > >  drivers/pci/controller/dwc/pcie-designware.c | 12 ++++++++++++
> > > drivers/pci/controller/dwc/pcie-designware.h |  9 +++++++++
> > >  2 files changed, 21 insertions(+)
> > >
> > > diff --git a/drivers/pci/controller/dwc/pcie-designware.c
> > > b/drivers/pci/controller/dwc/pcie-designware.c
> > > index 7d25102..97fb18d 100644
> > > --- a/drivers/pci/controller/dwc/pcie-designware.c
> > > +++ b/drivers/pci/controller/dwc/pcie-designware.c
> > > @@ -466,4 +466,16 @@ void dw_pcie_setup(struct dw_pcie *pci)
> > >  		break;
> > >  	}
> > >  	dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, val);
> > > +
> > > +	if (pci->quirk & DWC_EQUALIZATION_DISABLE) {
> > > +		val = dw_pcie_readl_dbi(pci, PCIE_PORT_GEN3_RELATED);
> > > +		val |= PORT_LOGIC_GEN3_EQ_DISABLE;
> > > +		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED, val);
> > > +	}
> > > +
> > > +	if (pci->quirk & DWC_EQ_PHASE_2_3_DISABLE) {
> > > +		val = dw_pcie_readl_dbi(pci, PCIE_PORT_GEN3_RELATED);
> > > +		val |= PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE;
> > > +		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED, val);
> > > +	}
> > >  }
> > > diff --git a/drivers/pci/controller/dwc/pcie-designware.h
> > > b/drivers/pci/controller/dwc/pcie-designware.h
> > > index ffed084..e428b62 100644
> > > --- a/drivers/pci/controller/dwc/pcie-designware.h
> > > +++ b/drivers/pci/controller/dwc/pcie-designware.h
> > > @@ -29,6 +29,10 @@
> > >  #define LINK_WAIT_MAX_IATU_RETRIES	5
> > >  #define LINK_WAIT_IATU			9
> > >
> > > +/* Parameters for GEN3 related quirks */
> > > +#define DWC_EQUALIZATION_DISABLE	BIT(1)
> > > +#define DWC_EQ_PHASE_2_3_DISABLE	BIT(2)
> > > +
> > >  /* Synopsys-specific PCIe configuration registers */
> > >  #define PCIE_PORT_LINK_CONTROL		0x710
> > >  #define PORT_LINK_MODE_MASK		GENMASK(21, 16)
> > > @@ -60,6 +64,10 @@
> > >  #define PCIE_MSI_INTR0_MASK		0x82C
> > >  #define PCIE_MSI_INTR0_STATUS		0x830
> > >
> > > +#define PCIE_PORT_GEN3_RELATED		0x890
> > 
> > I hadn't noticed this in the previous version - what is the proper name
> for this
> > register? Does it end in _RELATED?
> 
> As per SNPS databook the name of the register is "GEN3_RELATED_OFF". It is
> port logic register so, to keep similarity with other port logic registers
> in this file we named it as "PCIE_PORT_GEN3_RELATED". 

OK.

Reviewed-by: Andrew Murray <andrew.murray@arm.com>

Also is the SNPS databook publicly available? I'd be interested in reading
it.

Thanks,

Andrew Murray

> 
> > 
> > Thanks,
> > 
> > Andrew Murray
> > 
> > > +#define PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE	BIT(9)
> > > +#define PORT_LOGIC_GEN3_EQ_DISABLE		BIT(16)
> > > +
> > >  #define PCIE_ATU_VIEWPORT		0x900
> > >  #define PCIE_ATU_REGION_INBOUND		BIT(31)
> > >  #define PCIE_ATU_REGION_OUTBOUND	0
> > > @@ -244,6 +252,7 @@ struct dw_pcie {
> > >  	struct dw_pcie_ep	ep;
> > >  	const struct dw_pcie_ops *ops;
> > >  	unsigned int		version;
> > > +	unsigned int		quirk;
> > >  };
> > >
> > >  #define to_dw_pcie_from_pp(port) container_of((port), struct dw_pcie,
> > > pp)
> > > --
> > > 2.7.4
> > >
> 

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

* RE: [PATCH v2] PCI: dwc: Add support to add GEN3 related equalization quirks
  2019-09-16 12:24       ` Andrew Murray
@ 2019-09-16 12:52         ` Gustavo Pimentel
  2019-09-19 11:24           ` Vidya Sagar
  0 siblings, 1 reply; 14+ messages in thread
From: Gustavo Pimentel @ 2019-09-16 12:52 UTC (permalink / raw)
  To: Andrew Murray, Pankaj Dubey
  Cc: linux-pci, linux-kernel, jingoohan1,
	gustavo.pimentel@synopsys.com, lorenzo.pieralisi, bhelgaas,
	'Anvesh Salveru'

On Mon, Sep 16, 2019 at 13:24:1, Andrew Murray <andrew.murray@arm.com> 
wrote:

> On Mon, Sep 16, 2019 at 04:36:33PM +0530, Pankaj Dubey wrote:
> > 
> > 
> > > -----Original Message-----
> > > From: Andrew Murray <andrew.murray@arm.com>
> > > Sent: Monday, September 16, 2019 3:46 PM
> > > To: Pankaj Dubey <pankaj.dubey@samsung.com>
> > > Cc: linux-pci@vger.kernel.org; linux-kernel@vger.kernel.org;
> > > jingoohan1@gmail.com; gustavo.pimentel@synopsys.com;
> > > lorenzo.pieralisi@arm.com; bhelgaas@google.com; Anvesh Salveru
> > > <anvesh.s@samsung.com>
> > > Subject: Re: [PATCH v2] PCI: dwc: Add support to add GEN3 related
> > equalization
> > > quirks
> > > 
> > > On Fri, Sep 13, 2019 at 04:09:50PM +0530, Pankaj Dubey wrote:
> > > > From: Anvesh Salveru <anvesh.s@samsung.com>
> > > >
> > > > In some platforms, PCIe PHY may have issues which will prevent linkup
> > > > to happen in GEN3 or higher speed. In case equalization fails, link
> > > > will fallback to GEN1.
> > > >
> > > > DesignWare controller gives flexibility to disable GEN3 equalization
> > > > completely or only phase 2 and 3 of equalization.
> > > >
> > > > This patch enables the DesignWare driver to disable the PCIe GEN3
> > > > equalization by enabling one of the following quirks:
> > > >  - DWC_EQUALIZATION_DISABLE: To disable GEN3 equalization all phases
> > > >  - DWC_EQ_PHASE_2_3_DISABLE: To disable GEN3 equalization phase 2 & 3
> > > >
> > > > Platform drivers can set these quirks via "quirk" variable of "dw_pcie"
> > > > struct.
> > > >
> > > > Signed-off-by: Anvesh Salveru <anvesh.s@samsung.com>
> > > > Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> > > > ---
> > > > Patchset v1 can be found at:
> > > >  - 1/2: https://urldefense.proofpoint.com/v2/url?u=https-3A__lkml.org_lkml_2019_9_10_443&d=DwIBAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=bkWxpLoW-f-E3EdiDCCa0_h0PicsViasSlvIpzZvPxs&m=MtEKKeJsQvi2UM1eSZUv2vPLLxrYU0aI1Ry4ICIDaiQ&s=s_nPmMNbQFswYRxQgBkeg4H9J_0FEtzRE-0AruC5WI4&e= 
> > > >  - 2/2: https://urldefense.proofpoint.com/v2/url?u=https-3A__lkml.org_lkml_2019_9_10_444&d=DwIBAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=bkWxpLoW-f-E3EdiDCCa0_h0PicsViasSlvIpzZvPxs&m=MtEKKeJsQvi2UM1eSZUv2vPLLxrYU0aI1Ry4ICIDaiQ&s=kkfdwcX6bYcLrnJSgw_GcMMGAjnDTMtN2v6svWuANpk&e= 
> > > >
> > > > Changes w.r.t v1:
> > > >  - Squashed two patches from v1 into one as suggested by Gustavo
> > > >  - Addressed review comments from Andrew
> > > >
> > > >  drivers/pci/controller/dwc/pcie-designware.c | 12 ++++++++++++
> > > > drivers/pci/controller/dwc/pcie-designware.h |  9 +++++++++
> > > >  2 files changed, 21 insertions(+)
> > > >
> > > > diff --git a/drivers/pci/controller/dwc/pcie-designware.c
> > > > b/drivers/pci/controller/dwc/pcie-designware.c
> > > > index 7d25102..97fb18d 100644
> > > > --- a/drivers/pci/controller/dwc/pcie-designware.c
> > > > +++ b/drivers/pci/controller/dwc/pcie-designware.c
> > > > @@ -466,4 +466,16 @@ void dw_pcie_setup(struct dw_pcie *pci)
> > > >  		break;
> > > >  	}
> > > >  	dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, val);
> > > > +
> > > > +	if (pci->quirk & DWC_EQUALIZATION_DISABLE) {
> > > > +		val = dw_pcie_readl_dbi(pci, PCIE_PORT_GEN3_RELATED);
> > > > +		val |= PORT_LOGIC_GEN3_EQ_DISABLE;
> > > > +		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED, val);
> > > > +	}
> > > > +
> > > > +	if (pci->quirk & DWC_EQ_PHASE_2_3_DISABLE) {
> > > > +		val = dw_pcie_readl_dbi(pci, PCIE_PORT_GEN3_RELATED);
> > > > +		val |= PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE;
> > > > +		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED, val);
> > > > +	}
> > > >  }
> > > > diff --git a/drivers/pci/controller/dwc/pcie-designware.h
> > > > b/drivers/pci/controller/dwc/pcie-designware.h
> > > > index ffed084..e428b62 100644
> > > > --- a/drivers/pci/controller/dwc/pcie-designware.h
> > > > +++ b/drivers/pci/controller/dwc/pcie-designware.h
> > > > @@ -29,6 +29,10 @@
> > > >  #define LINK_WAIT_MAX_IATU_RETRIES	5
> > > >  #define LINK_WAIT_IATU			9
> > > >
> > > > +/* Parameters for GEN3 related quirks */
> > > > +#define DWC_EQUALIZATION_DISABLE	BIT(1)
> > > > +#define DWC_EQ_PHASE_2_3_DISABLE	BIT(2)
> > > > +
> > > >  /* Synopsys-specific PCIe configuration registers */
> > > >  #define PCIE_PORT_LINK_CONTROL		0x710
> > > >  #define PORT_LINK_MODE_MASK		GENMASK(21, 16)
> > > > @@ -60,6 +64,10 @@
> > > >  #define PCIE_MSI_INTR0_MASK		0x82C
> > > >  #define PCIE_MSI_INTR0_STATUS		0x830
> > > >
> > > > +#define PCIE_PORT_GEN3_RELATED		0x890
> > > 
> > > I hadn't noticed this in the previous version - what is the proper name
> > for this
> > > register? Does it end in _RELATED?
> > 
> > As per SNPS databook the name of the register is "GEN3_RELATED_OFF". It is
> > port logic register so, to keep similarity with other port logic registers
> > in this file we named it as "PCIE_PORT_GEN3_RELATED". 
> 
> OK.
> 
> Reviewed-by: Andrew Murray <andrew.murray@arm.com>
> 
> Also is the SNPS databook publicly available? I'd be interested in reading
> it.

The databook isn't openly available, sorry.

Gustavo

> 
> Thanks,
> 
> Andrew Murray
> 
> > 
> > > 
> > > Thanks,
> > > 
> > > Andrew Murray
> > > 
> > > > +#define PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE	BIT(9)
> > > > +#define PORT_LOGIC_GEN3_EQ_DISABLE		BIT(16)
> > > > +
> > > >  #define PCIE_ATU_VIEWPORT		0x900
> > > >  #define PCIE_ATU_REGION_INBOUND		BIT(31)
> > > >  #define PCIE_ATU_REGION_OUTBOUND	0
> > > > @@ -244,6 +252,7 @@ struct dw_pcie {
> > > >  	struct dw_pcie_ep	ep;
> > > >  	const struct dw_pcie_ops *ops;
> > > >  	unsigned int		version;
> > > > +	unsigned int		quirk;
> > > >  };
> > > >
> > > >  #define to_dw_pcie_from_pp(port) container_of((port), struct dw_pcie,
> > > > pp)
> > > > --
> > > > 2.7.4
> > > >
> > 



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

* Re: [PATCH v2] PCI: dwc: Add support to add GEN3 related equalization quirks
  2019-09-16 12:52         ` Gustavo Pimentel
@ 2019-09-19 11:24           ` Vidya Sagar
  2019-09-24  9:28             ` Pankaj Dubey
  0 siblings, 1 reply; 14+ messages in thread
From: Vidya Sagar @ 2019-09-19 11:24 UTC (permalink / raw)
  To: Gustavo Pimentel, Andrew Murray, Pankaj Dubey
  Cc: linux-pci, linux-kernel, jingoohan1, lorenzo.pieralisi, bhelgaas,
	'Anvesh Salveru'

On 9/16/2019 6:22 PM, Gustavo Pimentel wrote:
> On Mon, Sep 16, 2019 at 13:24:1, Andrew Murray <andrew.murray@arm.com>
> wrote:
> 
>> On Mon, Sep 16, 2019 at 04:36:33PM +0530, Pankaj Dubey wrote:
>>>
>>>
>>>> -----Original Message-----
>>>> From: Andrew Murray <andrew.murray@arm.com>
>>>> Sent: Monday, September 16, 2019 3:46 PM
>>>> To: Pankaj Dubey <pankaj.dubey@samsung.com>
>>>> Cc: linux-pci@vger.kernel.org; linux-kernel@vger.kernel.org;
>>>> jingoohan1@gmail.com; gustavo.pimentel@synopsys.com;
>>>> lorenzo.pieralisi@arm.com; bhelgaas@google.com; Anvesh Salveru
>>>> <anvesh.s@samsung.com>
>>>> Subject: Re: [PATCH v2] PCI: dwc: Add support to add GEN3 related
>>> equalization
>>>> quirks
>>>>
>>>> On Fri, Sep 13, 2019 at 04:09:50PM +0530, Pankaj Dubey wrote:
>>>>> From: Anvesh Salveru <anvesh.s@samsung.com>
>>>>>
>>>>> In some platforms, PCIe PHY may have issues which will prevent linkup
>>>>> to happen in GEN3 or higher speed. In case equalization fails, link
>>>>> will fallback to GEN1.
>>>>>
>>>>> DesignWare controller gives flexibility to disable GEN3 equalization
>>>>> completely or only phase 2 and 3 of equalization.
>>>>>
>>>>> This patch enables the DesignWare driver to disable the PCIe GEN3
>>>>> equalization by enabling one of the following quirks:
>>>>>   - DWC_EQUALIZATION_DISABLE: To disable GEN3 equalization all phases
I don't think Gen-3 equalization can be skipped altogether.
PCIe Spec Rev 4.0 Ver 1.0 in Section-4.2.3 has the following statement.

"All the Lanes that are associated with the LTSSM
(i.e., those Lanes that are currently operational or may be operational in the future due to Link
Upconfigure) must participate in the Equalization procedure"

and in Section-4.2.6.4.2.1.1 it says
"Note: A transition to Recovery.RcvrLock might be used in the case where the
Downstream Port determines that Phase 2 and Phase 3 are not needed based on the
platform and channel characteristics."

Based on the above statements, I think it is Ok to skip only Phases 2&3 of equalization but not 0&1.
I even checked with our hardware engineers and it seems DWC_EQUALIZATION_DISABLE is present
only for debugging purpose in hardware simulations and shouldn't be used on real silicon otherwise it seems.

- Vidya Sagar


>>>>>   - DWC_EQ_PHASE_2_3_DISABLE: To disable GEN3 equalization phase 2 & 3
>>>>>
>>>>> Platform drivers can set these quirks via "quirk" variable of "dw_pcie"
>>>>> struct.
>>>>>
>>>>> Signed-off-by: Anvesh Salveru <anvesh.s@samsung.com>
>>>>> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
>>>>> ---
>>>>> Patchset v1 can be found at:
>>>>>   - 1/2: https://urldefense.proofpoint.com/v2/url?u=https-3A__lkml.org_lkml_2019_9_10_443&d=DwIBAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=bkWxpLoW-f-E3EdiDCCa0_h0PicsViasSlvIpzZvPxs&m=MtEKKeJsQvi2UM1eSZUv2vPLLxrYU0aI1Ry4ICIDaiQ&s=s_nPmMNbQFswYRxQgBkeg4H9J_0FEtzRE-0AruC5WI4&e=
>>>>>   - 2/2: https://urldefense.proofpoint.com/v2/url?u=https-3A__lkml.org_lkml_2019_9_10_444&d=DwIBAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=bkWxpLoW-f-E3EdiDCCa0_h0PicsViasSlvIpzZvPxs&m=MtEKKeJsQvi2UM1eSZUv2vPLLxrYU0aI1Ry4ICIDaiQ&s=kkfdwcX6bYcLrnJSgw_GcMMGAjnDTMtN2v6svWuANpk&e=
>>>>>
>>>>> Changes w.r.t v1:
>>>>>   - Squashed two patches from v1 into one as suggested by Gustavo
>>>>>   - Addressed review comments from Andrew
>>>>>
>>>>>   drivers/pci/controller/dwc/pcie-designware.c | 12 ++++++++++++
>>>>> drivers/pci/controller/dwc/pcie-designware.h |  9 +++++++++
>>>>>   2 files changed, 21 insertions(+)
>>>>>
>>>>> diff --git a/drivers/pci/controller/dwc/pcie-designware.c
>>>>> b/drivers/pci/controller/dwc/pcie-designware.c
>>>>> index 7d25102..97fb18d 100644
>>>>> --- a/drivers/pci/controller/dwc/pcie-designware.c
>>>>> +++ b/drivers/pci/controller/dwc/pcie-designware.c
>>>>> @@ -466,4 +466,16 @@ void dw_pcie_setup(struct dw_pcie *pci)
>>>>>   		break;
>>>>>   	}
>>>>>   	dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, val);
>>>>> +
>>>>> +	if (pci->quirk & DWC_EQUALIZATION_DISABLE) {
>>>>> +		val = dw_pcie_readl_dbi(pci, PCIE_PORT_GEN3_RELATED);
>>>>> +		val |= PORT_LOGIC_GEN3_EQ_DISABLE;
>>>>> +		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED, val);
>>>>> +	}
>>>>> +
>>>>> +	if (pci->quirk & DWC_EQ_PHASE_2_3_DISABLE) {
>>>>> +		val = dw_pcie_readl_dbi(pci, PCIE_PORT_GEN3_RELATED);
>>>>> +		val |= PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE;
>>>>> +		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED, val);
>>>>> +	}
>>>>>   }
>>>>> diff --git a/drivers/pci/controller/dwc/pcie-designware.h
>>>>> b/drivers/pci/controller/dwc/pcie-designware.h
>>>>> index ffed084..e428b62 100644
>>>>> --- a/drivers/pci/controller/dwc/pcie-designware.h
>>>>> +++ b/drivers/pci/controller/dwc/pcie-designware.h
>>>>> @@ -29,6 +29,10 @@
>>>>>   #define LINK_WAIT_MAX_IATU_RETRIES	5
>>>>>   #define LINK_WAIT_IATU			9
>>>>>
>>>>> +/* Parameters for GEN3 related quirks */
>>>>> +#define DWC_EQUALIZATION_DISABLE	BIT(1)
>>>>> +#define DWC_EQ_PHASE_2_3_DISABLE	BIT(2)
>>>>> +
>>>>>   /* Synopsys-specific PCIe configuration registers */
>>>>>   #define PCIE_PORT_LINK_CONTROL		0x710
>>>>>   #define PORT_LINK_MODE_MASK		GENMASK(21, 16)
>>>>> @@ -60,6 +64,10 @@
>>>>>   #define PCIE_MSI_INTR0_MASK		0x82C
>>>>>   #define PCIE_MSI_INTR0_STATUS		0x830
>>>>>
>>>>> +#define PCIE_PORT_GEN3_RELATED		0x890
>>>>
>>>> I hadn't noticed this in the previous version - what is the proper name
>>> for this
>>>> register? Does it end in _RELATED?
>>>
>>> As per SNPS databook the name of the register is "GEN3_RELATED_OFF". It is
>>> port logic register so, to keep similarity with other port logic registers
>>> in this file we named it as "PCIE_PORT_GEN3_RELATED".
>>
>> OK.
>>
>> Reviewed-by: Andrew Murray <andrew.murray@arm.com>
>>
>> Also is the SNPS databook publicly available? I'd be interested in reading
>> it.
> 
> The databook isn't openly available, sorry.
> 
> Gustavo
> 
>>
>> Thanks,
>>
>> Andrew Murray
>>
>>>
>>>>
>>>> Thanks,
>>>>
>>>> Andrew Murray
>>>>
>>>>> +#define PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE	BIT(9)
>>>>> +#define PORT_LOGIC_GEN3_EQ_DISABLE		BIT(16)
>>>>> +
>>>>>   #define PCIE_ATU_VIEWPORT		0x900
>>>>>   #define PCIE_ATU_REGION_INBOUND		BIT(31)
>>>>>   #define PCIE_ATU_REGION_OUTBOUND	0
>>>>> @@ -244,6 +252,7 @@ struct dw_pcie {
>>>>>   	struct dw_pcie_ep	ep;
>>>>>   	const struct dw_pcie_ops *ops;
>>>>>   	unsigned int		version;
>>>>> +	unsigned int		quirk;
>>>>>   };
>>>>>
>>>>>   #define to_dw_pcie_from_pp(port) container_of((port), struct dw_pcie,
>>>>> pp)
>>>>> --
>>>>> 2.7.4
>>>>>
>>>
> 
> 


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

* RE: [PATCH v2] PCI: dwc: Add support to add GEN3 related equalization quirks
  2019-09-19 11:24           ` Vidya Sagar
@ 2019-09-24  9:28             ` Pankaj Dubey
  2019-09-24 11:27               ` Vidya Sagar
  0 siblings, 1 reply; 14+ messages in thread
From: Pankaj Dubey @ 2019-09-24  9:28 UTC (permalink / raw)
  To: 'Vidya Sagar', 'Gustavo Pimentel',
	'Andrew Murray'
  Cc: linux-pci, linux-kernel, jingoohan1, lorenzo.pieralisi, bhelgaas,
	'Anvesh Salveru'



> -----Original Message-----
> From: Vidya Sagar <vidyas@nvidia.com>
> Sent: Thursday, September 19, 2019 4:54 PM
> Subject: Re: [PATCH v2] PCI: dwc: Add support to add GEN3 related equalization
> quirks
> 
> On 9/16/2019 6:22 PM, Gustavo Pimentel wrote:
> > On Mon, Sep 16, 2019 at 13:24:1, Andrew Murray
> <andrew.murray@arm.com>
> > wrote:
> >
> >> On Mon, Sep 16, 2019 at 04:36:33PM +0530, Pankaj Dubey wrote:
> >>>
> >>>
> >>>> -----Original Message-----
> >>>> From: Andrew Murray <andrew.murray@arm.com>
> >>>> Sent: Monday, September 16, 2019 3:46 PM
> >>>> To: Pankaj Dubey <pankaj.dubey@samsung.com>
> >>>> Cc: linux-pci@vger.kernel.org; linux-kernel@vger.kernel.org;
> >>>> jingoohan1@gmail.com; gustavo.pimentel@synopsys.com;
> >>>> lorenzo.pieralisi@arm.com; bhelgaas@google.com; Anvesh Salveru
> >>>> <anvesh.s@samsung.com>
> >>>> Subject: Re: [PATCH v2] PCI: dwc: Add support to add GEN3 related
> >>> equalization
> >>>> quirks
> >>>>
> >>>> On Fri, Sep 13, 2019 at 04:09:50PM +0530, Pankaj Dubey wrote:
> >>>>> From: Anvesh Salveru <anvesh.s@samsung.com>
> >>>>>
> >>>>> In some platforms, PCIe PHY may have issues which will prevent
> >>>>> linkup to happen in GEN3 or higher speed. In case equalization
> >>>>> fails, link will fallback to GEN1.
> >>>>>
> >>>>> DesignWare controller gives flexibility to disable GEN3
> >>>>> equalization completely or only phase 2 and 3 of equalization.
> >>>>>
> >>>>> This patch enables the DesignWare driver to disable the PCIe GEN3
> >>>>> equalization by enabling one of the following quirks:
> >>>>>   - DWC_EQUALIZATION_DISABLE: To disable GEN3 equalization all
> >>>>> phases
> I don't think Gen-3 equalization can be skipped altogether.
> PCIe Spec Rev 4.0 Ver 1.0 in Section-4.2.3 has the following statement.
> 
> "All the Lanes that are associated with the LTSSM (i.e., those Lanes that are
> currently operational or may be operational in the future due to Link
> Upconfigure) must participate in the Equalization procedure"
> 
> and in Section-4.2.6.4.2.1.1 it says
> "Note: A transition to Recovery.RcvrLock might be used in the case where the
> Downstream Port determines that Phase 2 and Phase 3 are not needed based on
> the platform and channel characteristics."
> 
> Based on the above statements, I think it is Ok to skip only Phases 2&3 of
> equalization but not 0&1.
> I even checked with our hardware engineers and it seems
> DWC_EQUALIZATION_DISABLE is present only for debugging purpose in
> hardware simulations and shouldn't be used on real silicon otherwise it seems.
> 

In DesignWare manual we don't see any comment that this feature is for debugging purpose only.
Even if it is meant for debugging purpose, if for some reason in an SoC, Gen3/4 linkup is failing due to equalization, and if disabling equalization is helping then IMO it is OK to do it. 
Just to re-confirm we tested one of the NVMe device on Jatson AGX Xavier RC with equalization disabled. We do see linkup works well in GEN3. As we have added this feature as a platform-quirk so only platforms that required this feature can enable it.

Snippet of lspci (from Jatson AGX Xavier RC) is given below, showing EQ is completely disabled and GEN3 linkup
-----
0005:01:00.0 Non-Volatile memory controller: Lite-On Technology Corporation Device 21f1 (rev 01) (prog-if 02 [NVM Express])
        Subsystem: Marvell Technology Group Ltd. Device 1093
         <snip>
                LnkCap: Port #0, Speed 8GT/s, Width x4, ASPM L1, Exit Latency L0s <512ns, L1 <64us
                        ClockPM+ Surprise- LLActRep- BwNot- ASPMOptComp+
                LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- CommClk+
                        ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
                LnkSta: Speed 8GT/s, Width x4, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
                DevCap2: Completion Timeout: Not Supported, TimeoutDis+, LTR+, OBFF Via message
                DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR+, OBFF Disabled
                LnkCtl2: Target Link Speed: 8GT/s, EnterCompliance- SpeedDis-
                         Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
                         Compliance De-emphasis: -6dB
                LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete-, EqualizationPhase1-
                         EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
-----
> - Vidya Sagar
> 
> 
> >>>>>   - DWC_EQ_PHASE_2_3_DISABLE: To disable GEN3 equalization phase 2
> >>>>> & 3
> >>>>>
> >>>>> Platform drivers can set these quirks via "quirk" variable of "dw_pcie"
> >>>>> struct.
> >>>>>
> >>>>> Signed-off-by: Anvesh Salveru <anvesh.s@samsung.com>
> >>>>> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> >>>>> ---
> >>>>> Patchset v1 can be found at:
> >>>>>   - 1/2: https://urldefense.proofpoint.com/v2/url?u=https-
> 3A__lkml.org_lkml_2019_9_10_443&d=DwIBAg&c=DPL6_X_6JkXFx7AXWqB0tg
> &r=bkWxpLoW-f-
> E3EdiDCCa0_h0PicsViasSlvIpzZvPxs&m=MtEKKeJsQvi2UM1eSZUv2vPLLxrYU0aI1
> Ry4ICIDaiQ&s=s_nPmMNbQFswYRxQgBkeg4H9J_0FEtzRE-0AruC5WI4&e=
> >>>>>   - 2/2:
> >>>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__lkml.org_lkml
> >>>>>
> _2019_9_10_444&d=DwIBAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=bkWxpLoW-f-
> E3Ed
> >>>>>
> iDCCa0_h0PicsViasSlvIpzZvPxs&m=MtEKKeJsQvi2UM1eSZUv2vPLLxrYU0aI1Ry
> >>>>> 4ICIDaiQ&s=kkfdwcX6bYcLrnJSgw_GcMMGAjnDTMtN2v6svWuANpk&e=
> >>>>>
> >>>>> Changes w.r.t v1:
> >>>>>   - Squashed two patches from v1 into one as suggested by Gustavo
> >>>>>   - Addressed review comments from Andrew
> >>>>>
> >>>>>   drivers/pci/controller/dwc/pcie-designware.c | 12 ++++++++++++
> >>>>> drivers/pci/controller/dwc/pcie-designware.h |  9 +++++++++
> >>>>>   2 files changed, 21 insertions(+)
> >>>>>
> >>>>> diff --git a/drivers/pci/controller/dwc/pcie-designware.c
> >>>>> b/drivers/pci/controller/dwc/pcie-designware.c
> >>>>> index 7d25102..97fb18d 100644
> >>>>> --- a/drivers/pci/controller/dwc/pcie-designware.c
> >>>>> +++ b/drivers/pci/controller/dwc/pcie-designware.c
> >>>>> @@ -466,4 +466,16 @@ void dw_pcie_setup(struct dw_pcie *pci)
> >>>>>   		break;
> >>>>>   	}
> >>>>>   	dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, val);
> >>>>> +
> >>>>> +	if (pci->quirk & DWC_EQUALIZATION_DISABLE) {
> >>>>> +		val = dw_pcie_readl_dbi(pci, PCIE_PORT_GEN3_RELATED);
> >>>>> +		val |= PORT_LOGIC_GEN3_EQ_DISABLE;
> >>>>> +		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED, val);
> >>>>> +	}
> >>>>> +
> >>>>> +	if (pci->quirk & DWC_EQ_PHASE_2_3_DISABLE) {
> >>>>> +		val = dw_pcie_readl_dbi(pci, PCIE_PORT_GEN3_RELATED);
> >>>>> +		val |= PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE;
> >>>>> +		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED, val);
> >>>>> +	}
> >>>>>   }
> >>>>> diff --git a/drivers/pci/controller/dwc/pcie-designware.h
> >>>>> b/drivers/pci/controller/dwc/pcie-designware.h
> >>>>> index ffed084..e428b62 100644
> >>>>> --- a/drivers/pci/controller/dwc/pcie-designware.h
> >>>>> +++ b/drivers/pci/controller/dwc/pcie-designware.h
> >>>>> @@ -29,6 +29,10 @@
> >>>>>   #define LINK_WAIT_MAX_IATU_RETRIES	5
> >>>>>   #define LINK_WAIT_IATU			9
> >>>>>
> >>>>> +/* Parameters for GEN3 related quirks */
> >>>>> +#define DWC_EQUALIZATION_DISABLE	BIT(1)
> >>>>> +#define DWC_EQ_PHASE_2_3_DISABLE	BIT(2)
> >>>>> +
> >>>>>   /* Synopsys-specific PCIe configuration registers */
> >>>>>   #define PCIE_PORT_LINK_CONTROL		0x710
> >>>>>   #define PORT_LINK_MODE_MASK		GENMASK(21, 16)
> >>>>> @@ -60,6 +64,10 @@
> >>>>>   #define PCIE_MSI_INTR0_MASK		0x82C
> >>>>>   #define PCIE_MSI_INTR0_STATUS		0x830
> >>>>>
> >>>>> +#define PCIE_PORT_GEN3_RELATED		0x890
> >>>>
> >>>> I hadn't noticed this in the previous version - what is the proper
> >>>> name
> >>> for this
> >>>> register? Does it end in _RELATED?
> >>>
> >>> As per SNPS databook the name of the register is "GEN3_RELATED_OFF".
> >>> It is port logic register so, to keep similarity with other port
> >>> logic registers in this file we named it as "PCIE_PORT_GEN3_RELATED".
> >>
> >> OK.
> >>
> >> Reviewed-by: Andrew Murray <andrew.murray@arm.com>
> >>
> >> Also is the SNPS databook publicly available? I'd be interested in
> >> reading it.
> >
> > The databook isn't openly available, sorry.
> >
> > Gustavo
> >
> >>
> >> Thanks,
> >>
> >> Andrew Murray
> >>
> >>>
> >>>>
> >>>> Thanks,
> >>>>
> >>>> Andrew Murray
> >>>>
> >>>>> +#define PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE	BIT(9)
> >>>>> +#define PORT_LOGIC_GEN3_EQ_DISABLE		BIT(16)
> >>>>> +
> >>>>>   #define PCIE_ATU_VIEWPORT		0x900
> >>>>>   #define PCIE_ATU_REGION_INBOUND		BIT(31)
> >>>>>   #define PCIE_ATU_REGION_OUTBOUND	0
> >>>>> @@ -244,6 +252,7 @@ struct dw_pcie {
> >>>>>   	struct dw_pcie_ep	ep;
> >>>>>   	const struct dw_pcie_ops *ops;
> >>>>>   	unsigned int		version;
> >>>>> +	unsigned int		quirk;
> >>>>>   };
> >>>>>
> >>>>>   #define to_dw_pcie_from_pp(port) container_of((port), struct
> >>>>> dw_pcie,
> >>>>> pp)
> >>>>> --
> >>>>> 2.7.4
> >>>>>
> >>>
> >
> >



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

* Re: [PATCH v2] PCI: dwc: Add support to add GEN3 related equalization quirks
  2019-09-24  9:28             ` Pankaj Dubey
@ 2019-09-24 11:27               ` Vidya Sagar
  2019-09-24 12:11                 ` Pankaj Dubey
  0 siblings, 1 reply; 14+ messages in thread
From: Vidya Sagar @ 2019-09-24 11:27 UTC (permalink / raw)
  To: Pankaj Dubey, 'Gustavo Pimentel', 'Andrew Murray'
  Cc: linux-pci, linux-kernel, jingoohan1, lorenzo.pieralisi, bhelgaas,
	'Anvesh Salveru'

On 9/24/2019 2:58 PM, Pankaj Dubey wrote:
> 
> 
>> -----Original Message-----
>> From: Vidya Sagar <vidyas@nvidia.com>
>> Sent: Thursday, September 19, 2019 4:54 PM
>> Subject: Re: [PATCH v2] PCI: dwc: Add support to add GEN3 related equalization
>> quirks
>>
>> On 9/16/2019 6:22 PM, Gustavo Pimentel wrote:
>>> On Mon, Sep 16, 2019 at 13:24:1, Andrew Murray
>> <andrew.murray@arm.com>
>>> wrote:
>>>
>>>> On Mon, Sep 16, 2019 at 04:36:33PM +0530, Pankaj Dubey wrote:
>>>>>
>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Andrew Murray <andrew.murray@arm.com>
>>>>>> Sent: Monday, September 16, 2019 3:46 PM
>>>>>> To: Pankaj Dubey <pankaj.dubey@samsung.com>
>>>>>> Cc: linux-pci@vger.kernel.org; linux-kernel@vger.kernel.org;
>>>>>> jingoohan1@gmail.com; gustavo.pimentel@synopsys.com;
>>>>>> lorenzo.pieralisi@arm.com; bhelgaas@google.com; Anvesh Salveru
>>>>>> <anvesh.s@samsung.com>
>>>>>> Subject: Re: [PATCH v2] PCI: dwc: Add support to add GEN3 related
>>>>> equalization
>>>>>> quirks
>>>>>>
>>>>>> On Fri, Sep 13, 2019 at 04:09:50PM +0530, Pankaj Dubey wrote:
>>>>>>> From: Anvesh Salveru <anvesh.s@samsung.com>
>>>>>>>
>>>>>>> In some platforms, PCIe PHY may have issues which will prevent
>>>>>>> linkup to happen in GEN3 or higher speed. In case equalization
>>>>>>> fails, link will fallback to GEN1.
>>>>>>>
>>>>>>> DesignWare controller gives flexibility to disable GEN3
>>>>>>> equalization completely or only phase 2 and 3 of equalization.
>>>>>>>
>>>>>>> This patch enables the DesignWare driver to disable the PCIe GEN3
>>>>>>> equalization by enabling one of the following quirks:
>>>>>>>    - DWC_EQUALIZATION_DISABLE: To disable GEN3 equalization all
>>>>>>> phases
>> I don't think Gen-3 equalization can be skipped altogether.
>> PCIe Spec Rev 4.0 Ver 1.0 in Section-4.2.3 has the following statement.
>>
>> "All the Lanes that are associated with the LTSSM (i.e., those Lanes that are
>> currently operational or may be operational in the future due to Link
>> Upconfigure) must participate in the Equalization procedure"
>>
>> and in Section-4.2.6.4.2.1.1 it says
>> "Note: A transition to Recovery.RcvrLock might be used in the case where the
>> Downstream Port determines that Phase 2 and Phase 3 are not needed based on
>> the platform and channel characteristics."
>>
>> Based on the above statements, I think it is Ok to skip only Phases 2&3 of
>> equalization but not 0&1.
>> I even checked with our hardware engineers and it seems
>> DWC_EQUALIZATION_DISABLE is present only for debugging purpose in
>> hardware simulations and shouldn't be used on real silicon otherwise it seems.
>>
> 
> In DesignWare manual we don't see any comment that this feature is for debugging purpose only.
Agree and as I mentioned even I got to know about it offline.

> Even if it is meant for debugging purpose, if for some reason in an SoC, Gen3/4 linkup is failing due to equalization, and if disabling equalization is helping then IMO it is OK to do it.
Well, I don't have specific reservations to not have it. We can use this as a fall back option.

> Just to re-confirm we tested one of the NVMe device on Jatson AGX Xavier RC with equalization disabled. We do see linkup works well in GEN3. As we have added this feature as a platform-quirk so only platforms that required this feature can enable it.
> 
Curious to know...You did it because link didn't come up with equalization enabled? or just as an experiment?

> Snippet of lspci (from Jatson AGX Xavier RC) is given below, showing EQ is completely disabled and GEN3 linkup
> -----
> 0005:01:00.0 Non-Volatile memory controller: Lite-On Technology Corporation Device 21f1 (rev 01) (prog-if 02 [NVM Express])
>          Subsystem: Marvell Technology Group Ltd. Device 1093
>           <snip>
>                  LnkCap: Port #0, Speed 8GT/s, Width x4, ASPM L1, Exit Latency L0s <512ns, L1 <64us
>                          ClockPM+ Surprise- LLActRep- BwNot- ASPMOptComp+
>                  LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- CommClk+
>                          ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
>                  LnkSta: Speed 8GT/s, Width x4, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
>                  DevCap2: Completion Timeout: Not Supported, TimeoutDis+, LTR+, OBFF Via message
>                  DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR+, OBFF Disabled
>                  LnkCtl2: Target Link Speed: 8GT/s, EnterCompliance- SpeedDis-
>                           Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
>                           Compliance De-emphasis: -6dB
>                  LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete-, EqualizationPhase1-
>                           EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
> -----
>> - Vidya Sagar
>>
>>
>>>>>>>    - DWC_EQ_PHASE_2_3_DISABLE: To disable GEN3 equalization phase 2
>>>>>>> & 3
>>>>>>>
>>>>>>> Platform drivers can set these quirks via "quirk" variable of "dw_pcie"
>>>>>>> struct.
>>>>>>>
>>>>>>> Signed-off-by: Anvesh Salveru <anvesh.s@samsung.com>
>>>>>>> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
>>>>>>> ---
>>>>>>> Patchset v1 can be found at:
>>>>>>>    - 1/2: https://urldefense.proofpoint.com/v2/url?u=https-
>> 3A__lkml.org_lkml_2019_9_10_443&d=DwIBAg&c=DPL6_X_6JkXFx7AXWqB0tg
>> &r=bkWxpLoW-f-
>> E3EdiDCCa0_h0PicsViasSlvIpzZvPxs&m=MtEKKeJsQvi2UM1eSZUv2vPLLxrYU0aI1
>> Ry4ICIDaiQ&s=s_nPmMNbQFswYRxQgBkeg4H9J_0FEtzRE-0AruC5WI4&e=
>>>>>>>    - 2/2:
>>>>>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__lkml.org_lkml
>>>>>>>
>> _2019_9_10_444&d=DwIBAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=bkWxpLoW-f-
>> E3Ed
>>>>>>>
>> iDCCa0_h0PicsViasSlvIpzZvPxs&m=MtEKKeJsQvi2UM1eSZUv2vPLLxrYU0aI1Ry
>>>>>>> 4ICIDaiQ&s=kkfdwcX6bYcLrnJSgw_GcMMGAjnDTMtN2v6svWuANpk&e=
>>>>>>>
>>>>>>> Changes w.r.t v1:
>>>>>>>    - Squashed two patches from v1 into one as suggested by Gustavo
>>>>>>>    - Addressed review comments from Andrew
>>>>>>>
>>>>>>>    drivers/pci/controller/dwc/pcie-designware.c | 12 ++++++++++++
>>>>>>> drivers/pci/controller/dwc/pcie-designware.h |  9 +++++++++
>>>>>>>    2 files changed, 21 insertions(+)
>>>>>>>
>>>>>>> diff --git a/drivers/pci/controller/dwc/pcie-designware.c
>>>>>>> b/drivers/pci/controller/dwc/pcie-designware.c
>>>>>>> index 7d25102..97fb18d 100644
>>>>>>> --- a/drivers/pci/controller/dwc/pcie-designware.c
>>>>>>> +++ b/drivers/pci/controller/dwc/pcie-designware.c
>>>>>>> @@ -466,4 +466,16 @@ void dw_pcie_setup(struct dw_pcie *pci)
>>>>>>>    		break;
>>>>>>>    	}
>>>>>>>    	dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, val);
>>>>>>> +
>>>>>>> +	if (pci->quirk & DWC_EQUALIZATION_DISABLE) {
>>>>>>> +		val = dw_pcie_readl_dbi(pci, PCIE_PORT_GEN3_RELATED);
>>>>>>> +		val |= PORT_LOGIC_GEN3_EQ_DISABLE;
>>>>>>> +		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED, val);
>>>>>>> +	}
>>>>>>> +
>>>>>>> +	if (pci->quirk & DWC_EQ_PHASE_2_3_DISABLE) {
>>>>>>> +		val = dw_pcie_readl_dbi(pci, PCIE_PORT_GEN3_RELATED);
>>>>>>> +		val |= PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE;
>>>>>>> +		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED, val);
>>>>>>> +	}
>>>>>>>    }
>>>>>>> diff --git a/drivers/pci/controller/dwc/pcie-designware.h
>>>>>>> b/drivers/pci/controller/dwc/pcie-designware.h
>>>>>>> index ffed084..e428b62 100644
>>>>>>> --- a/drivers/pci/controller/dwc/pcie-designware.h
>>>>>>> +++ b/drivers/pci/controller/dwc/pcie-designware.h
>>>>>>> @@ -29,6 +29,10 @@
>>>>>>>    #define LINK_WAIT_MAX_IATU_RETRIES	5
>>>>>>>    #define LINK_WAIT_IATU			9
>>>>>>>
>>>>>>> +/* Parameters for GEN3 related quirks */
>>>>>>> +#define DWC_EQUALIZATION_DISABLE	BIT(1)
>>>>>>> +#define DWC_EQ_PHASE_2_3_DISABLE	BIT(2)
>>>>>>> +
>>>>>>>    /* Synopsys-specific PCIe configuration registers */
>>>>>>>    #define PCIE_PORT_LINK_CONTROL		0x710
>>>>>>>    #define PORT_LINK_MODE_MASK		GENMASK(21, 16)
>>>>>>> @@ -60,6 +64,10 @@
>>>>>>>    #define PCIE_MSI_INTR0_MASK		0x82C
>>>>>>>    #define PCIE_MSI_INTR0_STATUS		0x830
>>>>>>>
>>>>>>> +#define PCIE_PORT_GEN3_RELATED		0x890
>>>>>>
>>>>>> I hadn't noticed this in the previous version - what is the proper
>>>>>> name
>>>>> for this
>>>>>> register? Does it end in _RELATED?
>>>>>
>>>>> As per SNPS databook the name of the register is "GEN3_RELATED_OFF".
>>>>> It is port logic register so, to keep similarity with other port
>>>>> logic registers in this file we named it as "PCIE_PORT_GEN3_RELATED".
>>>>
>>>> OK.
>>>>
>>>> Reviewed-by: Andrew Murray <andrew.murray@arm.com>
>>>>
>>>> Also is the SNPS databook publicly available? I'd be interested in
>>>> reading it.
>>>
>>> The databook isn't openly available, sorry.
>>>
>>> Gustavo
>>>
>>>>
>>>> Thanks,
>>>>
>>>> Andrew Murray
>>>>
>>>>>
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> Andrew Murray
>>>>>>
>>>>>>> +#define PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE	BIT(9)
>>>>>>> +#define PORT_LOGIC_GEN3_EQ_DISABLE		BIT(16)
>>>>>>> +
>>>>>>>    #define PCIE_ATU_VIEWPORT		0x900
>>>>>>>    #define PCIE_ATU_REGION_INBOUND		BIT(31)
>>>>>>>    #define PCIE_ATU_REGION_OUTBOUND	0
>>>>>>> @@ -244,6 +252,7 @@ struct dw_pcie {
>>>>>>>    	struct dw_pcie_ep	ep;
>>>>>>>    	const struct dw_pcie_ops *ops;
>>>>>>>    	unsigned int		version;
>>>>>>> +	unsigned int		quirk;
>>>>>>>    };
>>>>>>>
>>>>>>>    #define to_dw_pcie_from_pp(port) container_of((port), struct
>>>>>>> dw_pcie,
>>>>>>> pp)
>>>>>>> --
>>>>>>> 2.7.4
>>>>>>>
>>>>>
>>>
>>>
> 
> 


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

* RE: [PATCH v2] PCI: dwc: Add support to add GEN3 related equalization quirks
  2019-09-24 11:27               ` Vidya Sagar
@ 2019-09-24 12:11                 ` Pankaj Dubey
  2019-09-25  4:11                   ` Vidya Sagar
  0 siblings, 1 reply; 14+ messages in thread
From: Pankaj Dubey @ 2019-09-24 12:11 UTC (permalink / raw)
  To: 'Vidya Sagar', 'Gustavo Pimentel',
	'Andrew Murray'
  Cc: linux-pci, linux-kernel, jingoohan1, lorenzo.pieralisi, bhelgaas,
	'Anvesh Salveru'



> -----Original Message-----
> From: Vidya Sagar <vidyas@nvidia.com>
> Sent: Tuesday, September 24, 2019 4:57 PM
> To: Pankaj Dubey <pankaj.dubey@samsung.com>; 'Gustavo Pimentel'
> <Gustavo.Pimentel@synopsys.com>; 'Andrew Murray'
> <andrew.murray@arm.com>
> Cc: linux-pci@vger.kernel.org; linux-kernel@vger.kernel.org;
> jingoohan1@gmail.com; lorenzo.pieralisi@arm.com; bhelgaas@google.com;
> 'Anvesh Salveru' <anvesh.s@samsung.com>
> Subject: Re: [PATCH v2] PCI: dwc: Add support to add GEN3 related equalization
> quirks
> 
> On 9/24/2019 2:58 PM, Pankaj Dubey wrote:
> >
> >
> >> -----Original Message-----
> >> From: Vidya Sagar <vidyas@nvidia.com>
> >> Sent: Thursday, September 19, 2019 4:54 PM
> >> Subject: Re: [PATCH v2] PCI: dwc: Add support to add GEN3 related
> >> equalization quirks
> >>
> >> On 9/16/2019 6:22 PM, Gustavo Pimentel wrote:
> >>> On Mon, Sep 16, 2019 at 13:24:1, Andrew Murray
> >> <andrew.murray@arm.com>
> >>> wrote:
> >>>
> >>>> On Mon, Sep 16, 2019 at 04:36:33PM +0530, Pankaj Dubey wrote:
> >>>>>
> >>>>>
> >>>>>> -----Original Message-----
> >>>>>> From: Andrew Murray <andrew.murray@arm.com>
> >>>>>> Sent: Monday, September 16, 2019 3:46 PM
> >>>>>> To: Pankaj Dubey <pankaj.dubey@samsung.com>
> >>>>>> Cc: linux-pci@vger.kernel.org; linux-kernel@vger.kernel.org;
> >>>>>> jingoohan1@gmail.com; gustavo.pimentel@synopsys.com;
> >>>>>> lorenzo.pieralisi@arm.com; bhelgaas@google.com; Anvesh Salveru
> >>>>>> <anvesh.s@samsung.com>
> >>>>>> Subject: Re: [PATCH v2] PCI: dwc: Add support to add GEN3 related
> >>>>> equalization
> >>>>>> quirks
> >>>>>>
> >>>>>> On Fri, Sep 13, 2019 at 04:09:50PM +0530, Pankaj Dubey wrote:
> >>>>>>> From: Anvesh Salveru <anvesh.s@samsung.com>
> >>>>>>>
> >>>>>>> In some platforms, PCIe PHY may have issues which will prevent
> >>>>>>> linkup to happen in GEN3 or higher speed. In case equalization
> >>>>>>> fails, link will fallback to GEN1.
> >>>>>>>
> >>>>>>> DesignWare controller gives flexibility to disable GEN3
> >>>>>>> equalization completely or only phase 2 and 3 of equalization.
> >>>>>>>
> >>>>>>> This patch enables the DesignWare driver to disable the PCIe
> >>>>>>> GEN3 equalization by enabling one of the following quirks:
> >>>>>>>    - DWC_EQUALIZATION_DISABLE: To disable GEN3 equalization all
> >>>>>>> phases
> >> I don't think Gen-3 equalization can be skipped altogether.
> >> PCIe Spec Rev 4.0 Ver 1.0 in Section-4.2.3 has the following statement.
> >>
> >> "All the Lanes that are associated with the LTSSM (i.e., those Lanes
> >> that are currently operational or may be operational in the future
> >> due to Link
> >> Upconfigure) must participate in the Equalization procedure"
> >>
> >> and in Section-4.2.6.4.2.1.1 it says
> >> "Note: A transition to Recovery.RcvrLock might be used in the case
> >> where the Downstream Port determines that Phase 2 and Phase 3 are not
> >> needed based on the platform and channel characteristics."
> >>
> >> Based on the above statements, I think it is Ok to skip only Phases
> >> 2&3 of equalization but not 0&1.
> >> I even checked with our hardware engineers and it seems
> >> DWC_EQUALIZATION_DISABLE is present only for debugging purpose in
> >> hardware simulations and shouldn't be used on real silicon otherwise it seems.
> >>
> >
> > In DesignWare manual we don't see any comment that this feature is for
> debugging purpose only.
> Agree and as I mentioned even I got to know about it offline.
> 
> > Even if it is meant for debugging purpose, if for some reason in an SoC, Gen3/4
> linkup is failing due to equalization, and if disabling equalization is helping then
> IMO it is OK to do it.
> Well, I don't have specific reservations to not have it. We can use this as a fall
> back option.
> 
> > Just to re-confirm we tested one of the NVMe device on Jatson AGX Xavier RC
> with equalization disabled. We do see linkup works well in GEN3. As we have
> added this feature as a platform-quirk so only platforms that required this
> feature can enable it.
> >
> Curious to know...You did it because link didn't come up with equalization
> enabled? or just as an experiment?
> 

We did this, just as an experiment.

> > Snippet of lspci (from Jatson AGX Xavier RC) is given below, showing
> > EQ is completely disabled and GEN3 linkup
> > -----
> > 0005:01:00.0 Non-Volatile memory controller: Lite-On Technology
> Corporation Device 21f1 (rev 01) (prog-if 02 [NVM Express])
> >          Subsystem: Marvell Technology Group Ltd. Device 1093
> >           <snip>
> >                  LnkCap: Port #0, Speed 8GT/s, Width x4, ASPM L1, Exit Latency L0s
> <512ns, L1 <64us
> >                          ClockPM+ Surprise- LLActRep- BwNot- ASPMOptComp+
> >                  LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- CommClk+
> >                          ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
> >                  LnkSta: Speed 8GT/s, Width x4, TrErr- Train- SlotClk+ DLActive-
> BWMgmt- ABWMgmt-
> >                  DevCap2: Completion Timeout: Not Supported, TimeoutDis+, LTR+,
> OBFF Via message
> >                  DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR+,
> OBFF Disabled
> >                  LnkCtl2: Target Link Speed: 8GT/s, EnterCompliance- SpeedDis-
> >                           Transmit Margin: Normal Operating Range,
> EnterModifiedCompliance- ComplianceSOS-
> >                           Compliance De-emphasis: -6dB
> >                  LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete-,
> EqualizationPhase1-
> >                           EqualizationPhase2-, EqualizationPhase3-,
> > LinkEqualizationRequest-
> > -----
> >> - Vidya Sagar
> >>
> >>
> >>>>>>>    - DWC_EQ_PHASE_2_3_DISABLE: To disable GEN3 equalization
> >>>>>>> phase 2 & 3
> >>>>>>>
> >>>>>>> Platform drivers can set these quirks via "quirk" variable of "dw_pcie"
> >>>>>>> struct.
> >>>>>>>
> >>>>>>> Signed-off-by: Anvesh Salveru <anvesh.s@samsung.com>
> >>>>>>> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> >>>>>>> ---
> >>>>>>> Patchset v1 can be found at:
> >>>>>>>    - 1/2: https://urldefense.proofpoint.com/v2/url?u=https-
> >>
> 3A__lkml.org_lkml_2019_9_10_443&d=DwIBAg&c=DPL6_X_6JkXFx7AXWqB0tg
> >> &r=bkWxpLoW-f-
> >>
> E3EdiDCCa0_h0PicsViasSlvIpzZvPxs&m=MtEKKeJsQvi2UM1eSZUv2vPLLxrYU0aI1
> >> Ry4ICIDaiQ&s=s_nPmMNbQFswYRxQgBkeg4H9J_0FEtzRE-0AruC5WI4&e=
> >>>>>>>    - 2/2:
> >>>>>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__lkml.org_lk
> >>>>>>> ml
> >>>>>>>
> >> _2019_9_10_444&d=DwIBAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=bkWxpLoW-
> f-
> >> E3Ed
> >>>>>>>
> >> iDCCa0_h0PicsViasSlvIpzZvPxs&m=MtEKKeJsQvi2UM1eSZUv2vPLLxrYU0aI1Ry
> >>>>>>>
> 4ICIDaiQ&s=kkfdwcX6bYcLrnJSgw_GcMMGAjnDTMtN2v6svWuANpk&e=
> >>>>>>>
> >>>>>>> Changes w.r.t v1:
> >>>>>>>    - Squashed two patches from v1 into one as suggested by Gustavo
> >>>>>>>    - Addressed review comments from Andrew
> >>>>>>>
> >>>>>>>    drivers/pci/controller/dwc/pcie-designware.c | 12
> >>>>>>> ++++++++++++ drivers/pci/controller/dwc/pcie-designware.h |  9
> +++++++++
> >>>>>>>    2 files changed, 21 insertions(+)
> >>>>>>>
> >>>>>>> diff --git a/drivers/pci/controller/dwc/pcie-designware.c
> >>>>>>> b/drivers/pci/controller/dwc/pcie-designware.c
> >>>>>>> index 7d25102..97fb18d 100644
> >>>>>>> --- a/drivers/pci/controller/dwc/pcie-designware.c
> >>>>>>> +++ b/drivers/pci/controller/dwc/pcie-designware.c
> >>>>>>> @@ -466,4 +466,16 @@ void dw_pcie_setup(struct dw_pcie *pci)
> >>>>>>>    		break;
> >>>>>>>    	}
> >>>>>>>    	dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL,
> val);
> >>>>>>> +
> >>>>>>> +	if (pci->quirk & DWC_EQUALIZATION_DISABLE) {
> >>>>>>> +		val = dw_pcie_readl_dbi(pci,
> PCIE_PORT_GEN3_RELATED);
> >>>>>>> +		val |= PORT_LOGIC_GEN3_EQ_DISABLE;
> >>>>>>> +		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED,
> val);
> >>>>>>> +	}
> >>>>>>> +
> >>>>>>> +	if (pci->quirk & DWC_EQ_PHASE_2_3_DISABLE) {
> >>>>>>> +		val = dw_pcie_readl_dbi(pci,
> PCIE_PORT_GEN3_RELATED);
> >>>>>>> +		val |= PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE;
> >>>>>>> +		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED,
> val);
> >>>>>>> +	}
> >>>>>>>    }
> >>>>>>> diff --git a/drivers/pci/controller/dwc/pcie-designware.h
> >>>>>>> b/drivers/pci/controller/dwc/pcie-designware.h
> >>>>>>> index ffed084..e428b62 100644
> >>>>>>> --- a/drivers/pci/controller/dwc/pcie-designware.h
> >>>>>>> +++ b/drivers/pci/controller/dwc/pcie-designware.h
> >>>>>>> @@ -29,6 +29,10 @@
> >>>>>>>    #define LINK_WAIT_MAX_IATU_RETRIES	5
> >>>>>>>    #define LINK_WAIT_IATU			9
> >>>>>>>
> >>>>>>> +/* Parameters for GEN3 related quirks */
> >>>>>>> +#define DWC_EQUALIZATION_DISABLE	BIT(1)
> >>>>>>> +#define DWC_EQ_PHASE_2_3_DISABLE	BIT(2)
> >>>>>>> +
> >>>>>>>    /* Synopsys-specific PCIe configuration registers */
> >>>>>>>    #define PCIE_PORT_LINK_CONTROL		0x710
> >>>>>>>    #define PORT_LINK_MODE_MASK		GENMASK(21, 16)
> >>>>>>> @@ -60,6 +64,10 @@
> >>>>>>>    #define PCIE_MSI_INTR0_MASK		0x82C
> >>>>>>>    #define PCIE_MSI_INTR0_STATUS		0x830
> >>>>>>>
> >>>>>>> +#define PCIE_PORT_GEN3_RELATED		0x890
> >>>>>>
> >>>>>> I hadn't noticed this in the previous version - what is the
> >>>>>> proper name
> >>>>> for this
> >>>>>> register? Does it end in _RELATED?
> >>>>>
> >>>>> As per SNPS databook the name of the register is "GEN3_RELATED_OFF".
> >>>>> It is port logic register so, to keep similarity with other port
> >>>>> logic registers in this file we named it as "PCIE_PORT_GEN3_RELATED".
> >>>>
> >>>> OK.
> >>>>
> >>>> Reviewed-by: Andrew Murray <andrew.murray@arm.com>
> >>>>
> >>>> Also is the SNPS databook publicly available? I'd be interested in
> >>>> reading it.
> >>>
> >>> The databook isn't openly available, sorry.
> >>>
> >>> Gustavo
> >>>
> >>>>
> >>>> Thanks,
> >>>>
> >>>> Andrew Murray
> >>>>
> >>>>>
> >>>>>>
> >>>>>> Thanks,
> >>>>>>
> >>>>>> Andrew Murray
> >>>>>>
> >>>>>>> +#define PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE	BIT(9)
> >>>>>>> +#define PORT_LOGIC_GEN3_EQ_DISABLE		BIT(16)
> >>>>>>> +
> >>>>>>>    #define PCIE_ATU_VIEWPORT		0x900
> >>>>>>>    #define PCIE_ATU_REGION_INBOUND		BIT(31)
> >>>>>>>    #define PCIE_ATU_REGION_OUTBOUND	0
> >>>>>>> @@ -244,6 +252,7 @@ struct dw_pcie {
> >>>>>>>    	struct dw_pcie_ep	ep;
> >>>>>>>    	const struct dw_pcie_ops *ops;
> >>>>>>>    	unsigned int		version;
> >>>>>>> +	unsigned int		quirk;
> >>>>>>>    };
> >>>>>>>
> >>>>>>>    #define to_dw_pcie_from_pp(port) container_of((port), struct
> >>>>>>> dw_pcie,
> >>>>>>> pp)
> >>>>>>> --
> >>>>>>> 2.7.4
> >>>>>>>
> >>>>>
> >>>
> >>>
> >
> >



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

* Re: [PATCH v2] PCI: dwc: Add support to add GEN3 related equalization quirks
  2019-09-24 12:11                 ` Pankaj Dubey
@ 2019-09-25  4:11                   ` Vidya Sagar
  0 siblings, 0 replies; 14+ messages in thread
From: Vidya Sagar @ 2019-09-25  4:11 UTC (permalink / raw)
  To: Pankaj Dubey, 'Gustavo Pimentel', 'Andrew Murray'
  Cc: linux-pci, linux-kernel, jingoohan1, lorenzo.pieralisi, bhelgaas,
	'Anvesh Salveru'

On 9/24/2019 5:41 PM, Pankaj Dubey wrote:
> 
> 
>> -----Original Message-----
>> From: Vidya Sagar <vidyas@nvidia.com>
>> Sent: Tuesday, September 24, 2019 4:57 PM
>> To: Pankaj Dubey <pankaj.dubey@samsung.com>; 'Gustavo Pimentel'
>> <Gustavo.Pimentel@synopsys.com>; 'Andrew Murray'
>> <andrew.murray@arm.com>
>> Cc: linux-pci@vger.kernel.org; linux-kernel@vger.kernel.org;
>> jingoohan1@gmail.com; lorenzo.pieralisi@arm.com; bhelgaas@google.com;
>> 'Anvesh Salveru' <anvesh.s@samsung.com>
>> Subject: Re: [PATCH v2] PCI: dwc: Add support to add GEN3 related equalization
>> quirks
>>
>> On 9/24/2019 2:58 PM, Pankaj Dubey wrote:
>>>
>>>
>>>> -----Original Message-----
>>>> From: Vidya Sagar <vidyas@nvidia.com>
>>>> Sent: Thursday, September 19, 2019 4:54 PM
>>>> Subject: Re: [PATCH v2] PCI: dwc: Add support to add GEN3 related
>>>> equalization quirks
>>>>
>>>> On 9/16/2019 6:22 PM, Gustavo Pimentel wrote:
>>>>> On Mon, Sep 16, 2019 at 13:24:1, Andrew Murray
>>>> <andrew.murray@arm.com>
>>>>> wrote:
>>>>>
>>>>>> On Mon, Sep 16, 2019 at 04:36:33PM +0530, Pankaj Dubey wrote:
>>>>>>>
>>>>>>>
>>>>>>>> -----Original Message-----
>>>>>>>> From: Andrew Murray <andrew.murray@arm.com>
>>>>>>>> Sent: Monday, September 16, 2019 3:46 PM
>>>>>>>> To: Pankaj Dubey <pankaj.dubey@samsung.com>
>>>>>>>> Cc: linux-pci@vger.kernel.org; linux-kernel@vger.kernel.org;
>>>>>>>> jingoohan1@gmail.com; gustavo.pimentel@synopsys.com;
>>>>>>>> lorenzo.pieralisi@arm.com; bhelgaas@google.com; Anvesh Salveru
>>>>>>>> <anvesh.s@samsung.com>
>>>>>>>> Subject: Re: [PATCH v2] PCI: dwc: Add support to add GEN3 related
>>>>>>> equalization
>>>>>>>> quirks
>>>>>>>>
>>>>>>>> On Fri, Sep 13, 2019 at 04:09:50PM +0530, Pankaj Dubey wrote:
>>>>>>>>> From: Anvesh Salveru <anvesh.s@samsung.com>
>>>>>>>>>
>>>>>>>>> In some platforms, PCIe PHY may have issues which will prevent
>>>>>>>>> linkup to happen in GEN3 or higher speed. In case equalization
>>>>>>>>> fails, link will fallback to GEN1.
>>>>>>>>>
>>>>>>>>> DesignWare controller gives flexibility to disable GEN3
>>>>>>>>> equalization completely or only phase 2 and 3 of equalization.
>>>>>>>>>
>>>>>>>>> This patch enables the DesignWare driver to disable the PCIe
>>>>>>>>> GEN3 equalization by enabling one of the following quirks:
>>>>>>>>>     - DWC_EQUALIZATION_DISABLE: To disable GEN3 equalization all
>>>>>>>>> phases
>>>> I don't think Gen-3 equalization can be skipped altogether.
>>>> PCIe Spec Rev 4.0 Ver 1.0 in Section-4.2.3 has the following statement.
>>>>
>>>> "All the Lanes that are associated with the LTSSM (i.e., those Lanes
>>>> that are currently operational or may be operational in the future
>>>> due to Link
>>>> Upconfigure) must participate in the Equalization procedure"
>>>>
>>>> and in Section-4.2.6.4.2.1.1 it says
>>>> "Note: A transition to Recovery.RcvrLock might be used in the case
>>>> where the Downstream Port determines that Phase 2 and Phase 3 are not
>>>> needed based on the platform and channel characteristics."
>>>>
>>>> Based on the above statements, I think it is Ok to skip only Phases
>>>> 2&3 of equalization but not 0&1.
>>>> I even checked with our hardware engineers and it seems
>>>> DWC_EQUALIZATION_DISABLE is present only for debugging purpose in
>>>> hardware simulations and shouldn't be used on real silicon otherwise it seems.
>>>>
>>>
>>> In DesignWare manual we don't see any comment that this feature is for
>> debugging purpose only.
>> Agree and as I mentioned even I got to know about it offline.
>>
>>> Even if it is meant for debugging purpose, if for some reason in an SoC, Gen3/4
>> linkup is failing due to equalization, and if disabling equalization is helping then
>> IMO it is OK to do it.
>> Well, I don't have specific reservations to not have it. We can use this as a fall
>> back option.
>>
>>> Just to re-confirm we tested one of the NVMe device on Jatson AGX Xavier RC
>> with equalization disabled. We do see linkup works well in GEN3. As we have
>> added this feature as a platform-quirk so only platforms that required this
>> feature can enable it.
>>>
>> Curious to know...You did it because link didn't come up with equalization
>> enabled? or just as an experiment?
>>
> 
> We did this, just as an experiment.
Ok. Thanks for the clarification.

Reviewed-by: Vidya Sagar <vidyas@nvidia.com>

> 
>>> Snippet of lspci (from Jatson AGX Xavier RC) is given below, showing
>>> EQ is completely disabled and GEN3 linkup
>>> -----
>>> 0005:01:00.0 Non-Volatile memory controller: Lite-On Technology
>> Corporation Device 21f1 (rev 01) (prog-if 02 [NVM Express])
>>>           Subsystem: Marvell Technology Group Ltd. Device 1093
>>>            <snip>
>>>                   LnkCap: Port #0, Speed 8GT/s, Width x4, ASPM L1, Exit Latency L0s
>> <512ns, L1 <64us
>>>                           ClockPM+ Surprise- LLActRep- BwNot- ASPMOptComp+
>>>                   LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- CommClk+
>>>                           ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
>>>                   LnkSta: Speed 8GT/s, Width x4, TrErr- Train- SlotClk+ DLActive-
>> BWMgmt- ABWMgmt-
>>>                   DevCap2: Completion Timeout: Not Supported, TimeoutDis+, LTR+,
>> OBFF Via message
>>>                   DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR+,
>> OBFF Disabled
>>>                   LnkCtl2: Target Link Speed: 8GT/s, EnterCompliance- SpeedDis-
>>>                            Transmit Margin: Normal Operating Range,
>> EnterModifiedCompliance- ComplianceSOS-
>>>                            Compliance De-emphasis: -6dB
>>>                   LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete-,
>> EqualizationPhase1-
>>>                            EqualizationPhase2-, EqualizationPhase3-,
>>> LinkEqualizationRequest-
>>> -----
>>>> - Vidya Sagar
>>>>
>>>>
>>>>>>>>>     - DWC_EQ_PHASE_2_3_DISABLE: To disable GEN3 equalization
>>>>>>>>> phase 2 & 3
>>>>>>>>>
>>>>>>>>> Platform drivers can set these quirks via "quirk" variable of "dw_pcie"
>>>>>>>>> struct.
>>>>>>>>>
>>>>>>>>> Signed-off-by: Anvesh Salveru <anvesh.s@samsung.com>
>>>>>>>>> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
>>>>>>>>> ---
>>>>>>>>> Patchset v1 can be found at:
>>>>>>>>>     - 1/2: https://urldefense.proofpoint.com/v2/url?u=https-
>>>>
>> 3A__lkml.org_lkml_2019_9_10_443&d=DwIBAg&c=DPL6_X_6JkXFx7AXWqB0tg
>>>> &r=bkWxpLoW-f-
>>>>
>> E3EdiDCCa0_h0PicsViasSlvIpzZvPxs&m=MtEKKeJsQvi2UM1eSZUv2vPLLxrYU0aI1
>>>> Ry4ICIDaiQ&s=s_nPmMNbQFswYRxQgBkeg4H9J_0FEtzRE-0AruC5WI4&e=
>>>>>>>>>     - 2/2:
>>>>>>>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__lkml.org_lk
>>>>>>>>> ml
>>>>>>>>>
>>>> _2019_9_10_444&d=DwIBAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=bkWxpLoW-
>> f-
>>>> E3Ed
>>>>>>>>>
>>>> iDCCa0_h0PicsViasSlvIpzZvPxs&m=MtEKKeJsQvi2UM1eSZUv2vPLLxrYU0aI1Ry
>>>>>>>>>
>> 4ICIDaiQ&s=kkfdwcX6bYcLrnJSgw_GcMMGAjnDTMtN2v6svWuANpk&e=
>>>>>>>>>
>>>>>>>>> Changes w.r.t v1:
>>>>>>>>>     - Squashed two patches from v1 into one as suggested by Gustavo
>>>>>>>>>     - Addressed review comments from Andrew
>>>>>>>>>
>>>>>>>>>     drivers/pci/controller/dwc/pcie-designware.c | 12
>>>>>>>>> ++++++++++++ drivers/pci/controller/dwc/pcie-designware.h |  9
>> +++++++++
>>>>>>>>>     2 files changed, 21 insertions(+)
>>>>>>>>>
>>>>>>>>> diff --git a/drivers/pci/controller/dwc/pcie-designware.c
>>>>>>>>> b/drivers/pci/controller/dwc/pcie-designware.c
>>>>>>>>> index 7d25102..97fb18d 100644
>>>>>>>>> --- a/drivers/pci/controller/dwc/pcie-designware.c
>>>>>>>>> +++ b/drivers/pci/controller/dwc/pcie-designware.c
>>>>>>>>> @@ -466,4 +466,16 @@ void dw_pcie_setup(struct dw_pcie *pci)
>>>>>>>>>     		break;
>>>>>>>>>     	}
>>>>>>>>>     	dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL,
>> val);
>>>>>>>>> +
>>>>>>>>> +	if (pci->quirk & DWC_EQUALIZATION_DISABLE) {
>>>>>>>>> +		val = dw_pcie_readl_dbi(pci,
>> PCIE_PORT_GEN3_RELATED);
>>>>>>>>> +		val |= PORT_LOGIC_GEN3_EQ_DISABLE;
>>>>>>>>> +		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED,
>> val);
>>>>>>>>> +	}
>>>>>>>>> +
>>>>>>>>> +	if (pci->quirk & DWC_EQ_PHASE_2_3_DISABLE) {
>>>>>>>>> +		val = dw_pcie_readl_dbi(pci,
>> PCIE_PORT_GEN3_RELATED);
>>>>>>>>> +		val |= PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE;
>>>>>>>>> +		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED,
>> val);
>>>>>>>>> +	}
>>>>>>>>>     }
>>>>>>>>> diff --git a/drivers/pci/controller/dwc/pcie-designware.h
>>>>>>>>> b/drivers/pci/controller/dwc/pcie-designware.h
>>>>>>>>> index ffed084..e428b62 100644
>>>>>>>>> --- a/drivers/pci/controller/dwc/pcie-designware.h
>>>>>>>>> +++ b/drivers/pci/controller/dwc/pcie-designware.h
>>>>>>>>> @@ -29,6 +29,10 @@
>>>>>>>>>     #define LINK_WAIT_MAX_IATU_RETRIES	5
>>>>>>>>>     #define LINK_WAIT_IATU			9
>>>>>>>>>
>>>>>>>>> +/* Parameters for GEN3 related quirks */
>>>>>>>>> +#define DWC_EQUALIZATION_DISABLE	BIT(1)
>>>>>>>>> +#define DWC_EQ_PHASE_2_3_DISABLE	BIT(2)
>>>>>>>>> +
>>>>>>>>>     /* Synopsys-specific PCIe configuration registers */
>>>>>>>>>     #define PCIE_PORT_LINK_CONTROL		0x710
>>>>>>>>>     #define PORT_LINK_MODE_MASK		GENMASK(21, 16)
>>>>>>>>> @@ -60,6 +64,10 @@
>>>>>>>>>     #define PCIE_MSI_INTR0_MASK		0x82C
>>>>>>>>>     #define PCIE_MSI_INTR0_STATUS		0x830
>>>>>>>>>
>>>>>>>>> +#define PCIE_PORT_GEN3_RELATED		0x890
>>>>>>>>
>>>>>>>> I hadn't noticed this in the previous version - what is the
>>>>>>>> proper name
>>>>>>> for this
>>>>>>>> register? Does it end in _RELATED?
>>>>>>>
>>>>>>> As per SNPS databook the name of the register is "GEN3_RELATED_OFF".
>>>>>>> It is port logic register so, to keep similarity with other port
>>>>>>> logic registers in this file we named it as "PCIE_PORT_GEN3_RELATED".
>>>>>>
>>>>>> OK.
>>>>>>
>>>>>> Reviewed-by: Andrew Murray <andrew.murray@arm.com>
>>>>>>
>>>>>> Also is the SNPS databook publicly available? I'd be interested in
>>>>>> reading it.
>>>>>
>>>>> The databook isn't openly available, sorry.
>>>>>
>>>>> Gustavo
>>>>>
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> Andrew Murray
>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>>
>>>>>>>> Andrew Murray
>>>>>>>>
>>>>>>>>> +#define PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE	BIT(9)
>>>>>>>>> +#define PORT_LOGIC_GEN3_EQ_DISABLE		BIT(16)
>>>>>>>>> +
>>>>>>>>>     #define PCIE_ATU_VIEWPORT		0x900
>>>>>>>>>     #define PCIE_ATU_REGION_INBOUND		BIT(31)
>>>>>>>>>     #define PCIE_ATU_REGION_OUTBOUND	0
>>>>>>>>> @@ -244,6 +252,7 @@ struct dw_pcie {
>>>>>>>>>     	struct dw_pcie_ep	ep;
>>>>>>>>>     	const struct dw_pcie_ops *ops;
>>>>>>>>>     	unsigned int		version;
>>>>>>>>> +	unsigned int		quirk;
>>>>>>>>>     };
>>>>>>>>>
>>>>>>>>>     #define to_dw_pcie_from_pp(port) container_of((port), struct
>>>>>>>>> dw_pcie,
>>>>>>>>> pp)
>>>>>>>>> --
>>>>>>>>> 2.7.4
>>>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>
>>>
> 
> 


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

* RE: [PATCH v2] PCI: dwc: Add support to add GEN3 related equalization quirks
  2019-10-14 15:13   ` Lorenzo Pieralisi
@ 2019-10-15  2:58     ` Pankaj Dubey
  0 siblings, 0 replies; 14+ messages in thread
From: Pankaj Dubey @ 2019-10-15  2:58 UTC (permalink / raw)
  To: 'Lorenzo Pieralisi'
  Cc: linux-pci, linux-kernel, bhelgaas, andrew.murray,
	gustavo.pimentel, jingoohan1, vidyas, 'Anvesh Salveru'



> -----Original Message-----
> From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Sent: Monday, October 14, 2019 8:44 PM
> To: Pankaj Dubey <pankaj.dubey@samsung.com>
> Cc: linux-pci@vger.kernel.org; linux-kernel@vger.kernel.org;
> bhelgaas@google.com; andrew.murray@arm.com;
> gustavo.pimentel@synopsys.com; jingoohan1@gmail.com; vidyas@nvidia.com;
> Anvesh Salveru <anvesh.s@samsung.com>
> Subject: Re: [PATCH v2] PCI: dwc: Add support to add GEN3 related
equalization
> quirks
> 
> On Mon, Oct 14, 2019 at 12:48:29PM +0530, Pankaj Dubey wrote:
> > From: Anvesh Salveru <anvesh.s@samsung.com>
> >
> > In some platforms, PCIe PHY may have issues which will prevent linkup
> > to happen in GEN3 or higher speed. In case equalization fails, link
> > will fallback to GEN1.
> >
> > DesignWare controller gives flexibility to disable GEN3 equalization
> > completely or only phase 2 and 3 of equalization.
> >
> > This patch enables the DesignWare driver to disable the PCIe GEN3
> > equalization by enabling one of the following quirks:
> >  - DWC_EQUALIZATION_DISABLE: To disable GEN3 equalization all phases
> >  - DWC_EQ_PHASE_2_3_DISABLE: To disable GEN3 equalization phase 2 & 3
> >
> > Platform drivers can set these quirks via "quirk" variable of "dw_pcie"
> > struct.
> >
> > Signed-off-by: Anvesh Salveru <anvesh.s@samsung.com>
> > Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> > Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
> > Reviewed-by: Andrew Murray <andrew.murray@arm.com>
> > Reviewed-by: Vidya Sagar <vidyas@nvidia.com>
> > ---
> > Changes w.r.t v1:
> >  - Rebased on latest linus/master
> >  - Added Reviewed-by and Acked-by
> >
> >  drivers/pci/controller/dwc/pcie-designware.c | 12 ++++++++++++
> > drivers/pci/controller/dwc/pcie-designware.h |  9 +++++++++
> >  2 files changed, 21 insertions(+)
> 
> So this is v3 not v2, right ?
> 

Yes, you are right. I missed this. 
This can be discarded, I will resend the patch with v3 tag.

> Here is v2:
> 
> https://protect2.fireeye.com/url?k=47b7cdf58f33e5e1.47b646ba-
> 8ad463719e64eba8&u=https://patchwork.ozlabs.org/patch/1161958/
> 
> > diff --git a/drivers/pci/controller/dwc/pcie-designware.c
> > b/drivers/pci/controller/dwc/pcie-designware.c
> > index 820488d..e247d6d 100644
> > --- a/drivers/pci/controller/dwc/pcie-designware.c
> > +++ b/drivers/pci/controller/dwc/pcie-designware.c
> > @@ -556,4 +556,16 @@ void dw_pcie_setup(struct dw_pcie *pci)
> >  		       PCIE_PL_CHK_REG_CHK_REG_START;
> >  		dw_pcie_writel_dbi(pci, PCIE_PL_CHK_REG_CONTROL_STATUS,
> val);
> >  	}
> > +
> > +	if (pci->quirk & DWC_EQUALIZATION_DISABLE) {
> > +		val = dw_pcie_readl_dbi(pci, PCIE_PORT_GEN3_RELATED);
> > +		val |= PORT_LOGIC_GEN3_EQ_DISABLE;
> > +		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED, val);
> > +	}
> > +
> > +	if (pci->quirk & DWC_EQ_PHASE_2_3_DISABLE) {
> > +		val = dw_pcie_readl_dbi(pci, PCIE_PORT_GEN3_RELATED);
> > +		val |= PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE;
> > +		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED, val);
> > +	}
> >  }
> > diff --git a/drivers/pci/controller/dwc/pcie-designware.h
> > b/drivers/pci/controller/dwc/pcie-designware.h
> > index 5a18e94..7d3fe6f 100644
> > --- a/drivers/pci/controller/dwc/pcie-designware.h
> > +++ b/drivers/pci/controller/dwc/pcie-designware.h
> > @@ -29,6 +29,10 @@
> >  #define LINK_WAIT_MAX_IATU_RETRIES	5
> >  #define LINK_WAIT_IATU			9
> >
> > +/* Parameters for GEN3 related quirks */
> > +#define DWC_EQUALIZATION_DISABLE	BIT(1)
> > +#define DWC_EQ_PHASE_2_3_DISABLE	BIT(2)
> > +
> >  /* Synopsys-specific PCIe configuration registers */
> >  #define PCIE_PORT_LINK_CONTROL		0x710
> >  #define PORT_LINK_MODE_MASK		GENMASK(21, 16)
> > @@ -60,6 +64,10 @@
> >  #define PCIE_MSI_INTR0_MASK		0x82C
> >  #define PCIE_MSI_INTR0_STATUS		0x830
> >
> > +#define PCIE_PORT_GEN3_RELATED		0x890
> > +#define PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE	BIT(9)
> > +#define PORT_LOGIC_GEN3_EQ_DISABLE		BIT(16)
> > +
> >  #define PCIE_ATU_VIEWPORT		0x900
> >  #define PCIE_ATU_REGION_INBOUND		BIT(31)
> >  #define PCIE_ATU_REGION_OUTBOUND	0
> > @@ -253,6 +261,7 @@ struct dw_pcie {
> >  	struct dw_pcie_ep	ep;
> >  	const struct dw_pcie_ops *ops;
> >  	unsigned int		version;
> > +	unsigned int		quirk;
> >  };
> >
> >  #define to_dw_pcie_from_pp(port) container_of((port), struct dw_pcie,
> > pp)
> > --
> > 2.7.4
> >


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

* Re: [PATCH v2] PCI: dwc: Add support to add GEN3 related equalization quirks
  2019-10-14  7:18 ` Pankaj Dubey
@ 2019-10-14 15:13   ` Lorenzo Pieralisi
  2019-10-15  2:58     ` Pankaj Dubey
  0 siblings, 1 reply; 14+ messages in thread
From: Lorenzo Pieralisi @ 2019-10-14 15:13 UTC (permalink / raw)
  To: Pankaj Dubey
  Cc: linux-pci, linux-kernel, bhelgaas, andrew.murray,
	gustavo.pimentel, jingoohan1, vidyas, Anvesh Salveru

On Mon, Oct 14, 2019 at 12:48:29PM +0530, Pankaj Dubey wrote:
> From: Anvesh Salveru <anvesh.s@samsung.com>
> 
> In some platforms, PCIe PHY may have issues which will prevent linkup
> to happen in GEN3 or higher speed. In case equalization fails, link will
> fallback to GEN1.
> 
> DesignWare controller gives flexibility to disable GEN3 equalization
> completely or only phase 2 and 3 of equalization.
> 
> This patch enables the DesignWare driver to disable the PCIe GEN3
> equalization by enabling one of the following quirks:
>  - DWC_EQUALIZATION_DISABLE: To disable GEN3 equalization all phases
>  - DWC_EQ_PHASE_2_3_DISABLE: To disable GEN3 equalization phase 2 & 3
> 
> Platform drivers can set these quirks via "quirk" variable of "dw_pcie"
> struct.
> 
> Signed-off-by: Anvesh Salveru <anvesh.s@samsung.com>
> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
> Reviewed-by: Andrew Murray <andrew.murray@arm.com>
> Reviewed-by: Vidya Sagar <vidyas@nvidia.com>
> ---
> Changes w.r.t v1:
>  - Rebased on latest linus/master
>  - Added Reviewed-by and Acked-by
> 
>  drivers/pci/controller/dwc/pcie-designware.c | 12 ++++++++++++
>  drivers/pci/controller/dwc/pcie-designware.h |  9 +++++++++
>  2 files changed, 21 insertions(+)

So this is v3 not v2, right ?

Here is v2:

https://patchwork.ozlabs.org/patch/1161958/

> diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
> index 820488d..e247d6d 100644
> --- a/drivers/pci/controller/dwc/pcie-designware.c
> +++ b/drivers/pci/controller/dwc/pcie-designware.c
> @@ -556,4 +556,16 @@ void dw_pcie_setup(struct dw_pcie *pci)
>  		       PCIE_PL_CHK_REG_CHK_REG_START;
>  		dw_pcie_writel_dbi(pci, PCIE_PL_CHK_REG_CONTROL_STATUS, val);
>  	}
> +
> +	if (pci->quirk & DWC_EQUALIZATION_DISABLE) {
> +		val = dw_pcie_readl_dbi(pci, PCIE_PORT_GEN3_RELATED);
> +		val |= PORT_LOGIC_GEN3_EQ_DISABLE;
> +		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED, val);
> +	}
> +
> +	if (pci->quirk & DWC_EQ_PHASE_2_3_DISABLE) {
> +		val = dw_pcie_readl_dbi(pci, PCIE_PORT_GEN3_RELATED);
> +		val |= PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE;
> +		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED, val);
> +	}
>  }
> diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
> index 5a18e94..7d3fe6f 100644
> --- a/drivers/pci/controller/dwc/pcie-designware.h
> +++ b/drivers/pci/controller/dwc/pcie-designware.h
> @@ -29,6 +29,10 @@
>  #define LINK_WAIT_MAX_IATU_RETRIES	5
>  #define LINK_WAIT_IATU			9
>  
> +/* Parameters for GEN3 related quirks */
> +#define DWC_EQUALIZATION_DISABLE	BIT(1)
> +#define DWC_EQ_PHASE_2_3_DISABLE	BIT(2)
> +
>  /* Synopsys-specific PCIe configuration registers */
>  #define PCIE_PORT_LINK_CONTROL		0x710
>  #define PORT_LINK_MODE_MASK		GENMASK(21, 16)
> @@ -60,6 +64,10 @@
>  #define PCIE_MSI_INTR0_MASK		0x82C
>  #define PCIE_MSI_INTR0_STATUS		0x830
>  
> +#define PCIE_PORT_GEN3_RELATED		0x890
> +#define PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE	BIT(9)
> +#define PORT_LOGIC_GEN3_EQ_DISABLE		BIT(16)
> +
>  #define PCIE_ATU_VIEWPORT		0x900
>  #define PCIE_ATU_REGION_INBOUND		BIT(31)
>  #define PCIE_ATU_REGION_OUTBOUND	0
> @@ -253,6 +261,7 @@ struct dw_pcie {
>  	struct dw_pcie_ep	ep;
>  	const struct dw_pcie_ops *ops;
>  	unsigned int		version;
> +	unsigned int		quirk;
>  };
>  
>  #define to_dw_pcie_from_pp(port) container_of((port), struct dw_pcie, pp)
> -- 
> 2.7.4
> 

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

* [PATCH v2] PCI: dwc: Add support to add GEN3 related equalization quirks
       [not found] <CGME20191014071838epcas5p2901e45c978e5a9d6dfbdde2dadea6d9d@epcas5p2.samsung.com>
@ 2019-10-14  7:18 ` Pankaj Dubey
  2019-10-14 15:13   ` Lorenzo Pieralisi
  0 siblings, 1 reply; 14+ messages in thread
From: Pankaj Dubey @ 2019-10-14  7:18 UTC (permalink / raw)
  To: linux-pci, linux-kernel
  Cc: bhelgaas, andrew.murray, lorenzo.pieralisi, gustavo.pimentel,
	jingoohan1, vidyas, Anvesh Salveru, Pankaj Dubey

From: Anvesh Salveru <anvesh.s@samsung.com>

In some platforms, PCIe PHY may have issues which will prevent linkup
to happen in GEN3 or higher speed. In case equalization fails, link will
fallback to GEN1.

DesignWare controller gives flexibility to disable GEN3 equalization
completely or only phase 2 and 3 of equalization.

This patch enables the DesignWare driver to disable the PCIe GEN3
equalization by enabling one of the following quirks:
 - DWC_EQUALIZATION_DISABLE: To disable GEN3 equalization all phases
 - DWC_EQ_PHASE_2_3_DISABLE: To disable GEN3 equalization phase 2 & 3

Platform drivers can set these quirks via "quirk" variable of "dw_pcie"
struct.

Signed-off-by: Anvesh Salveru <anvesh.s@samsung.com>
Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Reviewed-by: Andrew Murray <andrew.murray@arm.com>
Reviewed-by: Vidya Sagar <vidyas@nvidia.com>
---
Changes w.r.t v1:
 - Rebased on latest linus/master
 - Added Reviewed-by and Acked-by

 drivers/pci/controller/dwc/pcie-designware.c | 12 ++++++++++++
 drivers/pci/controller/dwc/pcie-designware.h |  9 +++++++++
 2 files changed, 21 insertions(+)

diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
index 820488d..e247d6d 100644
--- a/drivers/pci/controller/dwc/pcie-designware.c
+++ b/drivers/pci/controller/dwc/pcie-designware.c
@@ -556,4 +556,16 @@ void dw_pcie_setup(struct dw_pcie *pci)
 		       PCIE_PL_CHK_REG_CHK_REG_START;
 		dw_pcie_writel_dbi(pci, PCIE_PL_CHK_REG_CONTROL_STATUS, val);
 	}
+
+	if (pci->quirk & DWC_EQUALIZATION_DISABLE) {
+		val = dw_pcie_readl_dbi(pci, PCIE_PORT_GEN3_RELATED);
+		val |= PORT_LOGIC_GEN3_EQ_DISABLE;
+		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED, val);
+	}
+
+	if (pci->quirk & DWC_EQ_PHASE_2_3_DISABLE) {
+		val = dw_pcie_readl_dbi(pci, PCIE_PORT_GEN3_RELATED);
+		val |= PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE;
+		dw_pcie_writel_dbi(pci, PCIE_PORT_GEN3_RELATED, val);
+	}
 }
diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
index 5a18e94..7d3fe6f 100644
--- a/drivers/pci/controller/dwc/pcie-designware.h
+++ b/drivers/pci/controller/dwc/pcie-designware.h
@@ -29,6 +29,10 @@
 #define LINK_WAIT_MAX_IATU_RETRIES	5
 #define LINK_WAIT_IATU			9
 
+/* Parameters for GEN3 related quirks */
+#define DWC_EQUALIZATION_DISABLE	BIT(1)
+#define DWC_EQ_PHASE_2_3_DISABLE	BIT(2)
+
 /* Synopsys-specific PCIe configuration registers */
 #define PCIE_PORT_LINK_CONTROL		0x710
 #define PORT_LINK_MODE_MASK		GENMASK(21, 16)
@@ -60,6 +64,10 @@
 #define PCIE_MSI_INTR0_MASK		0x82C
 #define PCIE_MSI_INTR0_STATUS		0x830
 
+#define PCIE_PORT_GEN3_RELATED		0x890
+#define PORT_LOGIC_GEN3_EQ_PHASE_2_3_DISABLE	BIT(9)
+#define PORT_LOGIC_GEN3_EQ_DISABLE		BIT(16)
+
 #define PCIE_ATU_VIEWPORT		0x900
 #define PCIE_ATU_REGION_INBOUND		BIT(31)
 #define PCIE_ATU_REGION_OUTBOUND	0
@@ -253,6 +261,7 @@ struct dw_pcie {
 	struct dw_pcie_ep	ep;
 	const struct dw_pcie_ops *ops;
 	unsigned int		version;
+	unsigned int		quirk;
 };
 
 #define to_dw_pcie_from_pp(port) container_of((port), struct dw_pcie, pp)
-- 
2.7.4


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

end of thread, other threads:[~2019-10-15  2:58 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20190913104018epcas5p3d93265a6786dc2b7b8a7d3231bfe9c14@epcas5p3.samsung.com>
2019-09-13 10:39 ` [PATCH v2] PCI: dwc: Add support to add GEN3 related equalization quirks Pankaj Dubey
2019-09-16  9:16   ` Gustavo Pimentel
2019-09-16 10:15   ` Andrew Murray
2019-09-16 11:06     ` Pankaj Dubey
2019-09-16 12:24       ` Andrew Murray
2019-09-16 12:52         ` Gustavo Pimentel
2019-09-19 11:24           ` Vidya Sagar
2019-09-24  9:28             ` Pankaj Dubey
2019-09-24 11:27               ` Vidya Sagar
2019-09-24 12:11                 ` Pankaj Dubey
2019-09-25  4:11                   ` Vidya Sagar
     [not found] <CGME20191014071838epcas5p2901e45c978e5a9d6dfbdde2dadea6d9d@epcas5p2.samsung.com>
2019-10-14  7:18 ` Pankaj Dubey
2019-10-14 15:13   ` Lorenzo Pieralisi
2019-10-15  2:58     ` Pankaj Dubey

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).