Skip to contentSkip to conversation

pci-dra7xx: Enable errata i870 workaround for RC mode

PATCH Superseded Vignesh R 2 participants 5 messages Sep 17, 2018 – Sep 18, 2018

Subsystems (4)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Vignesh R

author maintainer
#0 lore raw

v4 cover pci-dra7xx: Enable errata i870 workaround for RC mode

Make workaround for errata i870 applicable in Host mode as well(previously it was enabled only for EP mode) as per errata
documentation: http://www.ti.com/lit/er/sprz450/sprz450.pdf
Driver will continue to work with w/o applying errata in host mode when using older DT, to maintain backward compatibility.

Tested on DRA72 EVM

Changes since v3:
Rebase onto latest next
Drop DT patches from this series. They will be sent separately once driver changes in this series is merged.

Changes since v2:
Reorder patch 2 to appear at the last.
Collect all the ACKs

Changes since v1:
Drop IRQ handling rework (will be sent out separately)

v2: https://patchwork.ozlabs.org/cover/935454/
v1: https://lkml.org/lkml/2017/12/1/59

Vignesh R (2):
dt-bindings: PCI: dra7xx: Add bindings for unaligned access in host
mode
pci: dwc: pci-dra7xx: Enable errata i870 for both EP and RC mode

 Documentation/devicetree/bindings/pci/ti-pci.txt |  5 +++++
 drivers/pci/controller/dwc/pci-dra7xx.c          | 12 ++++++------
 2 files changed, 11 insertions(+), 6 deletions(-)
Signature · 1 line
2.19.0
author maintainer
#1 lore raw

PATCH v4 1/2 dt-bindings: PCI: dra7xx: Add bindings for unaligned access in host mode

Update device tree binding documentation of TI's dra7xx PCI controller for enabling unaligned mem access as applicable not just in EP mode but in host mode as well.

---
 Documentation/devicetree/bindings/pci/ti-pci.txt | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/pci/ti-pci.txt +5 -0
index 7f7af3044016..452fe48c4fdd 100644
@@ -26,6 +26,11 @@ HOST MODE
    ranges,
    interrupt-map-mask,
    interrupt-map : as specified in ../designware-pcie.txt
+ - ti,syscon-unaligned-access: phandle to the syscon DT node. The 1st argument
+			       should contain the register offset within syscon
+			       and the 2nd argument should contain the bit field
+			       for setting the bit to enable unaligned
+			       access.
 
 DEVICE MODE
 ===========
Signature · 1 line
2.19.0
author maintainer
#2 lore raw

PATCH v4 2/2 pci: dwc: pci-dra7xx: Enable errata i870 for both EP and RC mode

In reply to Vignesh R

Errata i870 is applicable in both EP and RC mode. Therefore rename function dra7xx_pcie_ep_unaligned_memaccess(), that implements errata workaround, to dra7xx_pcie_unaligned_memaccess() and call it from a common place. So, that errata workaround is applied for both modes of operation.

---
 drivers/pci/controller/dwc/pci-dra7xx.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/pci/controller/dwc/pci-dra7xx.c +6 -6
index ce9224a36f62..43711561a199 100644
@@ -542,7 +542,7 @@ static const struct of_device_id of_dra7xx_pcie_match[] = {
 };
 
 /*
- * dra7xx_pcie_ep_unaligned_memaccess: workaround for AM572x/AM571x Errata i870
+ * dra7xx_pcie_unaligned_memaccess: workaround for AM572x/AM571x Errata i870
  * @dra7xx: the dra7xx device where the workaround should be applied
  *
  * Access to the PCIe slave port that are not 32-bit aligned will result
@@ -552,7 +552,7 @@ static const struct of_device_id of_dra7xx_pcie_match[] = {
  *
  * To avoid this issue set PCIE_SS1_AXI2OCP_LEGACY_MODE_ENABLE to 1.
  */
-static int dra7xx_pcie_ep_unaligned_memaccess(struct device *dev)
+static int dra7xx_pcie_unaligned_memaccess(struct device *dev)
 {
 	int ret;
 	struct device_node *np = dev->of_node;
@@ -695,6 +695,10 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
 	if (dra7xx->link_gen < 0 || dra7xx->link_gen > 2)
 		dra7xx->link_gen = 2;
 
+	ret = dra7xx_pcie_unaligned_memaccess(dev);
+	if (ret)
+		dev_err(dev, "WA for Errata i870 not applied. Update DT\n");
+
 	switch (mode) {
 	case DW_PCIE_RC_TYPE:
 		if (!IS_ENABLED(CONFIG_PCI_DRA7XX_HOST)) {
@@ -717,10 +721,6 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
 		dra7xx_pcie_writel(dra7xx, PCIECTRL_TI_CONF_DEVICE_TYPE,
 				   DEVICE_TYPE_EP);
 
-		ret = dra7xx_pcie_ep_unaligned_memaccess(dev);
-		if (ret)
-			goto err_gpio;
-
 		ret = dra7xx_add_pcie_ep(dra7xx, pdev);
 		if (ret < 0)
 			goto err_gpio;
Signature · 1 line
2.19.0
#3 lore raw

Re: [PATCH v4 2/2] pci: dwc: pci-dra7xx: Enable errata i870 for both EP and RC mode

Quoted 37 lines · Vignesh R

Errata i870 is applicable in both EP and RC mode. Therefore rename function dra7xx_pcie_ep_unaligned_memaccess(), that implements errata workaround, to dra7xx_pcie_unaligned_memaccess() and call it from a common place. So, that errata workaround is applied for both modes of operation.

---
 drivers/pci/controller/dwc/pci-dra7xx.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/pci/controller/dwc/pci-dra7xx.c +2 -2
index ce9224a36f62..43711561a199 100644
@@ -542,7 +542,7 @@ static const struct of_device_id of_dra7xx_pcie_match[] = {
 };
 
 /*
- * dra7xx_pcie_ep_unaligned_memaccess: workaround for AM572x/AM571x Errata i870
+ * dra7xx_pcie_unaligned_memaccess: workaround for AM572x/AM571x Errata i870
  * @dra7xx: the dra7xx device where the workaround should be applied
  *
  * Access to the PCIe slave port that are not 32-bit aligned will result
@@ -552,7 +552,7 @@ static const struct of_device_id of_dra7xx_pcie_match[] = {
  *
  * To avoid this issue set PCIE_SS1_AXI2OCP_LEGACY_MODE_ENABLE to 1.
  */
-static int dra7xx_pcie_ep_unaligned_memaccess(struct device *dev)
+static int dra7xx_pcie_unaligned_memaccess(struct device *dev)
 {
 	int ret;
 	struct device_node *np = dev->of_node;

drivers/pci/controller/dwc/pci-dra7xx.c static int __init dra7xx_pcie_probe(struct platform_device *pdev) · line 700

Quoted 6 lines
drivers/pci/controller/dwc/pci-dra7xx.c +3 -0
@@ -695,6 +695,10 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
 	if (dra7xx->link_gen < 0 || dra7xx->link_gen > 2)
 		dra7xx->link_gen = 2;
 
+	ret = dra7xx_pcie_unaligned_memaccess(dev);
+	if (ret)
+		dev_err(dev, "WA for Errata i870 not applied. Update DT\n");

Hi Vignesh,

I am not sure you want this code merged into an -rc given that without a DTS update is basically pointless (and for that bindings should at least be merged too as a fix).

I would also like to understand why a dev_err() is sufficient, can the controller work without the WA applied ?

Nit: Lastly, in the dev_err() message, it is your call/code but I would not print "update DT", kernel log is not a command prompt but that's just my opinion so it is up to you.

Thanks,
Lorenzo

Quoted 17 lines
drivers/pci/controller/dwc/pci-dra7xx.c +0 -4
 	switch (mode) {
 	case DW_PCIE_RC_TYPE:
 		if (!IS_ENABLED(CONFIG_PCI_DRA7XX_HOST)) {
@@ -717,10 +721,6 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
 		dra7xx_pcie_writel(dra7xx, PCIECTRL_TI_CONF_DEVICE_TYPE,
 				   DEVICE_TYPE_EP);
 
-		ret = dra7xx_pcie_ep_unaligned_memaccess(dev);
-		if (ret)
-			goto err_gpio;
-
 		ret = dra7xx_add_pcie_ep(dra7xx, pdev);
 		if (ret < 0)
 			goto err_gpio;
Signature · 1 line
2.19.0
author maintainer
#4 lore raw

Re: [PATCH v4 2/2] pci: dwc: pci-dra7xx: Enable errata i870 for both EP and RC mode

Hi,

Quoted 1 line · Lorenzo Pieralisi

On Mon, Sep 17, 2018 at 11:36:35PM +0530, Vignesh R wrote:

[...]

Quoted 33 lines
Quoted 24 lines
drivers/pci/controller/dwc/pci-dra7xx.c +2 -2
index ce9224a36f62..43711561a199 100644
@@ -542,7 +542,7 @@ static const struct of_device_id of_dra7xx_pcie_match[] = {
 };
 
 /*
- * dra7xx_pcie_ep_unaligned_memaccess: workaround for AM572x/AM571x Errata i870
+ * dra7xx_pcie_unaligned_memaccess: workaround for AM572x/AM571x Errata i870
  * @dra7xx: the dra7xx device where the workaround should be applied
  *
  * Access to the PCIe slave port that are not 32-bit aligned will result
@@ -552,7 +552,7 @@ static const struct of_device_id of_dra7xx_pcie_match[] = {
  *
  * To avoid this issue set PCIE_SS1_AXI2OCP_LEGACY_MODE_ENABLE to 1.
  */
-static int dra7xx_pcie_ep_unaligned_memaccess(struct device *dev)
+static int dra7xx_pcie_unaligned_memaccess(struct device *dev)
 {
 	int ret;
 	struct device_node *np = dev->of_node;

drivers/pci/controller/dwc/pci-dra7xx.c static int __init dra7xx_pcie_probe(struct platform_device *pdev) · line 700

Quoted 6 lines
drivers/pci/controller/dwc/pci-dra7xx.c +3 -0
@@ -695,6 +695,10 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
 	if (dra7xx->link_gen < 0 || dra7xx->link_gen > 2)
 		dra7xx->link_gen = 2;
 
+	ret = dra7xx_pcie_unaligned_memaccess(dev);
+	if (ret)
+		dev_err(dev, "WA for Errata i870 not applied. Update DT\n");

Hi Vignesh,

Quoted 4 lines

I am not sure you want this code merged into an -rc given that without a DTS update is basically pointless (and for that bindings should at least be merged too as a fix).

Ok, I will wait for next -rc1 to post DT changes.

Quoted 3 lines

I would also like to understand why a dev_err() is sufficient, can the controller work without the WA applied ?

W/o this errata WA, I see that non 32-bit aligned accesses to configuration space of PEX 8606 switch card[1] returns corrupted data with dra7xx PCIe controller (unaligned access seems to work fine for other all other cards that I have tested with) and therefore fails to enumerate. Other than that, I am not aware of any other impact on functionality due to this issue in RC mode.
Also, since current DTBs do not have "ti,syscon-unaligned-access" DT property in PCIe RC node, I chose not to fail driver probe as that would break DT backward compatibility.

I see that in current driver code, probe used to fail in EP mode if DT property was absent. Therefore, will modify patch so to retain that behavior in v5, but keep WA optional for host mode.

Quoted 4 lines

Nit: Lastly, in the dev_err() message, it is your call/code but I would not print "update DT", kernel log is not a command prompt but that's just my opinion so it is up to you.

Ok, I will drop that part in next version.

[1]PCI bridge: PLX Technology, Inc. PEX 8606 6 Lane, 6 Port PCI Express Gen 2 (5.0 GT/s) Switch (rev ba)

Regards
Vignesh

Quoted 18 lines
Quoted 18 lines
drivers/pci/controller/dwc/pci-dra7xx.c +0 -4
 	switch (mode) {
 	case DW_PCIE_RC_TYPE:
 		if (!IS_ENABLED(CONFIG_PCI_DRA7XX_HOST)) {
@@ -717,10 +721,6 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
 		dra7xx_pcie_writel(dra7xx, PCIECTRL_TI_CONF_DEVICE_TYPE,
 				   DEVICE_TYPE_EP);
 
-		ret = dra7xx_pcie_ep_unaligned_memaccess(dev);
-		if (ret)
-			goto err_gpio;
-
 		ret = dra7xx_add_pcie_ep(dra7xx, pdev);
 		if (ret < 0)
 			goto err_gpio;
Signature · 1 line
2.19.0